/* ============================================================
   Proenerg Transport — Stiluri globale
   ============================================================ */

/* ── Variabile ─────────────────────────────────────────────── */
:root {
  --c-bg:         #f5f6fa;
  --c-surface:    #ffffff;
  --c-surface2:   #f0f1f5;
  --c-border:     #e2e4eb;
  --c-text:       #1a1d2e;
  --c-muted:      #6b7280;
  --c-primary:    #2563eb;
  --c-primary-h:  #1d4ed8;
  --c-success:    #16a34a;
  --c-warning:    #d97706;
  --c-danger:     #dc2626;
  --c-ok:         #16a34a;

  --radius:       10px;
  --radius-sm:    6px;
  --shadow:       0 1px 4px rgba(0,0,0,.08), 0 2px 12px rgba(0,0,0,.06);
  --shadow-lg:    0 4px 24px rgba(0,0,0,.12);
  --transition:   150ms ease;

  --nav-h:        56px;
  --bar-h:        72px; /* quick input bar */
}

/* Dark mode dezactivat — tema light implicit */

/* ── Reset & base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-tap-highlight-color: transparent; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  line-height: 1.5;
  min-height: 100dvh;
}

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

/* ── Layout ─────────────────────────────────────────────────── */
.app-nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--nav-h);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center; gap: 4px;
  padding: 0 12px;
  box-shadow: var(--shadow);
}

.app-nav .logo {
  font-weight: 700; font-size: 1rem; color: var(--c-primary);
  margin-right: auto;
}
.app-nav .logo span { font-weight: 400; color: var(--c-muted); font-size: .85rem; }

.nav-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 12px; border-radius: var(--radius-sm);
  font-size: .875rem; font-weight: 500; color: var(--c-muted);
  background: none; border: none; cursor: pointer;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}
.nav-btn:hover { background: var(--c-surface2); color: var(--c-text); }
.nav-btn.active { background: var(--c-primary); color: #fff; }

.page {
  margin-top: var(--nav-h);
  padding: 16px;
  min-height: calc(100dvh - var(--nav-h));
}
.page.with-bar { padding-bottom: calc(var(--bar-h) + 16px + env(safe-area-inset-bottom)); }

/* ── Carduri ──────────────────────────────────────────────── */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;
}
.card-header h2 { font-size: 1rem; font-weight: 600; flex: 1; }
.card-body { padding: 16px; }

/* ── Butoane ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  font-size: .875rem; font-weight: 500; cursor: pointer;
  border: 1px solid transparent; transition: all var(--transition);
  line-height: 1; white-space: nowrap; user-select: none;
}
.btn-primary   { background: var(--c-primary);  color: #fff; }
.btn-primary:hover { background: var(--c-primary-h); }
.btn-secondary { background: var(--c-surface2); color: var(--c-text); border-color: var(--c-border); }
.btn-secondary:hover { border-color: var(--c-primary); }
.btn-danger    { background: var(--c-danger);   color: #fff; }
.btn-danger:hover { opacity: .88; }
.btn-ghost     { background: none; color: var(--c-muted); border-color: transparent; }
.btn-ghost:hover { background: var(--c-surface2); color: var(--c-text); }
.btn-sm        { padding: 6px 11px; font-size: .8rem; }
.btn-icon      { padding: 9px; min-width: 38px; justify-content: center; }
.btn:disabled  { opacity: .5; cursor: not-allowed; }

/* ── Formulare ───────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-label { font-size: .8rem; font-weight: 500; color: var(--c-muted); }

.form-control {
  width: 100%; padding: 9px 12px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  font-size: .9rem; color: var(--c-text);
  transition: border-color var(--transition);
  outline: none;
}
.form-control:focus  { border-color: var(--c-primary); }
.form-control::placeholder { color: var(--c-muted); }
select.form-control  { cursor: pointer; }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

/* ── Dashboard grid ─────────────────────────────────────── */
.dashboard-nav {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 14px; flex-wrap: wrap;
}
.week-label {
  font-weight: 600; font-size: .95rem; flex: 1; text-align: center;
}

.grid-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.transport-grid {
  border-collapse: collapse;
  min-width: 600px;
  width: 100%;
  font-size: .85rem;
}
.transport-grid th, .transport-grid td {
  border: 1px solid var(--c-border);
  padding: 8px 10px;
  vertical-align: top;
}
.transport-grid thead th {
  background: var(--c-surface2);
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  position: sticky; top: var(--nav-h);
  z-index: 5;
}
.transport-grid .col-masina {
  background: var(--c-surface2);
  font-weight: 600;
  white-space: nowrap;
  min-width: 130px;
}
.transport-grid td { min-width: 110px; }

.cell-nota {
  background: var(--c-surface);
  border-radius: var(--radius-sm);
  padding: 6px 8px; cursor: pointer;
  border: 1px solid var(--c-border);
  transition: box-shadow var(--transition);
}
.cell-nota:hover { box-shadow: var(--shadow); }
.cell-nota .nota-nr { font-weight: 600; font-size: .78rem; color: var(--c-primary); }
.cell-nota .nota-sofer { font-size: .75rem; color: var(--c-muted); }
.cell-nota .nota-masa  { font-size: .75rem; }

.cell-empty {
  text-align: center; color: var(--c-border);
  cursor: pointer; min-height: 48px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.cell-empty:hover { background: var(--c-surface2); color: var(--c-muted); }

/* ── Status badge ───────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 20px;
  font-size: .72rem; font-weight: 600;
  white-space: nowrap;
}
.badge-draft      { background: #fef9c3; color: #854d0e; }
.badge-finalizata { background: #dcfce7; color: #166534; }
.badge-arhivata   { background: #f3f4f6; color: #6b7280; }

/* ── Indicator capacitate ───────────────────────────────── */
.capacity-bar-wrap {
  display: flex; gap: 10px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.capacity-item {
  flex: 1; min-width: 140px;
  background: var(--c-surface2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  border-left: 4px solid var(--c-ok);
}
.capacity-item.warning { border-color: var(--c-warning); }
.capacity-item.danger  { border-color: var(--c-danger); }
.capacity-label { font-size: .72rem; font-weight: 600; color: var(--c-muted); text-transform: uppercase; letter-spacing: .04em; }
.capacity-value { font-size: 1rem; font-weight: 700; margin-top: 2px; }
.capacity-value.ok      { color: var(--c-ok); }
.capacity-value.warning { color: var(--c-warning); }
.capacity-value.danger  { color: var(--c-danger); }
.capacity-pct   { font-size: .78rem; color: var(--c-muted); }
.capacity-track {
  height: 5px; border-radius: 3px;
  background: var(--c-border);
  margin-top: 6px; overflow: hidden;
}
.capacity-fill {
  height: 100%; border-radius: 3px;
  background: var(--c-ok);
  transition: width .4s ease;
}
.capacity-fill.warning { background: var(--c-warning); }
.capacity-fill.danger  { background: var(--c-danger); }

/* ── Lista articole ─────────────────────────────────────── */
.articol-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--c-border);
  transition: background var(--transition);
  position: relative;
}
.articol-item:last-child { border-bottom: none; }
.articol-item:hover { background: var(--c-surface2); }
.art-nr {
  min-width: 24px; height: 24px;
  background: var(--c-surface2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700; color: var(--c-muted);
  flex-shrink: 0; margin-top: 1px;
}
.art-body { flex: 1; min-width: 0; }
.art-furnizor { font-weight: 600; font-size: .9rem; }
.art-prefix   { color: var(--c-primary); font-size: .78rem; font-weight: 700; }
.art-comanda  { color: var(--c-muted); font-size: .8rem; }
.art-dims {
  display: flex; gap: 10px; flex-wrap: wrap;
  margin-top: 4px;
}
.art-dim      { font-size: .78rem; color: var(--c-muted); }
.art-dim strong { color: var(--c-text); font-weight: 600; }
.art-estimat  { font-style: italic; color: var(--c-muted); }
.art-delete {
  background: none; border: none; cursor: pointer;
  color: var(--c-muted); padding: 4px; border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
  flex-shrink: 0;
}
.art-delete:hover { color: var(--c-danger); background: #fee2e2; }

/* ── Quick Input Bar ─────────────────────────────────────── */
.quick-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 200;
  background: var(--c-surface);
  border-top: 1px solid var(--c-border);
  padding: 8px 12px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -4px 20px rgba(0,0,0,.1);
}
.quick-bar-row {
  display: flex; gap: 6px; align-items: center;
  flex-wrap: wrap;
}
.quick-bar .form-control {
  padding: 10px 10px;
  font-size: .875rem;
}
.quick-bar .f-prefix  { width: 62px; flex-shrink: 0; text-transform: uppercase; }
.quick-bar .f-furnizor{ flex: 2; min-width: 120px; position: relative; }
.quick-bar .f-comanda { flex: 1.5; min-width: 100px; }
.quick-bar .f-masa    { width: 80px; flex-shrink: 0; }
.quick-bar .f-volum   { width: 70px; flex-shrink: 0; }
.quick-bar .f-lungime { width: 70px; flex-shrink: 0; }
.quick-bar .btn-add {
  min-width: 56px; min-height: 44px; font-size: 1.3rem;
  flex-shrink: 0;
}

/* Autocomplete dropdown */
.autocomplete-drop {
  position: absolute; bottom: calc(100% + 4px); left: 0; right: 0;
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  z-index: 300; max-height: 220px; overflow-y: auto;
}
.autocomplete-drop .ac-item {
  padding: 9px 12px; cursor: pointer;
  border-bottom: 1px solid var(--c-border);
  display: flex; gap: 8px; align-items: baseline;
  font-size: .875rem;
}
.autocomplete-drop .ac-item:last-child { border-bottom: none; }
.autocomplete-drop .ac-item:hover { background: var(--c-surface2); }
.autocomplete-drop .ac-code { font-weight: 700; color: var(--c-primary); min-width: 44px; }
.autocomplete-drop .ac-loc  { color: var(--c-muted); font-size: .75rem; }

/* ── Tabele admin ─────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.data-table th, .data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--c-border);
  text-align: left;
}
.data-table th { font-weight: 600; color: var(--c-muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--c-surface2); }
.data-table .actions { display: flex; gap: 6px; }

/* ── Modal ───────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,.45);
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: env(safe-area-inset-bottom);
}
@media (min-width: 600px) {
  .modal-backdrop { align-items: center; }
}
.modal {
  background: var(--c-surface);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%; max-width: 520px;
  max-height: 90dvh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp .2s ease;
}
@media (min-width: 600px) {
  .modal { border-radius: var(--radius); }
}
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } }
.modal-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center; gap: 10px;
}
.modal-header h3 { flex: 1; font-size: 1rem; font-weight: 600; }
.modal-body  { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.modal-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--c-border);
  display: flex; gap: 8px; justify-content: flex-end;
}

/* ── Toast ───────────────────────────────────────────────── */
.toast-wrap {
  position: fixed; bottom: calc(var(--bar-h) + 8px + env(safe-area-inset-bottom));
  right: 12px; z-index: 600;
  display: flex; flex-direction: column; gap: 6px;
  pointer-events: none;
}
.toast {
  padding: 10px 16px; border-radius: var(--radius-sm);
  font-size: .875rem; font-weight: 500;
  box-shadow: var(--shadow-lg); color: #fff;
  animation: fadeInUp .25s ease;
  pointer-events: auto;
}
@keyframes fadeInUp { from { opacity:0; transform:translateY(10px); } }
.toast-success { background: var(--c-success); }
.toast-error   { background: var(--c-danger); }

/* ── Print / PDF ─────────────────────────────────────────── */
@media print {
  .app-nav, .quick-bar, .btn, .no-print { display: none !important; }
  .page { margin: 0; padding: 0; }
  body { background: #fff; color: #000; font-size: 11pt; }

  .print-nota { max-width: 100%; padding: 0; }
  .print-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; }
  .print-firma  { font-size: 9pt; }
  .print-nr     { font-size: 14pt; font-weight: 700; }

  .print-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 9pt; }
  .print-table th, .print-table td {
    border: 1px solid #999; padding: 5px 6px; text-align: left;
  }
  .print-table th { background: #eee; font-weight: 700; }

  .print-footer { display: flex; justify-content: space-between; margin-top: 32px; }
  .print-sign   { border-top: 1px solid #000; min-width: 140px; padding-top: 4px; font-size: 9pt; text-align: center; }

  .capacity-bar-wrap, .articol-item .art-delete { display: none; }
}

/* ── Utilitare ───────────────────────────────────────────── */
.text-muted  { color: var(--c-muted); }
.text-sm     { font-size: .8rem; }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.gap-8 { gap: 8px; }
.flex  { display: flex; }
.flex-1{ flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.empty-state {
  text-align: center; padding: 40px 20px;
  color: var(--c-muted); font-size: .9rem;
}
.spinner {
  display: inline-block; width: 20px; height: 20px;
  border: 2px solid var(--c-border);
  border-top-color: var(--c-primary);
  border-radius: 50%; animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-center { display: flex; align-items: center; justify-content: center; padding: 48px; gap: 10px; }
