/* Modern Coffee Roasting Timer Pro Styles */

:root {
    /* Light theme colors */
    --bg-primary: #ffffff;
    --bg-primary-rgb: 255, 255, 255;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --border-radius: 12px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    
    /* Brand colors */
    --coffee-brown: #8b4513;
    --coffee-light: #d2b48c;
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --success-color: #10b981;
    --success-hover: #059669;
    --warning-color: #f59e0b;
    --warning-hover: #d97706;
    --danger-color: #ef4444;
    --danger-hover: #dc2626;
    --secondary-color: #6b7280;
    --secondary-hover: #4b5563;
}

[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-primary-rgb: 15, 23, 42;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    --border-color: #334155;
    --coffee-brown: #d2b48c;
    --coffee-light: #f4e4bc;
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: all 0.3s ease;
}

/* App Container */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
    position: relative;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
}

.app-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.coffee-icon {
    font-size: 1.8rem;
    filter: sepia(1) hue-rotate(15deg) saturate(2);
}

.pro-badge {
    background: linear-gradient(135deg, var(--coffee-brown), var(--coffee-light));
    color: white;
    font-size: 0.75rem;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* Card System */
.card {
    background: var(--bg-primary);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07), 0 0 0 1px rgba(0, 0, 0, 0.03);
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, transparent 0%, rgba(59, 130, 246, 0.03) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.card:hover {
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.2);
}

.card:hover::before {
    opacity: 1;
}

.card-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h2,
.card-header h3 {
    color: var(--text-primary);
    font-weight: 600;
    margin: 0;
}

/* Timer Card */
.timer-card {
    margin-bottom: 2rem;
}

.timer-card .card-header {
    text-align: center;
}

.roast-status {
    color: var(--text-secondary);
    font-size: 0.9rem;
    background: var(--bg-tertiary);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    display: inline-block;
    margin: 0 auto;
}

.timer-display {
    padding: 3rem 2rem;
    text-align: center;
}

.time-container {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.25rem;
}

.timer-main {
    font-size: 4rem;
    font-weight: 700;
    color: var(--coffee-brown);
    font-variant-numeric: tabular-nums;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.timer-ms {
    font-size: 2rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.timer-controls {
    padding: 0 2rem 2rem;
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* Milestones Section */
.milestones-section {
    padding: 2rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.milestones-section h3 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.milestone-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

#finishRoastBtn {
    display: block;
    margin: 0 auto;
    max-width: 300px;
}

/* Data Grid */
.data-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 1.5rem;
}

/* Temperature Section */
.temp-display {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.current-temp {
    font-size: 2rem;
    font-weight: 700;
    color: var(--danger-color);
}

.ror-display {
    font-size: 1.25rem;
    color: var(--text-secondary);
}

.temp-input-section {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.input-group {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

.input-group.full-width {
    grid-column: 1 / -1;
}

.chart-container {
    padding: 1.5rem;
    height: 300px;
}

/* Roast Information */
.roast-info-grid {
    padding: 1.5rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.template-select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.9rem;
}

/* Analytics Grid */
.analytics-grid {
    padding: 1.5rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1.5rem;
}

.metric {
    text-align: center;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.metric-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

/* Milestones Display */
.milestones-display {
    padding: 1.5rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.milestone-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.milestone-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
}

.milestone-time {
    font-weight: 600;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

/* Form Elements */
.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.875rem;
}

input, textarea, select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.2s ease;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

textarea {
    resize: vertical;
    min-height: 100px;
}

/* Modern Button Styles with Enhanced Design */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 10px;
    font-size: 0.9375rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    position: relative;
    overflow: hidden;
    text-transform: none;
    letter-spacing: 0.025em;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* Button hover effect */
.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transform: translateX(-100%);
    transition: transform 0.6s;
}

.btn:hover::before {
    transform: translateX(100%);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    box-shadow: none;
}

.btn:active:not(:disabled) {
    transform: scale(0.98);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1rem;
    border-radius: 12px;
}

/* Primary Button - Gradient Style */
.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    box-shadow: 0 4px 6px rgba(59, 130, 246, 0.25), 0 1px 3px rgba(0, 0, 0, 0.08);
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--primary-hover), #1e40af);
    transform: translateY(-2px);
    box-shadow: 0 8px 12px rgba(59, 130, 246, 0.35), 0 2px 4px rgba(0, 0, 0, 0.08);
}

/* Secondary Button - Subtle Style */
.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1.5px solid var(--border-color);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-tertiary);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Success Button - Vibrant Green */
.btn-success {
    background: linear-gradient(135deg, var(--success-color), var(--success-hover));
    color: white;
    box-shadow: 0 4px 6px rgba(16, 185, 129, 0.25), 0 1px 3px rgba(0, 0, 0, 0.08);
}

.btn-success:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--success-hover), #047857);
    transform: translateY(-2px);
    box-shadow: 0 8px 12px rgba(16, 185, 129, 0.35), 0 2px 4px rgba(0, 0, 0, 0.08);
}

/* Warning Button - Warm Orange */
.btn-warning {
    background: linear-gradient(135deg, var(--warning-color), var(--warning-hover));
    color: white;
    box-shadow: 0 4px 6px rgba(245, 158, 11, 0.25), 0 1px 3px rgba(0, 0, 0, 0.08);
}

.btn-warning:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--warning-hover), #b45309);
    transform: translateY(-2px);
    box-shadow: 0 8px 12px rgba(245, 158, 11, 0.35), 0 2px 4px rgba(0, 0, 0, 0.08);
}

/* Danger Button - Bold Red */
.btn-danger {
    background: linear-gradient(135deg, var(--danger-color), var(--danger-hover));
    color: white;
    box-shadow: 0 4px 6px rgba(239, 68, 68, 0.25), 0 1px 3px rgba(0, 0, 0, 0.08);
}

.btn-danger:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--danger-hover), #b91c1c);
    transform: translateY(-2px);
    box-shadow: 0 8px 12px rgba(239, 68, 68, 0.35), 0 2px 4px rgba(0, 0, 0, 0.08);
}

/* Milestone Button - Special Style */
.btn-milestone {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
    position: relative;
    overflow: hidden;
}

.btn-milestone::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: var(--primary-color);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-milestone:hover:not(:disabled) {
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(59, 130, 246, 0.15);
}

.btn-milestone:hover:not(:disabled)::after {
    width: 300px;
    height: 300px;
    opacity: 0.1;
}

.btn-milestone:disabled {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    border-color: var(--border-color);
}

/* Icon animations */
.btn .icon {
    transition: transform 0.3s ease;
}

.btn:hover .icon {
    transform: scale(1.1);
}

/* Coffee-Themed Theme Toggle */
.theme-toggle {
    background: linear-gradient(135deg, var(--coffee-brown), var(--coffee-light));
    border: 2px solid var(--coffee-brown);
    border-radius: 50%;
    width: 3.5rem;
    height: 3.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.5rem;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(139, 69, 19, 0.3);
    position: relative;
    overflow: hidden;
}

.theme-toggle::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.2) 0%, transparent 70%);
    transform: rotate(45deg);
    transition: all 0.6s ease;
    opacity: 0;
}

.theme-toggle:hover::before {
    opacity: 1;
}

.theme-toggle:hover {
    transform: scale(1.1) rotate(360deg);
    box-shadow: 0 6px 20px rgba(139, 69, 19, 0.4);
}

.theme-toggle:active {
    transform: scale(0.95);
}

/* Theme Icon Styling */
.theme-icon-light,
.theme-icon-dark {
    position: absolute;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

/* Light theme shows coffee cup */
[data-theme="light"] .theme-icon-light {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

[data-theme="light"] .theme-icon-dark {
    opacity: 0;
    transform: scale(0.5) rotate(180deg);
}

/* Dark theme shows moon */
[data-theme="dark"] .theme-icon-light {
    opacity: 0;
    transform: scale(0.5) rotate(-180deg);
}

[data-theme="dark"] .theme-icon-dark {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

/* Dark theme adjustments */
[data-theme="dark"] .theme-toggle {
    background: linear-gradient(135deg, #2d3748, #4a5568);
    border-color: #4a5568;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .theme-toggle:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
}

/* Enhanced Modal/Popup Styles with Better Design */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 2rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    perspective: 1000px;
}

.modal-overlay[style*="display: flex"],
.modal-overlay[style*="display: block"] {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: 24px;
    box-shadow: 
        0 50px 100px -20px rgba(0, 0, 0, 0.3), 
        0 30px 60px -30px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.1) inset;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    transform: scale(0.8) translateY(30px) rotateX(-5deg);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    position: relative;
}

.modal-content > *:not(.modal-header) {
    position: relative;
    z-index: 1;
}

.modal-overlay[style*="display: flex"] .modal-content,
.modal-overlay[style*="display: block"] .modal-content {
    transform: scale(1) translateY(0) rotateX(0);
    opacity: 1;
}

.modal-large {
    max-width: 1000px;
}

.modal-header {
    padding: 2rem 2.5rem 1.75rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: transparent;
    position: relative;
    z-index: 20;
}

.modal-header h2 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.modal-close {
    background: rgba(239, 68, 68, 0.1);
    border: 2px solid transparent;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--danger-color);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.modal-close::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: var(--danger-color);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: var(--danger-color);
    color: white;
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(239, 68, 68, 0.3);
}

.modal-close:hover::before {
    width: 100px;
    height: 100px;
    opacity: 0.3;
}

.modal-close:active {
    transform: scale(0.95);
}

/* Modal Body */
.modal-content form,
.modal-content > div:not(.modal-header) {
    padding: 2rem;
}

/* Form styling in modals */
.modal-content .form-group {
    margin-bottom: 1.5rem;
}

.modal-content input,
.modal-content textarea,
.modal-content select {
    width: 100%;
    padding: 0.875rem 1.125rem;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.2s ease;
}

.modal-content input:focus,
.modal-content textarea:focus,
.modal-content select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
    background: var(--bg-primary);
}

/* Modal animations for specific content */
.history-content,
.compare-content {
    overflow-y: auto;
    flex: 1;
}

/* Loading state in modals */
.loading {
    text-align: center;
    color: var(--text-secondary);
    padding: 3rem;
    font-size: 1.125rem;
}

.loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    margin-left: 10px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Modal scrollbar styling */
.modal-content::-webkit-scrollbar {
    width: 8px;
}

.modal-content::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

.modal-content::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Enhanced Auth Modal Styling */
#authModal .modal-content,
#forgotPasswordModal .modal-content,
#resetPasswordModal .modal-content {
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    overflow: visible;
}

#authModal .modal-header::after {
    content: '☕';
    position: absolute;
    font-size: 120px;
    opacity: 0.05;
    right: -20px;
    top: -20px;
    transform: rotate(-15deg);
}

#authForm {
    padding: 2.5rem !important;
}

#authForm .form-group {
    margin-bottom: 1.75rem;
    position: relative;
}

#authForm input {
    width: 100%;
    padding: 1rem 1.25rem 1rem 3rem;
    border: 2px solid transparent;
    border-radius: 12px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

#authForm input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1), 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

/* Input Icons */
#authForm .form-group::before {
    content: '';
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    opacity: 0.5;
    z-index: 1;
}

#authForm .form-group:nth-child(1)::before {
    content: '✉️';
}

#authForm .form-group:nth-child(2)::before {
    content: '🔒';
}

#authNameGroup::before {
    content: '👤';
}

/* Submit Button Enhancement */
#authSubmit {
    width: 100%;
    margin-top: 1.5rem;
    padding: 1.125rem 2rem;
    font-size: 1.125rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--coffee-brown), var(--coffee-light));
    border: none;
    box-shadow: 0 4px 15px rgba(139, 69, 19, 0.3);
    position: relative;
    overflow: hidden;
}

#authSubmit::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

#authSubmit:hover::after {
    width: 300px;
    height: 300px;
}

#authSubmit:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 69, 19, 0.4);
}

#authSubmit:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* Loading State for Auth Button */
#authSubmit.loading {
    color: transparent;
}

#authSubmit.loading::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-left: -10px;
    margin-top: -10px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: authSpinner 0.8s linear infinite;
}

@keyframes authSpinner {
    to { transform: rotate(360deg); }
}

/* Auth Links */
.auth-links {
    margin-top: 2.5rem;
    text-align: center;
    padding-top: 2rem;
    border-top: 2px dashed var(--border-color);
}

.auth-toggle, .forgot-password {
    margin-bottom: 1rem;
    font-size: 0.9375rem;
}

.auth-toggle {
    color: var(--text-secondary);
}

.auth-toggle a, .forgot-password a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    display: inline-block;
    position: relative;
}

.auth-toggle a::after, .forgot-password a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--primary-color);
    transform: translateX(-50%);
    transition: width 0.3s ease;
}

.auth-toggle a:hover::after, .forgot-password a:hover::after {
    width: 80%;
}

.auth-toggle a:hover, .forgot-password a:hover {
    background: rgba(59, 130, 246, 0.08);
    color: var(--primary-hover);
    transform: translateY(-1px);
}

.forgot-password {
    font-size: 0.875rem;
}

.forgot-password a {
    color: var(--text-secondary);
    font-weight: 500;
}

.debug-link {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 6px;
    font-size: 0.875rem;
}

/* History Styles */
.history-controls {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.search-bar {
    flex: 1;
    min-width: 250px;
}

.search-bar input {
    margin-bottom: 0;
}

.history-filters {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.history-content {
    padding: 1.5rem;
}

.history-grid {
    display: grid;
    gap: 1rem;
    margin-bottom: 2rem;
}

.history-item {
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 1.75rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.history-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    transform: scaleY(0);
    transition: transform 0.3s ease;
}

.history-item:hover {
    background: var(--bg-secondary);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
    border-color: var(--primary-color);
}

.history-item:hover::before {
    transform: scaleY(1);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.history-header h4 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.1rem;
}

.history-date {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.history-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
}

.history-details span {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.loading {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
}

/* Compare Styles */
.compare-controls {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.compare-selectors {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.compare-selectors select {
    flex: 1;
    min-width: 200px;
}

.compare-content {
    padding: 1.5rem;
}

.compare-chart {
    margin-bottom: 2rem;
    height: 400px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.stat-comparison {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    text-align: center;
}

.stat-comparison h4 {
    margin: 0 0 1rem 0;
    color: var(--text-primary);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-values {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    color: var(--text-primary);
}

.stat-values span:first-child,
.stat-values span:last-child {
    font-size: 1.25rem;
}

.stat-values span:nth-child(2) {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Icons */
.icon {
    font-size: 1em;
    line-height: 1;
}

/* Responsive Design for Popups */
@media (max-width: 768px) {
    .notification-container {
        top: 70px;
        right: 10px;
        left: 10px;
    }
    
    .notification {
        min-width: auto;
        max-width: none;
        width: 100%;
    }
    
    .toast-container {
        bottom: 10px;
        width: calc(100% - 20px);
    }
    
    .toast {
        width: 100%;
        max-width: 400px;
    }
    
    .modal-content {
        margin: 1rem;
        max-width: calc(100vw - 2rem);
    }
    
    .confirm-dialog {
        padding: 1.5rem;
    }
    
    .status-popup {
        padding: 2rem;
        width: calc(100vw - 2rem);
        max-width: 400px;
    }
}

/* Enhanced Mobile Responsive Design */
@media (max-width: 768px) {
    /* Ensure minimum touch target size of 44px */
    button, .btn, input, select, textarea {
        min-height: 44px;
    }
    
    /* Header Optimizations */
    .app-header {
        padding: 1rem;
        position: sticky;
        top: 0;
        width: 100%;
        background: var(--bg-primary);
    }
    
    .header-left {
        flex: 1;
    }
    
    .app-title {
        font-size: 1.25rem;
        gap: 0.35rem;
    }
    
    .coffee-icon {
        font-size: 1.5rem;
    }
    
    .pro-badge {
        font-size: 0.65rem;
        padding: 0.2rem 0.6rem;
    }
    
    .header-right {
        display: flex;
        gap: 0.75rem;
        align-items: center;
    }
    
    .header-right .btn {
        padding: 0.6rem 1rem;
        font-size: 0.875rem;
    }
    
    .header-right .btn .icon {
        display: inline-block;
        margin-right: 0.25rem;
    }
    
    .theme-toggle {
        width: 3rem;
        height: 3rem;
        font-size: 1.25rem;
    }

    /* Main Content Adjustments */
    .main-content {
        padding: 1.5rem 1rem;
    }
    
    /* Card Optimizations */
    .card {
        border-radius: 12px;
        margin-bottom: 1rem;
    }
    
    .card-header {
        padding: 1rem;
    }
    
    .timer-card .card-header {
        flex-direction: column;
        gap: 0.5rem;
        align-items: center;
    }
    
    .card-header h2 {
        font-size: 1.1rem;
    }
    
    .card-header h3 {
        font-size: 1rem;
    }
    
    .roast-status {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
        align-self: flex-start;
    }

    /* Timer Display */
    .timer-display {
        padding: 2rem 1rem;
    }
    
    .timer-main {
        font-size: 3.5rem;
    }

    .timer-ms {
        font-size: 1.75rem;
    }
    
    /* Button Optimizations */
    .timer-controls {
        flex-direction: row;
        gap: 0.75rem;
        padding: 0 1rem 1.5rem;
    }
    
    .timer-controls .btn {
        flex: 1;
        padding: 1rem 0.5rem;
        font-size: 0.9rem;
    }
    
    .milestone-buttons {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    
    .btn-milestone {
        padding: 0.875rem 0.5rem;
        font-size: 0.875rem;
    }
    
    #finishRoastBtn {
        margin-top: 1rem;
        width: 100%;
        padding: 1rem;
    }

    /* Data Grid */
    .data-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    /* Temperature Input */
    .temp-input-section {
        padding: 1rem;
    }
    
    .input-group {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .input-group input {
        width: 100%;
    }
    
    .input-group .btn {
        width: 100%;
    }
    
    /* Mobile-optimized temperature display */
    .temp-display {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
    
    .current-temp {
        font-size: 1.75rem;
    }
    
    .ror-display {
        font-size: 1rem;
    }
    
    /* Form Inputs */
    input[type="number"],
    input[type="text"],
    input[type="email"],
    input[type="password"],
    textarea,
    select {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 0.875rem 1rem;
    }
    
    /* Analytics Grid */
    .analytics-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    
    .metric {
        padding: 0.75rem;
    }
    
    .metric-label {
        font-size: 0.75rem;
    }
    
    .metric-value {
        font-size: 1.25rem;
    }

    /* Milestones Display */
    .milestones-display {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .milestone-item {
        padding: 0.875rem;
    }

    /* Modal Optimizations */
    .modal-overlay {
        padding: 0;
        align-items: flex-end;
    }
    
    .modal-content {
        border-radius: 20px 20px 0 0;
        max-height: 85vh;
        width: 100%;
        max-width: 100%;
        margin: 0;
        animation: slideUp 0.3s ease-out;
        position: relative;
    }
    
    /* Swipe indicator for mobile modals */
    .modal-content::before {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        background: var(--border-color);
        border-radius: 2px;
        opacity: 0.5;
    }
    
    @keyframes slideUp {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }
    
    .modal-header {
        padding: 1.5rem 1.5rem 1rem;
        position: sticky;
        top: 0;
        background: var(--bg-primary);
        z-index: 10;
    }
    
    .modal-header h2 {
        font-size: 1.25rem;
    }
    
    .modal-close {
        width: 36px;
        height: 36px;
        font-size: 1.25rem;
    }
    
    /* Form in Modals */
    .modal-content form,
    .modal-content > div:not(.modal-header) {
        padding: 1.5rem;
    }
    
    /* History/Compare specific */
    .history-controls {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }
    
    .search-bar {
        width: 100%;
    }
    
    .history-filters {
        width: 100%;
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .history-filters select,
    .history-filters .btn {
        width: 100%;
    }
    
    .compare-selectors {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .compare-selectors select,
    .compare-selectors .btn {
        width: 100%;
    }
    
    /* Chart Container */
    .chart-container {
        height: 250px;
        padding: 1rem;
    }
    
    .compare-chart {
        height: 300px;
    }
}

/* Extra Small Screens (phones in portrait) */
@media (max-width: 480px) {
    .app-header {
        padding: 0.75rem;
    }
    
    .app-title {
        font-size: 1.1rem;
    }
    
    .app-title .pro-badge {
        display: none;
    }
    
    .header-right .btn span:not(.icon) {
        display: none;
    }
    
    .header-right .btn {
        padding: 0.5rem 0.75rem;
    }
    
    .theme-toggle {
        width: 2.5rem;
        height: 2.5rem;
        font-size: 1.1rem;
    }
    
    /* Compact timer for small screens */
    .timer-display {
        padding: 1.5rem 1rem;
    }

    .timer-main {
        font-size: 2.5rem;
    }
    
    .timer-ms {
        font-size: 1.25rem;
    }
    
    /* Stack timer controls */
    .timer-controls {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .timer-controls .btn {
        width: 100%;
        padding: 0.875rem;
    }
    
    /* Optimize milestone buttons */
    .milestone-buttons {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .btn-milestone {
        display: flex;
        justify-content: space-between;
        padding: 0.75rem 1rem;
        text-align: left;
    }
    
    .btn-milestone .icon {
        order: 2;
    }

    /* Single column analytics */
    .analytics-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .metric {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.75rem 1rem;
    }
    
    .metric-label {
        font-size: 0.875rem;
    }
    
    .metric-value {
        font-size: 1.125rem;
    }

    /* Form optimizations */
    .roast-info-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 1rem;
    }
    
    /* Notification adjustments */
    .notification {
        min-width: auto;
        font-size: 0.875rem;
        padding: 1rem;
    }
    
    .notification-title {
        font-size: 0.9375rem;
    }
    
    .notification-message {
        font-size: 0.8125rem;
    }
    
    /* Status popup adjustments */
    .status-popup {
        padding: 1.5rem;
    }
    
    .status-icon {
        font-size: 3rem;
    }
    
    .status-title {
        font-size: 1.5rem;
    }
    
    .status-message {
        font-size: 1rem;
    }
    
    /* Confirm dialog adjustments */
    .confirm-dialog {
        padding: 1.5rem;
    }
    
    .confirm-icon {
        font-size: 2.5rem;
    }
    
    .confirm-title {
        font-size: 1.25rem;
    }
    
    .confirm-message {
        font-size: 0.9375rem;
    }
    
    .confirm-buttons {
        flex-direction: column;
        width: 100%;
        gap: 0.5rem;
    }
    
    .confirm-buttons .btn {
        width: 100%;
    }
}

/* Touch-friendly adjustments */
@media (hover: none) and (pointer: coarse) {
    /* Remove hover effects on touch devices */
    .btn:hover {
        transform: none;
    }
    
    .card:hover {
        transform: none;
        box-shadow: var(--shadow-md);
    }
    
    /* Larger touch targets */
    .btn, input, select, textarea {
        min-height: 48px;
    }
    
    /* Disable button animations on touch */
    .btn::before,
    .btn::after {
        display: none;
    }
    
    /* Simplify interactions */
    .theme-toggle:hover {
        transform: none;
    }
    
    .modal-close:hover {
        transform: none;
    }
}

/* Notification & Toast Styles */
.notification-container {
    position: fixed;
    top: 100px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    pointer-events: none;
}

.notification {
    background: var(--bg-primary);
    border-radius: 16px;
    box-shadow: 
        0 20px 25px -5px rgba(0, 0, 0, 0.15),
        0 10px 10px -5px rgba(0, 0, 0, 0.04),
        0 0 0 1px rgba(0, 0, 0, 0.05);
    padding: 1.25rem 1.5rem;
    min-width: 320px;
    max-width: 420px;
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
    overflow: hidden;
    transform: translateX(400px);
    opacity: 0;
    animation: slideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    pointer-events: all;
}

.notification::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--primary-color);
}

.notification.success::before {
    background: var(--success-color);
}

.notification.error::before {
    background: var(--danger-color);
}

.notification.warning::before {
    background: var(--warning-color);
}

.notification-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.notification-content {
    flex: 1;
}

.notification-title {
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    font-size: 1rem;
}

.notification-message {
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.4;
}

.notification-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.25rem;
    padding: 0.25rem;
    opacity: 0.6;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.notification-close:hover {
    opacity: 1;
    transform: scale(1.1);
}

.notification.removing {
    animation: slideOut 0.3s cubic-bezier(0.4, 0, 1, 1) forwards;
}

/* Toast Messages */
.toast-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2100;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    pointer-events: none;
}

.toast {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 50px;
    padding: 0.875rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: 
        0 10px 15px -3px rgba(0, 0, 0, 0.1),
        0 4px 6px -2px rgba(0, 0, 0, 0.05);
    transform: translateY(100px);
    opacity: 0;
    animation: toastUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    pointer-events: all;
}

.toast-icon {
    font-size: 1.125rem;
}

.toast-text {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-primary);
}

.toast.removing {
    animation: toastDown 0.3s cubic-bezier(0.4, 0, 1, 1) forwards;
}

/* Confirmation Dialog */
.confirm-dialog {
    background: var(--bg-primary);
    border-radius: 20px;
    padding: 2rem;
    max-width: 400px;
    text-align: center;
    box-shadow: 
        0 25px 50px -12px rgba(0, 0, 0, 0.25),
        0 0 0 1px rgba(255, 255, 255, 0.1) inset;
}

.confirm-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.confirm-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.confirm-message {
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: 2rem;
}

.confirm-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.confirm-buttons .btn {
    min-width: 120px;
}

/* Success/Error Popup */
.status-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.5);
    background: var(--bg-primary);
    border-radius: 24px;
    padding: 3rem;
    text-align: center;
    box-shadow: 
        0 50px 100px -20px rgba(0, 0, 0, 0.3),
        0 30px 60px -30px rgba(0, 0, 0, 0.3);
    z-index: 2200;
    opacity: 0;
    animation: popupIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.status-popup.success {
    border: 2px solid var(--success-color);
}

.status-popup.error {
    border: 2px solid var(--danger-color);
}

.status-icon {
    font-size: 4rem;
    margin-bottom: 1.5rem;
    display: inline-block;
    animation: iconBounce 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.2s;
}

.status-title {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.status-message {
    color: var(--text-secondary);
    font-size: 1.125rem;
    line-height: 1.6;
}

/* Animations */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

@keyframes slideIn {
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

@keyframes toastUp {
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes toastDown {
    to {
        transform: translateY(100px);
        opacity: 0;
    }
}

@keyframes popupIn {
    to {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

@keyframes iconBounce {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.roast-status.active {
    animation: pulse 2s infinite;
    background: var(--success-color);
    color: white;
}

/* Print Styles */
@media print {
    .app-header,
    .modal-overlay,
    .btn {
        display: none !important;
    }
    
    .main-content {
        padding: 0;
    }
    
    .card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #000;
    }
}