/* ==========================================================================
   PARKINSON ECOSYSTEM - DESIGN SYSTEM & ACCESSIBILITY (WCAG AA/AAA)
   Tối ưu hóa đặc biệt cho người cao tuổi và bệnh nhân suy giảm vận động
   ========================================================================== */

/* 1. TYPOGRAPHY & FONT SETUP */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Inter:wght@400;500;600;700&display=swap');

/* 2. DESIGN TOKENS (LIGHT THEME - DEFAULT) */
:root {
    --base-font-size: 16px;
    --font-sans: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

    /* Theme Colors: Medical Blue & Slate Foundation */
    --bg-page: #f1f5f9;
    --bg-page-gradient: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    --bg-card: #ffffff;
    --bg-card-subtle: #f8fafc;
    --bg-card-hover: #f1f5f9;
    --bg-sidebar: #ffffff;
    --bg-header: rgba(255, 255, 255, 0.92);

    /* Text Colors (Đạt chuẩn độ tương phản WCAG AA >= 4.5:1) */
    --text-primary: #0f172a;    /* Contrast ratio 14:1 trên #ffffff */
    --text-secondary: #334155;  /* Contrast ratio 8.5:1 trên #ffffff */
    --text-muted: #475569;      /* Contrast ratio 5.9:1 trên #ffffff */
    --text-light: #64748b;

    /* Border & Lines */
    --border-color: #e2e8f0;
    --border-color-hover: #cbd5e1;
    --border-color-focus: #2563eb;

    /* Brand Primary (Xanh Y tế Hiện đại) */
    --primary-50: #eff6ff;
    --primary-100: #dbeafe;
    --primary-200: #bfdbfe;
    --primary-500: #3b82f6;
    --primary-600: #2563eb;
    --primary-700: #1d4ed8;
    --primary-800: #1e40af;
    --primary-900: #1e3a8a;
    --brand-gradient: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    --brand-gradient-hover: linear-gradient(135deg, #162e58 0%, #1f4078 100%);

    /* Semantic Feedback Colors */
    --success: #059669;
    --success-bg: #ecfdf5;
    --success-border: #a7f3d0;
    --success-text: #065f46;

    --warning: #d97706;
    --warning-bg: #fffbeb;
    --warning-border: #fde68a;
    --warning-text: #92400e;

    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --danger-border: #fecaca;
    --danger-text: #991b1b;

    --info: #0284c7;
    --info-bg: #f0f9ff;
    --info-border: #bae6fd;
    --info-text: #075985;

    /* Shadows & Elevations */
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.07);
    --shadow-lg: 0 10px 25px -5px rgba(15, 23, 42, 0.08), 0 8px 10px -6px rgba(15, 23, 42, 0.03);
    --shadow-xl: 0 20px 35px -8px rgba(15, 23, 42, 0.12);
    --shadow-inner: inset 0 2px 4px rgba(0, 0, 0, 0.05);

    /* Radii */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Transitions & Focus */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-smooth: 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    --focus-ring: 0 0 0 3px rgba(37, 99, 235, 0.45);
    --focus-offset: 2px;

    /* Layout Dimensions */
    --sidebar-width: 280px;
    --header-height: 76px;
    --min-touch-target: 48px; /* Chuẩn web.dev: ít nhất 48x48px */
}

/* 3. DARK THEME TOKENS */
[data-theme="dark"] {
    --bg-page: #0b1120;
    --bg-page-gradient: linear-gradient(135deg, #0b1120 0%, #0f172a 100%);
    --bg-card: #131d33;
    --bg-card-subtle: #1a2642;
    --bg-card-hover: #1e2c4c;
    --bg-sidebar: #0f172a;
    --bg-header: rgba(15, 23, 42, 0.92);

    --text-primary: #f8fafc;
    --text-secondary: #e2e8f0;
    --text-muted: #cbd5e1;
    --text-light: #94a3b8;

    --border-color: #24324f;
    --border-color-hover: #33446b;
    --border-color-focus: #60a5fa;

    --primary-50: rgba(59, 130, 246, 0.12);
    --primary-100: rgba(59, 130, 246, 0.2);
    --primary-500: #60a5fa;
    --primary-600: #3b82f6;
    --primary-700: #2563eb;
    --brand-gradient: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);

    --success-bg: rgba(5, 150, 105, 0.18);
    --success-text: #6ee7b7;
    --warning-bg: rgba(217, 119, 6, 0.18);
    --warning-text: #fcd34d;
    --danger-bg: rgba(220, 38, 38, 0.18);
    --danger-text: #fca5a5;
    --info-bg: rgba(2, 132, 199, 0.18);
    --info-text: #7dd3fc;

    --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.45);
    --focus-ring: 0 0 0 3px rgba(96, 165, 250, 0.55);
}

/* 4. HIGH-CONTRAST MODE (Dành cho người già, thị lực kém - WCAG AAA >= 7:1) */
[data-contrast="high"] {
    --text-primary: #000000 !important;
    --text-secondary: #000000 !important;
    --text-muted: #1e293b !important;
    --border-color: #000000 !important;
    --border-color-focus: #000000 !important;
    --bg-page: #ffffff !important;
    --bg-card: #ffffff !important;
    --bg-card-subtle: #f8fafc !important;
    --focus-ring: 0 0 0 4px #000000 !important;
}

[data-theme="dark"][data-contrast="high"] {
    --text-primary: #ffffff !important;
    --text-secondary: #ffffff !important;
    --text-muted: #f1f5f9 !important;
    --border-color: #ffffff !important;
    --border-color-focus: #facc15 !important;
    --bg-page: #000000 !important;
    --bg-card: #0a0a0a !important;
    --bg-card-subtle: #171717 !important;
    --focus-ring: 0 0 0 4px #facc15 !important;
}

/* 5. DYNAMIC FONT SIZES (ĐIỀU CHỈNH CỠ CHỮ CHO NGƯỜI CAO TUỔI) */
html {
    font-size: var(--base-font-size);
}
[data-font-size="small"] { --base-font-size: 14px; }
[data-font-size="normal"] { --base-font-size: 16px; }
[data-font-size="large"] { --base-font-size: 18px; }
[data-font-size="xlarge"] { --base-font-size: 20px; }

/* 6. RESET & ACCESSIBILITY DEFAULTS */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-page-gradient);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* 7. FOCUS VISIBLE MANAGEMENT (CRITICAL A11Y) */
:focus-visible {
    outline: 3px solid var(--border-color-focus) !important;
    outline-offset: var(--focus-offset) !important;
    border-radius: 4px;
}

/* Bỏ outline mặc định khi click chuột, chỉ hiển thị khi dùng bàn phím */
:focus:not(:focus-visible) {
    outline: none;
}

/* Skip link dành cho người dùng điều hướng bàn phím */
.skip-link {
    position: absolute;
    top: -60px;
    left: 20px;
    background: var(--primary-700);
    color: #ffffff;
    padding: 14px 22px;
    font-size: 1rem;
    font-weight: 700;
    z-index: 9999;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xl);
    text-decoration: none;
    transition: top var(--transition-fast);
}
.skip-link:focus {
    top: 20px;
    outline: 4px solid #facc15;
}

/* Screen reader only */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Giảm chuyển động cho người nhạy cảm tiền đình hoặc Parkinson */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* 8. AUTH PAGE LAYOUT (INDEX.HTML) */
.auth-body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 24px;
    background: var(--bg-page-gradient);
    position: relative;
}

.auth-container {
    background: var(--bg-card);
    width: 100%;
    max-width: 460px;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: transform var(--transition-normal);
}

.auth-header {
    background: var(--brand-gradient);
    color: #ffffff;
    text-align: center;
    padding: 38px 24px 28px;
    position: relative;
}

.auth-header .brand-icon {
    font-size: 40px;
    color: #93c5fd;
    margin-bottom: 12px;
    display: inline-block;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.2));
}

.auth-header h1 {
    font-size: 1.55rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    line-height: 1.3;
    margin-bottom: 6px;
    color: #ffffff;
}

.auth-header p {
    font-size: 0.95rem;
    color: #e2e8f0;
    font-weight: 500;
    max-width: 340px;
    margin: 0 auto;
}

.tabs {
    display: flex;
    background: var(--bg-card-subtle);
    border-bottom: 2px solid var(--border-color);
    role: tablist;
}

.tab-btn {
    flex: 1;
    min-height: var(--min-touch-target);
    padding: 16px 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-muted);
    transition: all var(--transition-fast);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.tab-btn:hover {
    color: var(--primary-700);
    background: rgba(37, 99, 235, 0.05);
}

.tab-btn.active {
    color: var(--primary-700);
    background: var(--bg-card);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--primary-600);
    border-radius: 4px 4px 0 0;
}

.auth-form {
    display: none;
    padding: 32px 28px;
    animation: fadeIn 0.3s ease;
}

.auth-form.active {
    display: block;
}

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

/* 9. FORM CONTROLS & INPUTS (TẬP TRUNG TƯƠNG TÁC RÕ RÀNG) */
.form-group {
    margin-bottom: 22px;
    position: relative;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.form-group .input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.form-group .input-icon {
    position: absolute;
    left: 16px;
    color: var(--text-muted);
    font-size: 1.1rem;
    pointer-events: none;
}

.form-group input {
    width: 100%;
    min-height: var(--min-touch-target);
    padding: 12px 16px 12px 46px;
    background: var(--bg-card-subtle);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}

.form-group input.no-icon {
    padding-left: 16px;
}

.form-group input::placeholder {
    color: var(--text-light);
    opacity: 0.85;
}

.form-group input:hover {
    border-color: var(--border-color-hover);
}

.form-group input:focus {
    background: var(--bg-card);
    border-color: var(--primary-600);
    box-shadow: var(--focus-ring);
    outline: none;
}

.password-toggle-btn {
    position: absolute;
    right: 8px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    min-width: 40px;
    min-height: 40px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: color var(--transition-fast);
}
.password-toggle-btn:hover {
    color: var(--text-primary);
}

.error-msg {
    color: var(--danger);
    font-size: 0.92rem;
    min-height: 22px;
    margin-bottom: 12px;
    text-align: center;
    font-weight: 600;
}

.footer-note {
    text-align: center;
    padding: 18px 24px;
    font-size: 0.85rem;
    color: var(--text-muted);
    background: var(--bg-card-subtle);
    border-top: 1px solid var(--border-color);
}

/* 10. BUTTONS & INTERACTIVE ELEMENTS */
.submit-btn, .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: var(--min-touch-target);
    padding: 14px 24px;
    font-size: 1.05rem;
    font-weight: 700;
    border-radius: var(--radius-md);
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}

.submit-btn {
    width: 100%;
    background: var(--brand-gradient);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(30, 60, 114, 0.25);
    margin-top: 8px;
}

.submit-btn:hover:not(:disabled) {
    background: var(--brand-gradient-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(30, 60, 114, 0.35);
}

.submit-btn:active:not(:disabled) {
    transform: translateY(0);
}

.submit-btn:disabled, .btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.btn-primary {
    background: var(--primary-600);
    color: #ffffff;
}
.btn-primary:hover:not(:disabled) {
    background: var(--primary-700);
}

.btn-success {
    background: var(--success);
    color: #ffffff;
}
.btn-success:hover:not(:disabled) {
    background: #047857;
}

.btn-danger {
    background: var(--danger);
    color: #ffffff;
}
.btn-danger:hover:not(:disabled) {
    background: #b91c1c;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--border-color);
    color: var(--text-primary);
}
.btn-outline:hover {
    background: var(--bg-card-subtle);
    border-color: var(--border-color-hover);
}

/* 11. DASHBOARD APPLICATION LAYOUT */
.dashboard-body {
    display: flex;
    background-color: var(--bg-page);
    min-height: 100vh;
    position: relative;
}

/* Mobile Header Bar */
.mobile-topbar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: var(--bg-header);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 1050;
    padding: 0 16px;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.mobile-nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: transparent;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 1.25rem;
    cursor: pointer;
}

/* Sidebar Navigation */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    z-index: 1000;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transition: transform var(--transition-smooth);
}

.sidebar-header {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    border-bottom: 2px solid var(--border-color);
}

.sidebar-header .logo-icon {
    font-size: 32px;
    color: var(--primary-600);
}

.sidebar-header h2 {
    font-size: 1.35rem;
    color: var(--text-primary);
    font-weight: 800;
    letter-spacing: -0.3px;
}

.nav-links {
    list-style: none;
    padding: 16px 12px;
    flex: 1;
}

.nav-links li {
    margin-bottom: 6px;
}

.nav-links li a {
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: var(--min-touch-target);
    padding: 12px 18px;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 1.05rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.nav-links li a i {
    width: 26px;
    font-size: 1.25rem;
    text-align: center;
    color: var(--text-muted);
    transition: color var(--transition-fast);
}

.nav-links li a:hover {
    background: var(--bg-card-subtle);
    color: var(--primary-700);
}
.nav-links li a:hover i {
    color: var(--primary-600);
}

.nav-links li.active a {
    background: var(--primary-50);
    color: var(--primary-700);
    font-weight: 700;
}
.nav-links li.active a i {
    color: var(--primary-600);
}

.sidebar-footer {
    padding: 20px 16px;
    border-top: 1px solid var(--border-color);
}

.logout-btn {
    width: 100%;
    min-height: var(--min-touch-target);
    padding: 14px;
    background: var(--danger-bg);
    color: var(--danger-text);
    border: 2px solid var(--danger-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all var(--transition-fast);
}

.logout-btn:hover {
    background: var(--danger);
    color: #ffffff;
    border-color: var(--danger);
}

/* Sidebar overlay on mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 999;
}

/* Main Content Area */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 32px 36px;
    min-height: 100vh;
    flex: 1;
    max-width: 1440px;
    transition: margin-left var(--transition-smooth);
}

/* Top Header Bar */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
    gap: 20px;
    flex-wrap: wrap;
}

.top-header h1 {
    color: var(--text-primary);
    font-size: 1.85rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.top-header p {
    color: var(--text-muted);
    font-size: 1.05rem;
    margin-top: 4px;
    font-weight: 500;
}

/* Header Action Controls (A11y Toolbar + Profile) */
.header-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

/* Accessibility Control Toolbar */
.a11y-toolbar {
    display: inline-flex;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    padding: 4px;
    box-shadow: var(--shadow-sm);
    gap: 2px;
}

.a11y-btn {
    min-width: 38px;
    min-height: 38px;
    padding: 6px 10px;
    border-radius: var(--radius-full);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.a11y-btn:hover {
    background: var(--bg-card-hover);
    color: var(--primary-600);
}

.a11y-btn.active {
    background: var(--primary-600);
    color: #ffffff;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-card);
    padding: 8px 18px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.user-profile .avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--primary-600);
    color: #ffffff;
    font-size: 1.15rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-profile .info .name {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.user-profile .info .role {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* 12. DASHBOARD CARDS & GRID */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 26px 28px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
    position: relative;
}

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

.card h2, .card h3 {
    font-size: 1.25rem;
    color: var(--text-primary);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 14px;
    margin-bottom: 18px;
}

.card h2 i, .card h3 i {
    color: var(--primary-600);
    font-size: 1.35rem;
}

/* Clinical Questionnaire Cards */
.question-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.question-card:hover {
    border-color: var(--border-color-hover);
}

.question-card.answered {
    border-left: 6px solid var(--success);
}

.question-card h3 {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 16px;
    font-size: 1.15rem;
    color: var(--text-primary);
    line-height: 1.4;
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 52px;
    padding: 12px 18px;
    background: var(--bg-card-subtle);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
    transition: all var(--transition-fast);
    user-select: none;
}

.radio-label:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-color-hover);
}

.radio-label input[type="radio"] {
    width: 22px;
    height: 22px;
    min-width: 22px;
    accent-color: var(--primary-600);
    cursor: pointer;
}

.radio-label.selected {
    background: var(--primary-50);
    border-color: var(--primary-600);
    color: var(--primary-800);
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.15);
}

/* 13. HOSPITAL & EXERCISE ITEMS */
.hospital-item, .exercise-item {
    padding: 16px 20px;
    background: var(--bg-card-subtle);
    border-left: 5px solid var(--primary-600);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    margin-bottom: 14px;
    transition: transform var(--transition-fast);
}

.hospital-item:hover, .exercise-item:hover {
    transform: translateX(4px);
    background: var(--bg-card-hover);
}

.hospital-item strong, .exercise-item strong {
    color: var(--text-primary);
    font-size: 1.05rem;
    display: block;
    margin-bottom: 4px;
}

.hospital-item p, .exercise-item p {
    font-size: 0.95rem;
    color: var(--text-muted);
}

/* 14. BADGES & STATUS LABELS */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 0.88rem;
    font-weight: 700;
}

.badge-success {
    background: var(--success-bg);
    color: var(--success-text);
    border: 1px solid var(--success-border);
}

.badge-danger {
    background: var(--danger-bg);
    color: var(--danger-text);
    border: 1px solid var(--danger-border);
}

.badge-warning {
    background: var(--warning-bg);
    color: var(--warning-text);
    border: 1px solid var(--warning-border);
}

.badge-primary {
    background: var(--primary-50);
    color: var(--primary-700);
    border: 1px solid var(--primary-200);
}

/* 15. TABLES */
.table-responsive {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    background: var(--bg-card);
}

.history-table th {
    padding: 14px 18px;
    background: var(--bg-card-subtle);
    color: var(--text-secondary);
    font-size: 0.92rem;
    font-weight: 700;
    border-bottom: 2px solid var(--border-color);
}

.history-table td {
    padding: 16px 18px;
    font-size: 0.98rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.history-table tbody tr:last-child td {
    border-bottom: none;
}

.history-table tbody tr:hover {
    background-color: var(--bg-card-hover);
}

/* 16. TOAST NOTIFICATIONS (THAY THẾ ALERT BROWSER ĐỂ ĐẢM BẢO A11Y) */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 420px;
    pointer-events: none;
}

.toast {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    box-shadow: var(--shadow-xl);
    border-left: 6px solid var(--primary-600);
    border-top: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    color: var(--text-primary);
    pointer-events: auto;
    animation: toastSlideIn 0.3s ease;
    min-height: 52px;
}

.toast.toast-success { border-left-color: var(--success); }
.toast.toast-danger, .toast.toast-error { border-left-color: var(--danger); }
.toast.toast-warning { border-left-color: var(--warning); }
.toast.toast-info { border-left-color: var(--info); }

.toast-content {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.95rem;
    font-weight: 600;
}

.toast-close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    font-size: 1.1rem;
    border-radius: var(--radius-sm);
    min-width: 32px;
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.toast-close-btn:hover {
    color: var(--text-primary);
}

@keyframes toastSlideIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

/* 17. RESPONSIVE BREAKPOINTS */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 260px;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .main-content {
        padding: 24px 20px;
    }
}

@media (max-width: 768px) {
    .mobile-topbar {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay.active {
        display: block;
    }

    .main-content {
        margin-left: 0;
        padding-top: calc(64px + 20px);
        padding-left: 16px;
        padding-right: 16px;
    }

    .top-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .header-actions {
        width: 100%;
        justify-content: space-between;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 18px;
    }

    .card {
        padding: 20px 18px;
    }

    .auth-container {
        border-radius: var(--radius-lg);
    }

    .toast-container {
        left: 16px;
        right: 16px;
        bottom: 80px;
        max-width: none;
    }

    /* Đảm bảo nội dung không bị thanh điều hướng che khuất trên điện thoại */
    .main-content {
        padding-bottom: calc(85px + env(safe-area-inset-bottom, 0px)) !important;
    }
}

/* ==========================================================================
   18. MOBILE BOTTOM NAVIGATION (TỐI ƯU HÓA ĐẶC BIỆT CHO ĐIỆN THOẠI THÔNG MINH)
   Thiết kế chuẩn ứng dụng di động bản địa (Native Mobile App Experience)
   ========================================================================== */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(64px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.08);
    z-index: 1000;
    align-items: center;
    justify-content: space-around;
}

[data-theme="dark"] .mobile-bottom-nav {
    background: rgba(15, 23, 42, 0.95);
    border-top-color: var(--border-color);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
}

[data-contrast="high"] .mobile-bottom-nav {
    background: #ffffff !important;
    border-top: 3px solid #000000 !important;
}

[data-theme="dark"][data-contrast="high"] .mobile-bottom-nav {
    background: #000000 !important;
    border-top: 3px solid #ffffff !important;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex: 1;
    height: 100%;
    min-height: 48px; /* Chuẩn tiếp cận ngón tay chạm Web.dev */
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 700;
    transition: var(--transition-fast);
    position: relative;
    padding: 6px 2px;
}

.mobile-nav-item i {
    font-size: 1.25rem;
    transition: transform var(--transition-fast);
}

.mobile-nav-item:hover, .mobile-nav-item:focus-visible {
    color: var(--primary-600);
    outline: none;
}

.mobile-nav-item.active {
    color: var(--primary-600);
}

.mobile-nav-item.active i {
    transform: translateY(-2px);
    color: var(--primary-600);
}

.mobile-nav-item.active::after {
    content: "";
    position: absolute;
    top: 0;
    left: 25%;
    right: 25%;
    height: 3px;
    background: var(--primary-600);
    border-radius: 0 0 4px 4px;
}

@media (max-width: 768px) {
    .mobile-bottom-nav {
        display: flex;
    }
}

/* ==========================================================================
   19. HƯỚNG DẪN TƯ THẾ ĐO RUN TAY & HÌNH BÀN TAY QUANG HỌC (TREMOR PROTOCOLS)
   Giải quyết trực tiếp yêu cầu: "Hình bàn tay dơ để người dùng biết"
   ========================================================================== */
.posture-selector-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.posture-card {
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    cursor: pointer;
    transition: all var(--transition-normal);
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-align: left;
    position: relative;
}

.posture-card:hover {
    border-color: var(--primary-500);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.posture-card.active {
    border-color: var(--primary-600);
    background: var(--primary-50);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

[data-theme="dark"] .posture-card.active {
    background: rgba(37, 99, 235, 0.12);
}

.posture-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.posture-icon-badge {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    background: var(--primary-100);
    color: var(--primary-700);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    flex-shrink: 0;
}

.posture-card.active .posture-icon-badge {
    background: var(--primary-600);
    color: #ffffff;
}

.posture-title {
    font-size: 0.98rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
}

.posture-desc {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.posture-badge {
    align-self: flex-start;
    font-size: 0.75rem;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    font-weight: 700;
    background: var(--bg-card-subtle);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

.posture-card.active .posture-badge {
    background: var(--primary-100);
    color: var(--primary-800);
    border-color: var(--primary-200);
}

/* Khung hình bàn tay mẫu đè trên camera (Silhouette Overlay) */
.hand-guide-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 5;
    transition: opacity 0.3s ease;
}

.hand-silhouette-svg {
    width: 200px;
    height: 240px;
    max-width: 60%;
    max-height: 60%;
    stroke: rgba(250, 204, 21, 0.85); /* Vàng tươi dễ nhìn */
    stroke-width: 2.5;
    stroke-dasharray: 8 6;
    fill: rgba(250, 204, 21, 0.08);
    animation: dashPulse 2s linear infinite;
    filter: drop-shadow(0 0 8px rgba(0,0,0,0.8));
}

.hand-guide-overlay.detected .hand-silhouette-svg {
    stroke: #10b981;
    fill: rgba(16, 185, 129, 0.15);
    stroke-dasharray: none;
    animation: none;
}

@keyframes dashPulse {
    0% { stroke-dashoffset: 0; transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { stroke-dashoffset: 28; transform: scale(1); }
}

.hand-guide-hint {
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    color: #ffffff;
    font-size: 0.92rem;
    font-weight: 700;
    padding: 6px 14px;
    border-radius: var(--radius-full);
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

/* ==========================================================================
   20. RESEARCH & SCIENTIFIC ECOSYSTEM HUB (THƯ VIỆN KHOA HỌC & Y HỌC)
   Cung cấp thông tin nghiên cứu quốc tế, cơ chế bệnh học, bài tập phục hồi
   ========================================================================== */
.research-hero {
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 50%, #0284c7 100%);
    border-radius: var(--radius-lg);
    padding: 32px 28px;
    color: #ffffff;
    margin-bottom: 24px;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.research-hero::after {
    content: "";
    position: absolute;
    right: -40px;
    bottom: -40px;
    width: 240px;
    height: 240px;
    background: radial-gradient(circle, rgba(255,255,255,0.18) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

.research-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-top: 24px;
}

.research-stat-card {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: var(--radius-md);
    padding: 14px 18px;
}

.research-stat-num {
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1.1;
}

.research-stat-label {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.9);
    margin-top: 4px;
    font-weight: 600;
}

.paper-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 16px;
    transition: all var(--transition-normal);
}

.paper-card:hover {
    border-color: var(--primary-500);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.paper-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.paper-journal-badge {
    background: var(--primary-50);
    color: var(--primary-700);
    border: 1px solid var(--primary-200);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: var(--radius-full);
}

.paper-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.4;
    margin-bottom: 10px;
}

.paper-summary {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 14px;
}

.rehab-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 18px;
    margin-top: 16px;
}

.rehab-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.rehab-card h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    color: var(--primary-700);
    margin-bottom: 10px;
}

.rehab-card ul {
    padding-left: 20px;
    margin-bottom: 14px;
    color: var(--text-secondary);
    font-size: 0.92rem;
    line-height: 1.6;
}