/* Logisti-Mécano — Design dark mode industriel */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  --bg-dark: #0d0f1a;
  --bg-card: #141625;
  --bg-card2: #1c1f35;
  --bg-hover: #232640;
  --accent: #f97316;
  --accent-dim: #c2560f;
  --accent-glow: rgba(249,115,22,0.25);
  --blue: #3b82f6;
  --blue-dim: #1d4ed8;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #eab308;
  --text: #e2e8f0;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  --border: rgba(255,255,255,0.08);
  --border-accent: rgba(249,115,22,0.4);
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-accent: 0 4px 24px rgba(249,115,22,0.2);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --transition: 0.2s cubic-bezier(0.4,0,0.2,1);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--bg-hover); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-dim); }

/* ── Nav ───────────────────────────────────────────────────── */
.navbar {
  position: sticky; top: 0; z-index: 100;
  background: rgba(13,15,26,0.92);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  height: 64px;
  display: flex; align-items: center; justify-content: space-between;
}

.navbar-brand {
  display: flex; align-items: center; gap: 12px;
  text-decoration: none;
}

.navbar-logo {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  box-shadow: var(--shadow-accent);
}

.navbar-title {
  font-size: 1.1rem; font-weight: 700;
  background: linear-gradient(135deg, #fff, var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

.navbar-subtitle { font-size: 0.65rem; color: var(--text-muted); font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase; }

.navbar-nav {
  display: flex; align-items: center; gap: 4px;
  list-style: none;
}

.nav-link {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-dim);
  font-size: 0.875rem; font-weight: 500;
  transition: var(--transition);
}

.nav-link:hover, .nav-link.active {
  background: var(--bg-card2);
  color: var(--text);
}

.nav-link.active { color: var(--accent); }

.nav-link .nav-icon { font-size: 1rem; }

/* ── Layout ────────────────────────────────────────────────── */
.container { max-width: 1400px; margin: 0 auto; padding: 2rem; }
.page-header { margin-bottom: 2rem; }
.page-title { font-size: 1.75rem; font-weight: 800; margin-bottom: 0.25rem; }
.page-subtitle { color: var(--text-muted); font-size: 0.9rem; }

.grid { display: grid; gap: 1.5rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  transition: var(--transition);
}

.card:hover { border-color: rgba(255,255,255,0.12); }
.card-accent { border-color: var(--border-accent); box-shadow: var(--shadow-accent); }

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.25rem; padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 1rem; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
}

.card-title .icon {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem;
}

/* ── Stat Cards ────────────────────────────────────────────── */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  display: flex; align-items: center; gap: 1rem;
  transition: var(--transition);
}

.stat-card:hover { transform: translateY(-2px); border-color: var(--border-accent); box-shadow: var(--shadow-accent); }

.stat-icon {
  width: 48px; height: 48px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 1.4rem;
}

.stat-icon.orange { background: rgba(249,115,22,0.15); }
.stat-icon.blue { background: rgba(59,130,246,0.15); }
.stat-icon.green { background: rgba(34,197,94,0.15); }
.stat-icon.yellow { background: rgba(234,179,8,0.15); }

.stat-value { font-size: 1.8rem; font-weight: 800; line-height: 1; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; margin-top: 2px; }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px;
  border: none; border-radius: var(--radius-sm);
  font-family: inherit; font-size: 0.875rem; font-weight: 600;
  cursor: pointer; text-decoration: none;
  transition: var(--transition);
  white-space: nowrap;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  color: white;
  box-shadow: 0 2px 12px rgba(249,115,22,0.3);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 4px 20px rgba(249,115,22,0.45); }

.btn-secondary { background: var(--bg-card2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-hover); border-color: var(--border-accent); }

.btn-blue { background: linear-gradient(135deg, var(--blue), var(--blue-dim)); color: white; }
.btn-blue:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(59,130,246,0.4); }

.btn-green { background: linear-gradient(135deg, #16a34a, #15803d); color: white; }
.btn-green:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(34,197,94,0.35); }

.btn-red { background: rgba(239,68,68,0.15); color: var(--red); border: 1px solid rgba(239,68,68,0.3); }
.btn-red:hover:not(:disabled) { background: rgba(239,68,68,0.25); }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }
.btn-full { width: 100%; justify-content: center; }

/* ── Forms ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-label {
  display: block; margin-bottom: 6px;
  font-size: 0.8rem; font-weight: 600;
  color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em;
}

.form-control {
  width: 100%;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text);
  font-family: inherit; font-size: 0.9rem;
  transition: var(--transition);
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-control::placeholder { color: var(--text-muted); }
select.form-control { cursor: pointer; }
select.form-control option { background: var(--bg-card2); }

.form-row { display: grid; gap: 1rem; }
.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ── Tables ────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; border-radius: var(--radius); }

table { width: 100%; border-collapse: collapse; }

th {
  padding: 12px 16px;
  text-align: left;
  font-size: 0.75rem; font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.08em;
  background: var(--bg-dark);
  border-bottom: 1px solid var(--border);
}

td {
  padding: 12px 16px;
  font-size: 0.875rem;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.02); }

/* ── Badges / Tags ─────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 0.75rem; font-weight: 600;
}

.badge-orange { background: rgba(249,115,22,0.15); color: var(--accent); }
.badge-blue { background: rgba(59,130,246,0.15); color: #60a5fa; }
.badge-green { background: rgba(34,197,94,0.15); color: var(--green); }
.badge-red { background: rgba(239,68,68,0.15); color: #f87171; }
.badge-yellow { background: rgba(234,179,8,0.15); color: var(--yellow); }
.badge-gray { background: rgba(100,116,139,0.15); color: var(--text-muted); }

/* ── Upload Zone ───────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.upload-zone input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}

.upload-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.upload-text { color: var(--text-dim); font-size: 0.9rem; }
.upload-text strong { color: var(--accent); }

/* ── Steps / Tournée ───────────────────────────────────────── */
.step-item {
  display: flex; align-items: flex-start; gap: 1rem;
  padding: 1rem;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: var(--transition);
  position: relative;
}

.step-item:hover { border-color: rgba(255,255,255,0.12); }
.step-item.livree { opacity: 0.6; }
.step-item.livree .step-num { background: var(--green); }

.step-num {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 0.875rem;
}

.step-connector {
  position: absolute; left: 29px; top: 100%; width: 2px; height: 1rem;
  background: var(--border); z-index: 0;
}

.step-body { flex: 1; }
.step-client { font-weight: 700; font-size: 0.95rem; }
.step-address { color: var(--text-muted); font-size: 0.82rem; margin-top: 2px; }
.step-meta { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.step-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* ── Map ───────────────────────────────────────────────────── */
#map {
  width: 100%; height: 420px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  background: #1a1a2e;
}

/* ── Progress ──────────────────────────────────────────────── */
.progress-bar {
  background: var(--bg-dark);
  border-radius: 100px; height: 8px; overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--yellow));
  border-radius: 100px;
  transition: width 0.5s ease;
}

/* ── Toggle / Checkbox ─────────────────────────────────────── */
.toggle-group {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.toggle-group:hover { border-color: var(--accent); }
.toggle-group input { display: none; }

.toggle-switch {
  width: 44px; height: 24px; border-radius: 12px;
  background: var(--bg-hover); position: relative; flex-shrink: 0;
  transition: var(--transition);
}

.toggle-switch::after {
  content: ''; position: absolute;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--text-muted); top: 3px; left: 3px;
  transition: var(--transition);
}

.toggle-group input:checked + .toggle-switch { background: var(--accent); }
.toggle-group input:checked + .toggle-switch::after { left: 23px; background: white; }

.toggle-label { font-size: 0.875rem; font-weight: 500; }
.toggle-desc { font-size: 0.78rem; color: var(--text-muted); }

/* ── Alerts ────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  display: flex; align-items: flex-start; gap: 10px;
  margin-bottom: 1rem;
}

.alert-info { background: rgba(59,130,246,0.1); border: 1px solid rgba(59,130,246,0.3); color: #93c5fd; }
.alert-success { background: rgba(34,197,94,0.1); border: 1px solid rgba(34,197,94,0.3); color: #86efac; }
.alert-warning { background: rgba(234,179,8,0.1); border: 1px solid rgba(234,179,8,0.3); color: #fde047; }
.alert-error { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); color: #fca5a5; }

/* ── Loading Spinner ───────────────────────────────────────── */
.spinner {
  width: 24px; height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  position: fixed; inset: 0; z-index: 999;
  background: rgba(13,15,26,0.8); backdrop-filter: blur(4px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem;
  display: none;
}
.loading-overlay.active { display: flex; }
.loading-text { color: var(--text-dim); font-size: 0.9rem; }

/* ── Toast notifications ───────────────────────────────────── */
.toast-container {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 1000;
  display: flex; flex-direction: column; gap: 8px;
}

.toast {
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem; font-weight: 500;
  box-shadow: var(--shadow);
  animation: slideIn 0.3s ease;
  max-width: 320px;
}

.toast-success { background: #166534; border: 1px solid #16a34a; color: #bbf7d0; }
.toast-error { background: #7f1d1d; border: 1px solid #ef4444; color: #fecaca; }
.toast-info { background: #1e3a5f; border: 1px solid #3b82f6; color: #bfdbfe; }

@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Driver Interface (Tablette optimisée) ─────────────────── */
.driver-header {
  background: linear-gradient(135deg, var(--bg-card), var(--bg-card2));
  border-bottom: 1px solid var(--border);
  padding: 1.5rem 2rem;
  position: sticky; top: 64px; z-index: 50;
}

.driver-progress-info {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;
}

.step-card-driver {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  transition: var(--transition);
}

.step-card-driver:hover { border-color: var(--border-accent); }
.step-card-driver.completed { opacity: 0.5; border-color: rgba(34,197,94,0.3); }
.step-card-driver.active-step { border-color: var(--accent); box-shadow: var(--shadow-accent); }

.step-number-big {
  font-size: 2rem; font-weight: 800;
  color: var(--accent); line-height: 1;
}

.gps-btn {
  font-size: 1.1rem;
  padding: 12px 20px;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .navbar { padding: 0 1rem; }
  .navbar-subtitle { display: none; }
  .nav-link span:not(.nav-icon) { display: none; }
  .container { padding: 1rem; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
  .page-title { font-size: 1.35rem; }
  #map { height: 280px; }
}

/* ── Animations utilitaires ────────────────────────────────── */
.fade-in { animation: fadeIn 0.4s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.pulse { animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.6; } }

/* ── Divers ────────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 1.5rem 0; }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-right { text-align: right; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.gap-sm { gap: 8px; }
.gap-md { gap: 1rem; }
.gap-lg { gap: 1.5rem; }
.mt-sm { margin-top: 0.5rem; }
.mt-md { margin-top: 1rem; }
.mt-lg { margin-top: 1.5rem; }
.mb-sm { margin-bottom: 0.5rem; }
.mb-md { margin-bottom: 1rem; }
.hidden { display: none !important; }
.w-full { width: 100%; }
