/* 
 * CSS UTAMA - MENGGUNAKAN TEKNIK GLASSMORPHISM & DARK MODE 
 */
:root {
    /* Color Palette */
    --bg-dark: #09090b;
    --bg-darker: #000000;
    --glass-bg: rgba(24, 24, 27, 0.6);
    --glass-border: rgba(255, 255, 255, 0.08);
    --accent: #3b82f6;
    --accent-glow: rgba(59, 130, 246, 0.5);
    --accent-hover: #2563eb;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --success: #10b981;
    --danger: #ef4444;

    /* Theme Variable Overrides */
    --radial-glow: #1e1b4b;
    --navbar-bg: rgba(9, 9, 11, 0.6);
    --upload-bg: rgba(0, 0, 0, 0.2);
    --input-bg: rgba(0, 0, 0, 0.3);
    --input-border: rgba(255, 255, 255, 0.1);
    --meta-bg: rgba(0, 0, 0, 0.3);
    --badge-bg: rgba(255, 255, 255, 0.04);
    --dashed-border: rgba(255, 255, 255, 0.15);
    --pulse-bg: rgba(255, 255, 255, 0.03);
    --pulse-icon: rgba(255, 255, 255, 0.2);

    /* Spacing & Radii */
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    --bg-dark: #f1f5f9;
    --bg-darker: #e2e8f0;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(15, 23, 42, 0.08);
    --accent: #2563eb;
    --accent-glow: rgba(37, 99, 235, 0.2);
    --accent-hover: #1d4ed8;
    --text-main: #0f172a;
    --text-muted: #475569;
    --success: #059669;
    --danger: #dc2626;

    --radial-glow: #dbeafe;
    --navbar-bg: rgba(241, 245, 249, 0.8);
    --upload-bg: rgba(255, 255, 255, 0.45);
    --input-bg: rgba(255, 255, 255, 0.85);
    --input-border: rgba(15, 23, 42, 0.12);
    --meta-bg: rgba(15, 23, 42, 0.04);
    --badge-bg: rgba(15, 23, 42, 0.05);
    --dashed-border: rgba(15, 23, 42, 0.15);
    --pulse-bg: rgba(15, 23, 42, 0.03);
    --pulse-icon: rgba(15, 23, 42, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

/* 1. Latar Belakang & Efek Blur (Optimasi CPU) */
.glass-bg {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    background: radial-gradient(circle at 50% 0%, var(--radial-glow) 0%, var(--bg-dark) 60%);
}

.glow-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.25; /* Mengurangi opasitas untuk meringankan rendering */
    will-change: auto; /* Mencegah overhead GPU */
}

.orb-1 {
    width: 400px; height: 400px;
    background: #3b82f6;
    top: -100px; left: -100px;
    /* Dihilangkan animasinya agar CPU tidak konstan bekerja 100% menggambar ulang blur */
}

.orb-2 {
    width: 300px; height: 300px;
    background: #8b5cf6;
    bottom: -50px; right: -50px;
    /* Dihilangkan animasinya agar CPU tidak konstan bekerja 100% menggambar ulang blur */
}

/* 2. Menu Navigasi */
.navbar {
    border-bottom: 1px solid var(--glass-border);
    background: var(--navbar-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
    z-index: 50;
}

.nav-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo { display: flex; align-items: center; gap: 12px; }

.logo-icon {
    width: 40px; height: 40px;
    background: transparent;
    border-radius: 0;
    display: flex; align-items: center; justify-content: center;
    box-shadow: none;
}

.logo-icon img { width: 40px; height: 40px; object-fit: contain; }
.logo-icon svg { width: 20px; height: 20px; color: white; }

.logo-text h1 {
    font-size: 1.25rem; font-weight: 600;
    letter-spacing: -0.02em;
}

.logo-highlight { color: var(--accent); }

.tech-badge {
    font-size: 0.75rem; font-weight: 500;
    background: rgba(59, 130, 246, 0.1);
    color: #60a5fa;
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

/* 3. Struktur Layout & Panel */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.25rem 2rem;
    height: calc(100vh - 72px);
    display: flex;
    flex-direction: column;
}
@media (max-width: 1024px) {
    .container {
        height: auto;
    }
}

.page-header {
    text-align: center;
    margin-bottom: 1.25rem;
    margin-top: 0;
}

.page-header h2 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    background: linear-gradient(to right, var(--text-main), var(--text-muted));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.page-header p {
    color: var(--text-muted);
    max-width: 650px;
    margin: 0 auto;
    font-size: 0.92rem;
    line-height: 1.4;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    flex: 1;
    min-height: 0;
}

@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
        flex: none;
    }
}

/* 3. Struktur Layout & Panel */
.glass-panel {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-top: 3px solid var(--accent);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

.glass-panel:hover {
    border-color: var(--accent);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25), 0 0 15px var(--accent-glow);
    transform: translateY(-2px);
}

@media (max-width: 1024px) {
    .glass-panel {
        height: auto;
    }
    .glass-panel:hover {
        transform: none;
    }
}

/* Container Kolom Kanan */
.right-column-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    height: 100%;
    min-height: 0;
}

@media (max-width: 1024px) {
    .right-column-container {
        height: auto;
    }
}

/* Lencana Langkah (Step Badge) */
.step-badge {
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 20px;
    margin-right: 8px;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
}

.panel-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 1.25rem;
}

.panel-header h3 {
    font-size: 1rem; font-weight: 500; color: var(--text-main);
}

/* 4. Area Upload Gambar (Drag & Drop) */
.upload-zone {
    border: 2px dashed var(--dashed-border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--upload-bg);
    position: relative;
    overflow: hidden;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--accent); background: rgba(59, 130, 246, 0.05);
}

.upload-icon-wrapper {
    width: 60px; height: 60px;
    background: var(--badge-bg); border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 1rem; color: var(--text-muted); transition: var(--transition);
}

.upload-zone:hover .upload-icon-wrapper {
    background: rgba(59, 130, 246, 0.1); color: var(--accent); transform: translateY(-5px);
}

.upload-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 4px; }
.upload-subtitle { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1rem; }
.upload-subtitle span { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.upload-formats { font-size: 0.75rem; color: rgba(148, 163, 184, 0.6); }

/* 5. Tampilan Preview Gambar */
.preview-area {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.image-wrapper {
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #000;
    border: 1px solid var(--glass-border);
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.file-meta {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: 1rem; padding: 0.75rem 1rem; background: var(--meta-bg);
    border-radius: var(--radius-md); border: 1px solid var(--glass-border);
}

.file-details { display: flex; align-items: center; gap: 12px; }
.file-details svg { width: 20px; height: 20px; color: var(--accent); }
.name-size { display: flex; flex-direction: column; }
.file-name { font-size: 0.9rem; font-weight: 500; max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-size { font-size: 0.75rem; color: var(--text-muted); }

.btn-icon {
    background: var(--badge-bg); border: 1px solid var(--glass-border);
    color: var(--text-main); width: 34px; height: 34px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center; cursor: pointer; transition: var(--transition);
}
.btn-icon:hover { background: rgba(255,255,255,0.1); color: var(--accent); }
.btn-icon svg { width: 16px; height: 16px; }

/* 6. Form Input & Tombol */
.prompt-section { margin-bottom: 1.5rem; }
.input-label { display: block; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 8px; }

.textarea-wrapper textarea {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.9rem;
    padding: 0.75rem;
    height: 70px;
    resize: none;
    transition: var(--transition);
    line-height: 1.5;
}
.textarea-wrapper textarea:focus {
    outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.btn-primary {
    width: 100%;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    margin-bottom: 1rem;
}
.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover); box-shadow: 0 0 20px rgba(59, 130, 246, 0.4); transform: translateY(-2px);
}
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-primary:disabled { background: rgba(255,255,255,0.1); color: var(--text-muted); cursor: not-allowed; }

.btn-secondary {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 0.65rem 1.5rem;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent);
    color: var(--text-main);
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.15);
}

[data-theme="light"] .btn-secondary {
    background: rgba(15, 23, 42, 0.05);
    border-color: rgba(15, 23, 42, 0.08);
    color: var(--text-main);
}

[data-theme="light"] .btn-secondary:hover {
    background: rgba(15, 23, 42, 0.08);
    border-color: var(--accent);
}

.btn-content { display: flex; align-items: center; justify-content: center; gap: 8px; }
.btn-content svg { width: 18px; height: 18px; }

.btn-loader {
    width: 20px; height: 20px; border: 3px solid rgba(255,255,255,0.3);
    border-top-color: white; border-radius: 50%; animation: spin 1s linear infinite;
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
}
@keyframes spin { 100% { transform: translate(-50%, -50%) rotate(360deg); } }

/* 7. Hasil Diagnosis */
.results-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.result-container {
    background: var(--upload-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    min-height: 120px;
    padding: 1.25rem;
    position: relative;
    flex: 1;
    overflow-y: auto;
}

.status-badge {
    font-size: 0.75rem; font-weight: 500; padding: 4px 10px; border-radius: 20px;
    display: inline-flex; align-items: center; gap: 6px;
}
.status-badge::before { content: ''; display: block; width: 6px; height: 6px; border-radius: 50%; }

.status-badge.idle { background: rgba(148, 163, 184, 0.1); color: var(--text-muted); }
.status-badge.idle::before { background: var(--text-muted); }

.status-badge.processing { background: rgba(59, 130, 246, 0.1); color: #60a5fa; }
.status-badge.processing::before { background: #60a5fa; box-shadow: 0 0 8px #60a5fa; animation: blink 1s infinite alternate; }

.status-badge.success { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.status-badge.success::before { background: var(--success); }

.status-badge.error { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.status-badge.error::before { background: var(--danger); }

.empty-state {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    height: 150px; color: var(--text-muted);
}

.pulse-circle {
    width: 48px; height: 48px; border-radius: 50%; background: var(--pulse-bg);
    display: flex; align-items: center; justify-content: center; margin-bottom: 1rem; color: var(--pulse-icon);
}
.pulse-circle svg { width: 24px; height: 24px; }

.skeleton-loader { width: 100%; }
.skeleton-line, .skeleton-title {
    background: linear-gradient(90deg, rgba(255,255,255,0.05) 25%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.05) 75%);
    background-size: 200% 100%; border-radius: 4px; animation: shimmer 1.5s infinite;
}
.skeleton-line { height: 12px; margin-bottom: 10px; }
.skeleton-title { height: 16px; width: 40%; margin-bottom: 16px; }

@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.result-content { font-size: 0.95rem; line-height: 1.7; white-space: pre-wrap; color: var(--text-main); }

@keyframes blink { 0% { opacity: 0.4; } 100% { opacity: 1; } }

/* 8. Efek Scanner Animasi */
.scanner-overlay {
    position: absolute; inset: 0; pointer-events: none; z-index: 10;
    display: none; overflow: hidden; background: rgba(0,0,0,0.2);
}
.scanner-overlay.active { display: block; }

.scan-beam {
    position: absolute; width: 100%; height: 15vh;
    background: linear-gradient(to bottom, rgba(59, 130, 246, 0) 0%, rgba(59, 130, 246, 0.4) 50%, rgba(59, 130, 246, 0.8) 100%);
    border-bottom: 2px solid #60a5fa; box-shadow: 0 5px 15px rgba(59, 130, 246, 0.4);
    animation: scan 2.5s cubic-bezier(0.4, 0, 0.2, 1) infinite alternate;
    will-change: top;
    transform: translateZ(0); /* GPU acceleration fallback */
}

.scan-particles { position: absolute; inset: 0; background: radial-gradient(rgba(59, 130, 246, 0.1) 1px, transparent 1px); background-size: 20px 20px; opacity: 0.5; }
.scan-hud { position: absolute; inset: 10px; }
.corner { position: absolute; width: 20px; height: 20px; border: 2px solid rgba(96, 165, 250, 0.8); }
.corner.tl { top: 0; left: 0; border-right: none; border-bottom: none; }
.corner.tr { top: 0; right: 0; border-left: none; border-bottom: none; }
.corner.bl { bottom: 0; left: 0; border-right: none; border-top: none; }
.corner.br { bottom: 0; right: 0; border-left: none; border-top: none; }

.hud-text {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    color: #60a5fa; font-size: 0.8rem; font-weight: 600; letter-spacing: 2px;
    text-shadow: 0 0 10px rgba(59, 130, 246, 0.8); background: rgba(0,0,0,0.7);
    padding: 8px 16px; border-radius: 4px; border: 1px solid rgba(96, 165, 250, 0.3);
    animation: blink 1s infinite alternate;
    will-change: opacity;
}

@keyframes scan { 
    0% { top: -15vh; } 
    100% { top: 100%; } 
}

/* ── 9. Server Status Badge (Navbar) ── */
.badge-container {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.server-status-badge {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    padding: 5px 11px;
    border-radius: 20px;
    background: var(--badge-bg);
    border: 1px solid var(--glass-border);
    transition: var(--transition);
    cursor: default;
}

.server-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
    transition: background 0.4s ease, box-shadow 0.4s ease;
}

/* Status: checking (default — abu-abu berkedip) */
.server-dot.checking {
    background: var(--text-muted);
    animation: blink 1.2s infinite alternate;
}

/* Status: online + model loaded */
.server-dot.online {
    background: var(--success);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.7);
    animation: pulse-green 2s ease-in-out infinite;
}

/* Status: online tapi model belum siap */
.server-dot.warning {
    background: #f59e0b;
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.6);
}

/* Status: offline / error */
.server-dot.offline {
    background: var(--danger);
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.5);
}

@keyframes pulse-green {
    0%, 100% { box-shadow: 0 0 6px rgba(16, 185, 129, 0.5); }
    50%       { box-shadow: 0 0 14px rgba(16, 185, 129, 0.9); }
}

/* ── 10. Theme Switcher (Navbar) ── */
.theme-switcher {
    display: flex;
    align-items: center;
    background: var(--badge-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 3px;
    gap: 2px;
}

.theme-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.theme-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

[data-theme="light"] .theme-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.theme-btn.active {
    background: var(--accent);
    color: #ffffff;
    box-shadow: 0 0 10px var(--accent-glow);
}

.theme-btn svg {
    width: 14px;
    height: 14px;
    display: block;
}

/* ── 11. Camera Viewfinder styles ── */
.camera-trigger-container {
    display: flex;
    justify-content: center;
    margin-top: 1rem;
    width: 100%;
}

.btn-camera-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--badge-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-camera-trigger:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.15);
}

[data-theme="light"] .btn-camera-trigger:hover {
    background: rgba(0, 0, 0, 0.03);
}

.camera-area {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.video-wrapper {
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #000;
    border: 1px solid var(--glass-border);
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-wrapper video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.camera-hud {
    position: absolute;
    inset: 15px;
    pointer-events: none;
    z-index: 5;
}

.camera-controls {
    display: flex;
    gap: 12px;
    margin-top: 1rem;
}

.camera-controls .btn-primary {
    margin-bottom: 0;
    flex: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.camera-controls .btn-secondary {
    flex: 1;
    background: var(--badge-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.camera-controls .btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
}

/* ── 12. Modal Overlay & Content Styles ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    animation: fadeIn 0.2s ease-out;
}

.modal-content {
    animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    width: 100%;
    max-width: 480px;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* ── 15. Responsive Mobile & Tablet Adaptations ── */
@media (max-width: 850px) {
    /* Prevent height collapse of image previews, video, and upload zone when stacked */
    .image-wrapper, .video-wrapper, .upload-zone {
        min-height: 350px;
        height: 400px;
    }
}

@media (max-width: 600px) {
    .container {
        padding: 1rem 1rem;
    }

    .page-header h2 {
        font-size: 1.45rem;
    }

    .page-header p {
        font-size: 0.82rem;
        line-height: 1.35;
    }

    .nav-content {
        padding: 0.75rem 1rem;
    }

    .logo-text h1 {
        font-size: 1.1rem;
    }

    .logo-icon {
        width: 32px;
        height: 32px;
    }

    .logo-icon img {
        width: 32px;
        height: 32px;
    }

    .logo-icon svg {
        width: 16px;
        height: 16px;
    }

    /* Hide technology badge on mobile to avoid wrapping and preserve space */
    .tech-badge {
        display: none;
    }

    /* Tighten grids and container gaps on mobile */
    .dashboard-grid {
        gap: 1rem;
    }

    .right-column-container {
        gap: 1rem;
    }

    .panel {
        padding: 1rem;
    }

    /* Adjust upload zones text sizing */
    .upload-title {
        font-size: 0.95rem;
    }

    .upload-subtitle {
        font-size: 0.8rem;
    }
}

/* ── 16. Custom Vision Transformer & Chat Layout Styles ── */
@media (min-width: 1201px) {
    /* 50-50 Balanced Widescreen Grid */
    .dashboard-grid {
        grid-template-columns: 1fr 1fr;
    }

    /* Posisikan Laporan Medis di ATAS dengan tinggi tetap */
    .report-panel {
        order: 1;
        flex: none;
        height: 550px !important;
        min-height: 0;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    }
    
    /* Posisikan Konfigurasi Prompt di BAWAH */
    .config-panel {
        order: 2;
        display: flex;
        flex-direction: row;
        align-items: center;
        background: var(--glass-bg);
        border: 1px solid var(--glass-border);
        border-radius: var(--radius-lg);
        padding: 0.75rem 1rem;
        margin-bottom: 0;
        gap: 1rem;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
        flex-shrink: 0;
        height: auto !important;
        transition: var(--transition);
    }
    
    /* Explicit High-Specificity Light Mode Override for Panel Container */
    [data-theme="light"] .config-panel {
        background: rgba(255, 255, 255, 0.7) !important;
        border: 1px solid rgba(15, 23, 42, 0.08) !important;
    }
    
    .config-panel .panel-header, 
    .config-panel .input-label {
        display: none !important;
    }
    
    .config-panel .prompt-section {
        flex: 1;
        margin-bottom: 0;
    }
    
    .config-panel .textarea-wrapper {
        background: transparent;
        border: none;
        padding: 0;
    }
    
    .config-panel textarea {
        background: var(--input-bg);
        border: 1px solid var(--input-border);
        border-radius: var(--radius-sm);
        height: 76px !important;
        min-height: 76px;
        padding: 12px 16px;
        font-size: 0.9rem;
        resize: none;
        color: var(--text-main);
        line-height: 1.4;
        overflow-y: hidden;
        transition: var(--transition);
    }
    
    /* Explicit High-Specificity Light Mode Override for Textarea */
    [data-theme="light"] .config-panel textarea {
        background: #ffffff !important;
        border: 1px solid rgba(15, 23, 42, 0.12) !important;
        color: #0f172a !important;
    }
    
    .config-panel textarea:focus {
        border-color: var(--accent);
        box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
    }
    
    .config-panel .btn-primary {
        width: auto;
        min-width: 180px;
        height: 76px;
        margin-bottom: 0;
        border-radius: var(--radius-sm);
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* ── 17. Camera & XAI Header Actions ── */
.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.camera-trigger-container, .xai-header-trigger {
    display: flex;
    align-items: center;
}

.panel-header .camera-trigger-container,
.panel-header .xai-header-trigger {
    margin-top: 0;
    width: auto;
}

.btn-camera-trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: 20px;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-camera-trigger:hover {
    background: rgba(255, 255, 255, 0.10);
    border-color: var(--accent);
    color: var(--text-main);
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.2);
}

[data-theme="light"] .btn-camera-trigger:hover {
    background: rgba(0, 0, 0, 0.04);
}

.btn-xai-header {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.35);
    color: #60a5fa;
    padding: 6px 12px;
    border-radius: 20px;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-xai-header:hover {
    background: rgba(59, 130, 246, 0.25);
    border-color: var(--accent);
    color: var(--text-main);
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.45);
}

[data-theme="light"] .btn-xai-header {
    background: rgba(37, 99, 235, 0.08);
    border-color: rgba(37, 99, 235, 0.22);
    color: #1d4ed8;
}

[data-theme="light"] .btn-xai-header:hover {
    background: rgba(37, 99, 235, 0.15);
    color: #0f172a;
}

/* ── 18. Animasi Berkedip Otomatis Heatmap (XAI) ── */
.heatmap-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
    z-index: 2; /* Di atas previewImg, di bawah scannerOverlay */
}

@keyframes heatmapPulse {
    0% { opacity: 0; }
    15% { opacity: 0.85; }  /* Fade-in ke 85% */
    30% { opacity: 0.15; }  /* Fade-out tipis */
    45% { opacity: 0.85; }  /* Fade-in kedua */
    60% { opacity: 0.15; }  /* Fade-out tipis */
    75% { opacity: 0.85; }  /* Fade-in ketiga */
    90% { opacity: 0; }     /* Fade-out selesai */
    100% { opacity: 0; }    /* Tetap bersih (kembali ke gambar asli) */
}

.heatmap-pulse-animation {
    animation: heatmapPulse 6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* ── 19. ViT XAI Attention Breakdown Modal ── */
.xai-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.75); /* Slate 900 semi-transparan */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    animation: fadeIn 0.3s ease-out;
}

/* Container Modal */
.xai-modal-container {
    width: 100%;
    max-width: 1280px; /* Lebar penuh pas untuk 5 kolom */
    background: rgba(30, 41, 59, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.xai-modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.xai-modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-main);
    letter-spacing: 0.5px;
}

.btn-close-modal {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.8rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    transition: var(--transition);
}

.btn-close-modal:hover {
    color: var(--danger);
    transform: scale(1.1);
}

.xai-modal-body {
    padding: 1.5rem;
    overflow-x: auto; /* Scroll horizontal jika di layar kecil */
    flex: 1;
}

/* Flexbox Aliran Diagram */
.xai-flow-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: 1000px; /* Kunci lebar minimum agar layout kolom tidak gepeng */
    gap: 0.5rem;
}

/* Card Langkah XAI */
.xai-step-card {
    flex: 1;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-md);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.xai-step-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.xai-image-box {
    width: 100%;
    aspect-ratio: 1/1;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-sm);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.xai-image-box img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.xai-step-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Arrow Penghubung */
.xai-arrow {
    font-size: 1.5rem;
    color: rgba(255, 255, 255, 0.2);
    font-weight: bold;
    padding: 0 0.25rem;
    user-select: none;
}

.xai-modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.xai-footer-note {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
}

@media (max-width: 1100px) {
    .xai-modal-container {
        max-width: 95vw;
    }
}

/* ── 20. Logout Button ── */
.logout-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #f87171;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.25);
    border-color: #ef4444;
    color: #ef4444;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.4);
    transform: translateY(-1px);
}

.logout-btn svg {
    width: 16px;
    height: 16px;
}

/* ── 21. Sidebar Layout & Styles ── */
.app-layout {
    display: flex;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

.sidebar {
    width: 260px;
    height: 100%;
    background: var(--glass-bg);
    border-right: 1px solid var(--glass-border);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    display: flex;
    flex-direction: column;
    z-index: 60;
    transition: width var(--transition), transform var(--transition), border-color var(--transition);
    overflow: hidden;
    flex-shrink: 0;
}

.sidebar.collapsed {
    width: 0;
    transform: translateX(-260px);
    border-right-color: transparent;
}

.main-workspace {
    flex: 1;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    min-width: 0;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--glass-border);
}

.sidebar-header .logo {
    gap: 8px;
}

.sidebar-header .logo-icon {
    width: 40px;
    height: 40px;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.sidebar-header .logo-icon img {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

.sidebar-header .logo-text h2 {
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text-main);
}

.btn-toggle-sidebar {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-toggle-sidebar:hover {
    color: var(--text-main);
    background: var(--badge-bg);
}

.sidebar-action {
    padding: 1rem;
}

.btn-new-diagnosis {
    margin-bottom: 0 !important;
    height: 46px;
    font-size: 0.9rem;
    border-radius: var(--radius-md) !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-history-container {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 1rem;
    display: flex;
    flex-direction: column;
}

.history-title-row {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 1px;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
}

.sidebar-history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.empty-history {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-style: italic;
    border: 1px dashed var(--dashed-border);
    border-radius: var(--radius-md);
    background: rgba(0, 0, 0, 0.05);
}

.history-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.02);
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
}

.history-card:hover {
    background: var(--badge-bg);
    border-color: var(--glass-border);
    transform: translateX(2px);
}

.history-card.active {
    background: rgba(59, 130, 246, 0.08);
    border-color: rgba(59, 130, 246, 0.25);
}

.history-card-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.history-card-icon svg {
    width: 16px;
    height: 16px;
}

.history-card-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.history-card-title {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.history-card-time {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.1);
}

.sidebar-footer .user-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-badge {
    display: inline-flex;
    align-items: center;
    background: var(--badge-bg);
    border: 1px solid var(--glass-border);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-main);
}

/* ── 22. Mobile Sidebar Adaptations ── */
.navbar-toggle-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: none;
    align-items: center;
    justify-content: center;
    margin-right: 8px;
    transition: var(--transition);
}

.navbar-toggle-btn:hover {
    color: var(--text-main);
    background: var(--badge-bg);
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 55;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
}

@media (max-width: 1024px) {
    .navbar-toggle-btn {
        display: flex;
    }
    
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-260px);
        width: 260px;
        box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .sidebar.collapsed {
        width: 260px;
        transform: translateX(-260px);
    }
    
    .sidebar-overlay.active {
        opacity: 1;
        pointer-events: auto;
    }
}
