/* ═══════════════════════════════════════════
   tests.css — Psychological test form styles
   ═══════════════════════════════════════════ */

/* ─── Test Form Container ─── */
.test-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px 0;
}

.test-form-card {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.test-header {
    background: linear-gradient(135deg, #2c3e50, #34495e);
    color: #fff;
    padding: 20px 24px;
}

.test-header h1 {
    margin: 0 0 4px 0;
    font-size: 16pt;
    font-weight: 700;
}

.test-header .test-subtitle {
    font-size: 9pt;
    opacity: 0.8;
    margin: 0;
}

.test-header .test-category-badge {
    display: inline-block;
    background: rgba(255,255,255,0.2);
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 8pt;
    margin-top: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ─── Patient Info Bar ─── */
.test-patient-bar {
    background: #f8f9fa;
    border-bottom: 1px solid #ddd;
    padding: 10px 24px;
    font-size: 9pt;
    color: #555;
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}

.test-patient-bar strong {
    color: #2c3e50;
}

/* ─── Instructions ─── */
.test-instructions {
    padding: 16px 24px;
    background: #f0f7ff;
    border-bottom: 1px solid #d0e3f7;
    font-size: 9.5pt;
    color: #2c5282;
    line-height: 1.5;
}

.test-instructions .timeframe {
    font-weight: bold;
    color: #1a365d;
}

/* ─── Items Table (for scale-based tests like PHQ-9, GAD-7, BAI) ─── */
.test-items-table {
    width: 100%;
    border-collapse: collapse;
}

.test-items-table thead th {
    background: #ecf0f1;
    padding: 10px 8px;
    font-size: 8pt;
    text-align: center;
    border-bottom: 2px solid #bdc3c7;
    position: sticky;
    top: 0;
    z-index: 2;
    color: #2c3e50;
}

.test-items-table thead th:first-child {
    text-align: left;
    padding-left: 24px;
    width: 50%;
}

.test-items-table tbody tr {
    border-bottom: 1px solid #eee;
    transition: background 0.15s;
}

.test-items-table tbody tr:hover {
    background: #f7f9fc;
}

.test-items-table tbody tr.answered {
    background: #f0faf0;
}

.test-items-table tbody tr.critical-item {
    border-left: 3px solid #e74c3c;
}

.test-items-table td {
    padding: 12px 8px;
    text-align: center;
    vertical-align: middle;
}

.test-items-table td:first-child {
    text-align: left;
    padding-left: 24px;
    line-height: 1.4;
}

.test-items-table .item-number {
    font-weight: bold;
    color: #2c3e50;
    margin-right: 6px;
}

.test-items-table .item-text {
    font-size: 9.5pt;
    color: #333;
}

/* Radio button styling for test items */
.test-radio-cell {
    cursor: pointer;
    position: relative;
}

.test-radio-cell input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    border: 2px solid #bdc3c7;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.15s;
    vertical-align: middle;
}

.test-radio-cell input[type="radio"]:hover {
    border-color: #3498db;
    background: #ebf5fb;
}

.test-radio-cell input[type="radio"]:checked {
    border-color: #2980b9;
    background: #2980b9;
    box-shadow: inset 0 0 0 3px #fff;
}

.test-radio-cell .radio-value {
    display: block;
    font-size: 7.5pt;
    color: #999;
    margin-top: 2px;
}

/* ─── Statement-based items (BDI style) ─── */
.test-statement-items {
    padding: 0;
    list-style: none;
    margin: 0;
}

.test-statement-group {
    border-bottom: 1px solid #eee;
    padding: 16px 24px;
    transition: background 0.15s;
}

.test-statement-group:hover {
    background: #f7f9fc;
}

.test-statement-group.answered {
    background: #f0faf0;
}

.test-statement-group .group-header {
    font-weight: bold;
    font-size: 10pt;
    color: #2c3e50;
    margin-bottom: 10px;
}

.test-statement-group .group-header .group-num {
    display: inline-block;
    background: #2c3e50;
    color: #fff;
    width: 24px;
    height: 24px;
    line-height: 24px;
    text-align: center;
    border-radius: 50%;
    font-size: 8pt;
    margin-right: 8px;
}

.test-statement-option {
    display: block;
    padding: 8px 12px;
    margin: 4px 0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 9.5pt;
    border: 1px solid transparent;
}

.test-statement-option:hover {
    background: #ebf5fb;
    border-color: #bde0fe;
}

.test-statement-option input[type="radio"] {
    margin-right: 10px;
    vertical-align: middle;
}

.test-statement-option.selected {
    background: #d4edda;
    border-color: #a3d9b1;
}

/* ─── Follow-up Question ─── */
.test-followup {
    background: #fff8e1;
    border-top: 2px solid #ffc107;
    padding: 16px 24px;
}

.test-followup .followup-text {
    font-size: 9.5pt;
    color: #5d4e37;
    margin-bottom: 12px;
    line-height: 1.4;
}

.test-followup .followup-options {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.test-followup .followup-option {
    padding: 8px 16px;
    border: 1px solid #e0c68a;
    border-radius: 20px;
    cursor: pointer;
    font-size: 9pt;
    transition: all 0.15s;
    background: #fff;
}

.test-followup .followup-option:hover {
    background: #fef3c7;
}

.test-followup .followup-option.selected {
    background: #f59e0b;
    color: #fff;
    border-color: #d97706;
}

/* ─── Progress Indicator ─── */
.test-progress {
    padding: 10px 24px;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    gap: 12px;
}

.test-progress-bar {
    flex: 1;
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    overflow: hidden;
}

.test-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3498db, #2ecc71);
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 0%;
}

.test-progress-text {
    font-size: 8pt;
    color: #777;
    white-space: nowrap;
}

/* ─── Score Results Panel ─── */
.test-results {
    display: none;
    padding: 24px;
    border-top: 3px solid #2c3e50;
}

.test-results.visible {
    display: block;
}

.test-results h2 {
    margin: 0 0 16px 0;
    font-size: 14pt;
    color: #2c3e50;
}

.score-card {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.score-card .score-big {
    flex: 0 0 auto;
    text-align: center;
    padding: 16px 24px;
    border-radius: 12px;
    min-width: 120px;
}

.score-card .score-big .score-number {
    font-size: 36pt;
    font-weight: 800;
    line-height: 1;
}

.score-card .score-big .score-max {
    font-size: 10pt;
    opacity: 0.7;
    margin-top: 4px;
}

.score-card .score-details {
    flex: 1;
    min-width: 200px;
}

.score-card .severity-label {
    font-size: 14pt;
    font-weight: 700;
    margin-bottom: 8px;
}

.score-card .score-interpretation {
    font-size: 9.5pt;
    color: #555;
    line-height: 1.5;
}

/* Cluster scores (PCL-5) */
.cluster-scores {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.cluster-score-card {
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 12px 16px;
}

.cluster-score-card .cluster-name {
    font-size: 8.5pt;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cluster-score-card .cluster-value {
    font-size: 16pt;
    font-weight: 700;
    color: #2c3e50;
}

.cluster-score-card .cluster-meta {
    font-size: 8pt;
    color: #999;
}

.cluster-score-card.met { border-left: 3px solid #27ae60; }
.cluster-score-card.unmet { border-left: 3px solid #e74c3c; }

/* ─── Action Bar ─── */
.test-actions {
    padding: 16px 24px;
    background: #f8f9fa;
    border-top: 1px solid #ddd;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: space-between;
}

.test-actions .btn-submit {
    background: #27ae60;
    color: #fff;
    border: none;
    padding: 10px 24px;
    border-radius: 6px;
    font-size: 10pt;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.test-actions .btn-submit:hover { background: #219a52; }
.test-actions .btn-submit:disabled { background: #95a5a6; cursor: not-allowed; }

/* ─── Kiosk Mode ─── */
body.kiosk-mode .top-nav,
body.kiosk-mode .lock-screen,
body.kiosk-mode .no-kiosk {
    display: none !important;
}

body.kiosk-mode .app-content {
    display: block !important;
}

body.kiosk-mode .app-content.unlocked {
    display: block !important;
}

body.kiosk-mode {
    background: #f0f2f5;
}

body.kiosk-mode .test-container {
    padding-top: 10px;
}

/* Kiosk completion screen */
.kiosk-complete {
    display: none;
    text-align: center;
    padding: 60px 24px;
    max-width: 500px;
    margin: 60px auto;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.1);
}

.kiosk-complete.visible {
    display: block;
}

.kiosk-complete .complete-icon {
    font-size: 48pt;
    margin-bottom: 16px;
}

.kiosk-complete h2 {
    color: #27ae60;
    margin-bottom: 8px;
}

.kiosk-complete p {
    color: #666;
    font-size: 10pt;
}

.kiosk-complete .btn-return {
    margin-top: 24px;
    display: inline-block;
    padding: 10px 24px;
    background: #2c3e50;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 10pt;
    cursor: pointer;
}

/* ─── Scan Upload ─── */
.scan-upload-area {
    border: 2px dashed #bdc3c7;
    border-radius: 8px;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: #fafafa;
    margin: 12px 0;
}

.scan-upload-area:hover {
    border-color: #3498db;
    background: #ebf5fb;
}

.scan-upload-area .upload-icon {
    font-size: 28pt;
    margin-bottom: 8px;
}

.scan-upload-area .upload-text {
    font-size: 9.5pt;
    color: #666;
}

.scan-preview {
    max-width: 100%;
    max-height: 400px;
    border: 1px solid #ddd;
    border-radius: 6px;
    margin: 12px 0;
}

.scan-manual-entry {
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 16px;
    margin-top: 12px;
}

.scan-manual-entry .form-group {
    margin-bottom: 12px;
}

.scan-manual-entry label {
    font-size: 9pt;
    font-weight: 600;
    color: #555;
    display: block;
    margin-bottom: 4px;
}

.scan-manual-entry input,
.scan-manual-entry select,
.scan-manual-entry textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 9.5pt;
    box-sizing: border-box;
}

/* ─── Test History (in patient modal) ─── */
.test-history-item {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.15s;
}

.test-history-item:hover {
    background: #f7f9fc;
}

.test-history-item .test-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12pt;
    margin-right: 12px;
    flex-shrink: 0;
}

.test-history-item .test-info {
    flex: 1;
}

.test-history-item .test-info .test-name-line {
    font-weight: 600;
    font-size: 9.5pt;
    color: #2c3e50;
}

.test-history-item .test-info .test-date-line {
    font-size: 8pt;
    color: #999;
}

.test-history-item .test-score-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 9pt;
    font-weight: 600;
    color: #fff;
}

/* ─── Print Styles ─── */
@media print {
    .test-actions, .test-progress, .no-print {
        display: none !important;
    }

    .test-form-card {
        box-shadow: none;
        border: none;
    }

    .test-header {
        background: #2c3e50 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .test-results {
        display: block !important;
        break-before: page;
    }

    .score-card .score-big {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    body.kiosk-mode .test-container {
        padding: 0;
    }
}

/* ─── Responsive ─── */
@media (max-width: 600px) {
    .test-header { padding: 14px 16px; }
    .test-header h1 { font-size: 13pt; }
    .test-instructions { padding: 12px 16px; }
    .test-items-table td:first-child { padding-left: 16px; }
    .test-items-table thead th:first-child { padding-left: 16px; }
    .test-statement-group { padding: 12px 16px; }
    .test-actions { padding: 12px 16px; }
    .test-results { padding: 16px; }
    .score-card { flex-direction: column; }

    .test-items-table thead th {
        font-size: 7pt;
        padding: 8px 4px;
    }

    .test-radio-cell input[type="radio"] {
        width: 18px;
        height: 18px;
    }
}
