/* ============================================
   Experiment 8 — Lab Interface Styles
   ============================================ */

/* Top Bar */
.lab-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    background: white;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}
.btn-back {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: var(--radius-xs);
    transition: all var(--transition);
}
.btn-back:hover { color: var(--primary); background: var(--primary-50); }
.lab-title-bar {
    display: flex;
    align-items: center;
    gap: 10px;
}
.exp-badge {
    background: var(--primary);
    color: white;
    padding: 4px 10px;
    border-radius: var(--radius-xs);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}
.exp-title-text {
    font-weight: 700;
    font-size: 0.95rem;
}
.lab-mode-selector {
    display: flex;
    gap: 4px;
    background: var(--border-light);
    border-radius: var(--radius-sm);
    padding: 3px;
}
.mode-btn {
    padding: 6px 14px;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: all var(--transition);
}
.mode-btn.active {
    background: white;
    color: var(--text);
    box-shadow: var(--shadow-sm);
}
.mode-btn:hover:not(.active) { color: var(--text); }

/* Lab Container - 3-column layout */
.lab-container {
    display: grid;
    grid-template-columns: 260px 1fr 280px;
    height: calc(100vh - 53px);
    overflow: hidden;
}

/* Panels */
.lab-panel {
    padding: 16px;
    overflow-y: auto;
    background: var(--bg);
    border-right: 1px solid var(--border-light);
}
.lab-right {
    border-right: none;
    border-left: 1px solid var(--border-light);
}
.panel-section {
    margin-bottom: 20px;
}
.panel-heading {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}
.panel-heading svg { color: var(--primary); }

/* Drug Rack */
.drug-rack {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.drug-bottle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: white;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
}
.drug-bottle:hover { border-color: var(--primary); transform: translateX(2px); }
.drug-bottle.selected {
    border-color: var(--primary);
    background: var(--primary-50);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}
.drug-bottle-color {
    width: 10px;
    height: 32px;
    border-radius: 3px;
    flex-shrink: 0;
}
.drug-bottle-info {
    flex: 1;
    min-width: 0;
}
.drug-bottle-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.drug-bottle-class {
    font-size: 0.7rem;
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.drug-bottle-check {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--success);
    color: white;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    flex-shrink: 0;
}
.drug-bottle.tested .drug-bottle-check { display: flex; }

/* Eye Selector */
.eye-selector { margin-bottom: 12px; }
.control-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    display: block;
}
.toggle-group {
    display: flex;
    gap: 4px;
    background: var(--border-light);
    border-radius: var(--radius-sm);
    padding: 3px;
}
.toggle-btn {
    flex: 1;
    padding: 8px 10px;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: all var(--transition);
}
.toggle-btn.active {
    background: white;
    color: var(--text);
    box-shadow: var(--shadow-sm);
}

/* Controls */
.controls-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Score Panel */
.score-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.score-item {
    display: flex;
    align-items: center;
    gap: 8px;
}
.score-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
    min-width: 70px;
}
.progress-bar {
    flex: 1;
    height: 6px;
    background: var(--border-light);
    border-radius: 3px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width var(--transition-slow);
}
.progress-score { background: var(--primary); width: 12%; }
.progress-doubt { background: var(--error); width: 0%; }
.score-value {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text);
    min-width: 32px;
    text-align: right;
}

/* ============================================
   CENTER — Canvas & Eye
   ============================================ */
.lab-center {
    display: flex;
    flex-direction: column;
    background: white;
    position: relative;
    overflow: hidden;
}

/* Tool Bar */
.tool-bar {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    background: var(--bg);
    border-bottom: 1px solid var(--border-light);
}
.tool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 16px;
    background: white;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
    min-width: 72px;
    font-family: inherit;
}
.tool-btn:hover { border-color: var(--primary); background: var(--primary-50); }
.tool-btn.active {
    border-color: var(--primary);
    background: var(--primary-50);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.12);
}
.tool-icon { font-size: 1.3rem; }
.tool-name { font-size: 0.7rem; font-weight: 600; color: var(--text); }
.tool-key {
    position: absolute;
    top: 4px;
    right: 6px;
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--text-light);
    background: var(--border-light);
    width: 16px;
    height: 16px;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Rabbit Scene */
.rabbit-scene {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    padding: 20px;
    position: relative;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
}
.rabbit-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}
#rabbit-canvas {
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    background: white;
}
.rabbit-label {
    margin-top: 8px;
    font-size: 0.75rem;
    color: var(--text-light);
    font-weight: 500;
    font-style: italic;
}

/* Eye Magnifier */
.eye-magnifier {
    position: relative;
}
.magnifier-frame {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-xl);
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 2px solid var(--border);
}
.magnifier-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--primary);
    margin-bottom: 8px;
}
#eye-canvas {
    border-radius: 50%;
    border: 3px solid var(--border);
}
.eye-reading {
    margin-top: 10px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    background: var(--bg);
    padding: 6px 16px;
    border-radius: var(--radius-xs);
    border: 1px solid var(--border);
}

/* Feedback Bar */
.feedback-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    background: var(--primary-50);
    border-top: 1px solid var(--primary-light);
    min-height: 48px;
    transition: all var(--transition);
}
.feedback-bar.error {
    background: #fef2f2;
    border-top-color: #fecaca;
}
.feedback-bar.success {
    background: #f0fdf4;
    border-top-color: #bbf7d0;
}
.feedback-icon { font-size: 1.1rem; }
.feedback-text {
    font-size: 0.85rem;
    color: var(--text);
    line-height: 1.4;
}

/* ============================================
   RIGHT PANEL — Observation & Drug Info
   ============================================ */
.obs-table-container {
    overflow-x: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}
.obs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
}
.obs-table th {
    background: var(--bg);
    padding: 8px 10px;
    text-align: left;
    font-weight: 700;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.obs-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text);
}
.obs-table tr:last-child td { border-bottom: none; }
.obs-table tr.highlight { background: var(--primary-50); }
.obs-cell-present {
    color: var(--success);
    font-weight: 600;
}
.obs-cell-absent {
    color: var(--error);
    font-weight: 600;
}
.obs-cell-pending {
    color: var(--text-light);
    font-style: italic;
}
.obs-cell-mydriasis {
    color: var(--warning);
    font-weight: 600;
}
.obs-cell-miosis {
    color: var(--accent);
    font-weight: 600;
}

/* Drug Info Panel */
.drug-info-panel {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
}
.drug-info-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}
.drug-info-class {
    font-size: 0.78rem;
    color: var(--primary);
    font-weight: 500;
    margin-bottom: 8px;
}
.drug-info-summary {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-light);
}
.drug-info-expected {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.info-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}
.info-value {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text);
}

/* ============================================
   MODALS
   ============================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}
.modal-overlay.visible {
    display: flex;
    animation: fadeIn 0.2s ease-out;
}
.modal {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-xl);
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease-out;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}
.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
}
.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--border-light);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}
.modal-close:hover { background: var(--border); color: var(--text); }

/* Viva Modal */
.viva-modal {
    width: 580px;
    max-width: 100%;
}
.viva-progress {
    padding: 16px 24px 0;
    display: flex;
    align-items: center;
    gap: 12px;
}
.viva-progress-bar {
    flex: 1;
    height: 4px;
    background: var(--border-light);
    border-radius: 2px;
    overflow: hidden;
}
.viva-progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 2px;
    transition: width var(--transition-slow);
}
#viva-qnum {
    font-size: 0.75rem;
    color: var(--text-light);
    font-weight: 500;
    white-space: nowrap;
}
.viva-body {
    padding: 24px;
    overflow-y: auto;
}
.viva-question {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 20px;
    line-height: 1.5;
}
.viva-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.viva-opt {
    padding: 14px 16px;
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.88rem;
    color: var(--text);
    text-align: left;
    font-family: inherit;
    transition: all var(--transition);
    line-height: 1.4;
}
.viva-opt:hover:not(.disabled) { border-color: var(--primary); background: var(--primary-50); }
.viva-opt.correct {
    border-color: var(--success);
    background: #f0fdf4;
    color: #166534;
}
.viva-opt.wrong {
    border-color: var(--error);
    background: #fef2f2;
    color: #991b1b;
}
.viva-opt.disabled { cursor: default; opacity: 0.7; }
.viva-explanation {
    margin-top: 16px;
    padding: 14px;
    background: #eff6ff;
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--accent);
    font-size: 0.85rem;
    color: var(--text);
    line-height: 1.6;
}
.viva-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
    align-items: center;
}
.viva-score-display {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
}

/* Journal Modal */
.journal-modal {
    width: 800px;
    max-width: 100%;
}
.journal-body {
    padding: 24px;
    overflow-y: auto;
}
.journal-section {
    margin-bottom: 24px;
}
.journal-section h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text);
}
.journal-section p {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
    line-height: 1.6;
}
.journal-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.journal-table th {
    background: var(--primary-50);
    padding: 10px 12px;
    text-align: left;
    font-weight: 700;
    color: var(--primary-dark);
    border-bottom: 1px solid var(--border);
}
.journal-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-light);
}
.journal-section ul {
    padding-left: 20px;
}
.journal-section li {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
    line-height: 1.6;
}
.journal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

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

/* Responsive for lab */
@media (max-width: 1100px) {
    .lab-container {
        grid-template-columns: 1fr;
        height: auto;
    }
    .lab-panel {
        border-right: none;
        border-left: none;
        border-bottom: 1px solid var(--border-light);
    }
    .lab-left {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 16px;
    }
    .rabbit-scene { flex-direction: column; min-height: 500px; }
    .lab-mode-selector { display: none; }
}

/* ============================================
   UNIVERSAL MULTI-ENGINE LAB WORKSPACE
   ============================================ */
.uni-layout {
    display: grid;
    grid-template-columns: 280px 1fr 300px;
    min-height: calc(100vh - 53px);
    background: var(--bg);
}
.uni-panel {
    padding: 18px;
    background: var(--bg);
    border-right: 1px solid var(--border-light);
    overflow-y: auto;
}
.uni-panel:last-child {
    border-right: none;
    border-left: 1px solid var(--border-light);
}
.uni-panel h3 {
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 6px;
}
.uni-sub {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-bottom: 14px;
}
.uni-drug-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 14px;
}
.uni-drug-btn {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    background: white;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    transition: all var(--transition);
}
.uni-drug-btn:hover { border-color: var(--primary); }
.uni-drug-btn.active {
    border-color: var(--primary);
    background: var(--primary-50);
}
.uni-drug-btn strong { display: block; font-size: 0.82rem; color: var(--text); }
.uni-drug-btn small { display: block; font-size: 0.72rem; color: var(--text-secondary); margin-top: 2px; }
.uni-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 4px; flex-shrink: 0; }
.uni-slider-box {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin-bottom: 12px;
}
.uni-slider-box label {
    display: flex;
    justify-content: space-between;
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.uni-slider-box input[type="range"] { width: 100%; accent-color: var(--primary); }
/* ============================================
   INSTITUTIONAL SCIENTIFIC LAB WORKSPACE
   (Labster / PhysioEx Medical-Grade Standard)
   ============================================ */

.uni-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: #0f172a;
    gap: 12px;
}

.game-stage-wrap {
    position: relative;
    width: 680px;
    max-width: 100%;
    height: 420px;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 16px 36px -8px rgba(0, 0, 0, 0.45);
    border: 1px solid #334155;
    background: #090d16;
    user-select: none;
    touch-action: none;
}

.game-stage-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
    filter: brightness(0.92) contrast(1.05);
}

.game-stage-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.game-bench-dock {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 10px;
    height: 84px;
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 14px;
    gap: 10px;
    z-index: 20;
}

.draggable-piece {
    cursor: grab;
    transition: transform 0.12s ease, filter 0.12s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    touch-action: none;
    user-select: none;
    position: relative;
    z-index: 25;
}

.draggable-piece:hover {
    transform: translateY(-2px) scale(1.04);
}

.draggable-piece.dragging {
    cursor: grabbing;
    position: fixed !important;
    z-index: 9999 !important;
    pointer-events: none;
    transform: scale(1.1) rotate(-3deg);
    transition: none;
}

.draggable-label {
    font-size: 0.65rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    color: #cbd5e1;
    background: rgba(30, 41, 59, 0.85);
    padding: 2px 6px;
    border-radius: 4px;
    margin-top: 2px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    letter-spacing: 0.2px;
}

.drop-target-ring {
    position: absolute;
    border: 2px dashed #0d9488;
    border-radius: 6px;
    background: rgba(13, 148, 136, 0.1);
    box-shadow: 0 0 0 4px rgba(13, 148, 136, 0.08);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 15;
}

.drop-target-ring.active {
    opacity: 1;
    animation: targetGlow 1.5s ease-in-out infinite;
}

@keyframes targetGlow {
    0%, 100% { border-color: #0d9488; background: rgba(13, 148, 136, 0.08); }
    50% { border-color: #14b8a6; background: rgba(20, 184, 166, 0.18); }
}

.scientific-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(148, 163, 184, 0.25);
    padding: 5px 12px;
    border-radius: 6px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    font-weight: 600;
    color: #5eead4;
    letter-spacing: 0.5px;
    z-index: 10;
}

.scientific-lcd {
    position: absolute;
    top: 12px;
    right: 12px;
    background: #020617;
    border: 1px solid #1e293b;
    border-radius: 6px;
    padding: 6px 12px;
    text-align: right;
    z-index: 10;
}

.scientific-lcd-label {
    font-size: 0.6rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.scientific-lcd-val {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.15rem;
    font-weight: 700;
    color: #2dd4bf;
}
.uni-stage canvas {
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    max-width: 100%;
    height: auto;
    touch-action: none;
    user-select: none;
}
#rabbit-canvas, #eye-canvas {
    touch-action: none;
    user-select: none;
}
.uni-readout {
    width: 100%;
    max-width: 560px;
    padding: 12px 16px;
    background: var(--primary-50);
    border: 1px solid var(--primary-light);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: var(--text);
}
@media (max-width: 1100px) {
    .uni-layout { grid-template-columns: 1fr; }
}
