/* ─────────────────────────────────────────────────────────────────────────────
   BVL Theme — matches Blazor app palette exactly
   ───────────────────────────────────────────────────────────────────────────── */
:root {
  --color-primary:        #1a2744;
  --color-primary-dark:   #111b33;
  --color-primary-light:  #2d4070;
  --color-secondary:      #0288d1;
  --color-secondary-dark: #01579b;
  --color-bg:             #eef1f6;
  --color-bg-gray:        #f0f3f9;
  --color-surface:        #ffffff;
  --color-text:           #1a1f2e;
  --color-text-muted:     #5a6378;
  --color-border:         #dde3ee;
  --color-hover:          #e3f0fd;
  --color-success:        #2e7d32;
  --color-success-light:  #e8f5e9;
  --color-warning:        #f57f17;
  --color-warning-light:  #fff8e1;
  --color-error:          #c62828;
  --border-radius:        8px;
  --shadow-sm:            0 1px 3px rgba(0,0,0,0.08);
  --shadow-md:            0 2px 10px rgba(0,0,0,0.12);
  --header-height:        56px;
  --nav-height:           64px;
}

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

html {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  height: 100%;
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100dvh;
  overflow-x: hidden;
  height: 100%;
}

/* ── Utility ───────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ─────────────────────────────────────────────────────────────────────────────
   LOGIN SCREEN
   ───────────────────────────────────────────────────────────────────────────── */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 24px 20px;
}

.login-container {
  width: 100%;
  max-width: 380px;
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ── Card ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-md);
}

.login-card { padding: 28px 24px; }

/* ── Form Elements ─────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 20px; }

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  height: 50px;
  padding: 0 14px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--border-radius);
  font-size: 17px;
  color: var(--color-text);
  background: var(--color-bg);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
  font-family: inherit;
}

.form-group input:focus {
  border-color: var(--color-secondary);
  background: white;
}

.error-message {
  color: var(--color-error);
  font-size: 14px;
  margin-bottom: 16px;
  padding: 10px 14px;
  background: #ffebee;
  border-radius: var(--border-radius);
  border-left: 3px solid var(--color-error);
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 50px;
  padding: 0 20px;
  border: none;
  border-radius: var(--border-radius);
  font-size: 17px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primary { background: var(--color-primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--color-primary-light); }

.btn-success { background: var(--color-success); color: white; }
.btn-success:hover:not(:disabled) { background: #1b5e20; }

.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
  border: 1.5px solid var(--color-border);
  height: 44px;
  font-size: 15px;
}

.btn-full { width: 100%; }
.btn-large { height: 58px; font-size: 18px; width: 100%; }

/* ── Icon Button ───────────────────────────────────────────────────────────── */
.icon-btn {
  background: none;
  border: none;
  color: inherit;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}
.icon-btn:hover { background: rgba(255,255,255,0.12); }

/* ── Spinner (button) ──────────────────────────────────────────────────────── */
.btn-spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

/* ─────────────────────────────────────────────────────────────────────────────
   APP SHELL
   ───────────────────────────────────────────────────────────────────────────── */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

/* ── Sync Banner ───────────────────────────────────────────────────────────── */
.sync-banner {
  background: #fff3e0;
  border-bottom: 2px solid #ff8f00;
  color: #e65100;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  flex-shrink: 0;
  z-index: 20;
}

/* ── App Header ────────────────────────────────────────────────────────────── */
.app-header {
  background: var(--color-primary);
  color: white;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  z-index: 10;
}

.route-name {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

/* ── Content Area ──────────────────────────────────────────────────────────── */
.content-area {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.view {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
}

/* ── Pull-to-Refresh Indicator ─────────────────────────────────────────────── */
.ptr-indicator {
  text-align: center;
  padding: 12px;
  color: var(--color-text-muted);
  font-size: 13px;
  height: 0;
  overflow: hidden;
  transition: height 0.2s ease;
}

.ptr-indicator.visible {
  height: 44px;
}

/* ── Bottom Navigation ─────────────────────────────────────────────────────── */
.bottom-nav {
  background: #fff;
  border-top: 1px solid var(--color-border);
  height: 52px;
  display: flex;
  flex-shrink: 0;
  padding-bottom: env(safe-area-inset-bottom);
}

.nav-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--color-text-muted);
  font-size: 15px;
  font-weight: 400;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.nav-tab.active {
  background: var(--color-primary);
  color: #fff;
  font-weight: 500;
}

/* ── Loading Spinner ───────────────────────────────────────────────────────── */
.spinner-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 16px;
  color: var(--color-text-muted);
  font-size: 15px;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-secondary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ─────────────────────────────────────────────────────────────────────────────
   CHARGEMENT TAB
   ───────────────────────────────────────────────────────────────────────────── */
.summary-badge {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  padding: 7px 18px;
  font-size: 14px;
  color: var(--color-text-muted);
  text-align: center;
  margin-bottom: 16px;
  font-weight: 500;
}

.summary-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--color-bg-gray);
  padding: 10px 16px;
  font-size: 14px;
  color: var(--color-text-muted);
}

.product-section {
  background: var(--color-surface);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
  overflow: hidden;
  border: 1px solid var(--color-border);
}

.product-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-gray);
}

.section-pill {
  padding: 3px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.pill-pleine { background: var(--color-primary);   color: white; }
.pill-vide   { background: #607d8b;                color: white; }
.pill-jus    { background: var(--color-secondary);  color: white; }

.section-total {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-left: auto;
}

.product-list { padding: 2px 0; }

.product-row {
  display: flex;
  align-items: center;
  padding: 11px 16px;
  border-bottom: 1px solid var(--color-border);
  gap: 6px;
}
.product-row:last-child { border-bottom: none; }

.product-qty {
  font-weight: 700;
  font-size: 18px;
  color: var(--color-primary);
  min-width: 36px;
}

.product-code {
  font-size: 17px;
  font-family: 'Courier New', monospace;
  color: var(--color-text);
}

/* ─────────────────────────────────────────────────────────────────────────────
   LIVRAISONS TAB
   ───────────────────────────────────────────────────────────────────────────── */
.delivery-list { display: flex; flex-direction: column; gap: 10px; }

.delivery-card {
  background: var(--color-surface);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  padding: 12px 14px;
  cursor: pointer;
  transition: border-left-color 0.2s, background 0.2s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  border: 0.5px solid var(--color-border);
  border-left: 4px solid #dde3ee;
}

.delivery-card:active { background: var(--color-hover); }

.delivery-card.done {
  border-left-color: #2e7d32;
  background: #f1f8f1;
}

/* ── Status Badges ─────────────────────────────────────────────────────────── */
.status-done {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #2e7d32;
  color: white;
  font-size: 13px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 12px;
}

.status-pending {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #f0f3f9;
  color: #5a6378;
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 12px;
}

/* ─────────────────────────────────────────────────────────────────────────────
   DETAIL PANEL (slides in from right)
   ───────────────────────────────────────────────────────────────────────────── */
.detail-panel {
  position: fixed;
  inset: 0;
  background: var(--color-bg);
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 50;
  display: flex;
  flex-direction: column;
}

.detail-panel.open { transform: translateX(0); }

.detail-header {
  background: var(--color-primary);
  color: white;
  height: var(--header-height);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px 0 4px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}

.back-btn {
  background: none;
  border: none;
  color: white;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}
.back-btn:hover { background: rgba(255,255,255,0.12); }

.detail-title-area { min-width: 0; flex: 1; }

.detail-name {
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.detail-bvlid {
  font-size: 12px;
  opacity: 0.72;
  font-family: 'Courier New', monospace;
  display: block;
}

.detail-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  padding-bottom: 40px;
}

/* ── Info Sections (in detail) ─────────────────────────────────────────────── */
.info-section {
  background: var(--color-surface);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
  overflow: hidden;
  border: 1px solid var(--color-border);
}

.info-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--color-text-muted);
  padding: 9px 16px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-gray);
  display: flex;
  align-items: center;
  gap: 8px;
}

.info-row {
  display: flex;
  padding: 13px 16px;
  border-bottom: 1px solid var(--color-border);
  gap: 12px;
  align-items: flex-start;
}
.info-row:last-child { border-bottom: none; }

.info-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
  min-width: 78px;
  flex-shrink: 0;
  padding-top: 2px;
}

.info-value {
  font-size: 17px;
  color: var(--color-text);
  flex: 1;
  line-height: 1.35;
}

.info-value a {
  color: var(--color-secondary);
  text-decoration: none;
}

.badge-exclusif {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff3e0;
  color: #e65100;
  border: 1px solid #ffcc80;
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 14px;
  font-weight: 600;
}

/* ── Collect payment badge (delivery card) ────────────────────────────────── */
.badge-collect-payment {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #c62828;
  color: #fff;
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 700;
}

/* ── Collect payment banner (detail panel) ────────────────────────────────── */
.collect-payment-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #c62828;
  color: #fff;
  padding: 14px 16px;
  font-size: 16px;
  font-weight: 600;
  border-bottom: 1px solid #b71c1c;
}

.collect-payment-icon {
  font-size: 22px;
  font-weight: 900;
}

/* ── Inventory badge (delivery card) ──────────────────────────────────────── */
.badge-inventaire {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff8e1;
  color: #e65100;
  border: 1px solid #ffcc02;
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 700;
}

.badge-inventaire-done {
  background: #e8f5e9;
  color: #2e7d32;
  border-color: #a5d6a7;
  font-weight: 600;
}

/* ── Inventory section (detail panel) ─────────────────────────────────────── */
.inventory-section {
  padding: 16px;
  border-bottom: 1px solid var(--color-border);
}

.inventory-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  color: #e65100;
  margin-bottom: 12px;
}

.inventory-icon {
  font-size: 20px;
}

.inventory-section.inventory-done {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #e8f5e9;
  border-bottom-color: #a5d6a7;
  color: #2e7d32;
  font-size: 15px;
  font-weight: 600;
}

.inventory-section.inventory-done > div {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-inventory {
  background: #e65100;
  color: white;
  width: 100%;
  padding: 14px;
  font-size: 16px;
  font-weight: 600;
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
  letter-spacing: 0.3px;
}

.btn-inventory:active { background: #bf360c; }

/* ── Products in detail ────────────────────────────────────────────────────── */
.detail-product-sub {
  border-bottom: 1px solid var(--color-border);
}
.detail-product-sub:last-child { border-bottom: none; }

.detail-product-sub-header {
  padding: 8px 16px;
  background: var(--color-bg-gray);
  border-bottom: 1px solid var(--color-border);
}

.detail-product-row {
  padding: 11px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--color-border);
  font-size: 17px;
}
.detail-product-row:last-child { border-bottom: none; }

/* ── Notes card ────────────────────────────────────────────────────────────── */
.notes-card {
  background: var(--color-warning-light);
  border: 1px solid #ffe082;
  border-radius: var(--border-radius);
  padding: 14px 16px;
  margin-bottom: 14px;
}

.notes-card-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #c17900;
  margin-bottom: 8px;
}

.notes-card-text {
  font-size: 16px;
  color: #5d4037;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Driver Note ───────────────────────────────────────────────────────────── */
.driver-note-section {
  background: var(--color-surface);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
  overflow: hidden;
  border: 1px solid var(--color-border);
}

.driver-note-textarea {
  width: 100%;
  min-height: 90px;
  padding: 13px 16px;
  border: none;
  border-top: 1px solid var(--color-border);
  font-size: 16px;
  font-family: inherit;
  color: var(--color-text);
  resize: none;
  outline: none;
  background: var(--color-surface);
  display: block;
}
.driver-note-textarea::placeholder { color: #aab2c0; }

.note-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px 12px;
  justify-content: flex-end;
}

.note-save-btn {
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: var(--border-radius);
  padding: 10px 20px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  min-height: 44px;
  transition: opacity 0.2s;
}

.note-save-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.note-save-btn.loading {
  opacity: 0.7;
  cursor: not-allowed;
}

.note-status {
  font-size: 13px;
  transition: opacity 0.5s;
}

.note-status.success { color: #2e7d32; }
.note-status.offline { color: #e65100; }
.note-status.error   { color: #c62828; }

/* ── Save Icon Button (note + invoice) ─────────────────────────────────────── */
.save-icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: #2e7d32;
  color: white;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.2s, background 0.2s;
}
.save-icon-btn:disabled {
  background: #dde3ee;
  color: #5a6378;
  cursor: not-allowed;
}
.save-icon-btn.loading {
  background: #1b5e20;
  cursor: not-allowed;
}

/* ── Action Section ────────────────────────────────────────────────────────── */
.action-section { margin-bottom: 14px; }

.success-banner {
  background: var(--color-success-light);
  border: 1px solid #a5d6a7;
  border-radius: var(--border-radius);
  padding: 18px 16px;
  color: var(--color-success);
  font-size: 18px;
  font-weight: 600;
}

.success-banner .success-time {
  display: block;
  font-size: 14px;
  font-weight: 400;
  margin-top: 4px;
  color: #388e3c;
}

/* ── Undo completion link ──────────────────────────────────────────────────── */
.undo-link {
  display: block;
  width: 100%;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 13px;
  color: var(--color-text-muted);
  text-decoration: underline;
  text-align: center;
  cursor: pointer;
  margin-top: 12px;
  padding: 8px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.undo-link:hover { color: var(--color-error); }

.offline-note {
  font-size: 13px;
  color: var(--color-text-muted);
  text-align: center;
  margin-top: 10px;
  padding: 8px;
  background: #fff8e1;
  border-radius: var(--border-radius);
  border: 1px solid #ffe082;
}

/* ─────────────────────────────────────────────────────────────────────────────
   LOGIN — ROUTE SELECTOR
   ───────────────────────────────────────────────────────────────────────────── */

/* Loading spinner row */
.routes-loading-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 2px 16px;
  color: var(--color-text-muted);
  font-size: 15px;
}

.routes-spinner {
  width: 22px;
  height: 22px;
  border: 2.5px solid var(--color-border);
  border-top-color: var(--color-secondary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

/* Route dropdown */
.route-select {
  width: 100%;
  height: 56px;
  padding: 0 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  background: white;
  color: var(--color-text);
  font-size: 16px;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  appearance: auto; /* keep native OS chevron */
  transition: border-color 0.15s;
}

.route-select:focus {
  border-color: var(--color-secondary);
}

/* Stale-cache indicator below select */
.routes-cache-note {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 6px;
}

/* Offline / no-cache notice above manual input */
.routes-offline-msg {
  font-size: 14px;
  color: var(--color-warning);
  background: var(--color-warning-light);
  border: 1px solid #ffe082;
  border-radius: var(--border-radius);
  padding: 10px 14px;
  margin-bottom: 10px;
  font-weight: 500;
}

/* Se connecter button — secondary blue */
.login-submit-btn {
  background: var(--color-secondary);
  color: white;
}
.login-submit-btn:hover:not(:disabled) {
  background: var(--color-secondary-dark);
}

/* ── Confirmation Dialog ───────────────────────────────────────────────────── */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.dialog-box {
  background: var(--color-surface);
  border-radius: var(--border-radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.22);
  padding: 24px;
  width: 100%;
  max-width: 340px;
}

.dialog-message {
  font-size: 17px;
  color: var(--color-text);
  margin-bottom: 24px;
  line-height: 1.45;
}

.dialog-box--payment {
  border-top: 4px solid #c62828;
}

.dialog-box--payment .dialog-message {
  color: #c62828;
  font-weight: 600;
}

.dialog-box--payment #dialog-confirm {
  background: #c62828;
}
.dialog-box--payment #dialog-confirm:hover:not(:disabled) {
  background: #b71c1c;
}

.dialog-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}
