/* ============================================================
   Clinica — Panou programări. CSS propriu, fără framework.
   Font: system stack. Accent albastru, roșu doar urgență/ștergere.
   ============================================================ */

:root {
    --bg:        #f4f6f8;
    --card:      #ffffff;
    --ink:       #1a2230;
    --ink-soft:  #5b6472;
    --line:      #e3e8ee;
    --accent:    #1e4fd8;
    --accent-dk: #1840b0;
    --danger:    #d93025;
    --danger-dk: #b3271d;
    --urgent-bg: #fdecea;
    --urgent-bd: #f3b4ae;
    --warn:      #a15c00;
    --ok:        #147d3c;
    --radius:    12px;
    --shadow:    0 1px 3px rgba(16, 24, 40, .06), 0 6px 18px rgba(16, 24, 40, .05);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    max-width: 100%;
    overflow-x: hidden;          /* niciodată scroll orizontal pe mobil */
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
        Arial, "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Butoanele și inputurile respiră corect pe touch */
button, a, input { -webkit-tap-highlight-color: rgba(30, 79, 216, .15); }

/* ---------- Butoane ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .35em;
    font: inherit;
    font-weight: 600;
    line-height: 1;
    padding: .6rem .9rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    color: var(--ink);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background .12s, border-color .12s, transform .04s;
}
.btn:hover      { background: #f6f8fb; }
.btn:active     { transform: translateY(1px); }
.btn:disabled   { opacity: .5; cursor: not-allowed; }
.btn-sm         { padding: .5rem .7rem; font-size: .875rem; }
.btn-block      { width: 100%; padding: .8rem; font-size: 1rem; }

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.btn-primary:hover { background: var(--accent-dk); border-color: var(--accent-dk); }

.btn-danger {
    background: #fff;
    border-color: var(--danger);
    color: var(--danger);
}
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-call {
    background: #eaf0ff;
    border-color: #c9d7ff;
    color: var(--accent-dk);
}
.btn-call:hover { background: #dbe6ff; }

.btn-ghost { background: #fff; color: var(--ink-soft); }
.btn-ghost:hover { background: #f2f4f7; color: var(--ink); }

/* ---------- Topbar ---------- */
.topbar {
    background: #fff;
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar-inner {
    max-width: 1080px;
    margin: 0 auto;
    padding: .8rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
}
.topbar-inner .btn { flex: 0 0 auto; }
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.05rem; min-width: 0; }
.brand-dot {
    flex: 0 0 auto;
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 4px rgba(30, 79, 216, .12);
}
.brand-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;         /* nume lung de clinică nu împinge headerul */
}

/* ---------- Layout ---------- */
.container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 1.5rem 1.25rem 2rem;
}

/* ---------- Tabs ---------- */
.tabs {
    display: flex;
    gap: .5rem;
    margin-bottom: 1rem;
}
.tab {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .65rem 1rem;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 600;
    color: var(--ink-soft);
    background: #fff;
    border: 1px solid var(--line);
}
.tab:hover { color: var(--ink); }
.tab.is-active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.5rem;
    padding: 0 .4rem;
    border-radius: 999px;
    font-size: .8rem;
    font-weight: 700;
    background: rgba(0, 0, 0, .06);
    color: inherit;
}
.tab.is-active .tab-count { background: rgba(255, 255, 255, .25); }

/* ---------- Panel / tabel ---------- */
.panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.grid {
    width: 100%;
    border-collapse: collapse;
}
.grid thead th {
    text-align: left;
    font-size: .78rem;
    letter-spacing: .03em;
    text-transform: uppercase;
    color: var(--ink-soft);
    padding: .85rem 1rem;
    border-bottom: 1px solid var(--line);
    background: #fafbfc;
}
.grid tbody td {
    padding: .9rem 1rem;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
    overflow-wrap: anywhere;     /* nume/telefon lung se rup, nu depășesc */
}
.grid tbody tr:last-child td { border-bottom: 0; }
.grid tbody tr:hover { background: #fafbfd; }

.cell-name { font-weight: 600; }
.col-actions { text-align: right; }

.row-urgent { background: var(--urgent-bg); }
.row-urgent:hover { background: #fbe1de; }
.row-urgent td { box-shadow: inset 3px 0 0 var(--danger); }

.actions {
    display: flex;
    gap: .4rem;
    justify-content: flex-end;
    flex-wrap: wrap;
}

/* ---------- Badge / flags ---------- */
.badge {
    display: inline-block;
    padding: .25rem .55rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .04em;
}
.badge-urgent {
    background: var(--danger);
    color: #fff;
}
.flag-warn {
    display: inline-block;
    margin-top: .2rem;
    font-size: .75rem;
    font-weight: 600;
    color: var(--warn);
}

/* ---------- Empty state ---------- */
.empty { padding: 3.5rem 1.5rem; text-align: center; }
.empty-title { font-size: 1.15rem; font-weight: 700; margin: 0 0 .3rem; }
.empty-sub { color: var(--ink-soft); margin: 0; }

/* ---------- Pager ---------- */
.pager {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    justify-content: center;
    padding: 1rem;
    border-top: 1px solid var(--line);
    background: #fafbfc;
}
.pg {
    min-width: 2.25rem;
    text-align: center;
    padding: .5rem .7rem;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    text-decoration: none;
    font-weight: 600;
    font-size: .9rem;
}
.pg:hover { background: #f2f4f7; }
.pg.is-current { background: var(--accent); border-color: var(--accent); color: #fff; }
.pg.is-disabled { opacity: .45; pointer-events: none; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(16, 24, 40, .45); }
.modal-card {
    position: relative;
    width: min(560px, 100%);
    max-height: 90vh;
    overflow: auto;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(16, 24, 40, .25);
    padding: 1.5rem;
}
.modal-x {
    position: absolute;
    top: .6rem; right: .6rem;
    width: 2rem; height: 2rem;
    border: 0; border-radius: 8px;
    background: transparent;
    font-size: 1.5rem; line-height: 1;
    color: var(--ink-soft);
    cursor: pointer;
}
.modal-x:hover { background: #f2f4f7; color: var(--ink); }
.modal-title { margin: 0 0 1rem; font-size: 1.2rem; }

.detail { margin: 0; }
.detail div {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: .5rem;
    padding: .6rem 0;
    border-bottom: 1px solid var(--line);
}
.detail div:last-child { border-bottom: 0; }
.detail dt { color: var(--ink-soft); font-weight: 600; font-size: .9rem; margin: 0; }
.detail dd { margin: 0; word-break: break-word; }
.detail .d-urgent { color: var(--danger); font-weight: 700; }

/* ---------- Toast ---------- */
.toast {
    position: fixed;
    left: 50%;
    bottom: 1.5rem;
    transform: translateX(-50%) translateY(1rem);
    background: var(--ink);
    color: #fff;
    padding: .75rem 1.15rem;
    border-radius: 10px;
    font-weight: 600;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
    opacity: 0;
    transition: opacity .2s, transform .2s;
    z-index: 60;
    max-width: 90vw;
    text-align: center;
}
.toast[hidden] { display: none; }
.toast.is-show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.is-error { background: var(--danger); }

/* ---------- Login ---------- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1.25rem; }
.login-wrap { width: 100%; max-width: 400px; }
.login-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem 1.75rem;
}
.login-title { margin: 0 0 .25rem; font-size: 1.4rem; text-align: center; }
.login-sub { margin: 0 0 1.5rem; text-align: center; color: var(--ink-soft); }
.field { display: block; margin-bottom: 1rem; }
.field span { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .35rem; }
.field input {
    width: 100%;
    padding: .7rem .8rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    font: inherit;
    background: #fbfcfd;
}
.field input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(30, 79, 216, .15);
    background: #fff;
}
.alert {
    background: var(--urgent-bg);
    border: 1px solid var(--urgent-bd);
    color: var(--danger-dk);
    padding: .7rem .85rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    font-size: .9rem;
}

/* ---------- Footer ---------- */
.site-footer {
    text-align: center;
    color: var(--ink-soft);
    font-size: .85rem;
    padding: 1.5rem 1rem 0;
}
.site-footer a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}
.site-footer a:hover { text-decoration: underline; }

/* ============================================================
   Responsive
   ============================================================ */

/* --- Tabletă (portret) și mai mic: tabelul devine carduri --- */
@media (max-width: 820px) {
    .container { padding: 1rem .85rem 2rem; }

    /* Tab-urile ocupă lățimea egală, ușor de atins cu degetul */
    .tabs { gap: .4rem; }
    .tab {
        flex: 1 1 0;
        justify-content: center;
        padding: .8rem .5rem;
        min-height: 48px;
        text-align: center;
    }

    .grid thead { display: none; }
    .grid, .grid tbody, .grid tr, .grid td { display: block; width: 100%; }

    .grid tbody tr {
        border: 1px solid var(--line);
        border-radius: var(--radius);
        margin: .85rem;
        padding: .35rem .25rem;
        box-shadow: var(--shadow);
    }
    .grid tbody tr:hover { background: #fff; }

    .grid tbody td {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        gap: 1rem;
        padding: .65rem .9rem;
        border-bottom: 1px solid var(--line);
        text-align: right;
        min-width: 0;
    }
    .grid tbody td::before {
        content: attr(data-label);
        flex: 0 0 auto;
        font-size: .78rem;
        font-weight: 700;
        color: var(--ink-soft);
        text-transform: uppercase;
        letter-spacing: .02em;
        text-align: left;
    }

    .row-urgent td { box-shadow: none; }
    .row-urgent { border-color: var(--urgent-bd) !important; background: var(--urgent-bg); }

    /* Acțiunile: sub restul câmpurilor, butoane mari touch-friendly */
    .col-actions { border-bottom: 0 !important; padding-top: .8rem !important; }
    .col-actions::before { display: none; }
    .actions {
        width: 100%;
        gap: .5rem;
        justify-content: stretch;
    }
    .actions .btn {
        flex: 1 1 calc(50% - .25rem);
        min-height: 46px;
        padding: .75rem;
        font-size: .95rem;
    }
    /* „Sună" = acțiunea principală pe telefon → pe toată lățimea, sus */
    .actions .btn-call { flex: 1 1 100%; order: -1; }

    .detail div { grid-template-columns: 1fr; gap: .15rem; }
    .detail dt { font-size: .8rem; }
}

/* --- Telefon mic: și mai compact, butoane pe rânduri clare --- */
@media (max-width: 420px) {
    .topbar-inner { padding: .7rem .9rem; }
    .brand { font-size: .98rem; }
    .container { padding: .75rem .6rem 2rem; }

    .grid tbody tr { margin: .7rem .15rem; }
    .grid tbody td { padding: .6rem .75rem; font-size: .97rem; }

    .tab { font-size: .92rem; padding: .75rem .35rem; }
    .tab-count { min-width: 1.35rem; height: 1.35rem; }

    /* butoanele de acțiune pe toată lățimea = imposibil de ratat */
    .actions .btn { flex: 1 1 100%; }

    .modal { padding: 0; align-items: flex-end; }
    .modal-card {
        width: 100%;
        max-height: 92vh;
        border-radius: var(--radius) var(--radius) 0 0;
        padding: 1.25rem 1.1rem 1.5rem;
    }
    .pager { gap: .3rem; }
    .pg { min-width: 2.4rem; padding: .6rem .6rem; }   /* țintă touch mai mare */
}

/* Pe ecrane care nu au hover (touch), elimină efectele de hover „lipite" */
@media (hover: none) {
    .grid tbody tr:hover { background: #fff; }
    .btn:hover { background: #fff; }
    .btn-primary:hover { background: var(--accent); border-color: var(--accent); }
    .btn-danger:hover { background: #fff; color: var(--danger); }
    .btn-call:hover { background: #eaf0ff; }
}
