:root {
    --primary: #1a1a1a;
    --secondary: #4a4a4a;
    --accent: #d4af37;
    --beige: #f5f5dc;
    --gray: #e8e8e8;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    /* EEG / Channel UI colors (used by canvas CSS variables and channel elements) */
    --eeg-line: rgba(26,26,26,0.9);
    --eeg-grid: rgba(26,26,26,0.06);
    --channel-bg: #f3f4f6;
    --channel-fill-start: var(--primary);
    --channel-fill-end: var(--accent);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Segoe UI', sans-serif;
    overflow-x: hidden;
    background: radial-gradient(circle at top, #ffffff 0%, #f5f5dc 40%, #e8e8e8 100%);
    position: relative;
}

.eeg-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 120%;
    height: 120%;
    z-index: -1; /* keep background waves behind UI */
    opacity: 0.12;
    pointer-events: none;
}

.eeg-wave {
    position: absolute;
    width: 100%;
    height: 80px;
    opacity: 0.7;
}

.eeg-wave:nth-child(1) { top: 5%; animation: wave1 4.2s ease-in-out infinite; }
.eeg-wave:nth-child(2) { top: 15%; animation: wave2 3.8s ease-in-out infinite 0.3s; }
.eeg-wave:nth-child(3) { top: 25%; animation: wave3 4.5s ease-in-out infinite 0.6s; }
.eeg-wave:nth-child(4) { top: 35%; animation: wave1 3.5s ease-in-out infinite 0.9s; }
.eeg-wave:nth-child(5) { top: 45%; animation: wave2 4.1s ease-in-out infinite 1.2s; }
.eeg-wave:nth-child(6) { top: 55%; animation: wave3 3.9s ease-in-out infinite 1.5s; }
.eeg-wave:nth-child(7) { top: 65%; animation: wave1 4.3s ease-in-out infinite 1.8s; }
.eeg-wave:nth-child(8) { top: 75%; animation: wave2 3.7s ease-in-out infinite 2.1s; }
.eeg-wave:nth-child(9) { top: 85%; animation: wave3 4.0s ease-in-out infinite 2.4s; }
.eeg-wave:nth-child(10) { top: 95%; animation: wave1 3.6s ease-in-out infinite 2.7s; }

@keyframes wave1 {
    0%, 100% { transform: translateX(0) scaleY(5); }
    25% { transform: translateX(-15px) translateY(-8px); }
    50% { transform: translateX(-30px) translateY(5px); }
    75% { transform: translateX(-20px) translateY(-5px); }
}

@keyframes wave2 {
    0%, 100% { transform: translateX(0) scaleY(5); }
    33% { transform: translateX(-25px) scaleY(1.1); }
    66% { transform: translateX(-35px) scaleY(0.95); }
}

@keyframes wave3 {
    0%, 100% { transform: translateX(0) translateY(0) scaleY(5); }
    50% { transform: translateX(-40px) translateY(10px) scaleX(0.98); }
}

.glow-blob {
    position: fixed;
    border-radius: 999px;
    filter: blur(80px);
    pointer-events: none;
    z-index: 0;
    animation: blobFloat 8s ease-in-out infinite;
}

.glow-blob.gold { width: 350px; height: 350px; background: rgba(212, 175, 55, 0.35); top: -80px; right: 8%; }
.glow-blob.beige { width: 320px; height: 320px; background: rgba(245, 245, 220, 0.9); bottom: -60px; left: -60px; }
.glow-blob.gray { width: 280px; height: 280px; background: rgba(232, 232, 232, 0.6); top: 50%; left: 30%; animation-delay: 2s; }

@keyframes blobFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(20px, -30px) scale(1.05); }
    66% { transform: translate(-30px, 20px) scale(0.95); }
}

.top-header {
    background: rgba(26, 26, 26, 0.96);
    color: white;
    padding: 0.9rem 0;
    box-shadow: 0 10px 30px rgba(0,0,0,0.25);
    position: sticky;
    top: 0;
    z-index: 900;
    backdrop-filter: blur(14px);
}

.logo {
    display: flex;
    align-items: center;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.04em;
}

.logo i { margin-right: 0.5rem; animation: pulse 2.2s infinite; }

@keyframes pulse {
    0%, 100% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(212,175,55,0.0)); }
    50% { transform: scale(1.08); filter: drop-shadow(0 0 10px rgba(212,175,55,0.8)); }
}

.main-nav {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.nav-btn {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.25);
    color: white;
    padding: 0.5rem 1.3rem;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.2s ease-out;
    font-weight: 500;
    font-size: 0.9rem;
}

.nav-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #1a1a1a;
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.35);
}

.nav-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #1a1a1a;
    box-shadow: 0 10px 24px rgba(0,0,0,0.5);
}

.intro-container {
    min-height: 100vh;
    position: relative;
    z-index: 1;
    padding: 2rem 0;
}

.intro-hero {
    text-align: center;
    padding: 4rem 0 3rem;
    animation: fadeInDown 1s ease-out;
}

.intro-hero h1 {
    font-size: 3.5rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 1rem;
    letter-spacing: -0.02em;
}

.intro-hero .subtitle {
    font-size: 1.3rem;
    color: var(--secondary);
    margin-bottom: 2rem;
}

.feature-card {
    background: rgba(255,255,255,0.95);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 18px 45px rgba(0,0,0,0.16);
    border: 1px solid rgba(26,26,26,0.06);
    transition: all 0.3s ease;
    margin-bottom: 2rem;
}

.feature-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 25px 60px rgba(0,0,0,0.25);
}

.feature-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: white;
    margin-bottom: 1.5rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.btn-black {
    background: #111827;
    color: white;
    border: none;
    padding: 0.8rem 2rem;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
    transition: all 0.3s ease;
    cursor: pointer;
}

.btn-black:hover {
    background: #000;
    transform: translateY(-2px);
    box-shadow: 0 15px 40px rgba(0,0,0,0.6);
}

.btn-outline-black {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
    padding: 0.8rem 2rem;
    border-radius: 999px;
    font-weight: 600;
    transition: all 0.3s ease;
    cursor: pointer;
}

.btn-outline-black:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-2px);
}

.form-control {
    border-radius: 10px;
    border: 2px solid var(--gray);
    padding: 0.8rem 1rem;
    font-size: 0.95rem;
}

.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 0.2rem rgba(212,175,55,0.25);
}

.main-content {
    padding: 2rem 0;
    max-width: 1350px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

.stat-card {
    background: rgba(255,255,255,0.96);
    border-radius: 20px;
    padding: 1.5rem;
    box-shadow: 0 16px 40px rgba(0,0,0,0.14);
    border: 1px solid rgba(26,26,26,0.06);
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 22px 50px rgba(0,0,0,0.2);
}

.stat-icon {
    width: 70px;
    height: 70px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: white;
    background: var(--primary);
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

.pro-card {
    background: rgba(255,255,255,0.96);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 18px 45px rgba(0,0,0,0.16);
    border: 1px solid rgba(26,26,26,0.06);
    position: relative;
    overflow: hidden;
}

.pro-card:before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 5px;
    height: 100%;
    background: linear-gradient(to bottom, var(--accent), transparent);
}

.channel-bar {
    height: 45px;
    background: var(--gray);
    border-radius: 999px;
    overflow: hidden;
    position: relative;
}

.channel-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 999px;
    transition: width 0.15s ease;
    position: relative;
}

.channel-fill:after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 40px;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5));
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0%, 100% { opacity: 0; }
    50% { opacity: 1; }
}

.live-eeg {
    width: 100%;
    height: 220px; /* slightly taller to match Final.html look */
    background: #f9fafb;
    border-radius: 18px;
    position: relative;
    overflow: hidden;
    border: 2px solid var(--gray);
}

/* Canvas + waveform styling hooks */
.live-eeg canvas, #eegCanvas {
    display: block;
    width: 100%;
    height: 100%;
    background: transparent;
}

/* Grid of small channel bars beneath/next to waveform */
.channel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 6px; /* reduced spacing between channels */
    align-items: center;
    margin-top: 12px;
}

.channel {
    height: 18px; /* compact channel height */
    background: var(--channel-bg);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    padding: 3px 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--eeg-grid);
}

.channel .label {
    font-size: 0.78rem;
    color: var(--secondary);
    width: 48px;
    flex: 0 0 48px;
}

.channel .bar {
    flex: 1 1 auto;
    height: 6px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--channel-fill-start), var(--channel-fill-end));
    transform-origin: left center;
    animation: barPulse 1.6s ease-in-out infinite;
}

@keyframes barPulse {
    0% { transform: scaleX(0.15); opacity: 0.8; }
    40% { transform: scaleX(0.95); opacity: 1; }
    70% { transform: scaleX(0.6); opacity: 0.9; }
    100% { transform: scaleX(0.2); opacity: 0.85; }
}

/* Make animations RTL-aware */
body[dir="rtl"] .channel .bar { transform-origin: right center; }

/* RTL Support for Arabic Language */
body[dir="rtl"] {
    direction: rtl;
    text-align: right;
}

body[dir="rtl"] .main-content {
    direction: rtl;
}

body[dir="rtl"] .stat-card,
body[dir="rtl"] .pro-card,
body[dir="rtl"] .result-card {
    text-align: right;
}

body[dir="rtl"] .nav-btn i {
    margin-right: 0;
    margin-left: 0.5rem;
}

body[dir="rtl"] .logo i {
    margin-right: 0;
    margin-left: 0.5rem;
}

body[dir="rtl"] .form-control {
    text-align: right;
}

body[dir="rtl"] .btn-black i,
body[dir="rtl"] .btn-outline-black i {
    margin-right: 0;
    margin-left: 0.5rem;
}

body[dir="rtl"] .timeline:before {
    left: auto;
    right: 30px;
}

body[dir="rtl"] .timeline-item {
    padding-left: 0;
    padding-right: 80px;
}

body[dir="rtl"] .timeline-marker {
    left: auto;
    right: 16px;
}

body[dir="rtl"] .auth-box {
    direction: rtl;
}

body[dir="rtl"] .auth-box .auth-left {
    order: 2;
}

body[dir="rtl"] .auth-box > div:last-child {
    order: 1;
}

body[dir="rtl"] .auth-right {
    border-left: none;
    border-right: 1px solid rgba(0,0,0,0.04);
}

body[dir="rtl"] .main-nav {
    direction: rtl;
}

body[dir="rtl"] .toast-container {
    right: auto;
    left: 20px;
}

/* Arabic spacing adjustments */
body[dir="rtl"] .stat-card,
body[dir="rtl"] .pro-card,
body[dir="rtl"] .result-card,
body[dir="rtl"] .feature-card {
    padding: 1.5rem;
}

body[dir="rtl"] .form-control {
    padding: 0.8rem 1rem;
}

body[dir="rtl"] .btn-black,
body[dir="rtl"] .btn-outline-black {
    padding: 0.8rem 2rem;
}

body[dir="rtl"] .nav-btn {
    padding: 0.5rem 1.3rem;
}

/* Arabic text alignment */
body[dir="rtl"] h1,
body[dir="rtl"] h2,
body[dir="rtl"] h3,
body[dir="rtl"] h4,
body[dir="rtl"] h5,
body[dir="rtl"] h6,
body[dir="rtl"] p {
    text-align: right;
}

body[dir="rtl"] .text-center {
    text-align: center !important;
}

body[dir="rtl"] .text-left {
    text-align: right !important;
}

body[dir="rtl"] .text-right {
    text-align: left !important;
}

/* Dark mode overrides for EEG / channel visuals */
body.dark-mode {
    --eeg-line: rgba(240,240,240,0.95);
    --eeg-grid: rgba(255,255,255,0.04);
    --channel-bg: rgba(255,255,255,0.03);
    --channel-fill-start: rgba(245,220,153,0.15);
    --channel-fill-end: rgba(245,220,153,0.5);
}

/* Small responsive tweaks */
@media (max-width: 640px) {
    .channel-grid { gap: 4px; }
    .channel .label { display: none; }
}

/* Redesigned channel cards (targets existing inline markup inside #channelGrid) */
#channelGrid.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }

#channelGrid.row > div {
    padding: 0.8rem !important;
    background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(245,245,245,0.95)) !important;
    border-radius: 12px !important;
    border: 1px solid var(--eeg-grid) !important;
    text-align: center !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    align-items: center !important;
    justify-content: center !important;
    transition: transform 220ms ease, box-shadow 220ms ease, background 220ms ease;
    box-shadow: 0 6px 20px rgba(15,15,15,0.06);
}

#channelGrid.row > div:hover {
    transform: translateY(-6px);
    box-shadow: 0 18px 40px rgba(15,15,15,0.12);
}

#channelGrid .text-muted { display: block; font-size: 0.78rem; color: var(--secondary); }
#channelGrid h5 { margin: 0; font-size: 1.05rem; color: var(--primary); font-weight: 700; }

/* Map existing classes to new compact bars */
.channel-bar { width: 100%; height: 12px; background: var(--channel-bg); border-radius: 999px; overflow: hidden; position: relative; border: 1px solid rgba(0,0,0,0.04); }
.channel-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--channel-fill-start), var(--channel-fill-end)); transition: width 700ms cubic-bezier(.2,.9,.2,1); box-shadow: 0 6px 18px rgba(0,0,0,0.06) inset; }

/* shimmer */
.channel-fill:after {
    content: '';
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 40%;
    background: linear-gradient(90deg, rgba(255,255,255,0.06), rgba(255,255,255,0.18), rgba(255,255,255,0.06));
    transform: translateX(-110%);
    animation: fillShimmer 2.2s linear infinite;
    pointer-events: none;
}

@keyframes fillShimmer { 0% { transform: translateX(-110%); } 100% { transform: translateX(220%); } }

/* subtle pulsing background for high values */
.channel-fill[data-level-high="true"] {
    box-shadow: 0 0 28px rgba(212,175,55,0.12), 0 6px 18px rgba(0,0,0,0.06) inset;
    transform-origin: left center;
    animation: fillPulse 2.6s ease-in-out infinite;
}

@keyframes fillPulse {
    0% { transform: scaleX(1); }
    50% { transform: scaleX(1.02); }
    100% { transform: scaleX(1); }
}

/* Dark mode for channel cards */
body.dark-mode #channelGrid.row > div {
    background: linear-gradient(180deg, rgba(30,30,30,0.92), rgba(20,20,20,0.9)) !important;
    border-color: rgba(255,255,255,0.04) !important;
}

body.dark-mode #channelGrid h5 { color: #f5f5f5; }
body.dark-mode #channelGrid .text-muted { color: #b8b8b8; }

/* Small screens: stack into single column */
@media (max-width: 520px) {
    #channelGrid.row { grid-template-columns: 1fr; }
}

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    border-radius: 999px;
    font-weight: 600;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.status-badge.connected {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border: 2px solid var(--success);
}

.status-badge.disconnected {
    background: rgba(107, 114, 128, 0.1);
    color: var(--secondary);
    border: 2px solid var(--secondary);
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    animation: blink 1.5s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

@keyframes slideInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-30px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

.doctor-selector {
    background: rgba(245,245,220,0.8);
    border: 2px solid var(--primary);
    border-radius: 14px;
    padding: 1rem;
}

.doctor-chip {
    display: inline-flex;
    align-items: center;
    background: white;
    border: 2px solid var(--gray);
    padding: 0.5rem 1rem;
    border-radius: 999px;
    margin: 0.25rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.doctor-chip:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

.doctor-chip.selected {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.chat-container {
    height: 450px;
    overflow-y: auto;
    padding: 1rem;
    background: #f9fafb;
    border-radius: 14px;
    border: 2px solid var(--gray);
}

.message-bubble {
    max-width: 70%;
    padding: 0.8rem 1rem;
    border-radius: 15px;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-bubble.sent {
    background: var(--primary);
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 5px;
}

.message-bubble.received {
    background: white;
    border: 2px solid var(--gray);
    border-bottom-left-radius: 5px;
}

.result-card {
    border-radius: 20px;
    padding: 2rem;
    text-align: center;
    background: white;
    border: 3px solid var(--gray);
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

.result-card.detected {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.05);
    animation: glow 2.5s infinite;
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 20px rgba(16, 185, 129, 0.3); }
    50% { box-shadow: 0 0 40px rgba(16, 185, 129, 0.6); }
}

.timeline {
    position: relative;
    padding: 2rem 0;
}

.timeline:before {
    content: '';
    position: absolute;
    left: 30px;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(to bottom, var(--accent), transparent);
}

.timeline-item {
    position: relative;
    padding-left: 80px;
    margin-bottom: 2rem;
}

.timeline-marker {
    position: absolute;
    left: 16px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    border: 5px solid var(--accent);
    box-shadow: 0 0 20px rgba(212,175,55,0.7);
}

.toast-container {
    position: fixed;
    top: 90px;
    right: 20px;
    z-index: 9999;
}

/* Page content is visible by default - removed display: none */
.page-content { 
    display: block; 
}

@media (max-width: 992px) {
    .auth-shell { grid-template-columns: 1fr; }
    .auth-left { display: none; }
}

@media (max-width: 768px) {
    .main-nav { flex-wrap: wrap; }
    .nav-btn { padding: 0.4rem 1rem; font-size: 0.85rem; }
}

::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--beige); }
::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* Dark Mode Styles */
body.dark-mode {
    background: radial-gradient(circle at top, #1a1a1a 0%, #2a2a2a 40%, #1f1f1f 100%);
}

body.dark-mode .stat-card,
body.dark-mode .pro-card,
body.dark-mode .result-card {
    background: rgba(30, 30, 30, 0.96) !important;
    border-color: rgba(212, 175, 55, 0.2);
    color: #e0e0e0;
}

body.dark-mode h2, body.dark-mode h3, body.dark-mode h5, body.dark-mode h6 {
    color: #f0f0f0;
}

body.dark-mode .text-muted {
    color: #b0b0b0 !important;
}

body.dark-mode .form-control {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(212, 175, 55, 0.3);
    color: #e0e0e0;
}

body.dark-mode .form-control:focus {
    background: rgba(255, 255, 255, 0.12);
    color: #e0e0e0;
}

body.dark-mode .channel-bar {
    background: rgba(212, 175, 55, 0.15);
}

body.dark-mode .chat-container {
    background: rgba(30, 30, 30, 0.8);
    border-color: rgba(212, 175, 55, 0.2);
}

body.dark-mode .message-bubble.received {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(212, 175, 55, 0.3);
}

body.dark-mode .doctor-selector {
    background: rgba(212, 175, 55, 0.1);
    border-color: rgba(212, 175, 55, 0.3);
}

body.dark-mode .live-eeg {
    background: rgba(30, 30, 30, 0.8);
    border-color: rgba(212, 175, 55, 0.2);
}

body.dark-mode .feature-card {
    background: rgba(30, 30, 30, 0.95);
}

/* Language Switcher Button */
.lang-switcher {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999999;
    display: flex;
    gap: 10px;
    background: rgba(255, 255, 255, 0.95);
    padding: 12px 16px;
    border-radius: 999px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    transition: all 0.3s ease;
    pointer-events: auto;
}

body.dark-mode .lang-switcher {
    background: rgba(30, 30, 30, 0.95);
    border: 2px solid rgba(212, 175, 55, 0.3);
}

.lang-switcher button {
    background: transparent;
    border: none;
    padding: 8px 12px;
    cursor: pointer;
    font-weight: 600;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    pointer-events: auto;
    position: relative;
    z-index: 10001;
}

.lang-switcher button.active {
    background: var(--accent);
    color: var(--primary);
}

.lang-switcher button:not(.active) {
    color: var(--primary);
}

body.dark-mode .lang-switcher button:not(.active) {
    color: #e0e0e0;
}

/* RTL support for language switcher */
body[dir="rtl"] .lang-switcher {
    right: auto;
    left: 30px;
}

/* Bilingual visibility: show only the language matching the page lang */
.bilingual .en, .bilingual .ar { display: inline; }
html[lang="en"] .bilingual .ar { display: none !important; }
html[lang="ar"] .bilingual .en { display: none !important; }

/* When body direction is rtl, ensure Arabic spans have proper flow */
html[lang="ar"] .bilingual { direction: rtl; }

/* Theme Switcher Button */
.theme-switcher {
    position: fixed;
    bottom: 30px;
    right: 220px;
    z-index: 9999999;
    width: 50px;
    height: 50px;
    border-radius: 999px;
    background: var(--accent);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;    
    font-size: 1.2rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    transition: all 0.3s ease;
    color: var(--primary);
    pointer-events: auto;
}

.theme-switcher:hover {
    transform: scale(1.1);
    box-shadow: 0 15px 40px rgba(212, 175, 55, 0.5);
}

body.dark-mode .theme-switcher {
    background: rgba(212, 175, 55, 0.2);
    color: var(--accent);
    border: 2px solid var(--accent);
}

/* RTL support for theme switcher */
body[dir="rtl"] .theme-switcher {
    right: auto;
    left: 220px;
}

/* Ensure switchers are above auth page */
.auth-container ~ .theme-switcher,
.auth-container ~ .lang-switcher {
    z-index: 100001;
}

/* Role Card Background */
.role-card {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.08), rgba(26, 26, 26, 0.03)) !important;
    backdrop-filter: blur(10px);
}

body.dark-mode .role-card {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.15), rgba(255, 255, 255, 0.05)) !important;
}

.role-card.active {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.25), rgba(212, 175, 55, 0.1)) !important;
    border-color: var(--accent) !important;
}

body.dark-mode .role-card.active {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.3), rgba(212, 175, 55, 0.15)) !important;
}

/* Enhanced Dark Mode Text Colors */
body.dark-mode {
    color: #e0e0e0;
}

body.dark-mode h1, body.dark-mode h2, body.dark-mode h3, 
body.dark-mode h4, body.dark-mode h5, body.dark-mode h6 {
    color: #ffffff;
}

body.dark-mode .text-muted {
    color: #b0b0b0 !important;
}

body.dark-mode .intro-hero h1 {
    color: #ffffff;
}

body.dark-mode .intro-hero .subtitle {
    color: #b0b0b0;
}

body.dark-mode .feature-card h3 {
    color: #ffffff;
}

body.dark-mode .feature-card .text-muted {
    color: #b0b0b0 !important;
}

body.dark-mode .top-header {
    background: rgba(20, 20, 20, 0.98);
    border-bottom: 1px solid rgba(212, 175, 55, 0.2);
}

body.dark-mode .stat-card h3, body.dark-mode .pro-card h5, 
body.dark-mode .pro-card h6, body.dark-mode .result-card h5 {
    color: #ffffff;
}

body.dark-mode .stat-card .text-uppercase {
    color: #b0b0b0 !important;
}

body.dark-mode .form-control {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(212, 175, 55, 0.3);
    color: #e0e0e0;
}

body.dark-mode .form-control::placeholder {
    color: #707070;
}

body.dark-mode .form-control:focus {
    background: rgba(255, 255, 255, 0.12);
    color: #e0e0e0;
}

body.dark-mode .form-label {
    color: #e0e0e0;
}

body.dark-mode .chat-container {
    background: rgba(20, 20, 20, 0.8);
    border-color: rgba(212, 175, 55, 0.2);
}

body.dark-mode .message-bubble.received {
    background: rgba(40, 40, 40, 0.8);
    border-color: rgba(212, 175, 55, 0.3);
    color: #e0e0e0;
}

body.dark-mode .message-bubble.sent {
    background: rgba(212, 175, 55, 0.3);
    color: #ffffff;
}

body.dark-mode .doctor-selector {
    background: rgba(212, 175, 55, 0.08);
    border-color: rgba(212, 175, 55, 0.3);
}

body.dark-mode .doctor-chip {
    background: rgba(40, 40, 40, 0.8);
    border-color: rgba(100, 100, 100, 0.5);
    color: #e0e0e0;
}

body.dark-mode .doctor-chip:hover {
    border-color: var(--accent);
    background: rgba(40, 40, 40, 1);
}

body.dark-mode .doctor-chip.selected {
    background: rgba(212, 175, 55, 0.3);
    color: var(--accent);
    border-color: var(--accent);
}

body.dark-mode .live-eeg {
    background: rgba(20, 20, 20, 0.8);
    border-color: rgba(212, 175, 55, 0.2);
}

body.dark-mode .channel-bar {
    background: rgba(212, 175, 55, 0.15);
}

body.dark-mode .timeline-item h6 {
    color: #ffffff;
}

body.dark-mode .nav-btn {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--primary);
}

body.dark-mode .nav-btn:hover {
    background: #f5dc99;
    border-color: #f5dc99;
    color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(212, 175, 55, 0.5);
}

body.dark-mode .nav-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--primary);
    box-shadow: 0 10px 24px rgba(212, 175, 55, 0.6);
}

body.dark-mode .btn-black {
    background: var(--accent);
    color: var(--primary);
    border-color: var(--accent);
    box-shadow: 0 10px 30px rgba(212, 175, 55, 0.4);
}

body.dark-mode .btn-black:hover {
    background: #f5dc99;
    color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 15px 40px rgba(212, 175, 55, 0.6);
}

body.dark-mode .btn-outline-black {
    background: transparent;
    color: var(--accent);
    border: 2px solid var(--accent);
}

body.dark-mode .btn-outline-black:hover {
    background: var(--accent);
    color: var(--primary);
    transform: translateY(-2px);
}

body.dark-mode .nav-link {
    color: #b0b0b0 !important;
}

body.dark-mode .nav-link.active {
    color: var(--primary) !important;
}

body.dark-mode .intro-container {
    background: transparent;
}

body.dark-mode .glow-blob.gold {
    background: rgba(212, 175, 55, 0.15);
}

body.dark-mode .glow-blob.beige {
    background: rgba(50, 50, 50, 0.5);
}

body.dark-mode .glow-blob.gray {
    background: rgba(100, 100, 100, 0.3);
}

body.dark-mode #scanHistory > div {
    background: rgba(40, 40, 40, 0.9);
    border-color: rgba(212, 175, 55, 0.2) !important;
}

/* Auth Page Right Side Dark Mode */
body.dark-mode .auth-right {
    background: rgba(30, 30, 30, 0.96) !important;
    color: #e0e0e0;
}

body.dark-mode .auth-right h4 {
    color: #ffffff;
}

body.dark-mode .auth-right .text-muted {
    color: #b0b0b0 !important;
}

body.dark-mode .auth-right .btn-black {
    background: var(--accent);
    color: var(--primary);
    border-color: var(--accent);
}

body.dark-mode .auth-right .btn-black:hover {
    background: #f5dc99;
    color: var(--primary);
}

body.dark-mode .auth-right .btn-outline-black {
    background: transparent;
    color: var(--accent);
    border: 2px solid var(--accent);
}

body.dark-mode .auth-right .btn-outline-black:hover {
    background: var(--accent);
    color: var(--primary);
}

body.dark-mode .auth-right .form-control {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(212, 175, 55, 0.3);
    color: #e0e0e0;
}

body.dark-mode .auth-right .form-label {
    color: #e0e0e0;
}

body.dark-mode .auth-right .tab-pane h5 {
    color: #ffffff;
}

body.dark-mode .auth-right .role-card {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.15), rgba(255, 255, 255, 0.05)) !important;
    border-color: rgba(212, 175, 55, 0.2);
}

body.dark-mode .auth-right .role-card.active {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.3), rgba(212, 175, 55, 0.15)) !important;
    border-color: var(--accent) !important;
}

/* Auth Page Dark Mode */
body.dark-mode .auth-box {
    background: rgba(30, 30, 30, 0.96) !important;
}

body.dark-mode .auth-left {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.15), rgba(100, 100, 100, 0.1)) !important;
}

body.dark-mode .auth-box h2, body.dark-mode .auth-box h3, body.dark-mode .auth-box h4 {
    color: #ffffff;
}

body.dark-mode .auth-box .text-muted {
    color: #b0b0b0 !important;
}

body.dark-mode .auth-box .form-control {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(212, 175, 55, 0.3);
    color: #e0e0e0;
}

body.dark-mode .auth-box .form-label {
    color: #e0e0e0;
}

body.dark-mode .auth-container {
    background: radial-gradient(circle at top, #1a1a1a 0%, #2a2a2a 40%, #1f1f1f 100%) !important;
}

body.dark-mode .intro-container {
    background: transparent;
}

body.dark-mode #authPage {
    background: radial-gradient(circle at top, #1a1a1a 0%, #2a2a2a 40%, #1f1f1f 100%) !important;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

body.dark-mode .intro-hero h1 {
    color: #ffffff;
}

body.dark-mode .intro-hero .subtitle {
    color: #b0b0b0;
}

/* RTL Support for Auth */
body[dir="rtl"] .auth-box {
    grid-template-columns: 1fr 1.2fr;
}

body[dir="rtl"] .auth-box .auth-left {
    order: 2;
}

body[dir="rtl"] .auth-box > div:last-child {
    order: 1;
}
