/* =====================================================================
   VoiceVet — app.css (consolidat din toate .html-urile)
   =====================================================================
   Versiune: v1
   Structură:
     1. Variabile (:root)
     2. Reset + bază (html, body, main)
     3. Header (.bar) + user info
     4. Meniu DB (.db-menu)
     5. Card, butoane, input-uri
     6. Tabele
     7. Status / meta / utilitare
     8. Loading bar
     9. Responsive
   ===================================================================== */


/* ── 1. Variabile ────────────────────────────────────────────────── */
:root {
    --bg: #f4f6f8;
    --card: #ffffff;
    --text: #1a2330;
    --muted: #6b7886;
    --accent: #2b6cb0;
    --accent-hover: #1e5a9a;
    --rec: #d63838;
    --ok: #2f9e44;
    --warn: #b97900;
    --border: #d8dee5;
    --err: #c0392b;

    /* specifice meniului (dark theme) */
    --menu-bg: #1f2937;
    --menu-text: #e5e7eb;
    --menu-border: #374151;
    --menu-hover: #374151;
    --menu-active: #2563eb;
}


/* ── 2. Reset + bază ─────────────────────────────────────────────── */
* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

main {
    margin: 0 auto;
    padding: 24px 16px 64px;
}

h1 { font-size: 22px; margin: 0 0 0; }
h2 { font-size: 18px; margin: 16px 0 8px; }

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

p { margin: 0 0 12px; }


/* ── 3. Header (.bar) + user info ────────────────────────────────── */
header.bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 0 18px;
    gap: 12px;
    flex-wrap: wrap;
}

header.bar .bar-left { min-width: 0; }
header.bar .bar-right { text-align: right; }

.user {
    font-size: 14px;
    color: var(--muted);
    margin-bottom: 6px;
}
.user b { color: var(--text); }
.user .user-role {
    font-size: 12px;
    color: var(--muted);
    background: #eef1f4;
    padding: 1px 7px;
    border-radius: 10px;
    margin-left: 4px;
}

.sub {
    color: var(--muted);
    font-size: 14px;
    margin-top: 2px;
}


/* ── 4. Meniu DB (server-side rendered, citit din voicevet_menu) ─── */
.db-menu {
    background: var(--menu-bg);
    color: var(--menu-text);
    padding: 8px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--menu-border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .1);
    margin: -24px -16px 18px;
}
@media (max-width: 700px) {
    .db-menu { margin: -16px -16px 14px; }
}

.db-menu-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 4px;
    align-items: center;
    flex-wrap: wrap;
}

.db-menu-list-sub {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 200px;
    background: var(--menu-bg);
    border: 1px solid var(--menu-border);
    border-radius: 4px;
    padding: 6px 0;
    margin: 0;
    list-style: none;
    z-index: 1000;
    flex-direction: column;
    gap: 0;
    box-shadow: 0 4px 6px rgba(0, 0, 0, .2);
}

.db-menu-parent { position: relative; }
.db-menu-parent:hover > .db-menu-list-sub,
.db-menu-parent:focus-within > .db-menu-list-sub { display: flex; }

.db-menu-item { margin: 0; }

.db-menu-item > a,
.db-menu-parent-label {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    color: var(--menu-text);
    text-decoration: none;
    border-radius: 4px;
    white-space: nowrap;
    transition: background .15s;
    cursor: pointer;
}
.db-menu-item > a:hover,
.db-menu-parent-label:hover { background: var(--menu-hover); }

.db-menu-item.active > a,
.db-menu-item.active > .db-menu-parent-label {
    background: var(--menu-active);
    color: #fff;
    font-weight: 500;
}

.db-menu-item-placeholder {
    padding: 6px 12px;
    color: #6b7280;
    font-style: italic;
    cursor: default;
}

.db-menu-icon { font-size: 1.1em; line-height: 1; }


/* ── 5. Card, butoane, input-uri ─────────────────────────────────── */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px;
    margin-bottom: 14px;
}

button {
    font-size: 16px;
    font-weight: 600;
    padding: 12px 22px;
    min-height: 48px;
    min-width: 140px;
    border: 0;
    border-radius: 10px;
    cursor: pointer;
    color: white;
    background: var(--accent);
    transition: transform .08s ease, background .2s ease;
    font-family: inherit;
}
button:hover { background: var(--accent-hover); }
button:active { transform: scale(.98); }
button:disabled { opacity: .45; cursor: not-allowed; }

button.primary { background: var(--accent); }
button.primary:hover { background: var(--accent-hover); }
button.ok { background: var(--ok); }
button.danger { background: var(--rec); }
button.danger:hover { background: #b02a2a; }

.logout {
    font-size: 13px;
    padding: 6px 12px;
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    min-height: 0;
    min-width: 0;
}
.logout:hover { color: var(--text); border-color: var(--text); }

.btn-secondary-small {
    font-size: 12px;
    padding: 6px 12px;
    background: white;
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}
.btn-secondary-small:hover { background: #eaf2fb; }
.btn-secondary-small:disabled { opacity: .45; cursor: not-allowed; }

input, select, textarea {
    width: 100%;
    font-size: 15px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: white;
    color: var(--text);
    font-family: inherit;
}
input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--accent);
    outline-offset: -1px;
    border-color: var(--accent);
}
textarea { resize: vertical; }

label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 14px; }


/* ── 6. Tabele ───────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th {
    background: #fafbfc;
    color: var(--muted);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
tbody tr:last-child td { border-bottom: 0; }


/* ── 7. Status / meta / utilitare ────────────────────────────────── */
.status {
    font-size: 14px;
    color: var(--muted);
    text-align: center;
    margin-top: 8px;
    min-height: 22px;
}
.status.ok    { color: var(--ok); }
.status.warn  { color: var(--warn); }
.status.err   { color: var(--rec); font-weight: 600; }

.err {
    color: var(--err);
    font-size: 14px;
    margin-top: 12px;
    min-height: 18px;
    text-align: center;
    font-weight: 500;
}

.meta {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--muted);
    margin-top: 4px;
    gap: 8px;
    flex-wrap: wrap;
}

details { margin-top: 18px; font-size: 14px; color: var(--muted); }
code { background: #eef1f4; padding: 1px 5px; border-radius: 3px; font-size: 13px; }

.hide { display: none !important; }
.grow { flex: 1; }

.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}
.tab {
    background: transparent;
    color: var(--muted);
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    min-height: 0;
    min-width: 0;
}
.tab:hover { color: var(--text); background: transparent; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

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

.toolbar {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
}
.status-badge.transcribed,
.status-badge.cleaned,
.status-badge.processed { background: #e6f4ea; color: #1b5e20; }
.status-badge.audio_only { background: #fdecea; color: var(--rec); }
.status-badge.transcribing { background: #fff8e1; color: #7a5900; }
.status-badge.unknown { background: #eef1f4; color: var(--muted); }

.btn-tiny {
    font-size: 12px;
    padding: 5px 12px;
    min-height: 28px;
    min-width: 0;
    background: var(--accent);
    color: white;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}
.btn-tiny:hover { background: var(--accent-hover); }
.btn-tiny:disabled { opacity: .45; cursor: not-allowed; }
.btn-tiny.danger { background: var(--rec); }
.btn-tiny.danger:hover { background: #b02a2a; }


/* ── 8. Loading bar (global, fixed top) ──────────────────────────── */
.loading-bar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--accent);
    z-index: 1000;
    animation: loadingBarPulse 1.4s ease-in-out infinite;
    box-shadow: 0 0 8px rgba(43, 108, 176, 0.5);
}
@keyframes loadingBarPulse {
    0%   { opacity: 0.3; }
    50%  { opacity: 1; }
    100% { opacity: 0.3; }
}


/* ── 9. Responsive ───────────────────────────────────────────────── */
@media (max-width: 700px) {
    body { font-size: 16px; }
    main { padding: 16px 12px 48px; }
    header.bar { flex-direction: column; align-items: flex-start; }
    header.bar .bar-right { text-align: left; width: 100%; }
}


/* ── 10. Login (pagina /login.php) ──────────────────────────────── */
/*
   Layout compact, centrat vertical. Fără header.bar (are doar titlul
   în interiorul card-ului). Stilurile specifice prefixate cu .login-
   pt a nu polua restul.
*/
body.login header.bar { display: none; }

.login-main {
    max-width: 380px;
    margin: 10vh auto 0;
    padding: 0 20px;
}
.login-main .card { padding: 28px 24px; }
.login-main h1 {
    font-size: 22px;
    margin: 0 0 4px;
    text-align: center;
}
.login-main .sub {
    color: var(--muted);
    font-size: 14px;
    text-align: center;
    margin-bottom: 20px;
}
.login-main label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin: 12px 0 6px;
}
.login-main input {
    width: 100%;
    font-size: 16px;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: white;
    font-family: inherit;
}
.login-main input:focus {
    outline: 2px solid var(--accent);
    outline-offset: -1px;
    border-color: var(--accent);
}
.login-main button {
    width: 100%;
    margin-top: 18px;
    font-size: 16px;
    font-weight: 600;
    padding: 12px 16px;
    min-height: 48px;
    border: 0;
    border-radius: 8px;
    background: var(--accent);
    color: white;
    cursor: pointer;
}
.login-main button:disabled { opacity: .5; cursor: not-allowed; }
.login-main .err {
    color: var(--err);
    font-size: 14px;
    margin-top: 12px;
    min-height: 18px;
    text-align: center;
    font-weight: 500;
}
.login-main .hint {
    color: var(--muted);
    font-size: 13px;
    text-align: center;
    margin-top: 14px;
}


/* ── 11. Scribe (pagina /scribe.php) ─────────────────────────────── */
/* Înregistrare audio, transcriere, editor bogat, listă sesiuni */

body.scribe-page main {
    max-width: min(80vw, 1800px);
    padding: 16px;
}

/* Visit context (selector de vizită + tip dictare) */
.visit-context-header {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}
.visit-context-header + .visit-context-header { margin-top: 8px; }
.visit-context-header .label {
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
}
.visit-context-header select {
    flex: 1;
    min-width: 280px;
    max-width: 600px;
    padding: 8px 10px;
    font-size: 14px;
}
#dictationTypeSelect { max-width: 360px; }
.visit-info { font-size: 12px; color: var(--muted); }
.visit-context-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--muted);
}
.visit-manage-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}
.visit-manage-link:hover { text-decoration: underline; }
#visitRefreshBtn { font-size: 14px; padding: 6px 10px; }

/* Recorder */
.timer {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 36px;
    font-weight: 600;
    color: var(--text);
    text-align: center;
    padding: 8px 0;
    font-variant-numeric: tabular-nums;
}
.timer.rec { color: var(--rec); }
.controls { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

#recBtn { background: var(--rec); }
#recBtn.recording { background: #555; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(214, 56, 56, 0.5); }
    50%      { box-shadow: 0 0 0 14px rgba(214, 56, 56, 0); }
}
#stopBtn { background: #2c3e50; }
#retypeBtn { background: var(--accent); }
#saveBtn  { background: var(--ok); }
#processBtn { background: #6f42c1; }
#exportTxtBtn {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
    min-width: 0;
    padding: 12px 18px;
}
#exportTxtBtn:hover { background: var(--accent); color: white; }
#exportTxtBtn:disabled { opacity: .45; }
audio { width: 100%; margin-top: 8px; }

/* Process (LLM) */
.process-toolbar {
    display: flex;
    gap: 8px;
    align-items: stretch;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.process-toolbar select {
    flex: 1;
    min-width: 200px;
    padding: 10px 12px;
}
.process-toolbar button { flex: 0 0 auto; min-width: 160px; }
.dual-pane { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
.pane { display: flex; flex-direction: column; min-width: 0; }
.pane label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}
.pane .label-meta {
    font-size: 12px;
    color: var(--muted);
    font-weight: 500;
    text-transform: none;
}
.pane textarea {
    width: 100%;
    min-height: 600px;
    font-size: 15px;
    line-height: 1.6;
    padding: 14px;
    background: #fafbfc;
}
.pane.clean textarea { background: #ffffff; }

/* Rich editor (contenteditable) */
.pane .rich-editor {
    width: 100%;
    min-height: 600px;
    font-size: 15px;
    line-height: 1.7;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #ffffff;
    overflow-y: auto;
    outline: none;
}
.pane .rich-editor:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(43, 108, 176, .12); }
.pane .rich-editor:empty::before {
    content: attr(data-placeholder);
    color: var(--muted);
    font-style: italic;
}
.pane .rich-editor h1, .pane .rich-editor h2, .pane .rich-editor h3 {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
    margin: 14px 0 8px;
    color: var(--text);
    line-height: 1.3;
}
.pane .rich-editor h3 { font-size: 17px; }
.pane .rich-editor p, .pane .rich-editor div { margin: 0 0 10px; }
.pane .rich-editor p:last-child, .pane .rich-editor div:last-child { margin-bottom: 0; }
.pane .rich-editor ul, .pane .rich-editor ol { margin: 0 0 10px; padding-left: 24px; }
.pane .rich-editor li { margin: 0 0 4px; }
.pane .rich-editor br { display: inline; }
.pane .rich-editor mark.anormal {
    background: #fff3a0;
    color: #5a4500;
    padding: 0 3px;
    border-radius: 3px;
    font-weight: 600;
    box-shadow: 0 0 0 1px #d4a82a;
}

/* Format toolbar (B I U H ⚠ Anormal) */
.format-toolbar {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 6px;
    padding: 5px 7px;
    background: #f4f6f8;
    border: 1px solid var(--border);
    border-radius: 8px;
}
.fmt-btn {
    font-size: 13px;
    font-weight: 700;
    padding: 4px 10px;
    min-height: 28px;
    min-width: 30px;
    background: white;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    line-height: 1.2;
}
.fmt-btn:hover { background: #eef1f4; border-color: var(--muted); }
.fmt-btn:disabled { opacity: .45; cursor: not-allowed; }
.fmt-btn.active { background: var(--accent); color: white; border-color: var(--accent); }
.fmt-anormal { background: #fff3a0; color: #5a4500; border-color: #d4a82a; }
.fmt-anormal:hover { background: #ffe880; }
.fmt-anormal.active { background: #5a4500; color: #fff3a0; border-color: #5a4500; }
.fmt-sep {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 3px;
}
.pane-actions {
    margin-top: 10px;
    display: flex;
    gap: 8px;
    align-items: center;
}
.pane-actions .grow { flex: 1; }

/* Tabel sesiuni anterioare */
.sessions-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.sessions-table th, .sessions-table td {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.sessions-table th {
    background: #fafbfc;
    color: var(--muted);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.sessions-table tr:last-child td { border-bottom: 0; }
.sessions-table td code { font-size: 12px; }
.sessions-table .col-name {
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sessions-table .col-name.no-name { color: var(--muted); font-style: italic; }
.sessions-table .col-actions { display: flex; gap: 6px; flex-wrap: nowrap; }

/* Modal generic (pt newVisitModal și orice alt modal)
   - display: none by default, .show îl face vizibil
   - align-items: flex-start (modale înalte pornesc de sus, nu centrate)
   - padding 32px 16px (aer în jur, nu lipit de margini viewport)
   - overflow: auto (scroll dacă modalul e mai înalt decât fereastra)
   - z-index 1000 (deasupra oricărui alt conținut, inclusiv header) */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 32px 16px;
    overflow: auto;
}
.modal-backdrop.show { display: flex; }
/* .modal-backdrop.hide rămâne util pt paginile care folosesc pattern-ul "hide by default"
   (patients.php, ai_config.php). .hide global (cu !important) deja face asta, dar
   păstrăm explicit și aici pt claritate. */
.modal-backdrop.hide { display: none; }
.modal-box {
    background: white;
    border-radius: 12px;
    padding: 24px;
    max-width: 540px;
    width: 90%;
    max-height: 90vh;
    overflow: auto;
}
.modal-box h2 { margin: 0 0 14px; font-size: 18px; }
.modal-form-row { margin-bottom: 12px; }
.modal-form-row label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
}
.modal-form-row select,
.modal-form-row input,
.modal-form-row textarea {
    width: 100%;
    padding: 8px;
    font-size: 14px;
}
.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

@media (max-width: 900px) {
    .dual-pane { grid-template-columns: 1fr; }
}


/* ── 12. Dictations (pagina /dictations.php) ─────────────────────── */
/* Listă de dicteuri salvate, cu filtrare pe tip și editare inline */

.dictation-row {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 10px;
    background: #fafbfc;
    transition: background .15s;
}
.dictation-row:hover { background: #f4f6f8; }
.dictation-row.editing { background: #fffbe6; border-color: var(--warn); }

.row-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}
.row-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    flex: 1;
    min-width: 200px;
}
.row-name code { font-size: 13px; color: var(--muted); font-weight: 400; margin-left: 6px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.badge-type {
    display: inline-block;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}
.badge-type[data-type="ultrasound_bulletin"] { background: #e7f5ff; color: #0a558c; }
.badge-type[data-type="clinical_note"]       { background: #f0f9f0; color: #1b5e20; }
.badge-type[data-type="general"]             { background: #f0f0f0; color: #555; }
.badge-type[data-type="unknown"]             { background: #fff8e1; color: #7a5900; }

.row-meta {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 8px;
}
.row-meta strong { color: var(--text); font-weight: 600; }

.row-preview {
    font-size: 14px;
    color: var(--text);
    line-height: 1.6;
    background: white;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 12px;
}
.row-preview p, .row-preview div { margin: 0 0 8px; }
.row-preview p:last-child, .row-preview div:last-child { margin-bottom: 0; }
.row-preview mark.anormal {
    background: #fff3a0;
    color: #5a4500;
    padding: 0 3px;
    border-radius: 3px;
    font-weight: 600;
}
.row-preview h1, .row-preview h2, .row-preview h3 {
    font-family: -apple-system, "Segoe UI", sans-serif;
    margin: 8px 0 4px;
    color: var(--text);
    line-height: 1.3;
}

/* Editor îmbogățit (dictations — variantă mai simplă) */
.rich-editor {
    min-height: 280px;
    line-height: 1.7;
    resize: vertical;
    background: white;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 14px;
    overflow: auto;
    outline: none;
}
.rich-editor:focus { border-color: var(--warn); }
.rich-editor p, .rich-editor div { margin: 0 0 10px; }
.rich-editor p:last-child, .rich-editor div:last-child { margin-bottom: 0; }
.rich-editor h1, .rich-editor h2, .rich-editor h3, .rich-editor h4 {
    font-family: -apple-system, "Segoe UI", sans-serif;
    margin: 14px 0 8px;
    color: var(--text);
    line-height: 1.3;
}
.rich-editor h3 { font-size: 16px; }
.rich-editor ul, .rich-editor ol { margin: 0 0 10px; padding-left: 24px; }
.rich-editor mark.anormal {
    background: #fff3a0;
    color: #5a4500;
    padding: 0 3px;
    border-radius: 3px;
    font-weight: 600;
}

.format-toolbar {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-wrap: wrap;
    margin: 4px 0 6px;
    padding: 4px 6px;
    background: #f4f6f8;
    border: 1px solid var(--border);
    border-radius: 6px;
}
.fmt-btn {
    font-size: 12px;
    font-weight: 700;
    padding: 3px 9px;
    min-height: 26px;
    min-width: 28px;
    background: white;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 5px;
    cursor: pointer;
    line-height: 1.2;
}
.fmt-btn:hover { background: #eef1f4; border-color: var(--muted); }
.fmt-anormal { background: #fff3a0; color: #5a4500; border-color: #d4a82a; }
.fmt-anormal:hover { background: #ffe880; }

/* Form (editare inline) */
.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 10px;
}
.form-grid label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.form-grid input[type="text"],
.form-grid select,
.form-grid textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: inherit;
    font-size: 14px;
    background: white;
    color: var(--text);
}

/* Butoane „secondary" (pt acțiuni mai puțin importante) */
.btn-outline {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
}
.btn-outline:hover { background: #eef1f4; color: var(--text); }

/* Variante de butoane (pt admin pages) */
.btn-primary  { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-success  { background: var(--ok); color: #fff; }
.btn-success:hover { background: #1a7a35; }
.btn-warning  { background: #d97706; color: #fff; }
.btn-warning:hover { background: #b45309; }
.btn-small {
    font-size: 12px;
    padding: 5px 10px;
    min-height: 28px;
    min-width: 0;
}
/* Anchor care arată ca buton (pt Export din dictations) */
a.btn-link {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

.empty {
    text-align: center;
    color: var(--muted);
    padding: 40px 20px;
}


/* ── 13. Patients + Visits (pagina /patients.php) ─────────────────── */
/* Tab-uri (Pacienți / Vizite), tabel, modal-uri cu form-grid, secțiuni */

.card-tab { /* un card din interiorul unui tab */ }
.btn-danger { background: var(--rec); }
.btn-danger:hover { background: #b02a2a; }

/* Form grid pt modal-uri (form-section separatoare + grid 2 coloane) */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 16px;
    margin-top: 12px;
}
.form-grid .full { grid-column: 1 / -1; }
.form-section {
    grid-column: 1 / -1;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    padding-bottom: 4px;
    margin-top: 8px;
}
.form-section:first-child { margin-top: 0; }
.form-grid label { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.form-grid input,
.form-grid select,
.form-grid textarea {
    width: 100%;
    padding: 8px 10px;
    font-size: 14px;
}
.req { color: var(--rec); }
.hint {
    color: var(--muted);
    font-size: 12px;
    font-weight: 400;
    text-transform: none;
    letter-spacing: normal;
    margin-left: 6px;
}

/* Modal generic (patients/visits) */
.modal {
    background: white;
    border-radius: 12px;
    padding: 24px;
    max-width: 720px;
    width: 90%;
    max-height: 90vh;
    overflow: auto;
    box-shadow: 0 12px 32px rgba(0, 0, 0, .25);
}
.modal h2 { margin: 0 0 4px; font-size: 18px; }
.modal-subtitle { font-size: 13px; color: var(--muted); margin-bottom: 14px; }

/* Rows în tabel (pt rânduri de pacient/vizită) */
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* ── Paginare (dictations.php, generic pt liste viitoare) ─────────── */
.pagination {
    display: flex;
    gap: 4px;
    justify-content: center;
    align-items: center;
    padding: 16px 12px;
    flex-wrap: wrap;
}
.pagination .page-btn {
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--border);
    background: white;
    color: var(--text);
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    line-height: 1;
    transition: background 0.1s, border-color 0.1s;
}
.pagination .page-btn:hover:not(:disabled):not(.active) {
    background: var(--bg);
    border-color: var(--accent);
    color: var(--accent);
}
.pagination .page-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    font-weight: 600;
    cursor: default;
}
.pagination .page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.pagination .page-ellipsis {
    color: var(--muted);
    padding: 0 6px;
    user-select: none;
}
.pagination .pagination-info {
    color: var(--muted);
    font-size: 13px;
    margin-left: 12px;
}

/* Link „Vezi toate" la sfârșit de card (scribe.php → dictations.php) */
.card-footer-link {
    text-align: center;
    padding: 12px;
    border-top: 1px solid var(--border);
    margin-top: 8px;
}
.card-footer-link a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
}
.card-footer-link a:hover {
    text-decoration: underline;
}


/* ── 14. Admin: Prompts + AI Config (admin/prompts.php, admin/ai_config.php) ── */
/* Tabele, formulare, rânduri inactive, istoric */

tr.inactive td { opacity: 0.55; }

input:disabled,
textarea:disabled,
select:disabled {
    background: #f4f6f8;
    color: var(--muted);
    cursor: not-allowed;
}

/* Butoane admin */
.btn-warn { background: var(--warn); }
.btn-warn:hover { background: #a06800; }

/* Detalii pt istoric (expand/collapse) */
details summary { cursor: pointer; color: var(--accent); }
details > div {
    background: #fafbfc;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 12px;
    margin-top: 6px;
    font-size: 13px;
    max-height: 220px;
    overflow: auto;
}
.history-item {
    padding: 6px 0;
    border-bottom: 1px dashed var(--border);
    font-size: 12px;
}
.history-item:last-child { border-bottom: 0; }
.history-type { font-weight: 600; }
.history-type.created     { color: var(--ok); }
.history-type.updated     { color: var(--accent); }
.history-type.deactivated { color: var(--rec); }
.history-body {
    white-space: pre-wrap;
    font-size: 11px;
    background: #fff;
    padding: 6px;
    border-radius: 4px;
    margin: 4px 0 0;
}

/* AI Config: API key cell (masked) */
.api-key {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    background: #eef1f4;
    padding: 1px 6px;
    border-radius: 3px;
    color: var(--muted);
}
.api-key-empty {
    color: var(--rec);
    font-weight: 600;
}

/* ── 15. Admin: AI Config (admin/ai_config.php) ─────────────────── */
/* Badge system (.badge-ok/warn/err/info/muted), category-header, check-row, key-row */

.badge {
    display: inline-block;
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 10px;
    font-weight: 600;
    margin-right: 4px;
    white-space: nowrap;
}
.badge-ok    { background: #e6f4ea; color: #1b5e20; }
.badge-warn  { background: #fff8e1; color: #7a5900; }
.badge-err   { background: #fdecea; color: var(--rec); }
.badge-info  { background: #e7f0fa; color: var(--accent); }
.badge-muted { background: #eef1f4; color: var(--muted); }

/* RBAC: badge-uri inline pt grupuri/locații (admin/users.php) */
.badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}
.badge-x, .badge-link {
    display: inline-block;
    margin-left: 4px;
    color: #c00;
    text-decoration: none;
    font-weight: 700;
    cursor: pointer;
}
.badge-x:hover { color: #f00; }
.badge-link { color: #888; }
.badge-link:hover { color: #1b5e20; }

.add-select {
    font-size: 11px;
    padding: 1px 4px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: #fff;
    cursor: pointer;
    min-width: 100px;
}

/* Switch (toggle on/off) */
.switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    cursor: pointer;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
    position: absolute;
    inset: 0;
    background: #ccc;
    border-radius: 20px;
    transition: 0.2s;
}
.switch span::before {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    left: 2px;
    top: 2px;
    background: #fff;
    border-radius: 50%;
    transition: 0.2s;
}
.switch input:checked + span { background: var(--accent, #2c7be5); }
.switch input:checked + span::before { transform: translateX(16px); }

.category-header td {
    background: #f4f6f8;
    color: var(--accent);
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 8px 12px;
}

.check-row { display: flex; gap: 18px; flex-wrap: wrap; }
.check-row label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
    font-size: 14px;
    margin-bottom: 0;
}

/* Key row (pt input API key + buton show/hide) */
.key-row { display: flex; gap: 8px; align-items: center; }
.key-row input {
    flex: 1;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 13px;
}
.key-status { font-size: 13px; margin-top: 4px; }

/* Modal AI Config (mai lat decât patient/visit modal) — proprietățile .modal-backdrop
   sunt deja definite mai sus (singure, la secțiunea 7.5). Aici rămâne doar
   stilizarea .modal-box (max-width 760px, lat față de .modal-box-ul default
   de 540px din scribe.php). */
.modal {
    background: var(--card);
    border-radius: 12px;
    border: 1px solid var(--border);
    width: 100%;
    max-width: 760px;
    padding: 22px 24px 24px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, .25);
}
.modal h2 { margin: 0 0 4px; font-size: 18px; }
.modal .modal-subtitle { font-size: 13px; color: var(--muted); margin-bottom: 16px; }
