/* JConvoyage App - Charte gold & black premium */

:root {
  --gold: #d4af37;
  --gold-bright: #e4c458;
  --gold-dim: #a88a2a;
  --black: #0a0a0a;
  --black-soft: #1a1a1a;
  --black-card: #161616;
  --gray: #888;
  --gray-light: #ccc;
  --white: #fff;
  --red: #c0392b;
  --green: #27ae60;
  --orange: #e67e22;
  --blue: #2980b9;
  --serif: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--black);
  color: var(--white);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-bright); }

/* === Header === */
.app-header {
  background: linear-gradient(180deg, #000 0%, #0f0f0f 100%);
  border-bottom: 1px solid var(--gold);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.app-header .logo {
  font-family: var(--serif);
  font-size: 22px;
  color: var(--gold);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.app-header .logo i {
  font-style: italic;
  font-size: 28px;
  font-weight: 400;
}
.app-header .logout {
  color: var(--gray);
  font-size: 13px;
}

/* === Container === */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 80px;
}

/* === Titres === */
h1, h2, h3 {
  font-family: var(--serif);
  color: var(--gold);
  font-weight: 600;
  letter-spacing: 0.5px;
}
h1 { font-size: 28px; margin: 16px 0 12px; }
h2 { font-size: 22px; margin: 20px 0 10px; }
h3 { font-size: 18px; margin: 16px 0 8px; }

.muted { color: var(--gray); }
.small { font-size: 13px; }

/* === Cartes === */
.card {
  background: var(--black-card);
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  padding: 16px;
  margin: 12px 0;
}
.card.with-gold-border { border-color: var(--gold); }
.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

/* === Stats grid === */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}
.stat-box {
  background: var(--black-card);
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  padding: 10px 6px;
  text-align: center;
}
.stat-box .num {
  font-size: 24px;
  font-weight: 700;
  color: var(--gold);
  font-family: var(--serif);
}
.stat-box .label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--gray);
  letter-spacing: 1px;
}

/* === Boutons === */
.btn {
  display: inline-block;
  padding: 12px 20px;
  border-radius: 6px;
  border: 1px solid var(--gold);
  background: transparent;
  color: var(--gold);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
  font-family: var(--sans);
  text-decoration: none;
  -webkit-appearance: none;
}
.btn:hover, .btn:active {
  background: var(--gold);
  color: var(--black);
}
.btn-primary {
  background: var(--gold);
  color: var(--black);
}
.btn-primary:hover, .btn-primary:active {
  background: var(--gold-bright);
  border-color: var(--gold-bright);
}
.btn-danger {
  border-color: var(--red);
  color: var(--red);
}
.btn-danger:hover { background: var(--red); color: var(--white); }
.btn-block { display: block; width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* === Forms === */
.field {
  margin-bottom: 14px;
}
.field label {
  display: block;
  margin-bottom: 6px;
  color: var(--gold);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}
.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 12px 14px;
  background: #0d0d0d;
  border: 1px solid #333;
  border-radius: 6px;
  color: var(--white);
  font-size: 16px;
  font-family: var(--sans);
}
.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--gold);
}
.field textarea { min-height: 80px; resize: vertical; }
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 480px) {
  .field-row { grid-template-columns: 1fr; }
}

/* === Mission card (liste) === */
.mission-item {
  background: var(--black-card);
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 10px;
  display: block;
  text-decoration: none;
  color: var(--white);
  transition: border-color 0.15s;
}
.mission-item:hover { border-color: var(--gold); }
.mission-item .row1 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.mission-item .vehicule {
  font-weight: 600;
  color: var(--gold);
  font-size: 16px;
}
.mission-item .trajet {
  color: var(--gray-light);
  font-size: 14px;
  margin: 4px 0;
}
.mission-item .meta {
  color: var(--gray);
  font-size: 12px;
}

/* === Status badges === */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
}
.badge-a_faire { background: #2a2a2a; color: var(--gray-light); }
.badge-en_cours { background: rgba(212,175,55,0.2); color: var(--gold); border: 1px solid var(--gold); }
.badge-termine { background: rgba(39,174,96,0.2); color: #2ecc71; border: 1px solid #2ecc71; }

/* === Flash messages === */
.flash {
  padding: 12px 16px;
  border-radius: 6px;
  margin: 10px 0;
  font-size: 14px;
}
.flash-success { background: rgba(39,174,96,0.15); border: 1px solid var(--green); color: #6dd49d; }
.flash-error { background: rgba(192,57,43,0.15); border: 1px solid var(--red); color: #ff7666; }
.flash-warning { background: rgba(230,126,34,0.15); border: 1px solid var(--orange); color: #f4b27b; }

/* === Login === */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(ellipse at top left, #1a1a1a 0%, #000 70%);
}
.login-box {
  width: 100%;
  max-width: 380px;
  background: var(--black-card);
  border: 1px solid var(--gold);
  border-radius: 12px;
  padding: 30px;
  text-align: center;
}
.login-box .login-logo {
  width: 100px;
  height: 100px;
  margin: 0 auto 16px;
  border-radius: 12px;
}
.login-box .brand {
  font-family: var(--serif);
  color: var(--gold);
  font-size: 24px;
  margin: 0 0 4px;
  letter-spacing: 1px;
}
.login-box .tagline {
  color: var(--gray);
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 24px;
}

/* === Carte (map) === */
#map {
  height: 60vh;
  min-height: 350px;
  border-radius: 8px;
  border: 1px solid var(--gold);
  background: #1a1a1a;
}
.tracking-info {
  background: var(--black-card);
  border-left: 3px solid var(--gold);
  padding: 12px;
  margin: 12px 0;
}

/* === Photos grid === */
.photos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px;
  margin: 12px 0;
}
.photo-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #333;
  background: #1a1a1a;
}
.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.photo-thumb .delete-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(192,57,43,0.85);
  color: white;
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

/* === Signature canvas === */
.sig-wrapper {
  background: white;
  border: 2px solid var(--gold);
  border-radius: 6px;
  margin: 8px 0;
}
#sig-canvas, .sig-canvas {
  display: block;
  width: 100%;
  height: 200px;
  touch-action: none;
}
.sig-actions {
  display: flex;
  gap: 8px;
}

/* === Section action ribbon (sticky bottom) === */
.action-ribbon {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(10,10,10,0.97);
  border-top: 1px solid var(--gold);
  padding: 12px 16px;
  z-index: 50;
}
.action-ribbon .container { padding: 0; }

/* === Tracking public client === */
.public-header {
  background: linear-gradient(180deg, #000 0%, #1a1a1a 100%);
  padding: 20px 16px;
  text-align: center;
  border-bottom: 2px solid var(--gold);
}
.public-header .logo-img {
  max-width: 280px;
  width: 80%;
  height: auto;
}
.public-header .status-line {
  margin-top: 12px;
  color: var(--gold);
  font-family: var(--serif);
  font-size: 18px;
}

/* === Tabs === */
.tabs {
  display: flex;
  border-bottom: 1px solid #333;
  margin: 16px 0 0;
}
.tab {
  flex: 1;
  padding: 12px;
  text-align: center;
  cursor: pointer;
  color: var(--gray);
  font-size: 14px;
  font-weight: 600;
  border-bottom: 2px solid transparent;
}
.tab.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

/* === FAB === */
.fab {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--black);
  font-size: 28px;
  border: none;
  box-shadow: 0 4px 12px rgba(212,175,55,0.5);
  cursor: pointer;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* === Tracking indicator === */
.tracking-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--gold);
}
.tracking-indicator .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #2ecc71;
  animation: pulse 1.5s infinite;
}
.tracking-indicator .dot.off { background: #555; animation: none; }
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.3); }
}

/* === Empty state === */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray);
}
.empty-icon { font-size: 48px; opacity: 0.3; margin-bottom: 12px; }

/* === Utilities === */
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.flex { display: flex; gap: 8px; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 16px; }

/* Pour iOS Safari : viewport height */
@supports (-webkit-touch-callout: none) {
  .login-page { min-height: -webkit-fill-available; }
}
