/* Puberphonia Voice Range Analyzer - Clinical UI */

:root {
    --color-primary: #2C6FAC;
    --color-primary-light: #3B82C4;
    --color-male: #4A90D9;
    --color-androgynous: #F5A623;
    --color-female: #D94A7A;
    --color-bg: #F5F7FA;
    --color-card: #FFFFFF;
    --color-text: #2D3748;
    --color-text-light: #718096;
    --color-border: #E2E8F0;
    --color-success: #38A169;
    --color-error: #E53E3E;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
}

/* === Navigation === */
.navbar {
    background: var(--color-primary);
    padding: 0 24px;
    display: flex;
    align-items: center;
    height: 56px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.navbar-brand {
    color: #fff;
    font-size: 1.1rem;
    font-weight: 600;
    text-decoration: none;
    margin-right: 32px;
}

.navbar-nav {
    display: flex;
    list-style: none;
    gap: 4px;
}

.navbar-nav a {
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.navbar-nav a:hover,
.navbar-nav a.active {
    background: rgba(255,255,255,0.15);
    color: #fff;
}

/* === Layout === */
.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 24px;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--color-text);
}

/* === Cards === */
.card {
    background: var(--color-card);
    border-radius: 10px;
    border: 1px solid var(--color-border);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--color-text);
}

/* === Recording UI === */
.record-section {
    text-align: center;
    padding: 32px 0;
}

.record-instruction {
    font-size: 1rem;
    color: var(--color-text-light);
    margin-bottom: 24px;
}

.record-btn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid var(--color-error);
    background: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    position: relative;
}

.voice-prompt {
    background: #EDF2F7;
    border-left: 4px solid var(--color-primary);
    padding: 14px 20px;
    margin: 12px auto 20px;
    max-width: 540px;
    border-radius: 0 8px 8px 0;
    font-size: 1.05rem;
    font-style: italic;
    color: var(--color-text);
    line-height: 1.7;
    text-align: left;
}

.record-btn:hover {
    background: #FFF5F5;
    transform: scale(1.05);
}

.record-btn .mic-icon {
    width: 32px;
    height: 32px;
    fill: var(--color-error);
}

.record-btn.recording {
    background: var(--color-error);
    animation: pulse 1.5s ease-in-out infinite;
}

.record-btn.recording .mic-icon {
    fill: #fff;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(229, 62, 62, 0.4); }
    50% { box-shadow: 0 0 0 16px rgba(229, 62, 62, 0); }
}

.record-timer {
    font-size: 1.8rem;
    font-weight: 600;
    color: var(--color-text);
    margin-top: 16px;
    font-variant-numeric: tabular-nums;
}

.record-status {
    font-size: 0.9rem;
    color: var(--color-text-light);
    margin-top: 8px;
}

/* === Analysis Button === */
.btn {
    display: inline-block;
    padding: 10px 24px;
    border-radius: 8px;
    border: none;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--color-primary-light);
}

.btn-primary:disabled {
    background: #A0AEC0;
    cursor: not-allowed;
}

.btn-success {
    background: var(--color-success);
    color: #fff;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text);
}

.btn-outline:hover {
    background: var(--color-bg);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.85rem;
}

/* === Results Display === */
.results-section {
    display: none;
}

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

.f0-display {
    text-align: center;
    padding: 20px 0;
}

.f0-value {
    font-size: 3.5rem;
    font-weight: 700;
    color: var(--color-primary);
    line-height: 1;
}

.f0-unit {
    font-size: 1.2rem;
    color: var(--color-text-light);
    margin-left: 4px;
}

.f0-label {
    font-size: 0.9rem;
    color: var(--color-text-light);
    margin-top: 4px;
}

.classification-badge {
    display: inline-block;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    margin-top: 8px;
}

.classification-badge.male { background: #EBF4FF; color: var(--color-male); }
.classification-badge.androgynous { background: #FFF8EB; color: #B7791F; }
.classification-badge.female { background: #FFF0F6; color: var(--color-female); }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
    margin: 16px 0;
}

.stat-item {
    text-align: center;
    padding: 12px;
    background: var(--color-bg);
    border-radius: 8px;
}

.stat-value {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--color-text);
}

.stat-label {
    font-size: 0.78rem;
    color: var(--color-text-light);
    margin-top: 2px;
}

/* === Canvas Visualizations === */
.canvas-container {
    width: 100%;
    margin: 16px 0;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    border: 1px solid var(--color-border);
}

.canvas-container canvas {
    display: block;
    width: 100%;
}

/* === Forms === */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-text);
    margin-bottom: 4px;
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 0.95rem;
    color: var(--color-text);
    background: #fff;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(44, 111, 172, 0.1);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

select.form-control {
    appearance: auto;
}

/* === Tables === */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 10px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--color-border);
}

td {
    padding: 10px 12px;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--color-border);
}

tr:hover {
    background: var(--color-bg);
}

tr.clickable {
    cursor: pointer;
}

/* === Disclaimer === */
.disclaimer {
    background: #FFF3CD;
    border-left: 4px solid #FFC107;
    padding: 12px 16px;
    font-size: 0.82rem;
    color: #856404;
    margin: 16px 0;
    border-radius: 0 6px 6px 0;
}

/* === Patient Selector === */
.patient-selector {
    display: flex;
    gap: 12px;
    align-items: end;
    margin-bottom: 16px;
}

.patient-selector .form-group {
    flex: 1;
    margin-bottom: 0;
}

/* === Loading === */
.loading {
    text-align: center;
    padding: 24px;
    color: var(--color-text-light);
}

.spinner {
    display: inline-block;
    width: 32px;
    height: 32px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* === Messages === */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    margin-bottom: 16px;
}

.alert-error {
    background: #FFF5F5;
    color: var(--color-error);
    border: 1px solid #FEB2B2;
}

.alert-success {
    background: #F0FFF4;
    color: var(--color-success);
    border: 1px solid #9AE6B4;
}

/* === Footer === */
.footer {
    text-align: center;
    padding: 16px;
    margin-top: 40px;
    font-size: 0.8rem;
    color: var(--color-text-light);
}

/* === Empty State === */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--color-text-light);
}

.empty-state h3 {
    margin-bottom: 8px;
    color: var(--color-text);
}

/* === Input Tabs === */
.input-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--color-border);
    padding-bottom: 0;
}

.input-tab {
    padding: 10px 20px;
    border: none;
    background: none;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--color-text-light);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}

.input-tab:hover {
    color: var(--color-text);
}

.input-tab.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* === File Upload / Drop Zone === */
.upload-section {
    text-align: center;
    padding: 16px 0;
}

.drop-zone {
    border: 2px dashed var(--color-border);
    border-radius: 12px;
    padding: 40px 24px;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--color-bg);
}

.drop-zone:hover {
    border-color: var(--color-primary);
    background: #F0F5FA;
}

.drop-zone.drag-over {
    border-color: var(--color-primary);
    background: #E8F0FE;
    box-shadow: 0 0 0 4px rgba(44, 111, 172, 0.1);
}

.upload-icon {
    margin-bottom: 12px;
}

.drop-zone-text {
    font-size: 1rem;
    font-weight: 500;
    color: var(--color-text);
    margin-bottom: 4px;
}

.drop-zone-hint {
    font-size: 0.85rem;
    color: var(--color-text-light);
}

.file-info {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    margin-top: 12px;
    background: #F0FFF4;
    border: 1px solid #9AE6B4;
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--color-success);
    font-weight: 500;
}

/* === Audio Playback === */
.audio-playback {
    margin: 16px 0;
    text-align: center;
}

.audio-playback audio {
    width: 100%;
    max-width: 400px;
}

/* === Exercise Grid === */
.exercise-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.exercise-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    background: #fff;
}

.exercise-card:hover {
    border-color: var(--color-primary);
    box-shadow: 0 2px 8px rgba(44, 111, 172, 0.1);
}

.exercise-number {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.exercise-info {
    flex: 1;
    min-width: 0;
}

.exercise-name {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.exercise-desc {
    font-size: 0.85rem;
    color: var(--color-text-light);
    margin-bottom: 6px;
}

.exercise-meta {
    display: flex;
    gap: 16px;
    font-size: 0.8rem;
}

.exercise-freq {
    color: var(--color-primary);
    font-weight: 600;
}

.exercise-class {
    color: var(--color-text-light);
}

.exercise-dur {
    color: var(--color-text-light);
}

.exercise-play-hint {
    color: var(--color-text-light);
    flex-shrink: 0;
}

/* === Reference Clip Section === */
.ref-clip-section {
    text-align: center;
    padding: 8px 0;
}

.ref-info {
    display: flex;
    justify-content: center;
    gap: 24px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.ref-stat {
    font-size: 0.9rem;
    color: var(--color-text);
}

/* === Feedback Banner === */
.feedback-card {
    text-align: center;
    padding: 24px;
}

.feedback-icon {
    font-size: 2.5rem;
    margin-bottom: 8px;
}

.feedback-text {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.feedback-diff {
    font-size: 0.95rem;
    color: var(--color-text-light);
}

.feedback-excellent {
    background: #F0FFF4;
    border: 2px solid #38A169;
}
.feedback-excellent .feedback-icon { color: #38A169; }
.feedback-excellent .feedback-text { color: #22543D; }

.feedback-good {
    background: #F0FFF4;
    border: 2px solid #68D391;
}
.feedback-good .feedback-icon { color: #38A169; }
.feedback-good .feedback-text { color: #276749; }

.feedback-moderate {
    background: #FFFAF0;
    border: 2px solid #F5A623;
}
.feedback-moderate .feedback-icon { color: #DD6B20; }
.feedback-moderate .feedback-text { color: #7B341E; }

.feedback-retry {
    background: #FFF5F5;
    border: 2px solid #FC8181;
}
.feedback-retry .feedback-icon { color: #E53E3E; }
.feedback-retry .feedback-text { color: #742A2A; }

/* === Comparison Bars === */
.comparison-bars {
    padding: 8px 0;
}

.comp-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.comp-label {
    width: 80px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-text);
    text-align: right;
    flex-shrink: 0;
}

.comp-bar-wrap {
    flex: 1;
    height: 28px;
    background: var(--color-bg);
    border-radius: 6px;
    overflow: hidden;
}

.comp-bar {
    height: 100%;
    border-radius: 6px;
    transition: width 0.6s ease;
    min-width: 4px;
}

.target-bar {
    background: linear-gradient(90deg, #38A169, #48BB78);
}

.patient-bar {
    background: linear-gradient(90deg, #2C6FAC, #4A90D9);
}

.comp-value {
    width: 75px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text);
    flex-shrink: 0;
}

/* === Responsive === */
@media (max-width: 600px) {
    .container { padding: 16px; }
    .form-row { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .f0-value { font-size: 2.5rem; }
    .ref-info { gap: 12px; }
    .comp-label { width: 60px; font-size: 0.8rem; }
}

/* ============================================================
   Patient-Friendly / Accessibility Mode (.patient-mode on body)
   Applied automatically for all patient sessions via base.html
   ============================================================ */

body { font-size: 16px; }

.patient-mode, .patient-mode body {
    font-size: 17px;
    line-height: 1.7;
}

/* Larger, easier-to-tap inputs */
.patient-mode .form-control {
    font-size: 1.05rem;
    padding: 13px 15px;
    min-height: 52px;
    border-radius: 8px;
    border-width: 2px;
}

.patient-mode .form-control:focus {
    box-shadow: 0 0 0 4px rgba(44, 111, 172, 0.15);
}

/* Bigger, bolder buttons */
.patient-mode .btn {
    font-size: 1.05rem;
    font-weight: 600;
    padding: 14px 28px;
    min-height: 52px;
    border-radius: 10px;
}

.patient-mode .btn-primary {
    box-shadow: 0 3px 10px rgba(44, 111, 172, 0.25);
}

/* Bigger form labels */
.patient-mode .form-group label {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 7px;
    color: var(--color-text);
}

/* Larger page titles */
.patient-mode .page-title {
    font-size: 1.7rem;
}

.patient-mode .card-title {
    font-size: 1.2rem;
}

/* Bigger stat values */
.patient-mode .stat-value {
    font-size: 1.4rem;
}

.patient-mode .stat-label {
    font-size: 0.85rem;
}

/* Bigger exercise cards */
.patient-mode .exercise-card {
    padding: 20px;
    border-radius: 12px;
}

.patient-mode .exercise-number {
    width: 48px;
    height: 48px;
    font-size: 1.2rem;
}

.patient-mode .exercise-name {
    font-size: 1.1rem;
}

/* Record button larger */
.patient-mode .record-btn {
    width: 96px;
    height: 96px;
}

.patient-mode .record-btn .mic-icon {
    width: 40px;
    height: 40px;
}

.patient-mode .record-timer {
    font-size: 2.2rem;
}

.patient-mode .record-status,
.patient-mode .record-instruction {
    font-size: 1.05rem;
}

/* F0 display bigger */
.patient-mode .f0-value {
    font-size: 4rem;
}

/* Navbar adjustments for patient */
.patient-mode .navbar-brand {
    font-size: 1.15rem;
}

/* Card slightly more padding */
.patient-mode .card {
    padding: 28px;
    border-radius: 12px;
}

/* Alert messages bigger */
.patient-mode .alert {
    font-size: 0.97rem;
    padding: 14px 18px;
}
