/* ═══════════════════════════════════════════
   Mind & Body Clinical Forms — Shared Styles
   ═══════════════════════════════════════════ */

:root {
    --primary: #2c3e50;
    --primary-light: #34495e;
    --accent: #3498db;
    --accent-hover: #2980b9;
    --danger: #e74c3c;
    --danger-hover: #c0392b;
    --success: #27ae60;
    --bg: #f4f4f4;
    --card-bg: #ffffff;
    --border: #ddd;
    --text: #333;
    --text-muted: #777;
    --input-bg: #ffffcc;
    --input-focus: #fffde7;
    --header-bg: #ecf0f1;
    --radius: 6px;
}

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

body {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 10pt;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* ─── Top Navigation ─── */

.top-nav {
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.top-nav .brand {
    font-size: 13pt;
    font-weight: bold;
    letter-spacing: 0.5px;
    text-decoration: none;
    color: #fff;
}
.top-nav .nav-actions {
    display: flex;
    gap: 8px;
}
.top-nav .nav-actions button,
.top-nav .nav-actions a {
    background: rgba(255,255,255,0.15);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.3);
    padding: 5px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 8.5pt;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.top-nav .nav-actions button:hover,
.top-nav .nav-actions a:hover {
    background: rgba(255,255,255,0.25);
}

/* ─── Main Container ─── */

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 16px;
}

/* ─── Nav Dropdown ─── */

.nav-dropdown {
    position: relative;
    display: inline-block;
}
.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 200px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 150;
    margin-top: 4px;
}
.nav-dropdown-menu.open {
    display: block;
}
.nav-dropdown-menu a {
    display: block;
    padding: 8px 14px;
    color: var(--text) !important;
    background: #fff !important;
    text-decoration: none;
    font-size: 9pt;
    border-bottom: 1px solid #eee;
}
.nav-dropdown-menu a:last-child {
    border-bottom: none;
}
.nav-dropdown-menu a:hover {
    background: #f0f8ff !important;
}

/* ─── Cards ─── */

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    margin-bottom: 12px;
}
.card-header {
    background: var(--header-bg);
    padding: 8px 14px;
    font-weight: bold;
    font-size: 10pt;
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.card-body {
    padding: 12px 14px;
}

/* ─── Search Bar ─── */

.search-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
}
.search-bar input {
    flex: 1;
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 10pt;
    outline: none;
}
.search-bar input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(52,152,219,0.2);
}

/* ─── Buttons ─── */

.btn {
    padding: 6px 14px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 9pt;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    text-decoration: none;
    white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #219a52; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--header-bg); }
.btn-sm { padding: 4px 10px; font-size: 8pt; }
.btn-dark { background: var(--primary); color: #fff; }
.btn-dark:hover { background: var(--primary-light); }

/* ─── Patient List ─── */

.patient-list {
    list-style: none;
}
.patient-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background 0.15s;
}
.patient-item:hover {
    background: #f0f8ff;
}
.patient-item:last-child {
    border-bottom: none;
}
.patient-info {
    display: flex;
    flex-direction: column;
}
.patient-name {
    font-weight: bold;
    font-size: 10pt;
}
.patient-meta {
    font-size: 8pt;
    color: var(--text-muted);
    margin-top: 1px;
}
.patient-actions {
    display: flex;
    gap: 6px;
}

/* ─── Session List ─── */

.session-list {
    list-style: none;
}
.session-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 14px;
    border-bottom: 1px solid #eee;
}
.session-item:last-child { border-bottom: none; }
.session-date {
    font-weight: bold;
    font-size: 9pt;
}
.session-meta {
    font-size: 8pt;
    color: var(--text-muted);
}

/* ─── Modal ─── */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    align-items: center;
    justify-content: center;
}
.modal-overlay.active {
    display: flex;
}
.modal {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}
.modal-header {
    padding: 10px 16px;
    font-weight: bold;
    font-size: 11pt;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header .close-btn {
    background: none;
    border: none;
    font-size: 18pt;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
}
.modal-body {
    padding: 14px 16px;
}
.modal-footer {
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* ─── Form Fields (modal + inline) ─── */

.form-group {
    margin-bottom: 10px;
}
.form-group label {
    display: block;
    font-weight: bold;
    font-size: 8pt;
    margin-bottom: 3px;
    color: var(--text);
}
.form-group input,
.form-group select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 9pt;
    font-family: inherit;
    background: var(--input-bg);
    outline: none;
}
.form-group input:focus,
.form-group select:focus {
    border-color: var(--accent);
    background: var(--input-focus);
}
.form-row {
    display: flex;
    gap: 10px;
}
.form-row .form-group {
    flex: 1;
}

/* ─── Empty State ─── */

.empty-state {
    text-align: center;
    padding: 30px;
    color: var(--text-muted);
    font-size: 10pt;
}
.empty-state .empty-icon {
    font-size: 28pt;
    margin-bottom: 8px;
}

/* ─── Toast ─── */

.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--primary);
    color: #fff;
    padding: 10px 18px;
    border-radius: var(--radius);
    font-size: 9pt;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    z-index: 300;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s;
    pointer-events: none;
}
.toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* ─── Backup Reminder ─── */

.backup-reminder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
    padding: 8px 14px;
    border-radius: var(--radius);
    font-size: 9pt;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 6px;
}

/* ═══════════ PROGRESS NOTE FORM ═══════════ */

.form-container {
    max-width: 900px;
    margin: 0 auto;
    background: #fff;
    border: 2px solid #333;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.form-title {
    background: var(--primary);
    color: #fff;
    text-align: center;
    font-size: 11pt;
    font-weight: bold;
    padding: 4px;
    letter-spacing: 1px;
}

.session-type-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 2px 8px;
    border-bottom: 1px solid #ccc;
    font-size: 7.5pt;
    flex-wrap: wrap;
}
.session-type-row label {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}

.clinician-instruction {
    text-align: center;
    font-style: italic;
    font-size: 7pt;
    padding: 1px;
    border-bottom: 1px solid #ccc;
    background: #fafafa;
}

.field-row {
    display: flex;
    border-bottom: 1px solid #ccc;
    min-height: 20px;
}
.field-row .label {
    font-weight: bold;
    font-size: 7pt;
    padding: 2px 5px;
    white-space: nowrap;
    display: flex;
    align-items: center;
    background: #fafafa;
}
.field-row .value {
    flex: 1;
    display: flex;
    align-items: center;
    padding: 1px 3px;
}
.field-row .value input[type="text"],
.field-row .value input[type="date"],
.field-row .value input[type="number"] {
    width: 100%;
    border: none;
    border-bottom: 1px solid #aaa;
    padding: 1px 3px;
    font-size: 7.5pt;
    font-family: inherit;
    background: var(--input-bg);
    border-radius: 0;
    outline: none;
}
.field-row .value input:focus {
    border-bottom: 2px solid var(--primary);
    background: var(--input-focus);
}

.section-header-form {
    background: var(--header-bg);
    font-weight: bold;
    font-size: 7.5pt;
    padding: 3px 8px;
    border-bottom: 1px solid #ccc;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border-bottom: 1px solid #ccc;
}
.checkbox-grid label {
    display: flex;
    align-items: flex-start;
    gap: 4px;
    padding: 1px 6px;
    font-size: 7pt;
    cursor: pointer;
    border-bottom: 1px solid #eee;
}
.checkbox-grid label:nth-child(odd) {
    border-right: 1px solid #eee;
}
.checkbox-grid input[type="checkbox"] {
    margin-top: 2px;
    flex-shrink: 0;
}
.checkbox-other {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 1px 6px;
    font-size: 7pt;
    border-bottom: 1px solid #eee;
}
.checkbox-other:nth-child(odd) {
    border-right: 1px solid #eee;
}
.checkbox-other input[type="text"] {
    flex: 1;
    border: none;
    border-bottom: 1px solid #aaa;
    padding: 1px 3px;
    font-size: 7pt;
    background: var(--input-bg);
    outline: none;
}

.text-section {
    padding: 3px 6px;
    border-bottom: 1px solid #ccc;
}
.text-section textarea {
    width: 100%;
    border: 1px solid #ccc;
    padding: 3px 5px;
    font-size: 7.5pt;
    font-family: inherit;
    resize: vertical;
    min-height: 48px;
    outline: none;
    background: var(--input-bg);
}
.text-section textarea:focus {
    border-color: var(--primary);
    background: var(--input-focus);
}

.certification-row {
    padding: 3px 6px;
    border-bottom: 1px solid #ccc;
    font-size: 7pt;
}

.signature-row {
    display: flex;
    gap: 12px;
    padding: 4px 6px;
    align-items: flex-end;
}
.signature-row .sig-group {
    flex: 1;
}
.signature-row .sig-group .sig-label {
    font-weight: bold;
    font-size: 7pt;
    margin-bottom: 2px;
}
.signature-row .sig-group input {
    width: 100%;
    border: none;
    border-bottom: 1px solid #aaa;
    padding: 1px 3px;
    font-size: 7.5pt;
    background: var(--input-bg);
    outline: none;
}

.form-actions-bar {
    display: flex;
    gap: 8px;
    justify-content: center;
    padding: 10px;
    background: #fafafa;
    flex-wrap: wrap;
}

/* ─── Print ─── */

@page {
    size: letter;
    margin: 0.3in;
}

@media print {
    body { background: #fff; padding: 0; margin: 0; font-size: 7pt; }
    .top-nav, .form-actions-bar, .no-print { display: none !important; }
    .container { padding: 0; max-width: 100%; }
    .form-container { box-shadow: none; border: 1px solid #000; max-width: 100%; }
    .field-row .value input,
    .signature-row .sig-group input,
    .checkbox-other input[type="text"] {
        border-bottom: none !important;
        font-size: 7pt;
    }
    .text-section textarea { border: none; font-size: 7pt; min-height: 40px; }
    .form-title { font-size: 10pt; padding: 3px; }
    .section-header-form { padding: 2px 6px; font-size: 7pt; }
    .field-row { min-height: 16px; }
    .checkbox-grid label, .checkbox-other { padding: 1px 5px; font-size: 6.5pt; }
    .certification-row { padding: 2px 5px; font-size: 6.5pt; }
    .signature-row { padding: 3px 5px; }
    .text-section { padding: 2px 5px; }
}

/* ─── Lock Screen ─── */

.lock-screen {
    position: fixed;
    inset: 0;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
.lock-screen.hidden {
    display: none;
}
.lock-box {
    background: #fff;
    padding: 30px 36px;
    border-radius: 10px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.4);
    text-align: center;
    width: 90%;
    max-width: 380px;
}
.lock-box h1 {
    font-size: 15pt;
    color: var(--primary);
    margin-bottom: 4px;
}
.lock-box .lock-icon {
    font-size: 36pt;
    margin-bottom: 8px;
}
.lock-box p {
    font-size: 9pt;
    color: var(--text-muted);
    margin-bottom: 16px;
}
.lock-box input[type="password"] {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 11pt;
    font-family: inherit;
    outline: none;
    margin-bottom: 8px;
    text-align: center;
    letter-spacing: 2px;
}
.lock-box input[type="password"]:focus {
    border-color: var(--accent);
}
.lock-box .lock-error {
    color: var(--danger);
    font-size: 8.5pt;
    min-height: 18px;
    margin-bottom: 8px;
}
.lock-box button {
    width: 100%;
    padding: 10px;
    font-size: 10pt;
    font-family: inherit;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    margin-bottom: 6px;
}
.lock-box .btn-unlock {
    background: var(--accent);
    color: #fff;
}
.lock-box .btn-unlock:hover {
    background: var(--accent-hover);
}
.lock-box .password-hint {
    font-size: 7.5pt;
    color: var(--text-muted);
    margin-top: 6px;
}
.lock-box .confirm-group {
    margin-bottom: 8px;
}
.lock-box .confirm-group input[type="password"] {
    margin-bottom: 4px;
}

/* App content hidden when locked */
.app-content {
    display: none;
}
.app-content.unlocked {
    display: block;
}

/* ─── Responsive ─── */

@media (max-width: 600px) {
    .container { padding: 8px; }
    .form-row { flex-direction: column; gap: 0; }
    .search-bar { flex-direction: column; }
    .top-nav { padding: 8px 12px; }
    .top-nav .brand { font-size: 11pt; }
    .patient-item { flex-direction: column; align-items: flex-start; gap: 6px; }
}
