/* =========================================
   SKULLSCAN PRO - V11.1.0
   ========================================= */

* { 
    box-sizing: border-box;
}

body { 
    margin: 0; 
    padding: 0; 
    background-color: #0d1117; 
    color: #ffffff; 
    font-family: -apple-system, sans-serif; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center; 
    min-height: 100vh; 
    overflow: hidden; 
    touch-action: none; 
}

h1 { 
    font-size: 1.5rem; 
    color: #00ffcc; 
    text-transform: uppercase; 
    letter-spacing: 2px; 
}

p { 
    font-size: 0.9rem; 
    color: #8b949e; 
    margin: 0 0 15px 0; 
    max-width: 85vw; 
}

/* --- VIEW PANELS --- */
.view-panel { 
    display: none; 
    flex-direction: column; 
    align-items: center; 
    width: 90vw; 
    max-width: 400px; 
}

.active-view { 
    display: flex; 
}

/* --- STANDARD BUTTONS --- */
.action-btn { 
    background-color: #21262d; 
    border: 1px solid #30363d; 
    color: #c9d1d9; 
    padding: 14px; 
    border-radius: 8px; 
    width: 100%; 
    text-align: center; 
    cursor: pointer; 
    text-transform: uppercase; 
    font-weight: 600; 
    margin-bottom: 10px; 
}

.action-btn:hover { 
    border-color: #00ffcc; 
    color: #00ffcc; 
}

.primary-btn { 
    background-color: #238636; 
    border-color: #2ea44f; 
    color: #ffffff; 
}

.api-btn {
    background-color: rgba(40, 44, 52, 0.9);
    color: #00ffcc;
    border: 1.5px solid rgba(0, 255, 204, 0.8);
    border-radius: 8px;
    padding: 10px 20px;
    font-family: inherit;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    box-shadow: 0 0 8px rgba(0, 255, 204, 0.2);
    width: 100%;
}

.api-btn:hover {
    background-color: rgba(0, 255, 204, 0.15);
    box-shadow: 0 0 15px rgba(0, 255, 204, 0.5);
    transform: translateY(-1px);
}

.api-btn:active {
    transform: translateY(1px);
}

.api-btn-danger {
    background-color: rgba(255, 50, 50, 0.2);
    border-color: rgba(255, 50, 50, 0.8);
    color: #ff6666;
    box-shadow: 0 0 8px rgba(255, 50, 50, 0.2);
}

.api-btn-danger:hover {
    background-color: rgba(255, 50, 50, 0.3);
    box-shadow: 0 0 15px rgba(255, 50, 50, 0.5);
}

/* --- UI ELEMENTS --- */
.divider { 
    color: #8b949e; 
    font-size: 0.75rem; 
    margin: 30px 0 10px 0; 
    text-transform: uppercase; 
    text-align: center; 
    font-weight: bold; 
}


.sample-thumb:hover { border-color: #00ffcc; }

.sample-thumb-img { 
    width: 40px; 
    height: 40px; 
    object-fit: cover; 
    border-radius: 4px; 
    margin-bottom: 6px; 
}

.sample-thumb label { 
    font-size: 0.65rem; 
    color: #c9d1d9; 
    text-transform: uppercase; 
    font-weight: bold; 
}

#imageLoader { display: none; }
#img-preview-element { max-width: 90%; max-height: 200px; margin-bottom: 15px; }
.hidden-media-container { display: none; }
.ios-hidden-file {
    width: 0.1px;
    height: 0.1px;
    opacity: 0;
    overflow: hidden;
    position: absolute;
    z-index: -1;
}

/* --- HEADER & NAVIGATION --- */
.app-header {
    width: 100%;
    max-width: 400px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid #30363d;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: monospace;
}

.logo-icon { font-size: 1.5rem; }

.logo-text {
    font-size: 1.2rem;
    font-weight: 800;
    color: #c9d1d9;
    letter-spacing: 1px;
}

.pro-badge {
    color: #00ffcc;
    font-weight: bold;
    margin-left: 2px;
}

.nav-btn {
    background: transparent;
    border: 2px solid #30363d;
    color: #8b949e;
    border-radius: 50%;
    width: 35px;
    height: 35px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-btn:hover {
    border-color: #00ffcc;
    color: #00ffcc;
    box-shadow: 0 0 10px rgba(0, 255, 204, 0.2);
}

/* --- MODAL --- */
.modal-overlay {
    position: fixed; 
    top: 0; left: 0; 
    width: 100vw;   
    height: 100vh;  
    background: rgba(9, 11, 15, 0.95);
    display: flex; 
    justify-content: center; 
    align-items: center;
    z-index: 999999; 
}

.modal-content {
    background: #161b22; 
    border: 2px solid #30363d;
    border-radius: 12px; 
    padding: 20px; 
    width: 90%; 
    max-width: 400px;
    text-align: center; 
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8), inset 0 0 15px rgba(0, 255, 204, 0.05);
}

.modal-content h3 {
    color: #00ffcc; 
    margin-top: 0; 
    font-family: monospace; 
    letter-spacing: 2px;
}

#snapshot-preview-img {
    width: 100%; 
    height: auto; 
    border-radius: 8px; 
    margin-bottom: 15px;
    border: 1px solid #21262d;
}

.modal-actions { display: flex; gap: 10px; }
.modal-actions button { flex: 1; }

/* =========================================
   V11 AR DASHBOARD OVERHAUL (3-COLUMN)
   ========================================= */

/* 1. MASTER CONTAINER */
/* 1. MASTER CONTAINER */
#canvas-container {
    position: relative;
    display: flex;
    flex-direction: column;
    
    /* THE MATH FIX: 100% of the screen minus the Header height */
    height: calc(100dvh - 85px); 
    width: 100%;
    
    background: #090b0f;
    border-radius: 12px; /* Soften the edges to match your panels */
    border: 1px solid #30363d;
    overflow: hidden;
}

/* 2. THE CANVAS CAGE */
#canvas-cage {
    flex: 1; /* Eat the middle space */
    width: 100%;
    min-height: 0; 
    position: relative; 
}

#examinerCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%; 
    object-fit: contain; 
    object-position: bottom center;
    filter: contrast(1.1) brightness(0.95) blur(0.5px);
}

/* 3. FLOATING RESET BUTTON (Top-Center) */
/* =========================================
   FLOATING RESET BUTTON
   ========================================= */
#btn-reset {
    position: absolute;
    z-index: 1000; 

    /* ==========================================
       🎛️ POSITION CONTROL PANEL 
       Change these values to move the button!
       Use 'auto' to disable a direction.
       ========================================== */
    top: auto;          /* Disabled so the button can fall */
    bottom: 15px;       /* Hovers 20px above the bottom edge of the image */
    
    left: 50%;          /* 50% keeps it dead center */
    right: auto;        
    transform: translateX(-50%); /* Required to perfectly center it with left: 50% */
    /* ========================================== */
    
    /* SHRINK-WRAP FIX */
    display: inline-block !important;
    width: max-content !important; 
    min-width: 0 !important;
    padding: 8px 20px !important;
    margin: 0 !important; 
    
    /* SLEEK PILL STYLING */
    background: rgba(10, 12, 16, 0.85) !important;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    border-radius: 25px !important;
    
    font-size: 0.85rem !important;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #fff;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

/* 2. THE CANVAS (Image) */
/* --- THE CANVAS CAGE --- */


#examinerCanvas {
    /* Pin the canvas directly to the walls of the cage */
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%; 
    
    object-fit: contain; 
    filter: contrast(1.1) brightness(0.95) blur(0.5px);
    transition: filter 0.3s ease;
}

/* 3. THE DASHBOARD */
.scan-controls-layout {
    display: flex !important;
    flex-direction: row !important; 
    flex-shrink: 0 !important; /* Protects from giant images */
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 10px;
    box-sizing: border-box; 
    
    padding: 15px 15px calc(20px + env(safe-area-inset-bottom)) 15px; 
    background: rgba(10, 12, 16, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid rgba(0, 255, 204, 0.2);
    z-index: 100;
}

/* --- DASHBOARD COLUMNS --- */

.action-column {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 12px;
    flex: 0 0 65px; 
}

.round-btn {
    width: 65px !important;
    height: 65px !important;
    flex-shrink: 0 !important; 
    padding: 0 !important; 
    border-radius: 50%;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: bold;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    display: flex;
    justify-content: center;
    align-items: center;
}

.scan-btn {
    background-color: rgba(40, 44, 52, 0.9);
    color: #00ffcc;
    border: 1.5px solid rgba(0, 255, 204, 0.8);
    box-shadow: 0 0 8px rgba(0, 255, 204, 0.2);
}
/* NEW: The Zero-Latency Flash */
.scan-btn:active {
    background-color: #ffffff !important;
    color: #000000 !important;
    box-shadow: 0 0 25px #ffffff, inset 0 0 10px #00ffcc !important;
    transform: scale(0.92);
    /* This overrides the 0.2s transition in round-btn to make it INSTANT */
    transition: none !important; 
}
.scan-btn:active { background-color: rgba(0, 255, 204, 0.2); transform: scale(0.95); }

.reset-btn {
    background-color: rgba(255, 50, 50, 0.1);
    color: #ff6666;
    border: 1.5px solid rgba(255, 50, 50, 0.6);
}

.reset-btn:active { background-color: rgba(255, 50, 50, 0.3); transform: scale(0.95); }

#trackpad.compact-trackpad {
    flex: 1; 
    height: 140px; 
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(40, 44, 52, 0.8);
    border: 1px dashed rgba(0, 255, 204, 0.5);
    border-radius: 12px;
    touch-action: none; 
    box-sizing: border-box;
    gap: 10px;
}

.trackpad-label {
    pointer-events: none; 
    -webkit-user-select: none; 
    user-select: none;
    color: #00ffcc;
    font-family: sans-serif;
    text-transform: uppercase;
}

.title { font-weight: bold; letter-spacing: 2px; font-size: 16px; }
.instruction { font-size: 12px; opacity: 0.7; }

/* --- RIGHT COLUMN: SLIDER --- */
/* --- RIGHT COLUMN: SLIDER --- */
.slider-container {
    flex: 0 0 45px; /* Slightly widened to fit text and slider side-by-side */
    height: 140px;
    display: flex !important;
    flex-direction: row !important; /* Stack them left-to-right */
    justify-content: center;
    align-items: center;
    gap: 8px; /* Breathing room between text and slider */
}

.vertical-text {
    writing-mode: vertical-rl;
    transform: rotate(180deg); /* Flips the text so it reads bottom-to-top */
    color: #00ffcc;
    font-size: 10px;
    font-weight: bold;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    opacity: 0.7;
    -webkit-user-select: none;
    user-select: none;
    text-align: center;
}

.vertical-slider {
    /* The Modern Vertical Command (Fixes the deprecation warning) */
    writing-mode: vertical-lr;
    direction: rtl; 
    
    width: 15px; 
    height: 130px; 
    accent-color: #00ffcc;
    cursor: pointer;
    margin: 0;
}

/* ========================================== */
/* 🛑 SPLASH SCREEN STYLES */
/* ========================================== */
/* ========================================== */
/* 🏥 CORPORATE CHECK-IN STYLES */
/* ========================================== */
.splash-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #f4f7f9; /* Bright, sterile hospital white/gray */
    z-index: 9999; /* Forces it above EVERYTHING else */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: opacity 0.8s ease-out, visibility 0.8s;
    /* Clean, corporate font override just for this screen */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* When we add this class via JS, it fades away */
.splash-hidden {
    opacity: 0;
    visibility: hidden;
}

.splash-content.corporate-vibe {
    text-align: center;
    max-width: 450px;
    padding: 40px;
    background: #ffffff;
    border: 1px solid #e0e6ed;
    border-radius: 12px;
    box-shadow: 0 15px 35px rgba(0, 50, 100, 0.1);
}

.splash-logo-placeholder {
    font-size: 50px;
    margin-bottom: 10px;
}

.medical-cross {
    color: #00ffcc; /* Keeping a hint of the neon cyan scanner color */
    font-size: 40px;
    vertical-align: middle;
}

.splash-title {
    color: #1a2b3c;
    font-size: 28px;
    letter-spacing: 0.5px;
    margin: 0 0 15px 0;
    font-weight: 700;
}

.splash-divider {
    height: 3px;
    width: 50px;
    margin: 0 auto 20px auto;
    background: #00ffcc; 
}

.splash-narrative {
    color: #5a6b7c;
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: 30px;
}

.tagline {
    color: #0055ff;
    font-weight: bold;
    font-style: italic;
    font-size: 17px;
    margin-bottom: 15px;
}

/* The Corporate Button */
.btn-corporate-checkin {
    background: #0055ff; /* Trustworthy medical blue */
    color: #ffffff;
    border: none;
    padding: 15px 40px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
    box-shadow: 0 4px 10px rgba(0, 85, 255, 0.3);
}

.btn-corporate-checkin:hover {
    background: #0044cc;
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 85, 255, 0.4);
}

/* ========================================== */
/* 🖥️ UNATTENDED TERMINAL (LIST UI) */
/* ========================================== */
.terminal-header {
    text-align: left;
    border-bottom: 1px solid rgba(255, 0, 85, 0.3);
    padding-bottom: 15px;
}

.terminal-prompt {
    font-family: monospace;
    color: #00ffcc;
    font-size: 13px;
    margin-top: 10px;
}

.patient-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 350px;
    overflow-y: auto;
    text-align: left;
}

.patient-record {
    display: flex;
    align-items: center;
    background: rgba(10, 15, 25, 0.8);
    border: 1px solid rgba(0, 255, 204, 0.1);
    padding: 10px;
    border-radius: 1px;
    cursor: pointer;
    transition: all 0.2s;
}

.patient-record:hover {
    background: rgba(0, 255, 204, 0.1);
    border-color: #00ffcc;
    transform: translateX(5px);
}

.record-avatar {
    width: 45px;
    height: 45px;
    border-radius: 4px;
    object-fit: cover;
    margin-right: 15px;
    border: 1px solid #5a6b7c;
    filter: grayscale(100%) contrast(1.2); /* Makes the photos look like clinical files */
}

/* ========================================== */
/* 📋 SINGLE-LINE SCAN LOGS (UNIFORM SMALL TEXT) */
/* ========================================== */
.record-details {
    display: flex;
    flex-direction: row; 
    justify-content: space-between; 
    align-items: center;
    width: 100%;
    gap: 15px; 
    overflow: hidden; 
    /* NEW: Force all text inside this row to be the same small size */
    font-size: 0.55em; 
}

.record-name {
    font-weight: bold;
    white-space: nowrap; 
    overflow: hidden;
    text-overflow: ellipsis; 
}

.record-time {
    color: #8899aa;
    white-space: nowrap; 
    text-align: right;
    /* (Removed the individual font-size so it perfectly matches the name) */
}
.terminal-btn {
    border-color: #ff0055;
    color: #ff0055;
    font-family: monospace;
    background: rgba(255, 0, 85, 0.05);
    width: 100%;
}

.terminal-btn:hover {
    background: rgba(255, 0, 85, 0.2);
    color: #ffffff;
}

/* ========================================== */
/* 🖥️ UNATTENDED TERMINAL (SPLIT LAYOUT) */
/* ========================================== */
.terminal-split-layout {
    display: flex;
    flex-direction: row;
    gap: 30px;
    align-items: stretch;
    width: 100%;
    margin-top: 10px;
}

.terminal-column-left {
    flex: 1.2;
    display: flex;
    flex-direction: column;
}

.terminal-column-right {
    flex: 0.8;
    display: flex;
    flex-direction: column; /* Added this to stack vertically */
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
    border: 1px dashed rgba(0, 255, 204, 0.2);
    border-radius: 8px;
    padding: 30px 20px;
}

/* 📱 Mobile Fallback: Stack them vertically if screen is too narrow */
@media (max-width: 768px) {
    .terminal-split-layout {
        flex-direction: column-reverse; /* Puts hardware on top, log on bottom */
        gap: 15px;
    }
    .terminal-column-right {
        padding: 15px;
    }
}

/* ========================================== */
/* 📱 PURE CSS HARDWARE REPRESENTATION */
/* ========================================== */
.hardware-representation {
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: hardwareFloat 4s ease-in-out infinite; 
    
    /* Reduced by roughly 25% */
    transform: scale(0.65); 
    
    /* This forces the scanner to shrink UPWARDS toward the button, 
       creating much more empty space below it for your list! */
    transform-origin: top center; 
}

/* On mobile, we shrink it just a tiny bit more to be safe */
@media (max-width: 768px) {
    .hardware-representation {
        transform: scale(0.55);
        margin-top: -10px;
    }
}

/* On mobile, shrink it even further so the touch targets are safe */
@media (max-width: 768px) {
    .hardware-representation {
        transform: scale(0.7);
        margin-top: -15px;
    }
}

.hardware-screen {
    width: 160px;
    height: 280px;
    background: rgba(0, 40, 20, 0.7);
    /* NEW: Bright Neon Green Outer Border */
    border: 5px solid #00ff33; 
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    z-index: 2;
    /* Green outer casing glow + Cyan inner screen glow */
    box-shadow: 0 0 15px rgba(0, 255, 51, 0.4), inset 0 0 40px rgba(0, 255, 255, 0.2);
    outline: 2px solid rgba(0, 255, 51, 0.6);
}

/* Inside X-ray theme: deep teal/blue medical grid */
.hardware-screen.xray-mode {
    background: 
        linear-gradient(rgba(0, 255, 255, 0.15) 1px, transparent 1px),
        linear-gradient(90deg, rgba(29, 120, 185, 0.15) 1px, transparent 1px),
        rgba(0, 20, 30, 0.9);
    background-size: 20px 20px;
    overflow: hidden; 
}

/* X-Ray cyan/white scanning beam */
.xray-beam {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 15px;
    background: rgba(0, 255, 255, 0.5);
    box-shadow: 0 0 25px 15px rgba(0, 255, 255, 0.3);
    border-bottom: 2px solid #ffffff;
    z-index: 2;
    animation: sweepBeam 2.5s linear infinite;
}

/* Cyan X-Ray text */
.flashing-ready {
    color: #00ffff;
    font-family: monospace;
    font-size: 16px;
    font-weight: bold;
    text-align: center;
    line-height: 1.5;
    text-shadow: 0 0 10px #00ffff;
    animation: fastPulse 1.5s infinite;
}

/* Deep cyan/blue x-ray filter for the skull */
.xray-skull {
    font-size: 55px;
    opacity: 0.9;
    filter: drop-shadow(0 0 15px rgba(0, 255, 255, 0.9)) sepia(1) hue-rotate(180deg) saturate(4) brightness(1.2);
    animation: pulseSkull 3s ease-in-out infinite;
}

.hardware-handle {
    width: 35px;
    height: 70px;
    /* Dark green/grey handle matching the vibe */
    background: #0a140f; 
    border-radius: 0 0 8px 8px;
    margin-top: -5px;
    z-index: 1;
    /* Green handle accents */
    border: 1px solid rgba(0, 255, 51, 0.3);
    border-top: none;
}
/* ========================================== */
/* 💀 X-RAY HARDWARE EFFECTS */
/* ========================================== */

/* Add grid background and hide the overflowing beam */
.hardware-screen.xray-mode {
    background: 
        linear-gradient(rgba(21, 174, 212, 0.1) 1px, transparent 1px),
        linear-gradient(90deg, rgba(45, 130, 196, 0.1) 1px, transparent 1px),
        rgba(0, 30, 20, 0.8);
    background-size: 20px 20px;
    overflow: hidden; 
}

.screen-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    z-index: 3;
}

/* Tint the skull cyan to match the X-Ray vibe */
.xray-skull {
    font-size: 55px;
    opacity: 0.9;
    filter: drop-shadow(0 0 15px rgba(22, 122, 230, 0.8)) sepia(1) hue-rotate(130deg) saturate(3);
    animation: pulseSkull 3s ease-in-out infinite;
}

/* The sweeping laser beam */
.xray-beam {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 15px;
    background: rgba(45, 124, 220, 0.4);
    box-shadow: 0 0 20px 10px #1b68dd33;
    border-bottom: 2px solid #4040ba;
    z-index: 2;
    animation: sweepBeam 2.5s linear infinite;
}

@keyframes sweepBeam {
    0% { top: -20px; opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { top: 100%; opacity: 0; }
}

@keyframes pulseSkull {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.05); opacity: 1; }
}