/* --- ACREVS SCOUT: NATIVE iOS (SAN FRANCISCO) & GLASSMORPHISM THEME --- */

:root {
    --accent-cyan: #007AFF; /* Native Apple System Blue */
    --accent-indigo: #5856D6; /* Native Apple Indigo */
    --text-main: #1C1C1E; /* iOS Primary Text */
    --text-muted: #8E8E93; /* iOS Muted Text */
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.8);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
}

* {
    -webkit-tap-highlight-color: transparent;
}

html {
    -webkit-text-size-adjust: 100%;
    overscroll-behavior: none;
    overscroll-behavior-y: contain;
}

body {
    background: linear-gradient(135deg, #e0eafc 0%, #cfdef3 100%);
    color: var(--text-main); 
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif; 
    font-size: 15px; 
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-text-size-adjust: 100%;
    margin: 0; padding: 15px; 
    display: flex; justify-content: center; align-items: flex-start;
    min-height: 100dvh;
    line-height: 1.5;
    overscroll-behavior: none;
    overscroll-behavior-y: contain;
}

/* --- GLASSMORPHISM CORE CLASSES --- */
.container, .expert-card, .tracking-box, #purified_sandbox, .hub-panel, .input-hub-actions {
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: 20px; 
}

.container {
    max-width: 600px; width: 100%; 
    padding: 30px; 
    box-sizing: border-box;
    position: relative;
}

#gateway_screen { text-align: center; padding: 20px 0; }

.pin-input {
    width: 140px; font-size: 26px; text-align: center; letter-spacing: 8px;
    background: rgba(255, 255, 255, 0.6); color: var(--accent-indigo); 
    border: 1px solid var(--glass-border); padding: 14px; 
    border-radius: 14px; margin: 20px 0; outline: none;
    font-family: -apple-system, BlinkMacSystemFont, monospace;
    font-weight: 600;
    transition: all 0.3s ease;
}
.pin-input:focus { border-color: var(--accent-cyan); background: rgba(255, 255, 255, 0.95); box-shadow: 0 0 15px rgba(0, 122, 255, 0.2); transform: scale(1.02); }

.disclaimer-box { background: rgba(255, 149, 0, 0.1); border-left: 3px solid #FF9500; padding: 14px; border-radius: 10px; font-size: 13.5px; color: var(--text-muted); text-align: left; }
.checkbox-container { display: flex; align-items: flex-start; gap: 10px; text-align: left; font-size: 14px; margin-bottom: 25px; cursor: pointer; color: var(--text-main); }
.checkbox-container input { margin-top: 3px; cursor: pointer; width: 18px; height: 18px; accent-color: var(--accent-cyan); }

#role_selection_screen, #main_app_screen, #expert_dashboard_screen, #emergency_dashboard_screen { display: none; animation: fadeIn 0.4s cubic-bezier(0.25, 0.1, 0.25, 1); }

.role-btn { margin-bottom: 15px; padding: 16px; font-size: 16px; }
.expert-card { padding: 20px; margin-top: 20px; text-align: center; position: relative; }

/* --- EXPERT DASHBOARD SPLIT-PANE --- */
.expert-dashboard {
    display: flex;
    gap: 20px;
    margin-top: 20px;
    align-items: flex-start;
}

.case-sidebar.specialty-sidebar {
    width: 20%;
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    border-radius: 12px;
    padding: 24px;
    box-sizing: border-box;
}

.case-sidebar h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: var(--text-main);
    font-size: 18px;
}

.specialty-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.specialty-filter {
    padding: 10px 15px;
    margin-bottom: 8px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-main);
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.specialty-filter:hover {
    background: rgba(0, 0, 0, 0.05);
}

.specialty-filter.active {
    background: var(--accent-indigo);
    color: white;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}


.case-feed-column {
    width: 30%;
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    border-radius: 12px;
    padding: 24px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    max-height: 80dvh; /* scrollable feed */
    -webkit-overflow-scrolling: touch;
}

.feed-list {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex-grow: 1;
    /* hide scrollbar */
    -ms-overflow-style: none;
    scrollbar-width: none;
}
.feed-list::-webkit-scrollbar {
    display: none;
}

.case-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.case-item {
    padding: 16px;
    margin-bottom: 12px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid var(--glass-border);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.case-item:hover {
    background: rgba(255, 255, 255, 1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transform: translateY(-2px);
}

.case-item.active {
    border-color: var(--accent-indigo);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.feed-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
}

.feed-txn {
    font-family: monospace;
    color: var(--text-muted);
    font-weight: 600;
}

.feed-badge {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    background: #E0E7FF;
    color: #3730A3;
}

.feed-preview {
    font-size: 13px;
    color: var(--text-main);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

.feed-status {
    font-size: 12px;
    font-weight: 500;
    color: #D97706; /* Default pending yellow */
}


.case-workspace {
    width: 50%;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.workspace-card {
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    border-radius: 12px;
    padding: 24px;
    box-sizing: border-box;
    text-align: left;
    transition: all 0.3s ease;
}

.workspace-card h4 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 16px;
    color: var(--text-main);
}

.workspace-card.ai-card {
    background: rgba(88, 86, 214, 0.05); /* Soft indigo background */
    border-color: rgba(88, 86, 214, 0.2);
}

.workspace-card.dispatch-card {
    background: rgba(225, 29, 72, 0.02);
    border-color: rgba(225, 29, 72, 0.1);
}

.data-content, .ai-output {
    background: #FFFFFF;
    color: var(--text-main);
    border: 1px solid rgba(0,0,0,0.06);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-family: monospace;
    font-size: 14px;
    line-height: 1.5;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}

.mobile-specialty-toggle {
    display: none;
    background: transparent;
    border: none;
    font-size: 24px;
    color: var(--text-main);
    cursor: pointer;
    margin-right: 10px;
}

.mobile-specialty-close {
    display: none;
    position: absolute;
    top: 25px;
    right: 25px;
    padding: 10px;
    background: transparent;
    border: none;
    font-size: 20px;
    color: var(--text-main);
    cursor: pointer;
}

/* Make Split Pane stack on mobile */
@media (max-width: 1023px) {
    .expert-dashboard {
        flex-direction: column;
    }
    .case-feed-column, .case-workspace {
        width: 100%;
    }
    .mobile-specialty-toggle {
        display: block;
    }
    .case-sidebar {
        display: none;
    }
    .case-sidebar.mobile-open {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100dvh;
        z-index: 9999;
        border-radius: 0;
        padding-top: 50px;
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(15px);
        -webkit-backdrop-filter: blur(15px);
    }
    .case-sidebar.mobile-open .mobile-specialty-close {
        display: block;
    }
}

@media (max-width: 768px) {
    .expert-dashboard {
        flex-direction: column;
    }
    .case-sidebar, .case-feed-column, .case-workspace {
        width: 100%;
    }
    .editor-actions .action-layout-btn {
        flex: 1 1 100%;
    }
}

.header-box { text-align: center; margin-bottom: 20px; border-bottom: 1px solid rgba(0,0,0,0.06); padding-bottom: 15px; }
h2 { color: var(--text-main); font-weight: 700; margin: 0 0 6px 0; font-size: 24px; letter-spacing: -0.5px; }
.subtitle { color: var(--accent-cyan); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px;}

label { display: block; margin-bottom: 8px; font-size: 15px; color: var(--text-main); font-weight: 500; }

select, textarea, input[type="text"] {
    width: 100%; background: rgba(255, 255, 255, 0.6); color: var(--text-main); 
    border: 1px solid var(--glass-border); 
    padding: 14px; border-radius: 12px; box-sizing: border-box; margin-bottom: 18px; 
    font-family: inherit; font-size: 16px;
    transition: all 0.3s ease;
    resize: vertical;
}
select:focus, textarea:focus, input[type="text"]:focus {
    border-color: var(--accent-cyan); background: rgba(255, 255, 255, 0.95); outline: none;
    box-shadow: 0 0 10px rgba(0, 122, 255, 0.15);
}

.input-hub-actions { padding: 12px; margin-bottom: 18px; }
.plus-btn { background: var(--accent-cyan); color: white; font-size: 26px; font-weight: 300; width: 45px; height: 45px; border-radius: 50%; border: none; cursor: pointer; display: flex; justify-content: center; align-items: center; transition: all 0.3s cubic-bezier(0.25, 0.1, 0.25, 1); box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3); }
.plus-btn:hover { transform: scale(1.08) rotate(90deg); box-shadow: 0 6px 16px rgba(0, 122, 255, 0.4); }

/* --- 🌟 NEW GEMINI STYLE ICON DOCK --- */
.hub-panel { 
    padding: 12px; margin-bottom: 18px; 
    display: none; justify-content: space-around; align-items: center; 
    background: rgba(255, 255, 255, 0.85); 
    border-radius: 20px;
}
.icon-btn {
    background: transparent; border: none; font-size: 26px; cursor: pointer;
    transition: all 0.2s ease; padding: 12px; border-radius: 50%;
    display: flex; justify-content: center; align-items: center; width: 55px; height: 55px;
}
.icon-btn:hover { 
    background: rgba(0, 122, 255, 0.1);
    transform: scale(1.15); 
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.15);
}

.action-layout-btn {
    width: 100%; padding: 16px; background: var(--text-main); color: white; border: none;
    cursor: pointer; border-radius: 14px; font-family: inherit; font-weight: 600; font-size: 16px;
    margin-top: 5px; transition: all 0.3s cubic-bezier(0.25, 0.1, 0.25, 1); box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    box-sizing: border-box;
}
.action-layout-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.15); }

.ai-tab-btn { background: var(--accent-cyan); animation: softPulse 2.5s infinite; }
.ai-tab-btn:hover { animation: none; transform: translateY(-2px) scale(1.01); background: #0062CC; box-shadow: 0 6px 20px rgba(0, 122, 255, 0.35); }

@keyframes softPulse {
    0% { box-shadow: 0 0 0 0 rgba(0, 122, 255, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(0, 122, 255, 0); }
    100% { box-shadow: 0 0 0 0 rgba(0, 122, 255, 0); }
}

#input_forms_area { position: relative; padding: 15px; margin-bottom: 15px; }
#purified_sandbox { padding: 20px; margin-top: 20px; border: 1.5px solid var(--accent-cyan); position: relative; }
.empowerment-banner { background: rgba(0, 122, 255, 0.06); border-left: 3px solid var(--accent-cyan); padding: 14px; border-radius: 10px; margin-bottom: 15px; font-size: 14px; line-height: 1.4; color: var(--text-main); }

#educational_block { display: none; background: var(--glass-bg); backdrop-filter: blur(15px); border: 1.5px dashed var(--accent-cyan); padding: 25px; border-radius: 16px; margin-top: 20px; text-align: center; font-weight: 500;}

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

.tracking-box { padding: 20px; margin-bottom: 25px; position: relative; }
#track_result { display: none; margin-top: 0; font-size: 14px; padding: 0; background: rgba(255,255,255,0.8); border-radius: 12px; border: 0; line-height: 1.5;}

::selection { background-color: rgba(0, 122, 255, 0.25); color: var(--text-main); }

/* --- FULL SCREEN LOGIC CLASSES --- */
.fullscreen-active {
    position: fixed !important; top: 0 !important; left: 0 !important; width: 100vw !important; height: 100dvh !important;
    max-width: none !important; margin: 0 !important; border-radius: 0 !important; z-index: 9999 !important; overflow-y: auto !important; -webkit-overflow-scrolling: touch !important;
    padding: 30px 10% !important; background: rgba(242, 242, 247, 0.95) !important; 
    backdrop-filter: blur(25px) !important; -webkit-backdrop-filter: blur(25px) !important; box-sizing: border-box !important;
}

/* नॉर्मल बटन का डिज़ाइन */
.fs-toggle-btn {
    position: absolute; 
    top: 15px; 
    right: 15px; 
    background: rgba(255, 255, 255, 0.9); 
    border: 1px solid rgba(0,0,0,0.1);
    font-size: 20px; 
    width: 40px; 
    height: 40px; 
    border-radius: 50%; 
    cursor: pointer; 
    z-index: 10000; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* फुल-स्क्रीन होने पर कार्ड कैसा दिखेगा */
.fullscreen-active {
    position: fixed !important;
    top: 0 !important; 
    left: 0 !important;
    width: 100vw !important; 
    height: 100dvh !important;
    margin: 0 !important; 
    border-radius: 0 !important;
    z-index: 9999 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    background: #ffffff !important;
    padding: 40px 20px !important;
}

/* फुल-स्क्रीन होने पर बटन स्क्रीन के टॉप-राइट पर फिक्स हो जाएगा */
/* फुल-स्क्रीन होने पर बटन डेस्कटॉप और मोबाइल दोनों पर काम करेगा */
.fullscreen-active .fs-toggle-btn {
    position: sticky !important;
    top: 20px !important;
    float: right !important; /* बटन को राइट साइड में धकेलने के लिए */
    margin-left: auto !important; 
    z-index: 10001 !important;
}

/* --- SPLASH SCREEN AND BACKGROUND VIDEO --- */
#splash_screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 24px;
    box-sizing: border-box;
    gap: 24px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    z-index: 1000;
}

#splash-bg-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: -1;
}

.splash-content-overlay {
    padding: 40px;
    text-align: center;
    width: 90%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100dvh;
}

.sliding-text-container {
    position: relative;
    width: 100%;
    height: 120px; /* Adjust based on expected text height */
    margin-bottom: 30px;
}

.slide-text {
    position: absolute;
    width: 100%;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    font-size: 28px; /* Elegant, slightly larger */
    font-weight: 700;
    color: #ffffff; /* White text for contrast */
    text-shadow: 0px 4px 15px rgba(0, 0, 0, 0.7); /* Smooth dark shadow */
    opacity: 0;
    animation-duration: 12s; /* 3 * 4s */
    animation-fill-mode: forwards; /* Stop at the end */
}

/* Fading animation logic for 3 items, 4s each out of 12s.
   Item 1: 0-4s (0-33%)
   Item 2: 4-8s (33-66%)
   Item 3: 8-12s (66-100%) and stays visible.
   Using slide up effect.
*/

@keyframes slide-fade-1 {
    0% { opacity: 0; transform: translateY(-30%); }
    5% { opacity: 1; transform: translateY(-50%); }
    28% { opacity: 1; transform: translateY(-50%); }
    33% { opacity: 0; transform: translateY(-70%); }
    100% { opacity: 0; }
}

@keyframes slide-fade-2 {
    0% { opacity: 0; transform: translateY(-30%); }
    33% { opacity: 0; transform: translateY(-30%); }
    38% { opacity: 1; transform: translateY(-50%); }
    61% { opacity: 1; transform: translateY(-50%); }
    66% { opacity: 0; transform: translateY(-70%); }
    100% { opacity: 0; }
}

@keyframes slide-fade-3 {
    0% { opacity: 0; transform: translateY(-30%); }
    66% { opacity: 0; transform: translateY(-30%); }
    71% { opacity: 1; transform: translateY(-50%); }
    100% { opacity: 1; transform: translateY(-50%); } /* Stays visible at the end */
}

.text-1 { animation-name: slide-fade-1; }
.text-2 { animation-name: slide-fade-2; }
.text-3 { animation-name: slide-fade-3; }

/* Get Started Button Animations */
#splash-start-btn {
    opacity: 0;
    pointer-events: none;
    border-radius: 50px; /* Pill-shaped */
    padding: 14px 28px;
    font-size: 16px;
    font-weight: 600;
    width: auto;
    /* Delay the appearance until the entire text sequence finishes at 12s */
    animation: fadeInBtn 1.5s ease 12s forwards;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4); /* Add shadow to button too to pop from video */
}

@keyframes fadeInBtn {
    0% { opacity: 0; transform: translateY(20px); pointer-events: none; }
    100% { opacity: 1; transform: translateY(0); pointer-events: auto; }
}

/* --- TOAST NOTIFICATIONS (GLASSMORPHISM) --- */
#toast-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 10000;
    pointer-events: none;
    align-items: center;
}

.toast {
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideUpFade 0.4s cubic-bezier(0.25, 0.1, 0.25, 1) forwards;
    pointer-events: auto;
    max-width: 90vw;
    text-align: center;
}

.toast-success {
    border-left: 4px solid #10B981;
}

.toast-error {
    border-left: 4px solid #EF4444;
}

.toast-info {
    border-left: 4px solid var(--accent-cyan);
}

@keyframes slideUpFade {
    0% { opacity: 0; transform: translateY(20px); }
    100% { opacity: 1; transform: translateY(0); }
}

@keyframes slideDownFadeOut {
    0% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(20px); }
}

/* --- BUTTON LOADING SPINNER --- */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
    vertical-align: middle;
    margin-right: 8px;
}

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

/* Specific styling for when spinner is active */
.action-layout-btn.loading {
    pointer-events: none;
    opacity: 0.8;
}

/* --- TRUST CENTER UI --- */
#trust_center_container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

.trust-toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
}

#trust_search_input {
    flex: 1;
    margin: 0;
}

.magic-eraser-btn {
    background: transparent;
    border: 2px solid var(--accent-indigo);
    color: var(--accent-indigo);
    padding: 12px 15px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.magic-eraser-btn.active {
    background: rgba(88, 86, 214, 0.15);
    box-shadow: 0 0 10px rgba(88, 86, 214, 0.3);
}

#purified_vignette_editor {
    width: 100%;
    min-height: 250px;
    background: rgba(255, 255, 255, 0.6);
    color: var(--text-main);
    border: 1.5px solid var(--accent-cyan);
    padding: 14px;
    border-radius: 12px;
    box-sizing: border-box;
    font-family: monospace;
    font-size: 14px;
    white-space: pre-wrap;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transition: all 0.3s ease;
    outline: none;
}

#purified_vignette_editor:focus {
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 0 10px rgba(0, 122, 255, 0.15);
}

/* Redaction badge styling */
.redacted-badge {
    background: rgba(16, 185, 129, 0.2);
    color: #047857;
    border: 1px solid rgba(16, 185, 129, 0.4);
    border-radius: 4px;
    padding: 2px 6px;
    font-weight: 600;
    user-select: none;
}

.redacted-manual {
    background: rgba(245, 158, 11, 0.2);
    color: #B45309;
    border: 1px solid rgba(245, 158, 11, 0.4);
}

/* Search match styling */
mark.search-hi {
    background: #FDE047;
    color: #854D0E;
    border-radius: 3px;
    padding: 0 2px;
}

/* X-Ray Vision State */
#purified_vignette_editor.xray-active {
    background: rgba(239, 68, 68, 0.05);
    border-color: #EF4444;
    color: #991B1B;
    box-shadow: inset 0 0 15px rgba(239, 68, 68, 0.1);
    cursor: not-allowed !important;
}

#btn_xray_vision {
    user-select: none;
    -webkit-user-select: none;
}
#btn_xray_vision:active {
    background: #EF4444 !important;
    transform: scale(0.98);
}

/* --- PATIENT CHAT WIDGET --- */
.glass-chat-window {
    background: #FFFFFF;
    border: 1px solid #E2E8F0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border-radius: 12px;
    width: 320px;
    height: 400px;
    display: flex;
    flex-direction: column;
    margin-bottom: 15px;
    overflow: hidden;
    animation: fadeIn 0.3s ease;
}

.chat-header {
    background: #F8F9FA;
    padding: 12px 15px;
    border-bottom: 1px solid #E2E8F0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h3 {
    margin: 0;
    font-size: 14px;
    color: #1F1F1F;
}

.chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.4;
    word-wrap: break-word;
}

.chat-message.ai {
    align-self: flex-start;
    background: #F0F4F9;
    color: #1F1F1F;
    border: none;
    border-bottom-left-radius: 4px;
}

.chat-message.user {
    align-self: flex-end;
    background: #F8F9FA;
    color: #1F1F1F;
    border: 1px solid #E2E8F0;
    border-bottom-right-radius: 4px;
}

.chat-input-area {
    padding: 10px;
    border-top: 1px solid #E2E8F0;
    display: flex;
    gap: 8px;
    background: #FFFFFF;
}

#chat_input {
    margin: 0;
    flex: 1;
    padding: 10px;
    font-size: 14px;
}

/* Typing Indicator Animation */
.typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 14px !important;
}

.typing .dot {
    width: 6px;
    height: 6px;
    background: #94A3B8;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing .dot:nth-child(1) { animation-delay: -0.32s; }
.typing .dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* --- PATIENT TIMELINE (GLASSMORPHISM) --- */
#patient_timeline_section {
    margin-top: 30px;
    padding: 20px;
    display: none;
}

.timeline-container {
    position: relative;
    padding-left: 30px;
    margin-top: 20px;
}

.timeline-container::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 10px;
    width: 2px;
    background: var(--accent-cyan);
    opacity: 0.3;
}

.timeline-item {
    position: relative;
    margin-bottom: 25px;
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: 16px;
    padding: 15px;
    transition: all 0.3s ease;
}

.timeline-header {
    cursor: pointer;
}

.timeline-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 122, 255, 0.15);
}

.timeline-marker {
    position: absolute;
    top: 20px;
    left: -29px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent-cyan);
    border: 3px solid #fff;
    box-shadow: 0 0 10px rgba(0, 122, 255, 0.5);
}

.timeline-date {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 8px;
}

.timeline-chief {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 10px;
}

.timeline-summary {
    font-size: 14px;
    color: var(--text-main);
    background: rgba(0, 122, 255, 0.05);
    padding: 10px;
    border-radius: 8px;
    margin-top: 10px;
}

.timeline-thumb {
    height: 60px;
    width: 60px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--accent-cyan);
    margin-right: 10px;
    vertical-align: middle;
}

.timeline-expanded {
    display: none;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--glass-border);
}

.timeline-item.open .timeline-expanded {
    display: block;
}

.xray-timeline-content {
    padding: 15px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.5);
    border: 1px dashed var(--glass-border);
    font-family: monospace;
    font-size: 13px;
    white-space: pre-wrap;
    transition: all 0.2s ease;
}

.xray-timeline-content.xray-active {
    background: rgba(239, 68, 68, 0.05);
    border-color: #EF4444;
    color: #991B1B;
    box-shadow: inset 0 0 15px rgba(239, 68, 68, 0.1);
}

/* --- EPHEMERAL SHARE LINK (TIME BOMB) --- */
.ephemeral-header {
    background: linear-gradient(135deg, #EF4444 0%, #B91C1C 100%);
    color: white;
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 20px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
    animation: pulseGlow 2s infinite;
}

.ephemeral-title {
    font-size: 16px;
    font-weight: bold;
    margin: 0 0 5px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

#self_destruct_timer {
    font-family: monospace;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 2px;
}

@keyframes pulseGlow {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.share-action-btn {
    background: #F59E0B !important;
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3) !important;
}
.share-action-btn:hover {
    background: #D97706 !important;
}

/* --- HYBRID SWIPEABLE APPROACH (MOBILE FIRST) --- */
@media (max-width: 1023px) {
    .container, .case-workspace, #expert_fullscreen_editor {
        max-width: 100vw !important;
        width: 100vw !important;
        padding: 0 !important;
        margin: 0 !important;
        overflow: hidden !important;
        border-radius: 0 !important;
        border: none !important;
        height: 100dvh !important;
        padding-bottom: env(safe-area-inset-bottom) !important;
    }

    #expert_fullscreen_editor {
        padding: 20px !important; /* Keep padding for content inside modal */
    }

    #splash_screen.container {
        padding: 24px !important;
        overflow-y: auto !important;
        min-height: 100dvh !important;
        height: auto !important;
    }

    #main_app_screen {
        width: 100vw;
        height: 100dvh;
        overflow: hidden;
    }

    .swipe-container {
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        width: 100vw;
        height: 100dvh;
        align-items: flex-start;
    }

    #main_patient_content.swipe-container {
        display: flex !important;
        flex-direction: row;
        width: 100vw;
        height: 100dvh;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        position: relative;
    }

    .swipe-container::-webkit-scrollbar {
        display: none;
    }

    .swipe-section {
        flex: 0 0 100vw;
        width: 100vw;
        height: 100dvh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        scroll-snap-align: center;
        box-sizing: border-box;
        padding: 20px;
        padding-bottom: 80px; /* Space for dots */
        margin: 0 !important;
        display: block !important;
    }

    /* Target direct children to avoid issues with absolute/relative positioning within swipe */
    #main_patient_content > .swipe-section {
        flex: 0 0 100vw;
        min-width: 100vw;
        height: 100%;
        max-height: 100dvh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Make blocks fill the screen naturally on mobile without borders if they are root sections */
    .swipe-section.tracking-box,
    .swipe-section.expert-card,
    .swipe-section#input_forms_area,
    .swipe-section#purified_sandbox {
        border-radius: 0;
        border: none;
        box-shadow: none;
        background: transparent;
    }

    .swipe-dots-container {
        position: fixed;
        bottom: 20px;
        left: 0;
        width: 100vw;
        display: flex;
        justify-content: center;
        gap: 8px;
        z-index: 100;
        pointer-events: none;
    }

    .swipe-dot {
        width: 10px;
        height: 10px;
        border-radius: 50%;
        background: rgba(0, 0, 0, 0.2);
        transition: all 0.3s ease;
        pointer-events: auto;
        cursor: pointer;
    }

    .swipe-dot.active {
        background: var(--accent-cyan);
        transform: scale(1.3);
    }
}

/* --- AI SPARK FLOATING WIDGET --- */
.floating-spark {
    position: fixed;
    top: 50%;
    left: 20px;
    width: 60px;
    height: 60px;
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    border-radius: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    cursor: grab;
    z-index: 9999;
    user-select: none;
    touch-action: none;
    will-change: transform;
    transition: width 0.3s cubic-bezier(0.25, 0.1, 0.25, 1), height 0.3s cubic-bezier(0.25, 0.1, 0.25, 1), border-radius 0.3s, opacity 0.3s;
}

.floating-spark:active {
    cursor: grabbing;
}

.floating-spark.edge-tab {
    width: 20px;
    height: 60px;
    border-radius: 0 10px 10px 0;
    opacity: 0.6;
    overflow: hidden;
    color: transparent;
}

.floating-spark.edge-tab.right-edge {
    border-radius: 10px 0 0 10px;
}

.blue-dot {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 14px;
    height: 14px;
    background: #007AFF;
    border-radius: 50%;
    border: 2px solid white;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s;
}

.blue-dot:hover {
    transform: scale(1.2);
}

.floating-spark.edge-tab .blue-dot {
    display: none;
}

/* God Mode Chat Message */
.chat-message.god-mode {
    background-color: #1e1e1e !important;
    color: #00ff00 !important;
    font-family: monospace !important;
    border-left: 4px solid #00ff00;
}
.chat-message.god-mode::before {
    content: "🛠️ "; }
.chat-message.god-mode {
    align-self: flex-start;
    background: #1F1F1F;
    color: #00FF00;
    font-family: 'Courier New', Courier, monospace;
    border: 1px solid #333;
    border-bottom-left-radius: 4px;
}

/* --- MINIMALIST SPA STYLES (NEW) --- */

.minimalist-editor-container {
    display: flex;
    position: relative;
    width: 100%;
    margin-bottom: 20px;
    align-items: flex-start;
}

.minimalist-editor {
    flex: 1;
    width: 100%;
    min-height: 50dvh;
    border: none !important;
    background: transparent !important;
    outline: none !important;
    box-shadow: none !important;
    font-size: 18px;
    line-height: 1.6;
    color: var(--text-main);
    resize: none;
    padding: 10px 20px;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.minimalist-editor::placeholder {
    color: var(--text-muted);
    font-weight: 300;
}

.editor-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 0;
    margin-top: auto;
    padding-bottom: max(25px, env(safe-area-inset-bottom)) !important;
    margin-bottom: 20px;
    box-sizing: border-box;
    position: relative;
    z-index: 10;
    pointer-events: auto;
}

.editor-actions .action-layout-btn {
    width: 100%;
    margin: 0;
    box-sizing: border-box;
    flex: 1 1 calc(50% - 10px);
    min-width: 140px;
    pointer-events: auto;
    z-index: 11;
}

/* Magic Plus Fan-out Menu */
.magic-plus-container {
    position: relative;
    width: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-right: 10px;
    opacity: 0.8;
    transition: opacity 0.3s ease;
    z-index: 100;
    pointer-events: auto;
}

.magic-plus-container:hover,
.magic-plus-container:active,
.magic-plus-container.open {
    opacity: 1;
}

.magic-plus-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: transparent;
    border: 1px solid var(--text-muted);
    color: var(--text-main);
    font-size: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: transform 0.3s ease, background 0.3s ease, color 0.3s ease, border-color 0.3s ease;
    z-index: 10;
    pointer-events: auto;
}

.magic-plus-container:hover .magic-plus-btn,
.magic-plus-container.open .magic-plus-btn {
    transform: rotate(45deg);
    background: var(--text-main);
    color: white;
    border-color: var(--text-main);
}

.fan-out-menu {
    position: absolute;
    top: 50px;
    left: 0;
    width: max-content;
    display: flex;
    flex-direction: column;
    gap: 4px;
    pointer-events: none;
    z-index: 100;
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border-radius: 8px;
    padding: 8px;
}

.fan-out-item {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-main);
    cursor: pointer;
    opacity: 0;
    transform: translateY(-20px);
    transition: opacity 0.3s ease, transform 0.3s ease, color 0.2s ease;
    user-select: none;
    padding: 10px 12px;
    line-height: 1.2;
    border-radius: 4px;
    text-align: left;
    pointer-events: auto;
}

.fan-out-item:hover {
    color: var(--accent-cyan);
    background: rgba(0, 122, 255, 0.05);
}

.magic-plus-container:hover .fan-out-menu,
.magic-plus-container.open .fan-out-menu {
    pointer-events: auto;
}

.magic-plus-container:hover .fan-out-item,
.magic-plus-container.open .fan-out-item {
    opacity: 1;
    transform: translateY(0);
}

/* --- CROPPER FAILSAFE STYLES --- */
.cropper-container {
    width: 100% !important;
    height: 100% !important;
    position: relative !important;
    overflow: hidden !important;
}
.cropper-hidden {
    display: none !important;
}
#cropper_image_target {
    display: block !important;
    max-width: 100% !important;
}

/* Staggered pure CSS animation */
.magic-plus-container:hover .fan-out-item:nth-child(1),
.magic-plus-container.open .fan-out-item:nth-child(1) { transition-delay: 0.05s; }
.magic-plus-container:hover .fan-out-item:nth-child(2),
.magic-plus-container.open .fan-out-item:nth-child(2) { transition-delay: 0.1s; }
.magic-plus-container:hover .fan-out-item:nth-child(3),
.magic-plus-container.open .fan-out-item:nth-child(3) { transition-delay: 0.15s; }
.magic-plus-container:hover .fan-out-item:nth-child(4),
.magic-plus-container.open .fan-out-item:nth-child(4) { transition-delay: 0.2s; }

/* Override legacy input styles for minimalism */
.minimalist-input {
    width: 100%;
    background: transparent !important;
    color: var(--text-main);
    border: none !important;
    border-bottom: 1px solid var(--text-muted) !important;
    padding: 10px 5px !important;
    border-radius: 0 !important;
    box-sizing: border-box;
    font-family: inherit;
    font-size: 16px;
    transition: border-color 0.3s ease;
    box-shadow: none !important;
}

.minimalist-input:focus {
    border-bottom-color: var(--accent-cyan) !important;
    outline: none;
}

/* --- PRINT FALLBACK --- */
@media print {
    @page { margin: 20mm; size: A4 portrait; }
    body { background: #FFFFFF !important; }
    body * { visibility: hidden; }
    .printable-content, .printable-content * {
        visibility: visible;
        font-size: 14pt !important;
        color: #000 !important;
    }
    .printable-content {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        padding: 20px;
        background: #FFFFFF !important;
        border: none !important;
        box-shadow: none !important;
    }

    /* Ensure elements explicitly hidden via JS stay hidden */
    [style*="display: none"] {
        display: none !important;
        visibility: hidden !important;
    }
}

/* --- iOS PWA INSTALL OVERLAY --- */
#ios-pwa-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100dvh;
    background: rgba(28, 28, 30, 0.85); /* Dark iOS backdrop */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 100000;
    display: none;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    padding-bottom: max(40px, env(safe-area-inset-bottom));
}

.ios-pwa-tooltip {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    border-radius: 16px;
    padding: 20px;
    margin: 0 20px 20px 20px;
    max-width: 350px;
    text-align: center;
    color: var(--text-main);
    animation: slideUpFade 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.ios-pwa-tooltip h3 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 18px;
    font-weight: 600;
}

.ios-pwa-tooltip p {
    margin: 0;
    font-size: 15px;
    color: var(--text-muted);
}

.ios-pwa-arrow {
    font-size: 40px;
    color: #FFFFFF;
    margin-bottom: 20px;
    animation: bounceDown 1.5s infinite;
}

@keyframes slideUpFade {
    0% { opacity: 0; transform: translateY(30px); }
    100% { opacity: 1; transform: translateY(0); }
}

@keyframes bounceDown {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(15px); }
}
#btn_install_pwa {
    padding-bottom: env(safe-area-inset-bottom);
}
@media all and (display-mode: standalone) {
    #btn_install_pwa, #ios-pwa-overlay {
        display: none !important;
    }
}
