﻿/* ==========================================================================
   ABIPal ServiceAuto — tema „Atelier v2”
   Sursa: ServiceAuto-tema.html (ghid temă). Încărcat ULTIMUL în <head> de Site.Master
   (și de paginile fără master), după polaris-theme.css și app-responsive.css.

   1. Tokeni (luminos / întunecat)          4. Componente comune (plate, pill, kpi…)
   2. Maparea variabilelor vechi             5. Plasă de siguranță pentru tema întunecată
   3. Elemente de bază (text, câmpuri)
   ========================================================================== */

/* ---------- 1. Tokeni ---------- */
html,
html[data-theme="light"] {
    --bg: #F2F3EF;
    --surface: #FFFFFF;
    --surface2: #F6F7F3;
    --line: #E1E4DD;
    --line-strong: #CBD0C7;
    --ink: #111513;
    --ink2: #47504B;
    --ink3: #5F6963;
    --acc: #0B7A55;
    --acc-strong: #086445;
    --acc-soft: #E2F1E9;
    --acc-ink: #FFFFFF;
    --warn: #9A5205;
    --warn-soft: #FCEFD9;
    --info: #1E4FD0;
    --info-soft: #E5ECFC;
    --bad: #B42318;
    --bad-soft: #FCE6E3;
    --r-sm: 12px;
    --r-md: 14px;
    --r-lg: 20px;
    --r-sheet: 28px;
    --font: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
    --focus: 0 0 0 3px rgba(11, 122, 85, .28);
    --elev-1: 0 1px 2px rgba(17, 21, 19, .05);
    --elev-2: 0 8px 24px rgba(17, 21, 19, .08);
    --elev-3: 0 24px 60px rgba(17, 21, 19, .16);
    --overlay: rgba(17, 21, 19, .42);
    --touch: 44px;
    color-scheme: light;
}

html[data-theme="dark"] {
    --bg: #0A0D0C;
    --surface: #121715;
    --surface2: #181E1B;
    --line: #252E2A;
    --line-strong: #34403A;
    --ink: #ECF1EE;
    --ink2: #B6C0BA;
    --ink3: #8E9993;
    --acc: #3CCB94;
    --acc-strong: #62D9AA;
    --acc-soft: #112C21;
    --acc-ink: #04140D;
    --warn: #F0A847;
    --warn-soft: #2E210E;
    --info: #8EAEFF;
    --info-soft: #16213B;
    --bad: #F27A6E;
    --bad-soft: #38181A;
    --focus: 0 0 0 3px rgba(60, 203, 148, .35);
    --elev-1: 0 1px 2px rgba(0, 0, 0, .4);
    --elev-2: 0 8px 24px rgba(0, 0, 0, .45);
    --elev-3: 0 24px 60px rgba(0, 0, 0, .6);
    --overlay: rgba(0, 0, 0, .66);
    color-scheme: dark;
}

/* ---------- 2. Variabile vechi → tokeni noi (paginile existente preiau tema) ---------- */
html,
html[data-theme="light"],
html[data-theme="dark"] {
    --c1: var(--acc);
    --c2: var(--acc-strong);
    --c3: var(--acc-soft);
    --brand: var(--acc);
    --brand-2: var(--acc-strong);
    --brand-dark: var(--acc-strong);
    --brand-soft: var(--acc-soft);
    --primary: var(--acc);
    --accent: var(--acc);
    --accent-2: var(--acc-strong);
    --accent-soft: var(--acc-soft);
    --accent-g: var(--acc);
    --accent-b: var(--info);
    --accent-r: var(--bad);
    --leaf: var(--acc);
    --leaf-soft: var(--acc-soft);
    --gold: var(--warn);
    --sky: var(--info-soft);
    --pine: var(--acc-strong);
    --pine-800: var(--acc-strong);

    --text: var(--ink);
    --text-1: var(--ink);
    --text-main: var(--ink);
    --text-soft: var(--ink2);
    --text-secondary: var(--ink3);
    --muted: var(--ink3);

    --surface-solid: var(--surface);
    --surface-2: var(--surface2);
    --surface-3: var(--bg);
    --bg-soft: var(--surface2);
    --bg-900: var(--bg);
    --bg-card: var(--surface);
    --card-bg: var(--surface);
    --panel-verse: var(--surface);
    --glass-bg: var(--surface);
    --glass-light: var(--surface);
    --glass-medium: var(--surface);
    --glass-strong: var(--surface);
    --glass-border: var(--line);
    --panel-border: var(--line);

    --border: var(--line);
    --border-strong: var(--line-strong);

    --shadow-soft: var(--elev-1);
    --shadow: var(--elev-2);
    --shadow-lg: var(--elev-3);
    --soft-shadow: var(--elev-1);

    --radius: var(--r-md);
    --radius-lg: var(--r-lg);

    --ui-ok: var(--acc);
    --ui-ok-soft: var(--acc-soft);
    --ui-warn: var(--warn);
    --ui-warn-soft: var(--warn-soft);
    --ui-danger: var(--bad);
    --ui-danger-soft: var(--bad-soft);
    --ui-info: var(--info);
    --ui-info-soft: var(--info-soft);
    --ui-neutral-soft: var(--surface2);

    --scroll-thumb: var(--line-strong);
    --scroll-thumb-accent: var(--ink3);
    --scroll-track: transparent;

    --topbar-bg: var(--bg);
    --sidebar-bg: var(--surface);
}

/* ---------- 3. Elemente de bază ---------- */
/* Fundal plin, fără gradient: tema veche punea un gradient pe body (mai specific), care se termina
   la jumătatea paginilor lungi și schimba nuanța. */
html, body,
html[data-theme] body,
html[data-theme] body > form {
    background: var(--bg);
}

body {
    font-family: var(--font);
    color: var(--ink);
    letter-spacing: 0;
}

body, a, button, input, select, textarea {
    color-scheme: inherit; /* anulează „only light” din tema veche: controalele native urmează tema */
}

a { color: var(--acc); }
a:hover { color: var(--acc-strong); }

::selection { background: var(--acc-soft); color: var(--ink); }

input, select, textarea, button { font-family: inherit; }

/* Câmpuri: lizibile în ambele teme, 44 px (ținte pentru mănuși). Specificitate mică (:where) ca paginile să poată ajusta. */
:where(input[type="text"], input[type="search"], input[type="email"], input[type="tel"], input[type="password"],
       input[type="number"], input[type="date"], input[type="datetime-local"], input[type="time"], input[type="month"],
       input[type="url"], input:not([type]), select, textarea) {
    background-color: var(--surface);
    color: var(--ink);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
}

:where(input, select):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="color"]):not([type="hidden"]) {
    min-height: 40px;
}

:where(input, select, textarea):focus {
    outline: none;
    border-color: var(--acc);
    box-shadow: var(--focus);
}

::placeholder { color: var(--ink3); opacity: 1; }

select option, select optgroup {
    background-color: var(--surface);
    color: var(--ink);
}

:where(input, select, textarea)[disabled], :where(input, textarea)[readonly] {
    background-color: var(--surface2);
    color: var(--ink2);
    -webkit-text-fill-color: var(--ink2);
    opacity: 1;
}

input[type="checkbox"], input[type="radio"], input[type="range"], progress { accent-color: var(--acc); }

:where(table) { color: var(--ink); }
:where(th) { color: var(--ink2); }
:where(hr) { border-color: var(--line); }

/* Numere aliniate în tabele și KPI */
.num, .tabular, .ui-kpi-value { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); }

/* ---------- 4. Componente comune ---------- */

/* Plăcuța de înmatriculare (identică în ambele teme, ca una reală) */
.plate {
    display: inline-flex; align-items: stretch; height: 28px;
    border: 1.5px solid #111; border-radius: 7px; overflow: hidden;
    background: #fff; color: #111;
    font-family: var(--mono); font-weight: 700; font-size: 13.5px; letter-spacing: .05em;
    white-space: nowrap; vertical-align: middle;
}
.plate .eu {
    background: #1F3FA8; color: #fff; font-family: var(--font); font-size: 8px; font-weight: 800;
    width: 13px; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 3px;
}
.plate .t { padding: 0 8px; display: flex; align-items: center; }
html[data-theme="dark"] .plate { border-color: #fff; }

/* Etichete de status: culoarea = starea */
.pill {
    display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px;
    border-radius: 999px; font-size: 12px; font-weight: 800; white-space: nowrap;
    background: var(--surface2); color: var(--ink2);
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }
.pill.new, .pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.accepted, .pill.info { background: var(--info-soft); color: var(--info); }
.pill.scheduled, .pill.ok, .pill.done { background: var(--acc-soft); color: var(--acc); }
.pill.urgent, .pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.muted { background: var(--surface2); color: var(--ink3); }

/* Etichetă mică de secțiune */
.lbl, .ui-kicker {
    font-size: 11px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: var(--ink3);
}

/* Componentele ui-* din app-responsive.css aliniate la temă */
.ui-hero, .ui-card, .ui-kpi {
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--elev-1);
}
.ui-card, .ui-hero { border-radius: var(--r-lg); }
.ui-kpi { border-radius: var(--r-lg); }
.ui-kpi::before { display: none; }
.ui-kpi-label { text-transform: none; letter-spacing: 0; font-size: 13px; font-weight: 600; color: var(--ink2); }
.ui-kpi-value { font-size: 32px; font-weight: 800; color: var(--ink); letter-spacing: -0.01em; }
.ui-kpi-foot { color: var(--ink3); font-size: 12px; }
.ui-kpi .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--acc); margin-right: 6px; vertical-align: middle; }
.ui-hero h1, .ui-hero h2, .ui-card-head h3 { color: var(--ink); }
.ui-hero p, .ui-muted, .ui-card-head .ui-sub { color: var(--ink3); }
.ui-kicker { color: var(--acc); }

.ui-btn {
    min-height: var(--touch); border-radius: var(--r-sm);
    background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong);
    font-weight: 800;
}
.ui-btn:hover { background: var(--surface2); box-shadow: none; }
.ui-btn.primary { background: var(--acc); color: var(--acc-ink); border-color: var(--acc); }
.ui-btn.primary:hover { background: var(--acc-strong); border-color: var(--acc-strong); }
.ui-btn.danger { background: var(--bad); color: #fff; border-color: var(--bad); }
html[data-theme="dark"] .ui-btn.danger { color: #1a0605; }

.ui-chip { background: var(--surface2); color: var(--ink2); }
.ui-chip.ok { background: var(--acc-soft); color: var(--acc); }
.ui-chip.warn { background: var(--warn-soft); color: var(--warn); }
.ui-chip.danger { background: var(--bad-soft); color: var(--bad); }
.ui-chip.info { background: var(--info-soft); color: var(--info); }

.ui-table th { color: var(--ink3); border-bottom-color: var(--line); }
.ui-table td { color: var(--ink); border-bottom-color: var(--line); }
.ui-table tbody tr:hover td { background: var(--surface2); }
.ui-list li { background: var(--surface2); border-color: var(--line); }
.ui-list a { color: var(--ink); }
.ui-error { background: var(--bad-soft); color: var(--bad); }
.ui-skeleton { background: linear-gradient(90deg, var(--surface2), var(--line), var(--surface2)); background-size: 200% 100%; }

/* Bootstrap (folosit pe câteva pagini) aliniat la temă */
.btn-primary, .btn-success { background-color: var(--acc); border-color: var(--acc); color: var(--acc-ink); }
.btn-primary:hover, .btn-success:hover { background-color: var(--acc-strong); border-color: var(--acc-strong); color: var(--acc-ink); }
.btn-outline-primary { color: var(--acc); border-color: var(--acc); }
.btn-danger { background-color: var(--bad); border-color: var(--bad); }
.text-muted { color: var(--ink3) !important; }
.card, .list-group-item, .modal-content, .dropdown-menu { background-color: var(--surface); color: var(--ink); border-color: var(--line); }
.table { color: var(--ink); --bs-table-color: var(--ink); --bs-table-bg: transparent; --bs-table-border-color: var(--line); }
.form-control, .form-select { background-color: var(--surface); color: var(--ink); border-color: var(--line-strong); }

/* Scrollbar discret */
* { scrollbar-color: var(--line-strong) transparent; }

/* ---------- 5. Plasă de siguranță pentru tema întunecată ----------
   Multe pagini au culori fixe (fundal alb, text închis) scrise direct în cod. În tema întunecată
   le rescriem pe cele mai comune, ca niciun text să nu rămână „negru pe negru” sau „alb pe alb”.
   Corecturile definitive se fac în paginile respective; asta e doar plasa de siguranță. */
html[data-theme="dark"] body { color: var(--ink); }

/* Fundaluri albe / foarte deschise scrise inline */
html[data-theme="dark"] [style*="background:#fff"], html[data-theme="dark"] [style*="background: #fff"],
html[data-theme="dark"] [style*="background:#FFF"], html[data-theme="dark"] [style*="background: #FFF"],
html[data-theme="dark"] [style*="background:#ffffff"], html[data-theme="dark"] [style*="background: #ffffff"],
html[data-theme="dark"] [style*="background:#FFFFFF"], html[data-theme="dark"] [style*="background: #FFFFFF"],
html[data-theme="dark"] [style*="background:white"], html[data-theme="dark"] [style*="background: white"],
html[data-theme="dark"] [style*="background-color:#fff"], html[data-theme="dark"] [style*="background-color: #fff"],
html[data-theme="dark"] [style*="background-color:#ffffff"], html[data-theme="dark"] [style*="background-color: #ffffff"],
html[data-theme="dark"] [style*="background-color:white"], html[data-theme="dark"] [style*="background-color: white"],
html[data-theme="dark"] [style*="background:#f8f"], html[data-theme="dark"] [style*="background: #f8f"],
html[data-theme="dark"] [style*="background:#f7f"], html[data-theme="dark"] [style*="background: #f7f"],
html[data-theme="dark"] [style*="background:#f5f"], html[data-theme="dark"] [style*="background: #f5f"],
html[data-theme="dark"] [style*="background:#f3f"], html[data-theme="dark"] [style*="background: #f3f"],
html[data-theme="dark"] [style*="background:#fafafa"], html[data-theme="dark"] [style*="background: #fafafa"] {
    background: var(--surface) !important;
    color: var(--ink) !important;
}

/* Text închis scris inline (negru / gri închis) */
html[data-theme="dark"] [style*="color:#000"], html[data-theme="dark"] [style*="color: #000"],
html[data-theme="dark"] [style*="color:#111"], html[data-theme="dark"] [style*="color: #111"],
html[data-theme="dark"] [style*="color:#222"], html[data-theme="dark"] [style*="color: #222"],
html[data-theme="dark"] [style*="color:#333"], html[data-theme="dark"] [style*="color: #333"],
html[data-theme="dark"] [style*="color:#444"], html[data-theme="dark"] [style*="color: #444"],
html[data-theme="dark"] [style*="color:#10202a"], html[data-theme="dark"] [style*="color:#13212c"],
html[data-theme="dark"] [style*="color:black"], html[data-theme="dark"] [style*="color: black"] {
    color: var(--ink) !important;
}
html[data-theme="dark"] [style*="color:#555"], html[data-theme="dark"] [style*="color: #555"],
html[data-theme="dark"] [style*="color:#666"], html[data-theme="dark"] [style*="color: #666"],
html[data-theme="dark"] [style*="color:#777"], html[data-theme="dark"] [style*="color: #777"],
html[data-theme="dark"] [style*="color:#5b6b78"], html[data-theme="dark"] [style*="color:#637381"] {
    color: var(--ink2) !important;
}

/* Câmpurile native rămân lizibile chiar dacă pagina le-a forțat fundal alb */
html[data-theme="dark"] input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="submit"]):not([type="button"]):not([type="reset"]):not([type="image"]),
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
    color: var(--ink);
    -webkit-text-fill-color: var(--ink);
}
html[data-theme="dark"] ::placeholder { color: var(--ink3); -webkit-text-fill-color: var(--ink3); }

/* Autocomplete-ul browserului (Chrome/Edge colorează câmpul în galben/alb) */
html[data-theme="dark"] input:-webkit-autofill,
html[data-theme="dark"] input:-webkit-autofill:hover,
html[data-theme="dark"] input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--ink);
    -webkit-box-shadow: 0 0 0 1000px var(--surface2) inset;
    caret-color: var(--ink);
}

/* Canvasul pentru semnătură rămâne alb (semnătura e cerneală închisă) */
html[data-theme="dark"] canvas[class*="sign"], html[data-theme="dark"] canvas[id*="sign"],
html[data-theme="dark"] canvas[class*="Sign"], html[data-theme="dark"] canvas[id*="Sign"] {
    background: #fff !important;
}

/* Imaginile/QR rămân pe fundal alb ca să poată fi citite */
html[data-theme="dark"] img[src*="qr" i], html[data-theme="dark"] canvas[id*="qr" i] { background: #fff; }

/* ---------- 6. Plasă de siguranță pentru telefon (≤ 767px) ----------
   Reguli generale; paginile își fac propriile ajustări. Specificitate mică (:where) unde paginile trebuie să poată suprascrie. */
body { overflow-wrap: break-word; }

@media (max-width: 767px) {
    /* iOS mărește pagina la focus dacă textul câmpului e sub 16px */
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):not([type="hidden"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="image"]),
    select,
    textarea {
        font-size: 16px !important;
    }

    /* Ținte tactile */
    :where(button, input[type="button"], input[type="submit"], input[type="reset"], .btn, .ui-btn, .btn-glass, .btn-report) {
        min-height: var(--touch);
    }

    /* Nimic nu iese din ecran */
    :where(#mainScroll) img,
    :where(#mainScroll) video,
    :where(#mainScroll) iframe {
        max-width: 100%;
    }
    :where(#mainScroll) img { height: auto; }

    :where(pre, code) { white-space: pre-wrap; overflow-wrap: anywhere; }

    /* Tabelele late derulează în containerul lor, nu toată pagina */
    :where(.table-responsive, .report-table-wrap) {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
    }

    /* Dialogurile generice încap pe ecran și derulează în interior */
    :where(.modal-dialog) { margin: 8px; max-width: calc(100vw - 16px); }
    /* Doar conținutul ferestrei; NU [role="dialog"] — pe multe pagini rolul e pus pe fundalul ferestrei,
       iar limitarea înălțimii lui lăsa bara de jos vizibilă sub fereastră. */
    :where(.modal-content) {
        max-width: 100vw;
        max-height: calc(100dvh - 16px);
        overflow-y: auto;
        overscroll-behavior: contain;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; }
}
