/* PlusDelivery - stiluri. Stil: Minimalism / Swiss. Culori: albastru urmarire
   + portocaliu livrare. Suporta light + dark (automat si cu comutator). */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --primary: #2563EB;
  --primary-on: #FFFFFF;
  --accent: #EA580C;
  --accent-on: #FFFFFF;
  --bg: #F5F7FB;
  --card: #FFFFFF;
  --text: #0F172A;
  --muted: #64748B;
  --border: #E2E8F0;
  --soft: #EFF4FE;
  --ok: #16A34A;
  --warn: #D97706;
  --danger: #DC2626;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15,23,42,.06), 0 8px 24px rgba(15,23,42,.06);
  --space: 16px;
}
:root[data-theme="dark"] {
  --bg: #0B1120;
  --card: #111A2E;
  --text: #E8EDF7;
  --muted: #94A3B8;
  --border: #22304C;
  --soft: #16213A;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px rgba(0,0,0,.35);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0B1120; --card: #111A2E; --text: #E8EDF7; --muted: #94A3B8;
    --border: #22304C; --soft: #16213A;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px rgba(0,0,0,.35);
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; font-family: Inter, system-ui, sans-serif; background: var(--bg);
  color: var(--text); line-height: 1.5; -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); }
button { font-family: inherit; cursor: pointer; }

/* ---- Header ---- */
.header {
  position: sticky; top: 0; z-index: 20; background: var(--card);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1120px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; }
.brand .dot { width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--accent)); display: grid; place-items: center; }
.brand .dot svg { width: 18px; height: 18px; color: #fff; }
.tabs { display: flex; gap: 4px; margin-left: auto; background: var(--soft);
  padding: 4px; border-radius: 12px; }
.tab { border: 0; background: transparent; color: var(--muted); font-weight: 600;
  padding: 8px 14px; border-radius: 9px; font-size: 14px; transition: all .2s; }
.tab:hover { color: var(--text); }
.tab.active { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.icon-btn { border: 1px solid var(--border); background: var(--card); color: var(--text);
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; transition: all .2s; }
.icon-btn:hover { border-color: var(--primary); }
.icon-btn svg { width: 18px; height: 18px; }

/* ---- Layout ---- */
.container { max-width: 1120px; margin: 0 auto; padding: 24px 20px 64px; }
.view { display: none; }
.view.active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.page-title { font-size: 26px; font-weight: 800; margin: 0 0 4px; letter-spacing: -.02em; }
.page-sub { color: var(--muted); margin: 0 0 24px; }

.grid { display: grid; gap: 20px; }
@media (min-width: 880px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; }
.card h3 { margin: 0 0 14px; font-size: 16px; font-weight: 700; }

/* ---- Formular ---- */
.field { margin-bottom: 14px; }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--muted); }
select, input, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg); color: var(--text); font-size: 14px; transition: border-color .2s;
}
select:focus, input:focus, textarea:focus { outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15); }

.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.seg button { border: 1px solid var(--border); background: var(--bg); color: var(--text);
  padding: 12px; border-radius: 10px; text-align: left; transition: all .2s; }
.seg button small { display: block; color: var(--muted); font-weight: 400; margin-top: 2px; font-size: 12px; }
.seg button.active { border-color: var(--primary); background: var(--soft); }
.seg button strong { font-weight: 700; font-size: 14px; }

.btn { width: 100%; border: 0; padding: 13px; border-radius: 10px; font-weight: 700;
  font-size: 15px; transition: transform .1s, filter .2s; }
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: scale(.99); }
.btn-primary { background: var(--primary); color: var(--primary-on); }
.btn-accent { background: var(--accent); color: var(--accent-on); }
.btn-ghost { background: var(--soft); color: var(--text); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---- Lista oferte vehicule ---- */
.vehicle { display: flex; align-items: center; gap: 12px; padding: 12px;
  border: 1px solid var(--border); border-radius: 12px; margin-bottom: 8px; transition: all .2s; }
.vehicle:hover { border-color: var(--primary); }
.vehicle.active { border-color: var(--primary); background: var(--soft); }
.vehicle .v-ic { width: 42px; height: 42px; border-radius: 10px; background: var(--soft);
  display: grid; place-items: center; color: var(--primary); flex-shrink: 0; }
.vehicle .v-ic svg { width: 22px; height: 22px; }
.vehicle .v-name { font-weight: 700; font-size: 14px; }
.vehicle .v-cap { color: var(--muted); font-size: 12px; }
.vehicle .v-meta { margin-left: auto; text-align: right; }
.vehicle .v-price { font-weight: 800; font-size: 16px; }
.vehicle .v-eta { color: var(--muted); font-size: 12px; }

/* ---- Harta reala (Leaflet) ---- */
.map { position: relative; z-index: 0; width: 100%; aspect-ratio: 4/3; border-radius: 12px;
  overflow: hidden; background: var(--soft); border: 1px solid var(--border); }
.leaflet-container { font: inherit; background: var(--soft); }
.order-card { margin-bottom: 18px; }
.oc-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
@media (max-width: 879px) { .oc-map { min-height: 240px; } }

/* ---- Timeline status ---- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 12px; padding-bottom: 16px; position: relative; }
.timeline li::before { content: ""; position: absolute; left: 10px; top: 22px; bottom: -4px;
  width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline .tl-dot { width: 22px; height: 22px; border-radius: 50%; background: var(--border);
  flex-shrink: 0; display: grid; place-items: center; z-index: 1; }
.timeline li.done .tl-dot { background: var(--ok); }
.timeline li.current .tl-dot { background: var(--primary); animation: pulse 1.4s infinite; }
.timeline .tl-dot svg { width: 13px; height: 13px; color: #fff; }
.timeline .tl-label { font-weight: 600; font-size: 14px; }
.timeline li.pending .tl-label { color: var(--muted); font-weight: 500; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(37,99,235,.4); } 50% { box-shadow: 0 0 0 7px rgba(37,99,235,0); } }

/* ---- Badge status ---- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; background: var(--soft); color: var(--primary); }
.badge.ok { background: rgba(22,163,74,.12); color: var(--ok); }
.badge.live { background: rgba(37,99,235,.12); color: var(--primary); }

/* ---- Stats ---- */
.stats { display: grid; grid-template-columns: repeat(2,1fr); gap: 14px; margin-bottom: 20px; }
@media (min-width: 720px) { .stats { grid-template-columns: repeat(4,1fr); } }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); }
.stat .s-val { font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.stat .s-lbl { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* ---- Job cards (sofer) ---- */
.job { border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin-bottom: 12px; }
.job .j-top { display: flex; justify-content: space-between; align-items: start; margin-bottom: 10px; }
.job .j-route { font-size: 13px; color: var(--muted); margin: 8px 0; display: flex; align-items: center; gap: 6px; }
.j-route { display: flex; align-items: center; gap: 6px; }
.j-route svg { width: 16px; height: 16px; flex-shrink: 0; }
.job .j-price { font-weight: 800; font-size: 18px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.muted { color: var(--muted); }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 12px 20px; border-radius: 10px;
  font-weight: 600; font-size: 14px; box-shadow: var(--shadow); z-index: 50; opacity: 0;
  transition: opacity .3s, transform .3s; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.notice { background: var(--soft); border: 1px dashed var(--border); border-radius: 10px;
  padding: 12px; font-size: 13px; color: var(--muted); margin-bottom: 16px; }

/* --- Autocomplete adresa (combobox) ------------------------------------- */
.ac { position: relative; }
.ac-list { list-style: none; margin: 4px 0 0; padding: 4px; position: absolute;
  left: 0; right: 0; top: 100%; z-index: 30; background: var(--card);
  border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow);
  max-height: 260px; overflow-y: auto; }
.ac-opt { display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--text); }
.ac-opt:hover, .ac-opt.active { background: var(--soft); }
.ac-opt .ac-ic { width: 16px; height: 16px; color: var(--primary); flex-shrink: 0; }
.ac-opt .ac-ic svg { width: 16px; height: 16px; }
.ac-opt .ac-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-opt .ac-tag { font-size: 11px; font-weight: 700; color: var(--primary);
  background: var(--soft); padding: 2px 6px; border-radius: 6px; flex-shrink: 0; }
.ac-opt.out { cursor: not-allowed; opacity: .55; }
.ac-opt.out .ac-tag.out { color: var(--warn); background: transparent; }
.ac-empty { padding: 10px; font-size: 13px; color: var(--muted); text-align: center; }

/* --- Header dreapta + chip utilizator ----------------------------------- */
.header-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.lang-select {
  width: auto; height: 38px; padding: 0 28px 0 12px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--card); color: var(--text); font-size: 13px;
  font-weight: 700; letter-spacing: .02em; cursor: pointer; transition: border-color .2s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; background-size: 14px;
  -webkit-appearance: none; appearance: none;
}
.lang-select:hover { border-color: var(--primary); }
.lang-select:focus { outline: none; border-color: var(--primary); }
.userbox { display: flex; align-items: center; gap: 8px; background: var(--soft);
  border: 1px solid var(--border); border-radius: 999px; padding: 4px 6px 4px 12px; }
.userbox .ub-ic { width: 18px; height: 18px; color: var(--primary); }
.userbox .ub-ic svg { width: 18px; height: 18px; }
.userbox .ub-txt { display: flex; flex-direction: column; line-height: 1.1; }
.userbox .ub-txt strong { font-size: 13px; }
.userbox .ub-txt small { font-size: 11px; color: var(--muted); }

/* --- Ecran de autentificare --------------------------------------------- */
.auth-wrap { display: grid; place-items: center; padding: 24px 0; }
.auth-card { width: 100%; max-width: 440px; }
.auth-seg { margin-bottom: 16px; }
.auth-err { background: #FEF2F2; color: var(--danger); border: 1px solid #FECACA;
  border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-bottom: 14px; }
:root[data-theme="dark"] .auth-err, :root:not([data-theme="light"]) .auth-err {
  background: rgba(220,38,38,.12); border-color: rgba(220,38,38,.4); }
.lbl { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--muted); }
.role-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.role-opt { display: flex; align-items: flex-start; gap: 8px; border: 1px solid var(--border);
  border-radius: 12px; padding: 12px; cursor: pointer; transition: border-color .2s, background .2s; }
.role-opt.active { border-color: var(--primary); background: var(--soft); }
.role-opt input { position: absolute; opacity: 0; width: 0; height: 0; }
.role-opt .r-ic { width: 22px; height: 22px; color: var(--primary); flex-shrink: 0; }
.role-opt .r-ic svg { width: 22px; height: 22px; }
.role-opt strong { display: block; font-size: 14px; }
.role-opt small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-bottom: 14px; cursor: pointer; }
.check input { width: auto; }

/* --- Panou sofer: status online + switch -------------------------------- */
.stat-wide { grid-column: 1 / -1; text-align: left; }
.online-row { display: flex; align-items: center; gap: 12px; }
.online-row .s-lbl { margin: 0; }
.s-val-sm { font-weight: 700; font-size: 15px; }
.dot-status { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.dot-status.on { background: var(--ok); box-shadow: 0 0 0 4px rgba(22,163,74,.18); }
.dot-status.off { background: var(--muted); }
.switch { margin-left: auto; width: 48px; height: 28px; border-radius: 999px; border: 0;
  background: var(--border); position: relative; cursor: pointer; transition: background .2s; flex-shrink: 0; }
.switch.on { background: var(--ok); }
.switch span { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch.on span { transform: translateX(20px); }

/* --- Rating dupa livrare ------------------------------------------------- */
.oc-rate { margin-top: 12px; }
.oc-rate .hint { display: block; }
.rate-stars { display: inline-flex; gap: 2px; margin-top: 4px; }
.star { background: none; border: 0; font-size: 24px; line-height: 1; cursor: pointer;
  color: var(--border); padding: 0 2px; transition: color .15s; }
.star.on, .star:hover { color: #F59E0B; }
.rated { font-size: 13px; color: var(--text); }
.rated .stars { color: #F59E0B; letter-spacing: 1px; }

/* --- Opriri intermediare (waypoints) ------------------------------------ */
.btn-link { display: inline-flex; align-items: center; gap: 5px; border: 0; background: none;
  color: var(--primary); font-weight: 600; font-size: 13px; cursor: pointer; padding: 4px 2px; }
.btn-link:hover { text-decoration: underline; }
.btn-link .bl-ic { display: inline-flex; }
.btn-link .bl-ic svg { width: 15px; height: 15px; }
.stops-block { margin-bottom: 14px; }
.stops-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.stops-head .lbl { margin-bottom: 0; }
.stop-row { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.stop-row .ac { flex: 1; }
.stop-num { flex-shrink: 0; width: 22px; height: 22px; margin-top: 10px; border-radius: 50%;
  background: var(--soft); color: var(--primary); font-size: 12px; font-weight: 700;
  display: grid; place-items: center; }
.stop-ctrls { display: flex; gap: 4px; flex-shrink: 0; }
.stop-btn { width: 40px; height: 40px; border: 1px solid var(--border); background: var(--card);
  color: var(--muted); border-radius: 10px; cursor: pointer; display: grid; place-items: center; transition: all .15s; }
.stop-btn svg { width: 18px; height: 18px; }
.stop-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.stop-btn.danger:hover:not(:disabled) { border-color: var(--danger); color: var(--danger); }
.stop-btn:disabled { opacity: .4; cursor: not-allowed; }
/* indicator compact „N opriri" pe linia de ruta */
.stop-chip { display: inline-flex; align-items: center; gap: 3px; padding: 1px 8px; border-radius: 999px;
  background: var(--soft); color: var(--primary); font-size: 11px; font-weight: 600; }
.stop-chip svg { width: 12px !important; height: 12px !important; }
/* marcaj numerotat pe harta (Leaflet divIcon) */
.stop-marker { background: var(--primary); color: #fff; border: 2px solid #fff; border-radius: 50%;
  font: 700 11px/18px Inter, sans-serif; text-align: center; box-shadow: 0 1px 4px rgba(0,0,0,.35); }

/* --- Istoric livrari (lista compacta) ----------------------------------- */
.hist-item { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.hist-top { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.hist-date { font-size: 12px; color: var(--muted); }
.hist-item .oc-rate { margin-top: 10px; }

/* --- Grafic castig pe zile (bare CSS) ----------------------------------- */
.earn-summary { font-size: 14px; color: var(--text); margin-bottom: 14px; }
.earn-bars { display: flex; align-items: flex-end; gap: 8px; height: 150px; }
.eb { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.eb-val { font-size: 10px; font-weight: 700; color: var(--text); margin-bottom: 4px; min-height: 13px; white-space: nowrap; }
.eb-track { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.eb-fill { width: 100%; max-width: 40px; margin: 0 auto; border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, var(--primary), #3b82f6); transition: height .4s ease; }
.eb-fill.zero { background: var(--border); border-radius: 3px 3px 0 0; }
.eb-lbl { font-size: 12px; color: var(--muted); margin-top: 6px; }
.earn-table { margin-top: 14px; }
.earn-table summary { font-size: 13px; color: var(--primary); cursor: pointer; font-weight: 600; }
.earn-table table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 13px; }
.earn-table th, .earn-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.earn-table th { color: var(--muted); font-weight: 600; }
.earn-table td:nth-child(2), .earn-table td:nth-child(3),
.earn-table th:nth-child(2), .earn-table th:nth-child(3) { text-align: right; }

@media (max-width: 560px) {
  .role-pick { grid-template-columns: 1fr; }
  .eb-val { font-size: 9px; }
  .earn-bars { gap: 4px; }
}

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
