/* ============================================================
   AIM — Smarter Public Procurement
   Sistem de design: minimalist, cald, precis (stil Apple).
   Brand: AIM Green #0B5E55 · Siena Gold #C8A15A
   ============================================================ */

:root {
  /* Neutre — light mode */
  --bg: #FAFAF8;
  --surface: #FFFFFF;
  --elevated: #FFFFFF;
  --ink: #1A1A1A;
  --muted: #6B6B6B;
  --border: #EAEAE4;
  --hover: #F5F5F1;

  /* Brand */
  --brand: #0B5E55;
  --brand-hover: #094B44;
  --brand-ink: #FFFFFF;
  --brand-soft: #E7F0EE;         /* fundal discret pentru stări active */
  --brand-mark: #0B5E55;         /* culoarea monogramei */
  --gold: #C8A15A;
  --gold-hover: #B58C42;
  --gold-soft: #F6EEDD;

  /* Aliasuri de compatibilitate (cod existent folosește --primary/--accent) */
  --primary: var(--brand);
  --primary-hover: var(--brand-hover);
  --primary-ink: var(--brand-ink);
  --accent: var(--gold);
  --text: var(--ink);

  /* Semantice */
  --success: #0F8A5F;  --success-bg: #E9F6EF;
  --danger:  #C0392B;  --danger-bg:  #FBEBE9;
  --info:    #2D6CDF;  --info-bg:    #EAF1FD;
  --warn:    #D18B1F;  --warn-bg:    #FBF1DE;

  /* Formă */
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(20,24,22,.05), 0 6px 20px rgba(20,24,22,.05);
  --shadow-lg: 0 10px 40px rgba(20,24,22,.12);
  --ring: 0 0 0 3px rgba(11,94,85,.20);

  --topbar-bg: rgba(250,250,248,.78);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111312;
    --surface: #191C1A;
    --elevated: #222624;
    --ink: #F5F5F3;
    --muted: #B8B8B4;
    --border: #232624;
    --hover: #20241F;

    --brand: #1E9184;         /* petrol mai luminos, vizibil pe fundal închis */
    --brand-hover: #26A597;
    --brand-ink: #04211D;
    --brand-soft: #16302C;
    --brand-mark: #2FB3A3;
    --gold: #D3AE68;
    --gold-hover: #E0BD7C;
    --gold-soft: #2A2416;

    --primary-ink: #04211D;

    --success: #35B07E;  --success-bg: #133026;
    --danger:  #E06557;  --danger-bg:  #341E1B;
    --info:    #5B92F0;  --info-bg:    #17243B;
    --warn:    #E0AA54;  --warn-bg:    #33290F;

    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.35);
    --shadow-lg: 0 12px 44px rgba(0,0,0,.5);
    --ring: 0 0 0 3px rgba(47,179,163,.28);

    --topbar-bg: rgba(17,19,18,.72);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-feature-settings: "cv02","cv03","cv04","cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  letter-spacing: -0.006em;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 22px;
  background: var(--topbar-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 0 26px; height: 60px;
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; color: var(--ink); }
.brand-mark { height: 26px; width: auto; display: block; color: var(--brand-mark); }
.brand-mark svg, .brand svg { height: 26px; width: auto; display: block; }
.brand-logo { height: 44px; width: auto; display: block; }
.brand-title {
  font-weight: 700; font-size: 1.18rem; letter-spacing: .02em;
  color: var(--ink);
}
.topbar nav { display: flex; gap: 2px; }
.topbar nav a {
  color: var(--muted); text-decoration: none; padding: 7px 13px;
  border-radius: 9px; font-size: .92rem; font-weight: 500;
  transition: background .15s, color .15s;
}
.topbar nav a:hover { background: var(--hover); color: var(--ink); }
.topbar nav a.active { color: var(--brand); background: var(--brand-soft); font-weight: 600; }
.user-box { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.user-name { color: var(--muted); font-size: .88rem; }

/* ---------- Layout ---------- */
.container { max-width: 1000px; margin: 0 auto; padding: 36px 24px 72px; }
main a { color: var(--brand); text-decoration-color: color-mix(in srgb, var(--brand) 35%, transparent); text-underline-offset: 2px; }
main a:hover { color: var(--brand-hover); }
main a.muted { color: var(--muted); }
h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; margin: 0 0 4px; }
h2 { font-size: 1.18rem; font-weight: 650; letter-spacing: -.015em; }
h3 { font-weight: 600; }
.section { margin-top: 40px; }
.muted { color: var(--muted); }
.narrow { max-width: 460px; margin: 0 auto; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px; margin: 18px 0;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 9px 17px; font-size: .92rem; font-weight: 600; cursor: pointer;
  text-decoration: none; line-height: 1.2;
  transition: background .15s, border-color .15s, transform .06s, box-shadow .15s;
}
.btn:active { transform: translateY(.5px); }
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand-hover); }
.btn-gold { background: var(--gold); color: #2A1E06; }
.btn-gold:hover { background: var(--gold-hover); }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--ink); }
.btn-ghost:hover { background: var(--hover); }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); }
.btn-block { width: 100%; }
.btn-sm { padding: 5px 11px; font-size: .82rem; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: progress; }

/* ---------- Forms ---------- */
label { display: block; font-size: .88rem; font-weight: 550; color: var(--ink); }
input[type=text], input[type=email], input[type=password], input[type=file], input[type=number],
input[type=date], input[type=search], textarea, select {
  width: 100%; margin-top: 6px; padding: 10px 13px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: .95rem;
  background: var(--surface); color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: var(--ring);
}
a:focus-visible, button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row-form { display: flex; flex-wrap: wrap; gap: 16px; align-items: end; }
.row-form label { flex: 1; min-width: 160px; }
.row-form .check { flex: 0; white-space: nowrap; }
.check input { width: auto; margin-left: 6px; }
.upload-form { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.upload-form input[type=file] { flex: 1; min-width: 220px; }
.inline { display: inline; }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 82vh; display: grid; place-items: center; }
.auth-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; box-shadow: var(--shadow-lg);
  padding: 40px 34px; width: 100%; max-width: 390px; text-align: center;
}
.auth-card h1 { font-size: 1.4rem; margin: 16px 0 2px; }
.auth-brand img, .auth-brand svg { height: 96px; width: auto; margin: 0 auto 12px; display: block; }
.auth-card form { margin-top: 24px; text-align: left; }

/* ---------- Alerts ---------- */
.alert { padding: 12px 15px; border-radius: var(--radius-sm); margin: 16px 0; font-size: .9rem; border: 1px solid transparent; }
.alert-error { background: var(--danger-bg); color: var(--danger); }
.alert-success { background: var(--success-bg); color: var(--success); }
.alert-info { background: var(--info-bg); color: var(--info); }
.pass { background: var(--surface); padding: 2px 8px; border-radius: 6px; border: 1px solid var(--border); font-size: 1rem; }

/* ---------- Tables ---------- */
.table, .mini-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: .9rem; }
.table th, .mini-table th { text-align: left; color: var(--muted); font-weight: 600;
  padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; }
.table td, .mini-table td { padding: 11px 12px; border-bottom: 1px solid var(--border); }
.table tr:hover td { background: var(--hover); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: .78rem; font-weight: 600; background: var(--hover); color: var(--muted);
  border: 1px solid var(--border);
}
.badge-text { background: var(--success-bg); color: var(--success); border-color: transparent; }
.badge-ocr { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge-mixed { background: var(--info-bg); color: var(--info); border-color: transparent; }
.badge-depasit { background: var(--danger); color: #fff; border-color: transparent; }
.badge-urgent { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.badges { display: flex; gap: 8px; flex-wrap: wrap; }

/* Numărul (ID-ul) documentului */
.doc-nr {
  display: inline-block; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .8rem; font-weight: 700; color: var(--brand);
  background: var(--brand-soft); border-radius: 6px; padding: 1px 7px; margin-right: 6px;
  vertical-align: middle;
}
.row-depasit td { background: var(--danger-bg); }
.row-depasit td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.table tr.row-depasit:hover td { background: color-mix(in srgb, var(--danger-bg) 80%, var(--danger)); }
.text-depasit { color: var(--danger); font-weight: 600; }
.task-done td { color: var(--muted); background: var(--hover); }
.task-done strong { text-decoration: line-through; font-weight: 500; color: var(--muted); }
.task-done .btn { opacity: 1; }

/* Statusuri sarcini */
.badge-status-defacut  { background: var(--hover); color: var(--muted); border-color: var(--border); }
.badge-status-inlucru  { background: var(--info-bg); color: var(--info); border-color: transparent; }
.badge-status-finalizat{ background: var(--success-bg); color: var(--success); border-color: transparent; }

/* ---------- Cronologie activitate ---------- */
.timeline { list-style: none; margin: 8px 0 0; padding: 14px 18px; }
.timeline li { display: grid; grid-template-columns: minmax(96px, max-content) 1fr; gap: 12px;
               padding: 6px 0 6px 14px; border-left: 2px solid var(--border); font-size: .9rem; }
.timeline li > .muted { font-variant-numeric: tabular-nums; white-space: nowrap; }
.timeline li:first-child { border-left-color: var(--brand); }
.noutati-card { padding: 14px 18px; }
.stats-compact .stat-num { font-size: 1.4rem; }

/* ---------- Dashboard ---------- */
.page-head { display: flex; justify-content: space-between; align-items: start; gap: 16px; flex-wrap: wrap; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin: 22px 0; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px;
  transition: border-color .15s, box-shadow .15s;
}
.stat-card:hover { box-shadow: var(--shadow-lg); }
.stat-num { font-size: 2.1rem; font-weight: 700; letter-spacing: -.02em; color: var(--brand); line-height: 1.1; }
.stat-label { font-weight: 600; margin-top: 2px; }
.stat-sub { color: var(--muted); font-size: .82rem; margin-top: 2px; }
.two-col { display: grid; grid-template-columns: 3fr 2fr; gap: 28px; align-items: start; }
@media (max-width: 820px) { .two-col { grid-template-columns: 1fr; } }
.dosar-card { display: block; text-decoration: none; color: var(--ink); margin: 0; transition: border-color .15s, box-shadow .15s, transform .1s; }
.dosar-card:hover { border-color: color-mix(in srgb, var(--brand) 40%, var(--border)); box-shadow: var(--shadow-lg); }
.dosar-card-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
a.user-name { text-decoration: none; }
a.user-name:hover { color: var(--ink); }

/* ---------- Result ---------- */
.result-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.extracted {
  background: #0F172A; color: #E2E8F0; padding: 16px; border-radius: var(--radius-sm);
  overflow: auto; max-height: 420px; font-size: .82rem; white-space: pre-wrap; word-break: break-word;
}
.extracted-full {
  background: var(--surface); color: var(--ink); border: 1px solid var(--border);
  padding: 22px 26px; border-radius: var(--radius); max-height: none;
  font-size: .9rem; line-height: 1.7; white-space: pre-wrap; word-break: break-word;
}

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; }
}
@media (max-width: 700px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 16px; gap: 12px; }
}

/* Buton-sumar pentru secțiuni pliabile */
.summary-btn { display: inline-block; cursor: pointer; list-style: none; user-select: none; }
.summary-btn::-webkit-details-marker { display: none; }
details[open] > .summary-btn { margin-bottom: 2px; }

/* ---------- Chat ---------- */
.chat-box {
  height: 320px; overflow-y: auto; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.chat-box:empty::before { content: "Niciun mesaj încă — scrie primul."; color: var(--muted); margin: auto; }
.chat-msg {
  max-width: 72%; padding: 8px 13px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border); align-self: flex-start;
}
.chat-msg.al-meu { align-self: flex-end; background: var(--brand-soft); border-color: transparent; }
.chat-meta { font-size: .72rem; color: var(--muted); margin-bottom: 2px; }
.chat-text { white-space: pre-wrap; word-break: break-word; }
.chat-form { display: flex; gap: 10px; margin-top: 10px; }
.chat-form input { flex: 1; }
.chat-box-mare { height: min(62vh, 640px); }
.summary-arrow { display: inline-block; transition: transform .15s; margin-left: 4px; }
details[open] > summary .summary-arrow { transform: rotate(180deg); }

/* Badge de necitite pe tab */
.nav-badge {
  display: inline-block; background: var(--danger); color: #fff;
  border-radius: 999px; font-size: .68rem; font-weight: 700;
  padding: 1px 6px; margin-left: 6px; vertical-align: top; line-height: 1.4;
}

/* ---------- Documente în dosar — tab-uri ---------- */
.doc-tabs { display: flex; gap: 6px; margin-bottom: -1px; flex-wrap: wrap; }
.doc-tab {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  background: var(--bg); color: var(--muted); font-weight: 600; font-size: .95rem;
  border: 1px solid var(--border); border-bottom: none;
  border-radius: 12px 12px 0 0; padding: 9px 16px;
}
.doc-tab:hover { color: var(--ink); }
.doc-tab.activ { background: var(--surface); color: var(--brand); border-color: var(--border); }
.doc-panel { border-top-left-radius: 0; margin-top: 0; }
.doc-panel.ascuns { display: none; }
.doc-count { background: var(--border); color: var(--muted); border-radius: 999px;
  font-size: .78rem; font-weight: 700; padding: 1px 9px; }
.doc-tab.activ .doc-count { background: var(--brand-soft); color: var(--brand); }
.doc-col-note { font-size: .8rem; margin: 0 0 10px; }
.doc-table { margin: 0; }
.doc-table td { vertical-align: top; padding: 8px 6px; }
.doc-sub { font-size: .76rem; margin-top: 2px; }
