/* =========================================
   1. VARIABLES & RESET
   ========================================= */
:root {
    --primary-color: #7c3aed; /* Purple */
    --primary-light: #f3e8ff;
    --secondary-color: #ea580c; /* Orange */
    --text-dark: #1e293b;
    --text-medium: #334155;
    --text-light: #64748b;
    --bg-page: #f8fafc;
    --bg-card: #ffffff;
    --bg-section: #fff1f2; /* Pale Rose for content boxes */
    --bg-ai: #f0f9ff;      /* Pale Blue for AI suggestions */
    --border-color: #e2e8f0;
    --radius-md: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    max-width: 900px;
    margin: 0 auto;
    padding: 40px 20px;
    background-color: var(--bg-page);
    color: var(--text-dark);
}

.container {
    background: var(--bg-card);
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.05);
    text-align: center;
}

h1 {
    color: #2d3748;
    margin-bottom: 30px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

/* =========================================
   2. CONTROLS (Mic & Tabs)
   ========================================= */
#status {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-light);
    height: 20px;
}

.mic-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
}

.mic-btn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: none;
    background-color: #f1f5f9;
    color: #555;
    font-size: 32px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.mic-btn:hover {
    transform: scale(1.05);
    background-color: #e2e8f0;
}

.mic-btn.recording {
    background-color: #ef4444;
    color: white;
    animation: pulse-red 2s infinite;
}

@keyframes pulse-red {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { box-shadow: 0 0 0 20px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* View Tabs - Logic preserved for JS toggling */
.view-tabs {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
    /* Hidden by default, toggled by JS adding .visible */
    opacity: 0;
    pointer-events: none; 
    transition: opacity 0.3s ease;
    background: #f1f5f9;
    padding: 5px;
    border-radius: 25px;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

.view-tabs.visible {
    opacity: 1;
    pointer-events: all;
}

.tab-btn {
    padding: 8px 20px;
    border: none;
    background: transparent;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.2s;
}

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

.tab-btn.active {
    background: white;
    color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

/* =========================================
   3. TRANSCRIPTION DISPLAY
   ========================================= */
.display-box {
    background-color: #fff;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 25px;
    height: 400px;
    overflow-y: auto;
    text-align: left;
    scroll-behavior: smooth;
    position: relative;
}

/* Specific text styling for live transcription */
.text-block {
    line-height: 1.8;
    color: var(--text-medium);
    font-size: 16px;
    white-space: pre-wrap; /* Essential for preserving formatting */
    word-wrap: break-word;
}

.final-text {
    color: var(--text-dark);
}

.interim-text {
    color: #94a3b8;
    font-style: italic;
}

/* =========================================
   4. CONFIG & ACTIONS
   ========================================= */
.config-section {
    margin-bottom: 20px;
    text-align: left;
}

.config-section label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-medium);
    font-size: 14px;
}

.template-select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-medium);
    background-color: white;
    cursor: pointer;
    transition: border-color 0.2s;
}

.template-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.action-area {
    margin-top: 20px;
    text-align: right;
}

#sendBtn {
    padding: 10px 24px;
    background-color: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
    box-shadow: 0 2px 4px rgba(234, 88, 12, 0.2);
}

#sendBtn:hover:not(:disabled) {
    background-color: #c2410c;
}

#sendBtn:disabled {
    background-color: #cbd5e1;
    cursor: not-allowed;
    box-shadow: none;
}

#costDisplay {
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-light);
    text-align: right;
}

/* =========================================
   5. CLINICAL NOTE RESPONSE (The New Look)
   ========================================= */
.response-section {
    margin-top: 40px;
    padding-top: 40px;
    border-top: 2px dashed var(--border-color);
    text-align: left;
}

.response-section h2 {
    color: var(--primary-color);
    margin-bottom: 25px;
    font-size: 24px;
    font-weight: 700;
}

.response-box {
    /* Reset default overrides */
    background: transparent;
    padding: 0;
    border: none;
}

/* Card Style for each section */
.clinical-section {
    margin-bottom: 24px;
    /* No background on container, background is on content */
    background: transparent; 
    padding: 0;
}

.clinical-section-title {
    color: var(--primary-color);
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 8px;
    display: block;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.clinical-section-content {
    background-color: var(--bg-section); /* Pale Rose */
    border-radius: var(--radius-md);
    padding: 16px 20px;
    color: #78350f;
    font-size: 15px;
    line-height: 1.6;
    border: 1px solid transparent;
}

/* Special Style for AI Suggestions */
.clinical-section.ai-suggestion .clinical-section-content {
    background-color: var(--bg-ai); /* Blue tint */
    border: 1px solid #e0f2fe;
    color: #0369a1;
}
.clinical-section.ai-suggestion .clinical-section-title {
    color: #0284c7;
}

/* Lists */
.action-items-list, .treatment-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.action-items-list li, .treatment-list li {
    padding: 6px 0 6px 24px;
    position: relative;
    border-bottom: 1px dashed rgba(0,0,0,0.05);
}
.action-items-list li:last-child, .treatment-list li:last-child {
    border-bottom: none;
}

.action-items-list li::before {
    content: "–";
    position: absolute;
    left: 0;
    color: var(--primary-color);
    font-weight: 700;
}

.treatment-list {
    counter-reset: treatment-counter;
}
.treatment-list li::before {
    content: counter(treatment-counter) ".";
    counter-increment: treatment-counter;
    position: absolute;
    left: 0;
    color: var(--primary-color);
    font-weight: 700;
}

/* =========================================
   6. TABLES (Medication & ICD)
   ========================================= */
.medication-table, .icd-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-top: 5px;
    box-shadow: var(--shadow-sm);
}

.medication-table thead, .icd-table thead {
    background-color: var(--bg-section);
}

.medication-table th, .icd-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    color: #881337;
    border-bottom: 1px solid #ffe4e6;
}

.medication-table td, .icd-table td {
    padding: 12px 16px;
    font-size: 14px;
    color: var(--text-medium);
    border-bottom: 1px solid var(--border-color);
}

.medication-table tr:last-child td, .icd-table tr:last-child td {
    border-bottom: none;
}

.medication-table tbody tr:hover, .icd-table tbody tr:hover {
    background-color: #fff9fa;
}

/* Buttons in Tables */
.btn-accept {
    padding: 4px 12px;
    border-radius: 12px;
    border: 1px solid #cbd5e1;
    background: white;
    color: var(--text-medium);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-accept:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
}

/* ICD Badges */
.icd-type-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.icd-type-primary {
    background-color: #dbeafe;
    color: #1e40af;
}

.icd-type-secondary {
    background-color: #f3e8ff;
    color: #6b21a8;
}