/* ==========================================================================
   Estimări Preț — foaie de stil unică.

   Scrisă de mână, fără pas de compilare: pe Plesk nu există Node.js.
   Paleta este preluată din aplicația anterioară (albastru Penrose #154375).
   ========================================================================== */

:root {
    --primary: #154375;
    --primary-light: #1e5a9e;
    --primary-dark: #0f3059;

    --bg: #f1f5f9;
    --surface: #ffffff;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;

    --text: #0f172a;
    --text-muted: #64748b;
    --text-subtle: #94a3b8;

    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --danger-border: #fecaca;
    --success: #16a34a;
    --success-bg: #f0fdf4;
    --success-border: #bbf7d0;
    --info-bg: #eff6ff;
    --info-border: #bfdbfe;
    --info: #1d4ed8;

    --radius: 8px;
    --radius-sm: 6px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
    --shadow: 0 1px 3px rgba(15, 23, 42, .1), 0 1px 2px rgba(15, 23, 42, .06);
    --shadow-lg: 0 10px 25px rgba(15, 23, 42, .12);

    --sidebar-width: 250px;
    --header-height: 64px;
}

/* --- Reset ---------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

h1, h2, h3, h4, p, figure { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img, svg { display: block; max-width: 100%; }

:focus-visible {
    outline: 2px solid var(--primary-light);
    outline-offset: 2px;
}

/* Sări la conținut — vizibil doar la navigarea cu tastatura. */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 100;
    padding: 10px 16px;
    background: var(--primary);
    color: #fff;
    border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { left: 0; }

/* --- Structura ------------------------------------------------------------ */

.app {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    flex: 0 0 var(--sidebar-width);
    background: var(--primary);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar__brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px;
    border-bottom: 1px solid var(--primary-light);
    font-size: 17px;
    font-weight: 700;
    letter-spacing: .01em;
    color: #fff;
}
.sidebar__brand:hover { text-decoration: none; }
.sidebar__brand small {
    display: block;
    font-size: 11px;
    font-weight: 400;
    color: #a9c4e0;
    letter-spacing: .02em;
}

.sidebar__nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.sidebar__link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    margin-bottom: 3px;
    border-radius: var(--radius-sm);
    color: #d7e3f0;
    font-weight: 500;
    transition: background-color .12s, color .12s;
}
.sidebar__link:hover {
    background: rgba(255, 255, 255, .1);
    color: #fff;
    text-decoration: none;
}
.sidebar__link--active {
    background: var(--primary-light);
    color: #fff;
}
/* Deconectarea este un buton (POST protejat CSRF), nu un link. */
.sidebar__link--button {
    width: 100%;
    border: 0;
    background: none;
    font: inherit;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
}
.sidebar__link .icon { flex: 0 0 18px; opacity: .9; }

.sidebar__footer {
    padding: 12px;
    border-top: 1px solid var(--primary-light);
}
.sidebar__user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px 10px;
    font-size: 13px;
    color: #a9c4e0;
    overflow: hidden;
}
.sidebar__user strong {
    color: #fff;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.header {
    height: var(--header-height);
    flex: 0 0 var(--header-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 10;
}
.header__title {
    font-size: 19px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.header__actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
}

.content {
    flex: 1;
    padding: 28px;
    max-width: 1400px;
    width: 100%;
}
.content--narrow { max-width: 860px; }

/* --- Card ----------------------------------------------------------------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}
.card:last-child { margin-bottom: 0; }

.card__header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.card__title { font-size: 15px; font-weight: 600; }
.card__hint { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.card__body { padding: 20px; }
.card__body--flush { padding: 0; }
.card__footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    background: #f8fafc;
    border-radius: 0 0 var(--radius) var(--radius);
}

/* --- Statistici ----------------------------------------------------------- */

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 18px;
    margin-bottom: 22px;
}
.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
}
.stat__icon {
    flex: 0 0 44px;
    height: 44px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: #e0eaf5;
    color: var(--primary);
}
.stat__label {
    font-size: 12.5px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    font-weight: 600;
}
.stat__value {
    font-size: 24px;
    font-weight: 700;
    line-height: 1.2;
    margin-top: 2px;
}
.stat__value--stack { font-size: 17px; }
.stat__value--stack span { display: block; }

/* --- Butoane -------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 15px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #fff;
    font: inherit;
    font-weight: 500;
    line-height: 1.35;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--primary-light); text-decoration: none; color: #fff; }
.btn:disabled, .btn[aria-disabled="true"] {
    opacity: .5;
    cursor: not-allowed;
    pointer-events: none;
}

.btn--secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border-strong);
}
.btn--secondary:hover { background: #f8fafc; color: var(--text); border-color: var(--text-subtle); }

.btn--danger { background: var(--danger); }
.btn--danger:hover { background: #b91c1c; }

.btn--ghost { background: transparent; color: var(--text-muted); }
.btn--ghost:hover { background: #eef2f7; color: var(--text); }

.btn--sm { padding: 5px 10px; font-size: 13px; }
.btn--block { width: 100%; }
.btn .icon { flex: 0 0 auto; }

/* Butoane discrete din coloana de acțiuni a tabelelor. */
.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: background-color .12s, color .12s;
}
.icon-btn:hover { background: #eef2f7; color: var(--primary); text-decoration: none; }
.icon-btn--danger:hover { background: var(--danger-bg); color: var(--danger); }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }

.actions { display: flex; gap: 2px; justify-content: flex-end; }
.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: wrap;
}
.form-actions--split { justify-content: space-between; }

/* --- Formulare ------------------------------------------------------------ */

.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }

.label {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
    font-weight: 600;
    color: #334155;
}
.label .req { color: var(--danger); }

.input, .select, .textarea {
    width: 100%;
    padding: 8px 11px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    line-height: 1.4;
    transition: border-color .12s, box-shadow .12s;
}
.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(21, 67, 117, .12);
}
.input:disabled, .select:disabled, .textarea:disabled {
    background: #f1f5f9;
    color: var(--text-muted);
}
.textarea { resize: vertical; min-height: 62px; }
.input--error, .select--error, .textarea--error { border-color: var(--danger-border); }

.select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%2364748b'%3E%3Cpath d='M4.5 6.5 8 10l3.5-3.5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 9px center;
    background-size: 16px;
    padding-right: 32px;
}

.field__error { margin-top: 4px; font-size: 12.5px; color: var(--danger); }
.field__hint { margin-top: 4px; font-size: 12.5px; color: var(--text-muted); }

.grid { display: grid; gap: 16px; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.checkbox, .radio {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13.5px;
    cursor: pointer;
}
.checkbox input, .radio input {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
    margin: 0;
}

/* Listă de bifat (persoane de contact pe ofertă). */
.check-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.check-list__item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    background: var(--surface);
    font-size: 13.5px;
    cursor: pointer;
    transition: border-color .12s, background-color .12s;
}
.check-list__item:hover { border-color: var(--primary-light); }
.check-list__item:has(input:checked) {
    border-color: var(--primary);
    background: #eef4fa;
}
.check-list__item small { color: var(--text-muted); }

/* --- Bara de căutare / filtre --------------------------------------------- */

.toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
}
.toolbar .input, .toolbar .select { width: auto; }
.toolbar__search { flex: 1 1 260px; min-width: 200px; }

/* --- Tabele --------------------------------------------------------------- */

.table-wrap { overflow-x: auto; }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
.table th {
    padding: 10px 16px;
    text-align: left;
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table td {
    padding: 11px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #f8fafc; }
.table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table .center { text-align: center; }
.table .shrink { width: 1%; white-space: nowrap; }
.table__primary { font-weight: 600; color: var(--text); }
.table__sub { display: block; font-size: 12.5px; color: var(--text-muted); }

.empty {
    padding: 44px 20px;
    text-align: center;
    color: var(--text-muted);
}
.empty strong { display: block; color: var(--text); margin-bottom: 4px; font-size: 15px; }

/* --- Etichete de stare ---------------------------------------------------- */

.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
}
.badge--draft    { background: #f1f5f9; color: #475569; }
.badge--sent     { background: #e0edfb; color: #1d4ed8; }
.badge--accepted { background: #dcfce7; color: #15803d; }
.badge--rejected { background: #fee2e2; color: #b91c1c; }

/* --- Mesaje --------------------------------------------------------------- */

.alerts { margin-bottom: 20px; display: grid; gap: 10px; }

.alert {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 11px 15px;
    border: 1px solid;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
}
.alert--success { background: var(--success-bg); border-color: var(--success-border); color: #14532d; }
.alert--error   { background: var(--danger-bg);  border-color: var(--danger-border);  color: #7f1d1d; }
.alert--info    { background: var(--info-bg);    border-color: var(--info-border);    color: #1e3a8a; }
.alert .icon { flex: 0 0 auto; margin-top: 1px; }

/* --- Autentificare -------------------------------------------------------- */

.auth {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: linear-gradient(160deg, #eef2f7 0%, #dde7f2 100%);
}
.auth__box { width: 100%; max-width: 400px; }
.auth__brand { text-align: center; margin-bottom: 22px; }
.auth__brand h1 {
    font-size: 30px;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -.01em;
}
.auth__brand p { color: var(--text-muted); font-size: 14px; margin-top: 2px; }
.auth__card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 26px;
}
.auth__footer {
    margin-top: 18px;
    text-align: center;
    font-size: 12.5px;
    color: var(--text-subtle);
}

/* --- Articolele ofertei --------------------------------------------------- */

.items {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
.items thead th {
    background: var(--primary);
    color: #fff;
    padding: 9px 10px;
    text-align: left;
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.items thead th:first-child { border-top-left-radius: var(--radius-sm); }
.items thead th:last-child  { border-top-right-radius: var(--radius-sm); }
.items td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.items tbody tr:hover { background: #f8fafc; }
.items .input, .items .select { padding: 6px 9px; font-size: 13.5px; }
.items .col-num     { width: 42px;  text-align: center; color: var(--text-muted); }
.items .col-section { width: 170px; }
.items .col-cost    { width: 118px; }
.items .col-hours   { width: 92px;  }
.items .col-total   { width: 118px; text-align: right; }
.items .col-actions { width: 96px;  text-align: right; }
.items .row-total {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    text-align: right;
    padding-right: 10px;
}
.items__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 14px;
    background: var(--primary);
    color: #fff;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    font-weight: 600;
}
.items__foot .total {
    font-size: 16px;
    font-variant-numeric: tabular-nums;
}
.items__add {
    padding: 11px 14px;
    background: #f8fafc;
    border-top: 1px solid var(--border);
}

/* Secțiuni ale ofertei. */
.sections__row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.sections__row .input { flex: 1; }
.sections__empty { color: var(--text-muted); font-size: 13px; margin-bottom: 10px; }

/* Persoane de contact în formularul de client. */
.contact-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 14px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #f8fafc;
}
.contact-row__head {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

/* --- Aspect în două coloane (formularul de ofertă) ------------------------- */

.split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 20px;
    align-items: start;
}

/* --- Fereastră de confirmare ---------------------------------------------- */

dialog.modal {
    width: min(440px, calc(100vw - 32px));
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    color: var(--text);
}
dialog.modal::backdrop { background: rgba(15, 23, 42, .45); }
.modal__body { padding: 22px; }
.modal__title { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.modal__text { color: var(--text-muted); font-size: 13.5px; }
.modal__actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 22px;
    background: #f8fafc;
    border-top: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
}

/* --- Paginare ------------------------------------------------------------- */

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 20px;
    border-top: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-muted);
}
.pagination__links { display: flex; gap: 6px; }

/* --- Pagină de eroare ----------------------------------------------------- */

.error-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    text-align: center;
}
.error-page__code {
    font-size: 60px;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}
.error-page__title { font-size: 20px; font-weight: 600; margin: 10px 0 6px; }
.error-page__text { color: var(--text-muted); max-width: 460px; margin: 0 auto 22px; }

/* --- Utilitare ------------------------------------------------------------ */

.muted { color: var(--text-muted); }
.subtle { color: var(--text-subtle); }
.small { font-size: 12.5px; }
.mono { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; }
.nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: 16px; }
.mb-2 { margin-bottom: 16px; }
.text-right { text-align: right; }
.visually-hidden {
    position: absolute;
    width: 1px; height: 1px;
    margin: -1px; padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* --- Ecrane mici ---------------------------------------------------------- */

@media (max-width: 1024px) {
    .split { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 768px) {
    .app { flex-direction: column; }
    .sidebar {
        width: 100%;
        flex: none;
        height: auto;
        position: static;
        flex-direction: column;
    }
    .sidebar__nav { display: flex; gap: 4px; overflow-x: auto; padding: 10px 12px; }
    .sidebar__link { margin-bottom: 0; white-space: nowrap; }
    .sidebar__footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
    .sidebar__user { padding: 0; }
    .header { height: auto; padding: 14px 18px; flex-wrap: wrap; }
    .content { padding: 18px; }
    .grid--2, .grid--3 { grid-template-columns: minmax(0, 1fr); }
    .contact-row { grid-template-columns: minmax(0, 1fr); }
    .items .col-section { width: auto; }
}

@media print {
    .sidebar, .header__actions, .toolbar, .actions { display: none !important; }
    body { background: #fff; }
    .card { border: 0; box-shadow: none; }
}
