/* CSS Variables / Theme */
:root {
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-primary-light: #dbeafe;
    --color-success: #16a34a;
    --color-success-light: #dcfce7;
    --color-warning: #eab308;
    --color-warning-light: #fef9c3;
    --color-danger: #dc2626;
    --color-danger-light: #fee2e2;
    --color-gray-50: #f9fafb;
    --color-gray-100: #f3f4f6;
    --color-gray-200: #e5e7eb;
    --color-gray-300: #d1d5db;
    --color-gray-500: #6b7280;
    --color-gray-600: #4b5563;
    --color-gray-700: #374151;
    --color-gray-800: #1f2937;
    --color-gray-900: #111827;
    --color-white: #ffffff;
    --color-orange: #f97316;
    --color-orange-light: #ffedd5;
    --border-radius: 0.5rem;
    --border-radius-lg: 0.75rem;
    --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);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

/* Dark Mode Overrides */
body.dark-theme {
    --color-white: #1f2937; /* override for backgrounds that use white */
    --color-gray-50: #111827;
    --color-gray-100: #1f2937;
    --color-gray-200: #374151;
    --color-gray-300: #4b5563;
    --color-gray-500: #9ca3af;
    --color-gray-600: #d1d5db;
    --color-gray-700: #e5e7eb;
    --color-gray-900: #f9fafb;
    --color-primary-light: #1e40af;
    --color-primary: #3b82f6;
    --color-primary-hover: #60a5fa;
    --color-white: #111827;
}

/* BASIC DARK MODE */
body.dark-theme {
    background-color: #0d1117; /* GitHub dark-ish */
    color: #c9d1d9; /* light gray for text */
}

/* LINKS AND TEXT ELEMENTS */
body.dark-theme a,
body.dark-theme h1,
body.dark-theme h2,
body.dark-theme h3,
body.dark-theme p,
body.dark-theme label {
    color: #c9d1d9;
}

/* CONTAINERS */
body.dark-theme .container,
body.dark-theme .menubar,
body.dark-theme .main-content,
body.dark-theme .exam-grid,
body.dark-theme .tabs,
body.dark-theme .dialog-content {
    background-color: #161b22; /* slightly lighter than body */
    color: #c9d1d9;
}

/* BUTTONS KEEP ORIGINAL COLORS */
body.dark-theme .btn {
    background-color: inherit; /* do not override btn colors */
    color: inherit;
    border-color: inherit;
}

/* BUTTON HOVER */
body.dark-theme .btn:hover {
    opacity: 0.85; /* subtle hover effect */
}

/* INPUTS, SELECTS, TEXTAREAS */
body.dark-theme input,
body.dark-theme select,
body.dark-theme textarea {
    background-color: #0d1117;
    color: #c9d1d9;
    border: 1px solid #30363d;
}

body.dark-theme input:focus,
body.dark-theme select:focus,
body.dark-theme textarea:focus {
    border-color: #58a6ff; /* focus blue */
    outline: none;
}

/* DIALOG OVERLAY */
body.dark-theme .dialog-overlay {
    background-color: rgba(13, 17, 23, 0.95);
}

/* CLOSE BUTTONS */
body.dark-theme .dialog-header .btn-outline {
    color: #c9d1d9;
    border-color: #30363d;
}

body.dark-theme .dialog-header .btn-outline:hover {
    color: #58a6ff;
    border-color: #58a6ff;
}

/* CHECKBOXES & RADIO */
body.dark-theme input[type="checkbox"],
body.dark-theme input[type="radio"] {
    accent-color: #58a6ff;
}

/* SCROLLBARS */
body.dark-theme ::-webkit-scrollbar {
    width: 8px;
}

body.dark-theme ::-webkit-scrollbar-thumb {
    background-color: #30363d;
    border-radius: 4px;
}

body.dark-theme ::-webkit-scrollbar-track {
    background-color: #0d1117;
}

/* Dark mode overrides for dialogs, tabs, and exam cards */
body.dark-theme .dialog-content {
    background-color: #161b22; /* matches container */
    color: #c9d1d9;
}

body.dark-theme .tabs-list {
    background-color: #161b22; /* tabs container */
    color: #c9d1d9;
}

body.dark-theme .tab-trigger,
body.dark-theme .tab-trigger.active,
body.dark-theme .tab-trigger:hover {
    background-color: #0d1117; /* tab buttons */
    color: #c9d1d9;
}

body.dark-theme .exam-card {
    background-color: #161b22; /* exam card background */
    border: 1px solid #30363d;
    color: #c9d1d9;
}

body.dark-theme .card-title h3,
body.dark-theme .card-body {
    color: #c9d1d9;
}

body.dark-theme .card-date svg {
    color: inherit !important;
}



/* Preserve badge colors in dark mode */
body.dark-theme .badge-none {
    background-color: var(--color-success-light) !important;
    color: var(--color-gray-800) !important;
}

body.dark-theme .badge-low,
body.dark-theme .badge-completed {
    background-color: var(--color-success-light) !important;
    color: #166534 !important;
}

body.dark-theme .badge-medium {
    background-color: var(--color-warning-light) !important;
    color: #854d0e !important;
}

body.dark-theme .badge-high {
    background-color: var(--color-danger-light) !important;
    color: #991b1b !important;
}

body.dark-theme .badge-overdue {
    background-color: var(--color-orange-light) !important;
    color: #9a3412 !important;
}

body.dark-theme .grade-display {
    background-color: #0d1117;
    color: #58a6ff; /* highlight grade */
}

body.dark-theme .dialog-header h2,
body.dark-theme .dialog-header p {
    color: #c9d1d9;
}

/* SETTINGS DIALOG FULL DARK MODE */
body.dark-theme #settings-dialog {
    background-color: rgba(13, 17, 23, 0.95); /* overlay same as other dialogs */
}

body.dark-theme #settings-dialog .dialog-content {
    background-color: #161b22; /* container matches main dialogs */
    color: #c9d1d9;
}

body.dark-theme #settings-dialog .dialog-header,
body.dark-theme #settings-dialog .dialog-body,
body.dark-theme #settings-dialog .dialog-footer {
    background-color: #161b22;
    color: #c9d1d9;
}

/* Header text */
body.dark-theme #settings-dialog .dialog-header h2,
body.dark-theme #settings-dialog .dialog-header p {
    color: #c9d1d9;
}

/* Labels, options */
body.dark-theme #settings-dialog label,
body.dark-theme #settings-dialog select,
body.dark-theme #settings-dialog input,
body.dark-theme #settings-dialog textarea {
    background-color: #161b22;
    color: #c9d1d9;
    border: 1px solid #30363d;
}

/* Inputs focus */
body.dark-theme #settings-dialog input:focus,
body.dark-theme #settings-dialog select:focus,
body.dark-theme #settings-dialog textarea:focus {
    border-color: #58a6ff;
    outline: none;
}

/* Buttons */
body.dark-theme #settings-dialog .btn-outline {
    color: #c9d1d9;
    border-color: #30363d;
}

body.dark-theme #settings-dialog .btn-outline:hover {
    color: #58a6ff;
    border-color: #58a6ff;
}

.swal2-popup {
  background: #1f2937 !important;
  color: #f9fafb !important;
}

.swal2-confirm {
  background-color: #2563eb !important;
}

.swal2-cancel {
  background-color: #dc2626 !important;
}


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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--color-gray-900);
    background-color: var(--color-gray-50);
    min-height: 100vh;
    overflow-x: hidden; /* Prevent horizontal scroll */
}

h1 {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

h2 {
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.3;
}

h3 {
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1.4;
}

/* Responsive Typography */
@media (max-width: 640px) {
    h1 {
        font-size: 1rem;
    }
    
    h2 {
        font-size: 1.125rem;
    }
    
    h3 {
        font-size: 1rem;
    }
}

/* Container */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1rem;
}

@media (max-width: 640px) {
    .container {
        padding: 0 0.75rem;
    }
}

/* Menu Bar */
.menubar {
    background-color: var(--color-white);
    border-bottom: 1px solid var(--color-gray-200);
    padding: 1rem 0;
}

@media (max-width: 640px) {
    .menubar {
        padding: 0.75rem 0;
    }
}

.menubar-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    flex-direction:row-reverse;
}

.menubar-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

@media (max-width: 640px) {
    .menubar {
        padding-top: 4.5rem;
    }

    .brand {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 100;
        width: 100%;
        padding: 0.75rem 1rem;
        background-color: var(--color-white);
        border-bottom: 1px solid var(--color-gray-200);
        gap: 0.5rem;
    }

    .brand h1 {
        font-size: 1.125rem;
    }

    .menubar-content {
        flex-direction: column;
        align-items: flex-start;
    }

    .menubar-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .settings-btn {
        position: fixed;
        top: 0.4rem;
        right: 1rem;
        z-index: 110;
    }
}

.brand .icon-lg {
    color: var(--color-primary);
    flex-shrink: 0; /* Prevent icon from shrinking */
}

.subtitle {
    font-size: 0.875rem;
    color: var(--color-gray-500);
    margin-top: 0.125rem;
}

@media (max-width: 640px) {
    .subtitle {
        font-size: 0.75rem;
        display: none; /* Hide on very small screens */
    }
}

/* Icons */
.icon {
    display: inline-block;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

.icon-sm {
    width: 1rem;
    height: 1rem;
}

.icon-lg {
    width: 1rem;
    height: 1rem;
}

@media (max-width: 640px) {
    .icon-lg {
        width: 1.5rem;
        height: 1.5rem;
    }
}

.icon-xl {
    width: 4rem;
    height: 4rem;
}

@media (max-width: 640px) {
    .icon-xl {
        width: 3rem;
        height: 3rem;
    }
}

.empty-icon {
    color: var(--color-gray-300);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25rem;
    border-radius: var(--border-radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

@media (max-width: 640px) {
    .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.813rem;
    }
}

.btn-primary {
    background-color: var(--color-primary);
    color: var(--color-white);
}

.btn-primary:hover {
    background-color: var(--color-primary-hover);
}

.btn-outline {
    background-color: var(--color-primary);
    color: var(--color-white);
}

.btn-outline:hover {
    background-color: var(--color-primary-hover);
}

.btn-outline {
    background-color: var(--color-white);
    border-color: var(--color-gray-300);
    color: var(--color-gray-700);
}

.btn-outline:hover {
    background-color: var(--color-gray-50);
}

.btn-ghost {
    background-color: transparent;
    color: var(--color-gray-700);
    padding: 0.5rem;
    min-width: 2rem;
    min-height: 2rem;
}

@media (max-width: 640px) {
    .btn-ghost {
        padding: 0.375rem;
        min-width: 1.75rem;
        min-height: 1.75rem;
    }
}

.btn-ghost:hover {
    background-color: var(--color-gray-100);
}

.btn-ghost.btn-danger {
    color: var(--color-danger);
}

.btn-ghost.btn-danger:hover {
    background-color: var(--color-danger-light);
}

/* Main Content */
.main-content {
    padding: 2rem 0;
}

@media (max-width: 640px) {
    .main-content {
        padding: 1rem 0;
    }
}

/* Tabs */
.tabs {
    width: 100%;
}

.tabs-list {
    display: flex;
    justify-content: center;
    align-items: center;
    max-width: 40rem;
    margin: 0 auto;
    background-color: var(--color-gray-100);
    border-radius: var(--border-radius);
    padding: 0.25rem;
    gap: 0.25rem;
}

@media (max-width: 640px) {
    .tabs-list {
        max-width: 100%;
        padding: 0.2rem;
    }
}

.tab-trigger {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    background-color: transparent;
    color: var(--color-gray-600);
    border: none;
    border-radius: calc(var(--border-radius) - 0.125rem);
    cursor: pointer;
    transition: all 0.2s ease;
}

@media (max-width: 640px) {
    .tab-trigger {
        padding: 0.5rem 0.5rem;
        font-size: 0.813rem;
        gap: 0.375rem;
    }
    
    .tab-trigger .icon-sm {
        width: 0.875rem;
        height: 0.875rem;
    }
}

.tab-trigger:hover {
    background-color: var(--color-white);
    color: var(--color-gray-900);
}

.tab-trigger.active {
    background-color: var(--color-white);
    color: var(--color-gray-900);
    box-shadow: var(--shadow-sm);
}

.tab-content {
    display: none;
    margin-top: 1.5rem;
}

@media (max-width: 640px) {
    .tab-content {
        margin-top: 1rem;
    }
}

.tab-content.active {
    display: block;
}

/* Exam Grid */
.exam-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr;
}

@media (min-width: 640px) {
    .exam-grid {
        gap: 1rem;
    }
}

@media (min-width: 768px) {
    .exam-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .exam-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 640px) {
    .exam-grid {
        gap: 0.75rem;
    }
}

/* Exam Card */
.exam-card {
    background-color: var(--color-white);
    border: 1px solid var(--color-gray-200);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s ease;
}

.exam-card:hover {
    box-shadow: var(--shadow-lg);
}

@media (max-width: 640px) {
    .exam-card:hover {
        box-shadow: var(--shadow-md); /* Less dramatic shadow on mobile */
    }
}

.card-header {
    padding: 1rem 1.5rem 0.75rem;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
}

@media (max-width: 640px) {
    .card-header {
        padding: 0.875rem 1rem 0.5rem;
    }
}

.card-title {
    flex: 1;
    min-width: 0; /* Allow text truncation */
}

.card-title h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--color-gray-900);
    margin-bottom: 0.25rem;
    word-wrap: break-word;
}

@media (max-width: 640px) {
    .card-title h3 {
        font-size: 1rem;
    }
}

.card-date {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--color-gray-600);
}

@media (max-width: 640px) {
    .card-date {
        font-size: 0.813rem;
        gap: 0.375rem;
    }
}

.card-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

@media (max-width: 640px) {
    .card-actions {
        gap: 0.25rem;
    }
}

.card-body {
    padding: 0 1.5rem 1.5rem;
}

@media (max-width: 640px) {
    .card-body {
        padding: 0 1rem 1rem;
    }
}

.card-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

@media (max-width: 640px) {
    .card-badges {
        gap: 0.375rem;
        margin-bottom: 0.5rem;
    }
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
    white-space: nowrap;
}

@media (max-width: 640px) {
    .badge {
        padding: 0.2rem 0.5rem;
        font-size: 0.688rem;
    }
    
    .badge .icon-sm {
        width: 0.75rem;
        height: 0.75rem;
    }
}

.badge-none {
    background-color: var(--color-gray-100);
    color: var(--color-gray-800);
}

.badge-low {
    background-color: var(--color-success-light);
    color: #166534;
}

.badge-medium {
    background-color: var(--color-warning-light);
    color: #854d0e;
}

.badge-high {
    background-color: var(--color-danger-light);
    color: #991b1b;
}

.badge-completed {
    background-color: var(--color-success-light);
    color: #166534;
}

.badge-overdue {
    background-color: var(--color-orange-light);
    color: #9a3412;
}

/* Grade Display */
.grade-display {
    background-color: var(--color-primary-light);
    border-radius: var(--border-radius);
    padding: 0.75rem;
    margin-bottom: 0.75rem;
}

@media (max-width: 640px) {
    .grade-display {
        padding: 0.625rem;
        margin-bottom: 0.5rem;
    }
}

.grade-display p:first-child {
    font-size: 0.875rem;
    color: var(--color-gray-600);
    margin-bottom: 0.25rem;
}

.grade-display p:last-child {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--color-primary-hover);
}

@media (max-width: 640px) {
    .grade-display p:first-child {
        font-size: 0.813rem;
    }
    
    .grade-display p:last-child {
        font-size: 1rem;
    }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 1rem;
}

@media (max-width: 640px) {
    .empty-state {
        padding: 2rem 1rem;
    }
}

.empty-state .icon {
    margin: 0 auto 1rem;
}

@media (max-width: 640px) {
    .empty-state .icon {
        margin-bottom: 0.75rem;
    }
}

.empty-state h3 {
    color: var(--color-gray-600);
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--color-gray-500);
    font-size: 0.875rem;
}

@media (max-width: 640px) {
    .empty-state p {
        font-size: 0.813rem;
    }
}

/* Dialog/Modal */
.dialog-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 50;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

@media (max-width: 640px) {
    .dialog-overlay {
        padding: 0.5rem;
        align-items: flex-end; /* Position at bottom on mobile */
    }
}

.dialog-overlay.active {
    display: flex;
}

.dialog-content {
    background-color: var(--color-white);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-xl);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

@media (max-width: 640px) {
    .dialog-content {
        max-height: 85vh;
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
    }
}

.dialog-header {
    padding: 1.5rem 1.5rem 1rem;
}

@media (max-width: 640px) {
    .dialog-header {
        padding: 1.25rem 1rem 0.75rem;
    }
}

.dialog-header h2 {
    color: var(--color-gray-900);
    margin-bottom: 0.25rem;
}

.dialog-header p {
    font-size: 0.875rem;
    color: var(--color-gray-500);
}

@media (max-width: 640px) {
    .dialog-header p {
        font-size: 0.813rem;
    }
}

.dialog-body {
    padding: 0 1.5rem 1rem;
}

@media (max-width: 640px) {
    .dialog-body {
        padding: 0 1rem 1rem;
    }
}

.dialog-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--color-gray-200);
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    flex-wrap: wrap;
}

@media (max-width: 640px) {
    .dialog-footer {
        padding: 1rem;
        gap: 0.5rem;
    }
    
    .dialog-footer .btn {
        flex: 1;
        min-width: 0;
    }
}

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

@media (max-width: 640px) {
    .form-group {
        margin-bottom: 0.875rem;
    }
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-gray-700);
    margin-bottom: 0.5rem;
}

@media (max-width: 640px) {
    .form-group label {
        font-size: 0.813rem;
    }
}

.input,
.select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid var(--color-gray-300);
    border-radius: var(--border-radius);
    background-color: var(--color-white);
    transition: all 0.2s ease;
}

@media (max-width: 640px) {
    .input,
    .select {
        font-size: 1rem; /* Prevent zoom on iOS */
        padding: 0.625rem 0.75rem;
    }
}

.input:focus,
.select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.checkbox {
    width: 1rem;
    height: 1rem;
    border: 1px solid var(--color-gray-300);
    border-radius: 0.25rem;
    cursor: pointer;
    flex-shrink: 0;
}

@media (max-width: 640px) {
    .checkbox {
        width: 1.125rem;
        height: 1.125rem;
    }
}

.checkbox-group label {
    margin-bottom: 0;
    cursor: pointer;
}

/* Utility Classes */
.btn-full {
    width: 100%;
}

/* Touch-friendly interactions on mobile */
@media (max-width: 640px) {
    button,
    a,
    .btn {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    }
}

/* Prevent text selection on buttons */
button,
.btn {
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
}


/* Settings Dialog Specific Styles */

/* Settings Dialog Overlay */
#settings-dialog.dialog-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 50;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    backdrop-filter: blur(2px);
}

@media (max-width: 640px) {
    #settings-dialog.dialog-overlay {
        padding: 0.5rem;
        align-items: flex-end;
    }
}

#settings-dialog.dialog-overlay.active {
    display: flex;
    animation: fadeIn 0.2s ease;
}

/* Settings Dialog Content */
#settings-dialog .dialog-content {
    background-color: var(--color-white);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-xl);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

@media (max-width: 640px) {
    #settings-dialog .dialog-content {
        max-height: 85vh;
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
    }
}

/* Settings Dialog Header Layout */
#settings-dialog .dialog-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 1.5rem 1.5rem 1.25rem;
    gap: 1rem;
}

@media (max-width: 640px) {
    #settings-dialog .dialog-header {
        padding: 1.25rem 1rem 1rem;
        gap: 0.75rem;
    }
}

/* Header Text Container */
#settings-dialog .header-text {
    flex: 1;
    min-width: 0;
}

#settings-dialog .header-text h2 {
    color: var(--color-gray-900);
    margin-bottom: 0.25rem;
    font-size: 1.5rem;
    font-weight: 700;
}

@media (max-width: 640px) {
    #settings-dialog .header-text h2 {
        font-size: 1.25rem;
    }
}

#settings-dialog .header-text p {
    font-size: 0.938rem;
    color: var(--color-gray-500);
    margin: 0;
}

@media (max-width: 640px) {
    #settings-dialog .header-text p {
        font-size: 0.875rem;
    }
}

/* Close Button - Top Right with Blue Theme */
#settings-dialog .dialog-header .btn-outline {
    flex-shrink: 0;
    background-color: var(--color-white);
    border: 1px solid var(--color-primary);
    color: var(--color-primary);
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

#settings-dialog .dialog-header .btn-outline:hover {
    background-color: var(--color-primary);
    color: var(--color-white);
    border-color: var(--color-primary);
}

#settings-dialog .dialog-header .btn-outline:active {
    transform: scale(0.98);
}

@media (max-width: 640px) {
    #settings-dialog .dialog-header .btn-outline {
        padding: 0.5rem 0.875rem;
        font-size: 0.875rem;
        min-height: 38px;
    }
}

/* Settings Dialog Body */
#settings-dialog .dialog-body {
    padding: 0 1.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

@media (max-width: 640px) {
    #settings-dialog .dialog-body {
        padding: 0 1rem 1rem;
        gap: 0.875rem;
    }
}

/* Form Groups - Light Gray Boxes */
#settings-dialog .form-group {
    background-color: var(--color-gray-50);
    border: 1px solid var(--color-gray-200);
    border-radius: var(--border-radius-lg);
    padding: 1.25rem;
    margin-bottom: 0;
}

@media (max-width: 640px) {
    #settings-dialog .form-group {
        padding: 1rem;
    }
}

/* Last form group (Sign Out button) - no background */
#settings-dialog .dialog-body > .form-group:last-child {
    background-color: transparent;
    border: none;
    padding: 0;
    margin-top: 0.5rem;
}

#settings-dialog .form-group label {
    display: block;
    font-size: 0.938rem;
    font-weight: 600;
    color: var(--color-gray-900);
    margin-bottom: 0.75rem;
}

@media (max-width: 640px) {
    #settings-dialog .form-group label {
        font-size: 0.875rem;
        margin-bottom: 0.625rem;
    }
}

/* Select Dropdown */
#settings-dialog .select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.938rem;
    border: 1px solid var(--color-gray-300);
    border-radius: var(--border-radius);
    background-color: var(--color-white);
    color: var(--color-gray-900);
    cursor: pointer;
    transition: all 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234b5563' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1.25rem;
    padding-right: 2.5rem;
}

@media (max-width: 640px) {
    #settings-dialog .select {
        font-size: 1rem; /* Prevent iOS zoom */
        padding: 0.75rem 0.875rem;
        padding-right: 2.5rem;
    }
}

#settings-dialog .select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

@media (max-width: 640px) {
    #settings-dialog .select:focus {
        box-shadow: 0 0 0 2px var(--color-primary-light);
    }
}

#settings-dialog .select:hover {
    border-color: var(--color-gray-400);
}

/* Sign Out Button - Red Theme at Bottom */
#settings-dialog #logoutBtn {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    font-size: 0.938rem;
    font-weight: 500;
    background-color: var(--color-white);
    border: 2px solid var(--color-danger);
    color: var(--color-danger);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s ease;
}

#settings-dialog #logoutBtn:hover {
    background-color: var(--color-danger);
    color: var(--color-white);
    border-color: var(--color-danger);
}

#settings-dialog #logoutBtn:active {
    transform: scale(0.98);
}

@media (max-width: 640px) {
    #settings-dialog #logoutBtn {
        padding: 0.875rem 1rem;
        font-size: 1rem;
        min-height: 48px;
    }
}

#settings-dialog #logoutBtn .icon {
    flex-shrink: 0;
}

/* Icon sizing in buttons */
#settings-dialog .icon-sm {
    width: 1.125rem;
    height: 1.125rem;
    stroke-width: 2;
}

@media (max-width: 640px) {
    #settings-dialog .icon-sm {
        width: 1.25rem;
        height: 1.25rem;
    }
}

/* Fade in animation */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Dialog content animation */
#settings-dialog.active .dialog-content {
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Custom Scrollbar for Settings Dialog */
#settings-dialog .dialog-content::-webkit-scrollbar {
    width: 8px;
}

#settings-dialog .dialog-content::-webkit-scrollbar-track {
    background: var(--color-gray-100);
    border-radius: var(--border-radius);
}

#settings-dialog .dialog-content::-webkit-scrollbar-thumb {
    background: var(--color-gray-300);
    border-radius: var(--border-radius);
}

#settings-dialog .dialog-content::-webkit-scrollbar-thumb:hover {
    background: var(--color-gray-400);
}

/* Focus visible for accessibility */
#settings-dialog button:focus-visible,
#settings-dialog select:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* Disabled state */
#settings-dialog button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#settings-dialog button:disabled:hover {
    background-color: var(--color-white);
    color: var(--color-danger);
    border-color: var(--color-danger);
}

/* Touch optimization for mobile */
@media (max-width: 640px) {
    #settings-dialog button {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
        touch-action: manipulation;
        -webkit-user-select: none;
        user-select: none;
    }
}

/* Hover effects for select dropdown */
#settings-dialog .select:not(:disabled):hover {
    border-color: var(--color-gray-400);
}

#settings-dialog .select:disabled {
    background-color: var(--color-gray-100);
    cursor: not-allowed;
    opacity: 0.6;
}

/* Close button on click animation */
#settings-dialog .dialog-header .btn-outline:active {
    transform: scale(0.95);
}

/* Sign out button loading state (optional) */
#settings-dialog #logoutBtn.loading {
    position: relative;
    color: transparent;
}

#settings-dialog #logoutBtn.loading::after {
    content: "";
    position: absolute;
    width: 1rem;
    height: 1rem;
    top: 50%;
    left: 50%;
    margin-left: -0.5rem;
    margin-top: -0.5rem;
    border: 2px solid var(--color-danger);
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 0.6s linear infinite;
}

#settings-dialog #logoutBtn.loading:hover::after {
    border-color: var(--color-white);
    border-top-color: transparent;
}

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

/* Stats Bar */
#stats-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: .75rem;
    margin-bottom: 1.5rem;
}

.stats-card {
    padding: 1rem !important;
}

.stats-label {
    font-size: .75rem;
    font-weight: 500;
    color: var(--color-gray-500);
    margin-bottom: .25rem;
    line-height: 1.3;
}

.stats-number {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--color-gray-900);
    line-height: 1;
}

@media (max-width: 640px) {
    #stats-bar {
        grid-template-columns: 1fr 1fr;
    }
    .stats-number {
        font-size: 1.5rem;
    }
}


