/* ════════════════════════════════════════════════════════
   docs.danesklinika.lt — modernus dizaino sluoksnis
   ════════════════════════════════════════════════════════ */

:root {
    /* Brand */
    --brand:        #2557d6;
    --brand-600:    #1f49b8;
    --brand-700:    #1b3e9e;
    --brand-50:     #eef3fd;
    --brand-100:    #dde8fb;
    --accent:       #0ea5a3;

    /* Neutrals */
    --bg:           #eef1f6;
    --surface:      #ffffff;
    --surface-2:    #f8fafc;
    --text:         #0f172a;
    --text-soft:    #334155;
    --muted:        #64748b;
    --border:       #e6eaf1;
    --border-soft:  #eef1f6;

    /* Semantic */
    --green:    #0f9d58; --green-bg: #e7f6ee;
    --red:      #dc2626; --red-bg:   #fdecec;
    --amber:    #b45309; --amber-bg: #fef3e2;
    --blue:     #1d4ed8; --blue-bg:  #e8effc;

    /* Shape & depth */
    --r-sm: 8px; --r: 12px; --r-lg: 16px; --r-xl: 22px;
    --sh-sm: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.05);
    --sh:    0 4px 12px -2px rgba(15,23,42,.08), 0 2px 6px -2px rgba(15,23,42,.05);
    --sh-lg: 0 18px 40px -12px rgba(15,23,42,.20);
    --ring:  0 0 0 3px rgba(37,87,214,.22);

    --sidebar-w: 248px;
    --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-700); }
h1, h2, h3 { color: var(--text); line-height: 1.25; letter-spacing: -.01em; }
h1 { font-weight: 700; }
h2 { font-weight: 650; font-size: 1.15rem; }
.muted { color: var(--muted); }
.mt { margin-top: 1rem; } .mb { margin-bottom: 1rem; }
code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: .1em .4em; font-size: .85em; }

/* ════════ App shell (sidebar + main) ════════ */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: linear-gradient(180deg, #16233f 0%, #111b30 100%);
    color: #c7d2e4;
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
    z-index: 50;
}
.sidebar-head { padding: 1.25rem 1.1rem .75rem; }
.brand { display: flex; align-items: center; gap: .65rem; color: #fff; font-weight: 700; }
.brand:hover { color: #fff; }
.brand-mark {
    width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
    background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 100%);
    display: grid; place-items: center; font-size: .82rem; font-weight: 800; color: #fff;
    box-shadow: 0 4px 12px -2px rgba(37,87,214,.5);
}
.brand-name { font-size: .98rem; letter-spacing: -.01em; }

.sidebar-nav { padding: .5rem .7rem; display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-section { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: #6b7a96; padding: 1rem .6rem .35rem; font-weight: 600; }
.nav-item {
    display: flex; align-items: center; gap: .7rem;
    padding: .6rem .7rem; border-radius: 10px;
    color: #b9c5da; font-size: .9rem; font-weight: 500;
    transition: background .15s, color .15s;
}
.nav-item svg { width: 19px; height: 19px; flex-shrink: 0; opacity: .9; }
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: var(--brand); color: #fff; box-shadow: 0 4px 14px -4px rgba(37,87,214,.7); }
.nav-item.active svg { opacity: 1; }

.sidebar-foot { padding: .8rem .8rem 1rem; border-top: 1px solid rgba(255,255,255,.08); }
.user-chip { display: flex; align-items: center; gap: .6rem; margin-bottom: .6rem; }
.avatar {
    width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
    background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 100%);
    color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .78rem;
}
.user-chip .uinfo { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.user-chip .uname { color: #e8edf5; font-size: .82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .urole { color: #7e8db0; font-size: .72rem; }
.logout-btn {
    width: 100%; background: rgba(255,255,255,.06); color: #c7d2e4;
    border: 1px solid rgba(255,255,255,.09); border-radius: 9px; padding: .5rem;
    font-size: .82rem; font-weight: 600; cursor: pointer; font-family: inherit;
    display: flex; align-items: center; justify-content: center; gap: .4rem;
}
.logout-btn:hover { background: rgba(255,255,255,.12); color: #fff; }
.logout-btn svg { width: 17px; height: 17px; flex-shrink: 0; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* Topbar (viršus) */
.topbar {
    height: 60px; display: flex; align-items: center; gap: .75rem;
    padding: 0 1.5rem; background: rgba(255,255,255,.85);
    backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 30;
}
.topbar-title { font-weight: 650; font-size: 1rem; }
.menu-btn { display: none; background: none; border: none; cursor: pointer; padding: 6px; color: var(--text); border-radius: 8px; }
.menu-btn:hover { background: var(--surface-2); }
.menu-btn svg { width: 24px; height: 24px; }

/* Turinys */
.container { max-width: 1120px; width: 100%; margin: 0 auto; padding: 1.75rem 1.5rem 3rem; flex: 1; }
.footer { text-align: center; color: var(--muted); padding: 1.25rem; font-size: .8rem; }

/* Overlay (mobiliam meniu) */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 45; }

/* ════════ Kortelės ════════ */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r-lg); box-shadow: var(--sh-sm);
    padding: 1.4rem; margin-bottom: 1.25rem;
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1.4rem; }
.page-head h1 { margin: 0; font-size: 1.55rem; }

/* ════════ Mygtukai ════════ */
.btn {
    display: inline-flex; align-items: center; gap: .45rem; cursor: pointer;
    border: 1px solid var(--border); border-radius: 10px;
    padding: .6rem 1.05rem; font-size: .9rem; font-weight: 600; font-family: inherit;
    background: var(--surface); color: var(--text-soft); text-decoration: none; line-height: 1.2;
    transition: all .15s ease;
}
.btn:hover { background: var(--surface-2); color: var(--text); box-shadow: var(--sh-sm); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 6px 16px -6px rgba(37,87,214,.6); }
.btn-primary:hover { background: var(--brand-600); color: #fff; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { background: #0c8c8a; border-color: #0c8c8a; color: #fff; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.btn-sm { padding: .4rem .75rem; font-size: .82rem; border-radius: 8px; }
.btn-link { background: none; border: none; color: var(--brand); cursor: pointer; padding: 0; font-size: .9rem; font-family: inherit; }
.btn-link:hover { text-decoration: underline; }
.btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; }
.inline { display: inline; margin: 0; }

/* ════════ Formos ════════ */
form.stack label, .field { display: block; margin-bottom: 1.1rem; font-weight: 600; font-size: .85rem; color: var(--text-soft); }
input[type=text], input[type=email], input[type=number], input[type=date],
input[type=tel], input[type=password], input[type=file], select, textarea {
    width: 100%; min-height: 2.7rem; margin-top: .4rem; padding: .65rem .8rem; font-size: .95rem; font-weight: 400;
    border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text);
    font-family: inherit; transition: border-color .15s, box-shadow .15s;
}
/* iOS/mobilus: datos laukas renderinamas natyviai ir nukrenta žemiau kitų — normalizuojam */
input[type=date] { -webkit-appearance: none; appearance: none; }
input[type=date]::-webkit-date-and-time-value { text-align: left; margin: 0; }
input[type=date]::-webkit-calendar-picker-indicator { margin-left: auto; }
input::placeholder, textarea::placeholder { color: #9aa6b6; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
textarea { min-height: 96px; resize: vertical; }
/* Modernūs „checkbox" */
input[type=checkbox] {
    appearance: none; -webkit-appearance: none;
    width: 20px; height: 20px; min-width: 20px; margin: 0;
    border: 1.6px solid #cbd5e1; border-radius: 6px;
    background: var(--surface); cursor: pointer; position: relative;
    vertical-align: middle; flex-shrink: 0;
    transition: background .15s, border-color .15s, box-shadow .15s;
}
input[type=checkbox]:hover { border-color: var(--brand); }
input[type=checkbox]:checked { background: var(--brand); border-color: var(--brand); }
input[type=checkbox]:checked::after {
    content: ""; position: absolute; left: 6px; top: 2px;
    width: 5px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
input[type=checkbox]:focus-visible { outline: none; box-shadow: var(--ring); }

.help { display: block; font-weight: 400; font-size: .8rem; color: var(--muted); margin-top: .3rem; }
.err-msg { color: var(--red); font-size: .8rem; font-weight: 400; margin-top: .25rem; }
.required-star { color: var(--red); }
.code-input { letter-spacing: .55rem; text-align: center; font-size: 1.5rem; font-weight: 600; }
fieldset { border: 1px solid var(--border); border-radius: var(--r); padding: 1.1rem; margin: 0 0 1rem; }
legend { font-weight: 700; color: var(--brand); padding: 0 .4rem; }

/* ════════ Lentelės ════════ */
.table-wrap { overflow-x: auto; border-radius: var(--r); }
table.data { width: 100%; border-collapse: collapse; background: var(--surface); }
table.data th, table.data td { padding: .8rem .85rem; text-align: left; border-bottom: 1px solid var(--border-soft); font-size: .9rem; }
table.data th { background: var(--surface-2); color: var(--muted); font-weight: 600; white-space: nowrap; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; }
table.data tbody tr { transition: background .12s; }
table.data tbody tr:hover td { background: var(--brand-50); }
table.data tr:last-child td { border-bottom: none; }

/* ════════ Žymos / būsenos ════════ */
.badge { display: inline-flex; align-items: center; gap: .4rem; padding: .25rem .65rem; border-radius: 999px; font-size: .74rem; font-weight: 600; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge-gray  { background: #eef1f6; color: #5b6878; }
.badge-blue  { background: var(--blue-bg);  color: var(--blue); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-red   { background: var(--red-bg);   color: var(--red); }

/* ════════ Flash ════════ */
.flash { padding: .85rem 1.1rem; border-radius: var(--r); margin-bottom: 1.1rem; font-size: .9rem; font-weight: 500; display: flex; gap: .5rem; border: 1px solid transparent; }
.flash-success { background: var(--green-bg); color: #0c6b3f; border-color: #bce7cf; }
.flash-error   { background: var(--red-bg);   color: #a51f1f; border-color: #f5cccc; }
.flash-info    { background: var(--blue-bg);  color: #1a44b8; border-color: #cbdcfa; }

/* ════════ Auth / Public ════════ */
.auth-body, .public-body { background:
    radial-gradient(1200px 600px at 100% -10%, #dbe6fb 0%, transparent 55%),
    radial-gradient(900px 500px at -10% 110%, #d7f1f0 0%, transparent 50%), var(--bg);
    min-height: 100vh; }
.auth-body { display: flex; align-items: center; justify-content: center; padding: 1.25rem; }
.auth-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r-xl); box-shadow: var(--sh-lg);
    padding: 2.4rem 2.2rem; width: 100%; max-width: 410px;
}
.auth-logo { display: flex; align-items: center; justify-content: center; gap: .6rem; font-size: 1.15rem; font-weight: 700; margin: 0 0 1.6rem; color: var(--text); }
.auth-logo::before { content: "DK"; width: 38px; height: 38px; border-radius: 11px; background: linear-gradient(135deg, var(--brand), var(--accent)); color: #fff; display: grid; place-items: center; font-size: .8rem; font-weight: 800; }
.auth-card h2 { margin-top: 0; }

.public-head { background: linear-gradient(135deg, #16233f, #1b3e9e); color: #fff; padding: 1.1rem 1.25rem; }
.public-head .brand { justify-content: flex-start; }
.public-head .brand::before { content: "DK"; width: 32px; height: 32px; border-radius: 9px; background: rgba(255,255,255,.16); display: grid; place-items: center; font-size: .72rem; font-weight: 800; }
.container-narrow { max-width: 660px; }
.container-wide { max-width: 1000px; }

/* Darbuotojo formos tinklelis (desktop — po du laukus į eilutę) */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem 1.6rem; }
.form-grid .fg-cell { min-width: 0; }
.form-grid .fg-cell .field { margin: 0; }
.form-grid .fg-full { grid-column: 1 / -1; }
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } }

/* ════════ Linijinės (inline) ikonos ════════ */
.ico { width: 1em; height: 1em; flex-shrink: 0; vertical-align: -.15em; }
.btn .ico { margin-right: .4em; }

/* ════════ Specifiniai komponentai ════════ */
.doc-list { list-style: none; padding: 0; margin: .5rem 0 0; }
.doc-list li { padding: .55rem .75rem; color: var(--text-soft); font-size: .9rem; background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: 9px; margin-bottom: .4rem; display: flex; align-items: center; gap: .55rem; }
.doc-list li::before { content: ""; flex-shrink: 0; width: 16px; height: 16px;
    background: no-repeat center/contain url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%2364748b" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z"/><path d="M14 3v5h5"/><path d="M9 13h6M9 17h6"/></svg>'); }

.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { padding: .8rem .9rem; border: 1px solid var(--border); border-radius: var(--r); margin-bottom: .55rem; display: flex; align-items: flex-start; gap: .7rem; transition: border-color .15s, background .15s; }
.checklist li:hover { border-color: var(--brand); background: var(--brand-50); }
.checklist input { margin: .1rem 0 0; }
.check-inline { display: inline-flex; align-items: center; gap: .55rem; font-weight: 500; color: var(--text-soft); cursor: pointer; margin: .2rem 0 1rem; }

/* Dublikato darbuotojo pranešimas */
.dup-box { margin-top: .75rem; background: var(--blue-bg); border: 1px solid #cbdcfa; border-radius: var(--r); padding: .9rem 1rem; }
.dup-title { margin: 0 0 .2rem; font-weight: 700; color: #1a44b8; font-size: .95rem; }
.dup-desc { margin: 0 0 .6rem; color: #44515f; font-size: .85rem; }
.dup-list { display: flex; flex-direction: column; gap: .15rem; }
.dup-item { display: flex; align-items: center; gap: .6rem; padding: .5rem .6rem; background: #fff; border: 1px solid var(--border); border-radius: 9px; cursor: pointer; font-size: .9rem; font-weight: 500; }
.dup-item:hover { border-color: var(--brand); }
.dup-item input { margin: 0; }

.steps { display: flex; gap: .5rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.step { flex: 1; min-width: 120px; padding: .55rem .8rem; border-radius: 10px; background: var(--surface-2); color: var(--muted); font-size: .82rem; font-weight: 600; text-align: center; border: 1px solid var(--border); }
.step.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.step.done { background: var(--green-bg); color: var(--green); border-color: #bce7cf; }

.kv { width: 100%; border-collapse: collapse; }
.kv td { padding: .55rem .2rem; border-bottom: 1px solid var(--border-soft); font-size: .9rem; vertical-align: top; }
.kv tr:last-child td { border-bottom: none; }
.kv td.k { width: 42%; color: var(--muted); font-weight: 500; }
.sensitive { color: var(--amber); font-weight: 600; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1.1rem; }
.stat { position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 1.3rem 1.4rem; box-shadow: var(--sh-sm); }
.stat::after { content: ""; position: absolute; right: -20px; top: -20px; width: 90px; height: 90px; border-radius: 50%; background: var(--brand-50); }
.stat .num { font-size: 2.1rem; font-weight: 800; color: var(--brand); letter-spacing: -.02em; position: relative; }
.stat .lbl { color: var(--muted); font-size: .82rem; font-weight: 500; position: relative; }

.success-box { text-align: center; padding: 2.5rem 1.25rem; }
.success-box .success-ico { display: inline-flex; margin-bottom: .4rem; color: #16a34a; }
.success-box .success-ico .ico { width: 64px; height: 64px; }
.actions { display: flex; gap: .65rem; flex-wrap: wrap; margin-top: 1.1rem; }

/* ════════ Autocomplete (darbuotojų paieška) ════════ */
.ac-wrap { position: relative; }
.ac-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 40;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
    box-shadow: var(--sh); max-height: 320px; overflow-y: auto; display: none; }
.ac-list.open { display: block; }
.ac-item { padding: .6rem .8rem; cursor: pointer; border-bottom: 1px solid var(--border-soft); font-size: .92rem; }
.ac-item:last-child { border-bottom: none; }
.ac-item:hover, .ac-item.active { background: var(--brand-50); }
.ac-item .ac-sub { color: var(--muted); font-size: .82rem; }
.ac-add { color: var(--brand); font-weight: 600; }
.ac-empty { padding: .6rem .8rem; color: var(--muted); font-size: .88rem; }
.emp-badge { display: inline-flex; align-items: center; gap: .6rem; background: var(--brand-50);
    border: 1px solid var(--brand-100); border-radius: 999px; padding: .4rem .9rem; font-weight: 600; color: var(--brand-700); }

/* ════════ Jungiklis (switch) ════════ */
.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; cursor: pointer; background: var(--border); border-radius: 999px; transition: background .15s; }
.switch .slider::before { content: ""; position: absolute; height: 16px; width: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + .slider { background: var(--brand); }
.switch input:checked + .slider::before { transform: translateX(16px); }

/* ════════ „Loading" perdanga (pateikiant duomenis) ════════ */
.loading-overlay { display: none; position: fixed; inset: 0; z-index: 60;
    background: rgba(15, 23, 42, .55); align-items: center; justify-content: center; }
.loading-overlay.open { display: flex; }
.loading-box { background: #fff; border-radius: 14px; padding: 1.8rem 2.2rem; text-align: center;
    box-shadow: var(--sh); max-width: 340px; }
.loading-box p { margin: 0; }
.loading-box .help { margin-top: .4rem; }
.spinner { width: 44px; height: 44px; margin: 0 auto 1rem; border-radius: 50%;
    border: 4px solid var(--border); border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ════════ Modalas (patvirtinimas) ════════ */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(15,23,42,.55);
    display: none; align-items: center; justify-content: center; z-index: 100; padding: 1rem;
    backdrop-filter: blur(2px);
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--sh-lg);
    width: 100%; max-width: 460px; padding: 1.6rem; animation: modalIn .15s ease;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-title { margin: 0 0 .6rem; font-size: 1.15rem; }
.modal-body { color: var(--text-soft); font-size: .92rem; max-height: 56vh; overflow: auto; }
.modal-body .review { list-style: none; margin: 0; padding: 0; }
.modal-body .review li { padding: .4rem 0; border-bottom: 1px solid var(--border-soft); display: flex; gap: .6rem; }
.modal-body .review li:last-child { border-bottom: none; }
.modal-body .review .rk { color: var(--muted); min-width: 42%; }
.modal-actions { display: flex; gap: .6rem; justify-content: flex-end; margin-top: 1.4rem; }

/* ════════ Tinkleliai ════════ */
@media (min-width: 700px) { .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; } }

/* ════════ Responsyvumas ════════ */
@media (max-width: 880px) {
    .sidebar {
        position: fixed; left: 0; top: 0; height: 100vh;
        transform: translateX(-100%); transition: transform .25s ease;
        box-shadow: var(--sh-lg);
    }
    .app-shell.nav-open .sidebar { transform: translateX(0); }
    .app-shell.nav-open .sidebar-overlay { display: block; }
    .menu-btn { display: inline-flex; }
    .container { padding: 1.25rem 1.1rem 2.5rem; }
    .page-head { flex-direction: column; align-items: stretch; }
    .page-head .btn { width: 100%; justify-content: center; }
}
