:root {
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --brand-light: #e8f0fe;
  --dark: #1f2430;
  --success: #17a673;
  --danger: #e34a4a;
}

body {
  background: #f4f5f7;
  font-family: 'Segoe UI', Roboto, Arial, sans-serif;
}

/* -------- Navbar -------- */
.app-navbar {
  background: linear-gradient(120deg, #151a24, #232b3d);
  padding: .6rem 0;
  box-shadow: 0 2px 12px rgba(0,0,0,.25);
  z-index: 1030;
}

.app-navbar .navbar-brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-weight: 800;
  font-size: 1.15rem;
  color: #fff;
}
.app-navbar .brand-icon {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  font-size: 1.05rem;
}

.app-navbar .navbar-nav {
  gap: .25rem;
}
.app-navbar .nav-link {
  color: rgba(255,255,255,.75) !important;
  font-weight: 600;
  font-size: .92rem;
  padding: .5rem .9rem !important;
  border-radius: 10px;
  transition: background-color .15s ease, color .15s ease;
  white-space: nowrap;
}
.app-navbar .nav-link i {
  margin-right: .35rem;
  width: 16px;
  text-align: center;
}
.app-navbar .nav-link:hover {
  color: #fff !important;
  background-color: rgba(255,255,255,.08);
}
.app-navbar .nav-link.active {
  color: #fff !important;
  background-color: var(--brand);
  box-shadow: 0 2px 10px rgba(37,99,235,.4);
}

.nav-user-block {
  border-left: 1px solid rgba(255,255,255,.15);
  padding-left: 1rem;
  margin-left: .5rem;
}
.nav-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .85rem;
  flex-shrink: 0;
}
.nav-user-name {
  color: #fff;
  font-size: .85rem;
  font-weight: 600;
  line-height: 1.1;
}
.nav-user-role {
  color: rgba(255,255,255,.6);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.btn-logout {
  background: rgba(255,255,255,.08);
  color: #fff;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 10px;
}
.btn-logout:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

@media (max-width: 991.98px) {
  .nav-user-block {
    border-left: none;
    padding-left: 0;
    margin-left: 0;
    margin-top: .75rem;
    padding-top: .75rem;
    border-top: 1px solid rgba(255,255,255,.15);
  }
}

/* -------- Login -------- */
.login-body {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--brand), var(--dark));
}
.login-card {
  width: 100%;
  max-width: 420px;
  border-radius: 18px;
}

/* -------- Boutons primaires -------- */
.btn-primary {
  background-color: var(--brand);
  border-color: var(--brand);
}
.btn-primary:hover, .btn-primary:focus {
  background-color: var(--brand-dark);
  border-color: var(--brand-dark);
}
.text-brand { color: var(--brand); }
.bg-brand { background-color: var(--brand); }

/* -------- Cartes statistiques -------- */
.stat-card {
  border: none;
  border-radius: 16px;
  color: #fff;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 6px 18px rgba(0,0,0,.08);
}
.stat-card .stat-icon { font-size: 2rem; opacity: .85; }
.stat-card .stat-value { font-size: 1.8rem; font-weight: 700; }
.stat-card .stat-label { font-size: .85rem; opacity: .9; }
.stat-card.orange  { background: linear-gradient(135deg,#ff7a00,#ff9d45); }
.stat-card.blue    { background: linear-gradient(135deg,#2563eb,#4f8bff); }
.stat-card.green   { background: linear-gradient(135deg,#17a673,#37c894); }
.stat-card.purple  { background: linear-gradient(135deg,#7c3aed,#a78bfa); }

/* -------- POS -------- */
.lot-card {
  border-radius: 18px;
  border: 2px solid #eee;
  background: #fff;
  padding: 1.25rem;
  text-align: center;
  transition: box-shadow .15s ease, border-color .15s ease;
}
.lot-card.active-qty {
  border-color: var(--brand);
  box-shadow: 0 8px 20px rgba(37,99,235,.15);
}
.lot-card .lot-price {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--brand);
}
.lot-card .lot-name {
  color: #444;
  text-transform: uppercase;
  font-size: .85rem;
  font-weight: 700;
  letter-spacing: .05em;
}
.qty-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  margin-top: .75rem;
}
.qty-btn {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  font-size: 1.4rem;
  font-weight: 700;
  border: none;
  color: #fff;
  background: var(--brand);
}
.qty-btn.minus { background: #6c757d; }
.qty-btn:active { transform: scale(0.94); }
.qty-input {
  width: 80px;
  height: 52px;
  text-align: center;
  font-size: 1.3rem;
  font-weight: 700;
  border-radius: 12px;
  border: 2px solid #e2e2e2;
}
.lot-line-total {
  margin-top: .5rem;
  font-weight: 700;
  color: var(--dark);
}
.quick-qty button {
  margin: 2px;
}

.pos-summary {
  position: sticky;
  top: 1rem;
  border-radius: 18px;
  border: none;
  box-shadow: 0 8px 24px rgba(0,0,0,.08);
}
.summary-row {
  display: flex;
  justify-content: space-between;
  padding: .35rem 0;
}
.summary-total {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--brand);
}
#btnValider:disabled {
  opacity: .5;
}

/* -------- Ticket -------- */
.ticket {
  width: 300px;
  margin: 0 auto;
  background: #fff;
  padding: 16px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  border: 1px dashed #ccc;
}
.ticket hr { border-top: 1px dashed #999; }
.ticket .ticket-title { text-align: center; font-weight: 700; font-size: 15px; }
.ticket .ticket-row { display: flex; justify-content: space-between; }

@media print {
  body * { visibility: hidden; }
  .ticket, .ticket * { visibility: visible; }
  /* La largeur réelle (58mm / 80mm / A4) est fixée dynamiquement par
     ticket.php selon le réglage "Format d'impression" de la boutique. */
  .ticket { position: absolute; top: 0; left: 0; border: none; }
  .no-print { display: none !important; }

  /* Impression plus foncée : le gris par défaut de Bootstrap (#212529)
     et l'anti-aliasing rendent le texte trop clair sur les imprimantes
     thermiques. On force du noir pur + un poids de police plus élevé,
     et on demande au navigateur de ne pas alléger les couleurs à l'impression. */
  .ticket, .ticket * {
    color: #000 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .ticket { font-weight: 600; }
  .ticket .ticket-title { font-weight: 800; }
}

@media (max-width: 576px) {
  .qty-input { width: 64px; }
  .qty-btn { width: 44px; height: 44px; }
}

/* -------- Barre totale mobile (POS) -------- */
.mobile-total-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1040;
  background: #fff;
  border-top: 1px solid #e2e2e2;
  box-shadow: 0 -6px 20px rgba(0,0,0,.12);
  padding: .65rem 1rem calc(.65rem + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}
.mobile-total-bar .mobile-total-label {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #888;
}
.mobile-total-bar .mobile-total-value {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--brand);
}
.mobile-total-bar .btn {
  flex-shrink: 0;
}
/* Espace pour ne pas masquer le contenu derrière la barre fixe */
@media (max-width: 991.98px) {
  body { padding-bottom: 78px; }
}
