/* ============================================================
   TIKOO LIVREURS APP — Styles mobile-first
   Couleur principale : #f97316 (orange)
   ============================================================ */

:root {
  --pri:    #f97316;
  --pri-dk: #ea6c0a;
  --pri-lt: #fff7ed;
  --sec:    #1e293b;
  --muted:  #64748b;
  --border: #e2e8f0;
  --bg:     #f1f5f9;
  --white:  #ffffff;
  --success:#16a34a;
  --danger: #dc2626;
  --warning:#d97706;
  --info:   #2563eb;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0,0,0,.08);
  --nav-h:  60px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--sec);
  padding-bottom: calc(var(--nav-h) + 8px);
  min-height: 100vh;
}
a { color: var(--pri); text-decoration: none; }
button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--sec);
  color: white;
  padding: .75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.topbar-brand {
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.topbar-brand span { color: var(--pri); }
.topbar-right { display: flex; align-items: center; gap: .75rem; }
.topbar-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--pri);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem;
  text-decoration: none;
}
.topbar-badge {
  background: var(--danger);
  color: white;
  border-radius: 50%;
  width: 18px; height: 18px;
  font-size: .65rem;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
}

/* ============================================================
   BOTTOM NAV
   ============================================================ */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--white);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 200;
  box-shadow: 0 -2px 12px rgba(0,0,0,.08);
}
.nav-item {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 2px;
  color: var(--muted);
  font-size: .65rem;
  font-weight: 600;
  text-decoration: none;
  transition: color .15s;
  padding: 6px 0;
  position: relative;
}
.nav-item svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; }
.nav-item.active { color: var(--pri); }
.nav-item.active svg { stroke: var(--pri); }
.nav-badge {
  position: absolute;
  top: 4px; right: calc(50% - 20px);
  background: var(--danger);
  color: white;
  border-radius: 8px;
  padding: 0 4px;
  font-size: .6rem;
  font-weight: 700;
  min-width: 16px;
  text-align: center;
}

/* ============================================================
   PAGE WRAPPER
   ============================================================ */
.page { max-width: 520px; margin: 0 auto; padding: .75rem; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1rem;
  margin-bottom: .75rem;
  box-shadow: var(--shadow);
}
.card-title {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: .05em;
  margin-bottom: .75rem;
  display: flex;
  align-items: center;
  gap: .4rem;
}

/* ============================================================
   STAT CARDS (dashboard)
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .5rem;
  margin-bottom: .75rem;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: .875rem .75rem;
  border: 1px solid var(--border);
  text-align: center;
}
.stat-card.urgent { border-color: var(--danger); background: #fef2f2; }
.stat-card.success-c { border-color: var(--success); background: #f0fdf4; }
.stat-val {
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: .25rem;
}
.stat-lbl {
  font-size: .7rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
}

/* ============================================================
   BADGES STATUTS
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: .2rem .5rem;
  border-radius: 4px;
  font-size: .7rem;
  font-weight: 700;
}
.badge-en_attente    { background:#eff6ff; color:#1d4ed8; }
.badge-en_cours      { background:#fff7ed; color:#c2410c; }
.badge-livre         { background:#f0fdf4; color:#15803d; }
.badge-annule        { background:#fef2f2; color:#b91c1c; }
.badge-reprogramme   { background:#fefce8; color:#a16207; }
.badge-retour_fournisseur { background:#faf5ff; color:#7e22ce; }

/* ============================================================
   COMMANDE CARDS (liste)
   ============================================================ */
.cmd-card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: .625rem;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.cmd-card.urgent   { border-left: 3px solid var(--danger); }
.cmd-card.retard   { border-left: 3px solid var(--danger); background: #fff5f5; }
.cmd-card.warning  { border-left: 3px solid var(--warning); }

.cmd-card-body    { padding: .75rem; }
.cmd-ref          { font-size: .7rem; color: var(--muted); font-family: monospace; }
.cmd-client       { font-weight: 700; font-size: .95rem; margin: .25rem 0; }
.cmd-produits     { font-size: .8rem; color: var(--muted); margin-bottom: .375rem; }
.cmd-meta         { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.cmd-montant      { font-weight: 800; color: var(--success); }
.cmd-date         { font-size: .75rem; color: var(--muted); }

.cmd-actions {
  display: flex;
  padding: .5rem .75rem;
  gap: .375rem;
  border-top: 1px solid var(--border);
  background: #f8fafc;
  flex-wrap: wrap;
}

/* ============================================================
   BOUTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: .35rem;
  padding: .5rem 1rem;
  border-radius: 8px;
  border: none;
  font-weight: 600;
  font-size: .82rem;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 3px 8px rgba(0,0,0,.15); }
.btn-sm { padding: .3rem .6rem; font-size: .72rem; border-radius: 6px; }
.btn-lg { padding: .75rem 1.5rem; font-size: .95rem; }
.btn-full { width: 100%; justify-content: center; }

.btn-pri    { background: var(--pri);    color: white; }
.btn-pri:hover { background: var(--pri-dk); color: white; }
.btn-sec    { background: var(--sec);    color: white; }
.btn-success{ background: var(--success); color: white; }
.btn-danger { background: var(--danger);  color: white; }
.btn-warning{ background: var(--warning); color: white; }
.btn-outline{ background: transparent; border: 1.5px solid var(--border); color: var(--sec); }
.btn-ghost  { background: transparent; border: 1.5px solid var(--pri); color: var(--pri); }

/* FAB (Floating Action Button) */
.fab {
  position: fixed;
  bottom: calc(var(--nav-h) + 16px);
  right: 1rem;
  width: 54px; height: 54px;
  border-radius: 50%;
  background: var(--pri);
  color: white;
  border: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  box-shadow: 0 4px 16px rgba(249,115,22,.45);
  cursor: pointer;
  z-index: 150;
  text-decoration: none;
  transition: all .2s;
}
.fab:hover { transform: scale(1.1); box-shadow: 0 6px 20px rgba(249,115,22,.55); }

/* ============================================================
   FORMULAIRES
   ============================================================ */
.form-group { margin-bottom: .875rem; }
.form-label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  margin-bottom: .35rem;
  color: var(--sec);
}
.form-label .req { color: var(--danger); margin-left: 2px; }
.form-control {
  width: 100%;
  padding: .65rem .875rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: .9rem;
  background: white;
  transition: border-color .15s;
  -webkit-appearance: none;
}
.form-control:focus {
  outline: none;
  border-color: var(--pri);
  box-shadow: 0 0 0 3px rgba(249,115,22,.12);
}
.form-control.is-invalid { border-color: var(--danger); }
.form-text { font-size: .75rem; color: var(--muted); margin-top: .25rem; }
.invalid-feedback { font-size: .75rem; color: var(--danger); margin-top: .25rem; }

/* Produit row dans nouvelle commande */
.produit-row {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .625rem;
  margin-bottom: .5rem;
  position: relative;
}
.produit-row .btn-remove {
  position: absolute; top: .4rem; right: .4rem;
  background: transparent; border: none;
  color: var(--danger); cursor: pointer; font-size: 1rem;
}

/* ============================================================
   FLASH MESSAGES
   ============================================================ */
.flash-msg {
  padding: .75rem 1rem;
  border-radius: 8px;
  font-size: .85rem;
  font-weight: 600;
  margin-bottom: .75rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.flash-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.flash-error   { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.flash-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.flash-info    { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* ============================================================
   ALERT URGENCE
   ============================================================ */
.alert-urgent {
  background: var(--danger);
  color: white;
  padding: .625rem .875rem;
  border-radius: 8px;
  font-size: .82rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .75rem;
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.75} }

/* ============================================================
   LISTES ITEMS (fournisseurs, catalogue...)
   ============================================================ */
.item-list { display: flex; flex-direction: column; gap: .5rem; }
.item-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  box-shadow: var(--shadow);
}
.item-icon {
  width: 42px; height: 42px; border-radius: 10px;
  background: var(--pri-lt);
  color: var(--pri);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.item-body { flex: 1; min-width: 0; }
.item-name { font-weight: 700; font-size: .9rem; }
.item-sub  { font-size: .75rem; color: var(--muted); margin-top: .1rem; }
.item-actions { display: flex; gap: .375rem; flex-shrink: 0; }

/* ============================================================
   PAGE AUTH
   ============================================================ */
.auth-page {
  min-height: 100vh;
  background: var(--sec);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  padding-bottom: 1rem; /* pas de nav sur ces pages */
}
body.auth-body { padding-bottom: 0; }
.auth-logo {
  font-size: 2rem;
  font-weight: 800;
  color: white;
  margin-bottom: .25rem;
}
.auth-logo span { color: var(--pri); }
.auth-sub { color: var(--muted); font-size: .85rem; margin-bottom: 2rem; text-align: center; }
.auth-box {
  background: white;
  border-radius: 16px;
  padding: 1.5rem;
  width: 100%; max-width: 400px;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
}
.auth-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  color: var(--sec);
}

/* ============================================================
   PAGE ABONNEMENT
   ============================================================ */
.plan-card {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: .75rem;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
}
.plan-card.selected, .plan-card:hover {
  border-color: var(--pri);
  background: var(--pri-lt);
}
.plan-prix { font-size: 1.75rem; font-weight: 800; color: var(--pri); }
.plan-nom  { font-weight: 700; font-size: 1rem; margin-bottom: .25rem; }
.plan-duree{ font-size: .8rem; color: var(--muted); }

/* ============================================================
   CARTE (navigation GPS)
   ============================================================ */
#map { height: calc(100vh - var(--nav-h) - 56px); width: 100%; }
.map-overlay {
  position: absolute; bottom: calc(var(--nav-h) + 12px); left: .5rem; right: .5rem;
  background: white;
  border-radius: var(--radius);
  padding: .875rem;
  box-shadow: var(--shadow);
  z-index: 400;
}
.map-page-wrapper { position: relative; }

/* ============================================================
   RAPPORT
   ============================================================ */
.rapport-table { width: 100%; border-collapse: collapse; font-size: .8rem; }
.rapport-table th { background: var(--sec); color: white; padding: .5rem .625rem; text-align: left; }
.rapport-table td { padding: .5rem .625rem; border-bottom: 1px solid var(--border); }
.rapport-table tr:nth-child(even) td { background: #f8fafc; }

/* ============================================================
   NOTATION
   ============================================================ */
.star-rating { display: flex; gap: .375rem; justify-content: center; margin: 1rem 0; }
.star { font-size: 2.5rem; cursor: pointer; color: #d1d5db; transition: color .15s; }
.star.active, .star:hover ~ .star.active { color: #f59e0b; }
.star:hover, .star:hover ~ .star { color: #f59e0b; }

/* ============================================================
   UTILS
   ============================================================ */
.text-pri     { color: var(--pri); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-muted   { color: var(--muted); }
.text-center  { text-align: center; }
.fw-700       { font-weight: 700; }
.fw-800       { font-weight: 800; }
.mt-1  { margin-top: .25rem; }
.mt-2  { margin-top: .5rem; }
.mt-3  { margin-top: .75rem; }
.mb-1  { margin-bottom: .25rem; }
.mb-2  { margin-bottom: .5rem; }
.mb-3  { margin-bottom: .75rem; }
.p-3   { padding: .75rem; }
.flex  { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: .5rem; }
.gap-3 { gap: .75rem; }
.w-full { width: 100%; }
.hidden { display: none; }
.divider { border: none; border-top: 1px solid var(--border); margin: .875rem 0; }

/* Section titre */
.section-title {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: .5rem;
  letter-spacing: .05em;
}
/* Empty state */
.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--muted);
}
.empty-state-icon { font-size: 3rem; margin-bottom: .5rem; }
.empty-state p { font-size: .9rem; }

/* Montant highlight */
.montant-hl {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--success);
}

/* Filtre bar */
.filter-bar {
  display: flex;
  gap: .375rem;
  overflow-x: auto;
  padding-bottom: .375rem;
  margin-bottom: .75rem;
  scrollbar-width: none;
}
.filter-bar::-webkit-scrollbar { display: none; }
.filter-chip {
  flex-shrink: 0;
  padding: .35rem .75rem;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
  border: 1.5px solid var(--border);
  background: white;
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
  transition: all .15s;
}
.filter-chip.active, .filter-chip:hover {
  border-color: var(--pri);
  background: var(--pri-lt);
  color: var(--pri);
}

/* Offline banner */
.offline-banner {
  background: #1e293b;
  color: #94a3b8;
  text-align: center;
  font-size: .75rem;
  padding: .35rem;
  position: sticky;
  top: 52px;
  z-index: 99;
  display: none;
}
.offline-banner.visible { display: block; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 500;
  display: flex; align-items: flex-end; justify-content: center;
  backdrop-filter: blur(2px);
}
.modal-box {
  background: white;
  border-radius: 16px 16px 0 0;
  padding: 1.25rem;
  width: 100%; max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  animation: slideUp .25s ease;
}
@keyframes slideUp { from{transform:translateY(100%)} to{transform:translateY(0)} }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-weight: 700; font-size: 1rem; }
.modal-close {
  background: none; border: none; font-size: 1.25rem;
  cursor: pointer; color: var(--muted);
}
