:root { 
    --primary: #3b82f6; 
    --radius-lg: 28px;
    --glass: rgba(15, 23, 42, 0.45);
}

/* --- Global Patient UI Background (Made Transparent) --- */
body { 
    font-family: 'Mulish', system-ui, -apple-system, sans-serif;
    background: transparent !important; 
    margin: 0; 
    min-height: 100vh;
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center; /* RESTORED: Centers your cards */
}

/* --- The actual background layer (Shows during Silence) --- */
.video-container { 
    position: fixed; 
    inset: 0; 
    z-index: -1; 
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}

/* --- Background Video --- */
.bg-video { 
    position: absolute; 
    top: 0; left: 0; width: 100%; height: 100%; 
    object-fit: cover; 
    display: block;
    opacity: 0.65; 
    z-index: 0; /* Ensures it sits on the base layer of the container */
}

/* --- The Scrim (The Dark Blue Clinical Tint) --- */
.video-overlay { 
    position: absolute; 
    inset: 0; 
    background: rgba(15, 23, 42, 0.45); 
    z-index: 1; /* Sits directly on top of the video */
    pointer-events: none;
}

/* --- ADMIN UI OVERRIDE (Untouched & Dark) --- */
/* --- Line 37: ADMIN UI OVERRIDE (Stacking Fixed) --- */
.admin-body { 
    background: linear-gradient(rgba(15, 23, 42, 0.85), rgba(15, 23, 42, 0.85)), 
                #f1f5f9 !important; 
    padding: 1px 20px !important; 
    box-sizing: border-box;
    /* CHANGED: Removed flex and centering to stop the "vertical stretch" */
    display: block !important; 
}

.admin-card {
    background: white; 
    width: 95%; 
    max-width: 767px; 
    padding: 2.2rem;   
    margin: 20px auto 0 auto !important;  
    border-radius: var(--radius-lg); 
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 10;
    overflow-x: hidden; /* Prevents horizontal scroll on the card */
}

/* Tighter spacing for text elements inside the card */
.admin-card h2 { 
    margin-top: 0; 
    margin-bottom: 4px; 
    font-size: 1.5rem; 
}

.admin-card p { 
    margin-bottom: 1rem !important; 
    font-size: 0.9rem;
}

.admin-footer { 
    /* CHANGED: This now sets the EXACT gap below the card */
    margin-top: 0 !important; 
    padding: 0 0 40px 0; 
    text-align: center; 
    color: #94a3b8; 
    font-size: 0.75rem; 
    width: 100%;
}

/* --- Material Design 3 Dialog Styles --- */
/* --- Material Design 3 Dialog (Centered) --- */
#resultModal {
    border: none;
    background: #ffffff;
    border-radius: 28px;
    padding: 32px 24px 24px 24px;
    width: 90%;
    max-width: 320px; /* Slimmer for M3 Confirmation */
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.15);
    outline: none;
    text-align: center;
}

#resultModal::backdrop {
    background: rgba(0, 0, 0, 0.4);
}

.md-icon-wrapper {
    color: #10b981; /* Green icon */
    margin-bottom: 16px;
}

.md-icon-wrapper .material-symbols-outlined {
    font-size: 40px;
    font-variation-settings: 'FILL' 1; /* Solid icon */
}

#resultModal h3 {
    font-size: 24px;
    font-weight: 400;
    color: #1c1b1f;
    margin: 0 0 12px 0;
}

#resultModal p {
    font-size: 14px;
    color: #49454f;
    margin-bottom: 24px;
}

.modal-link-box {
    background: #f1f5f9;
    padding: 12px;
    border-radius: 12px;
    margin-bottom: 24px;
    border: 1px dashed #cbd5e1;
}

#sessionLink {
    font-family: 'Roboto Mono', monospace;
    font-size: 12px;
    color: #0b57d0;
    word-break: break-all;
}

/* --- M3 Buttons --- */
.md-dialog-actions {
    display: flex;
    flex-direction: column; /* Stacked buttons for narrow mobile-first MD dialogs */
    gap: 8px;
}

.md-button-tonal {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #d3e3fd; /* Light blue tonal background */
    color: #041e49;
    border: none;
    padding: 12px;
    border-radius: 100px;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
}

.md-button-text {
    background: transparent;
    color: #0b57d0;
    border: none;
    padding: 12px;
    border-radius: 100px;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
}

.md-button-text:hover { background: rgba(11, 87, 208, 0.08); }

/* --- SHARED COMPONENTS --- */
.settings-grid { 
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 1.5rem; 
    text-align: left; 
    align-items: start; /* CRITICAL: Forces labels to line up horizontally */
}
.span-2 { grid-column: span 2; }
.input-group label { display: flex; align-items: center; gap: 8px; font-size: 0.75rem; font-weight: 800; color: #64748b; text-transform: uppercase; margin-bottom: 8px; }
input, select { width: 100%; padding: 14px; border-radius: 12px; border: 1px solid #e2e8f0; background: #f8fafc; font-size: 1rem; box-sizing: border-box; }

.primary-btn { width: 100%; padding: 18px; border-radius: 50px; background: var(--primary); color: white; border: none; font-weight: 700; cursor: pointer; display: flex; justify-content: center; align-items: center; gap: 10px; }
.secondary-btn { background: #f1f5f9; color: #475569; padding: 14px; border-radius: 50px; border: none; font-weight: 700; cursor: pointer; }

/* --- PATIENT LOBBY CARDS --- */
.ui-wrapper { flex: 1; display: flex; align-items: center; justify-content: center; width: 100%; z-index: 20; }
.landing-card, .preparation-card { 
    background: white; 
    padding: 3rem; 
    border-radius: var(--radius-lg); 
    box-shadow: 0 25px 50px rgba(0,0,0,0.5); /* Increased shadow opacity from 0.15 to 0.5 */
    width: 90%; 
    max-width: 420px; 
    text-align: center; 
    border: none; 
}

/* --- IMMERSIVE HUD --- */
.hud-overlay { position: fixed; inset: 0; z-index: 100; pointer-events: none; }
.hud-bottom-left { position: absolute; bottom: 40px; left: 40px; }
.hud-bottom-left h1 { color: white; font-size: 3.5rem; margin: 0; font-weight: 800; text-shadow: 0 4px 20px rgba(0,0,0,0.6); }

.hud-right-panel { position: absolute; top: 40px; right: 40px; bottom: 120px; width: 340px; display: flex; flex-direction: column; gap: 12px; }
.active-chat-log { flex-grow: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; pointer-events: auto; }
.hud-msg { background: var(--glass); backdrop-filter: blur(12px); color: white; padding: 12px 16px; border-radius: 18px; font-size: 0.8rem; border: none !important; text-align: left; }
.ai-hud-msg { border-left: 4px solid var(--primary); }
.user-hud-msg { border-left: 4px solid #10b981; }

.hud-bottom-center { position: absolute; bottom: 40px; left: 50%; transform: translateX(-50%); z-index: 1000; pointer-events: auto; }
.timer-orb { position: relative; width: 60px; height: 60px; display: flex; justify-content: center; align-items: center; cursor: pointer; pointer-events: auto !important; }
.orb-icon { color: white; font-size: 26px !important; z-index: 2; }
.progress-ring-hud { position: absolute; top: 0; left: 0; transform: rotate(-90deg); }
.ring-fill { transition: stroke-dashoffset 1s linear; }

/* Timer Bubble Tooltip */
.timer-orb::after {
    content: attr(data-tooltip); position: absolute; bottom: 75px; left: 50%; transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.95); color: white; padding: 8px 14px; border-radius: 10px;
    font-size: 0.8rem; font-weight: bold; white-space: nowrap; opacity: 0; visibility: hidden;
    transition: opacity 0.2s ease, transform 0.2s ease; z-index: 1001; box-shadow: 0 10px 20px rgba(0,0,0,0.3);
}
.timer-orb:hover::after, .timer-orb.show-time::after { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(-5px); }

.hud-bottom-right { position: absolute; bottom: 40px; right: 40px; pointer-events: auto; }
.hud-end-btn { background: #ef4444; color: white; border: none; padding: 15px 30px; border-radius: 50px; font-weight: 800; cursor: pointer; display: flex; align-items: center; gap: 8px; box-shadow: 0 10px 25px rgba(239, 68, 68, 0.4); }

.mic-status-indicator { display: flex; align-items: center; gap: 8px; color: white; background: rgba(0,0,0,0.4); padding: 8px 16px; border-radius: 20px; width: fit-content; margin-left: auto; font-size: 0.75rem; }

dialog::backdrop { background: rgba(15, 23, 42, 0.7); backdrop-filter: blur(4px); }

/* --- Global Responsive Fixes --- */
* {
    box-sizing: border-box; /* Ensures padding doesn't increase width */
}

/* Ensure all inputs and selectors take up exactly 100% of their container */
.input-group input, 
.input-group select, 
.input-group textarea {
    width: 100% !important;
    max-width: 100%;
    display: block;
}

/* --- Responsive Grid Logic --- */
@media (max-width: 732px) {
    .settings-grid {
        grid-template-columns: 1fr !important; /* Forces 1-column layout */
        gap: 20px;
    }

    /* Resets any 2-column spans so they fit on mobile */
    .input-group.span-2 {
        grid-column: span 1 !important;
    }

    .admin-body {
        padding: 10px;
        display: block; /* Allows natural scrolling on mobile */
    }
}

.security-row {
    display: flex;
    flex-wrap: wrap; /* Allows stacking on small screens */
    gap: 20px;
    align-items: flex-end; /* Aligns the input field with the bottom of the captcha */
    margin-top: 24px;
    margin-bottom:24px;
    width: 100%;
}

.captcha-wrapper {
    flex: 0 0 auto; /* Keeps the captcha at its fixed width */
}

.coupon-group {
    flex: 1 1 200px; /* Allows the coupon field to fill the remaining space */
    margin-bottom: 0 !important; /* Overrides default spacing for alignment */
}

/* Mobile Tweak: Ensure the coupon field stays full width when stacked */
@media (max-width: 650px) {
    .security-row {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .coupon-group {
        width: 100%;
    }
}

/* --- Captcha Alignment & Responsive Scaling --- */

.captcha-container {
    width: 100%;
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    min-height: 78px;
}

/* On mobile (narrower than 380px), scale the captcha so it doesn't cut off */
@media (max-width: 380px) {
    .h-captcha {
        transform: scale(0.85);
        transform-origin: 0 0; /* Keep it aligned to the left while shrinking */
    }
    
    .captcha-container {
        height: 70px; /* Adjust height for the scaled element */
    }
}

/* Ensure the coupon group aligns vertically with the captcha on desktop */
.settings-grid .input-group:last-of-type {
    align-self: end;
}