/* BUILD FLOW - Styles personnalisés */
:root {
  --primary: #ea580c;
  --primary-dark: #c2410c;
  --secondary: #0f172a;
  --sidebar-width: 260px;
}

* { box-sizing: border-box; }

body { margin: 0; font-family: 'Inter', system-ui, -apple-system, sans-serif; }

/* ===== LAYOUT ===== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--secondary);
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-logo {
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-logo .logo-icon {
  font-size: 28px;
}

.sidebar-logo .logo-text {
  font-size: 18px;
  font-weight: 800;
  color: #fb923c;
  letter-spacing: 1px;
}

.sidebar-logo .logo-sub {
  font-size: 10px;
  color: rgba(255,255,255,0.4);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.sidebar-menu {
  flex: 1;
  padding: 16px 0;
}

.menu-section {
  margin-bottom: 8px;
}

.menu-section-title {
  font-size: 10px;
  font-weight: 600;
  color: rgba(255,255,255,0.35);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 8px 24px 4px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 24px;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 14px;
  border-left: 3px solid transparent;
  text-decoration: none;
}

.menu-item:hover {
  background: rgba(255,255,255,0.08);
  color: white;
}

.menu-item.active {
  background: rgba(234, 88, 12, 0.15);
  color: #fb923c;
  border-left-color: #fb923c;
  font-weight: 600;
}

.menu-item .menu-icon {
  width: 20px;
  text-align: center;
  font-size: 15px;
}

.menu-badge {
  margin-left: auto;
  background: #ea580c;
  color: white;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
}

.sidebar-user {
  padding: 16px 24px;
  border-top: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-user .avatar {
  width: 36px; height: 36px;
  background: #ea580c;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}

.sidebar-user .user-info .user-name {
  font-size: 13px;
  font-weight: 600;
  color: white;
}

.sidebar-user .user-info .user-role {
  font-size: 11px;
  color: rgba(255,255,255,0.45);
  text-transform: capitalize;
}

.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: white;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #e2e8f0;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.page-content {
  flex: 1;
  padding: 24px;
}

/* ===== CARDS ===== */
.stat-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  border: 1px solid #f1f5f9;
  transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.stat-card .stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 12px;
}

.stat-card .stat-value {
  font-size: 24px;
  font-weight: 800;
  color: #0f172a;
  line-height: 1;
}

.stat-card .stat-label {
  font-size: 13px;
  color: #64748b;
  margin-top: 4px;
}

.stat-card .stat-change {
  font-size: 12px;
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ===== TABLES ===== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th {
  background: #f8fafc;
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid #e2e8f0;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
  vertical-align: middle;
}

.data-table tr:hover td {
  background: #f8fafc;
}

.data-table tr:last-child td {
  border-bottom: none;
}

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.badge-pending { background: #fef3c7; color: #92400e; }
.badge-preparing { background: #dbeafe; color: #1e40af; }
.badge-ready { background: #d1fae5; color: #065f46; }
.badge-delivering { background: #ede9fe; color: #5b21b6; }
.badge-delivered { background: #dcfce7; color: #166534; }
.badge-cancelled { background: #fee2e2; color: #991b1b; }
.badge-paid { background: #dcfce7; color: #166534; }
.badge-unpaid { background: #fee2e2; color: #991b1b; }
.badge-partial { background: #fef3c7; color: #92400e; }
.badge-ok { background: #dcfce7; color: #166534; }
.badge-alerte { background: #fef3c7; color: #92400e; }
.badge-rupture { background: #fee2e2; color: #991b1b; }
.badge-admin { background: #fce7f3; color: #9d174d; }
.badge-direction { background: #ede9fe; color: #5b21b6; }
.badge-magasinier { background: #dbeafe; color: #1e40af; }
.badge-comptable { background: #d1fae5; color: #065f46; }
.badge-livreur { background: #fed7aa; color: #9a3412; }
.badge-client { background: #f1f5f9; color: #475569; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: #ea580c;
  color: white;
}
.btn-primary:hover { background: #c2410c; }

.btn-secondary {
  background: #f1f5f9;
  color: #334155;
}
.btn-secondary:hover { background: #e2e8f0; }

.btn-success {
  background: #22c55e;
  color: white;
}
.btn-success:hover { background: #16a34a; }

.btn-danger {
  background: #ef4444;
  color: white;
}
.btn-danger:hover { background: #dc2626; }

.btn-outline {
  background: transparent;
  color: #ea580c;
  border: 1.5px solid #ea580c;
}
.btn-outline:hover { background: #fff7ed; }

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-icon {
  padding: 8px;
  border-radius: 8px;
  background: #f1f5f9;
  color: #64748b;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}
.btn-icon:hover { background: #e2e8f0; color: #334155; }

/* ===== FORMS ===== */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 6px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  font-size: 14px;
  color: #0f172a;
  background: white;
  transition: border-color 0.2s;
  outline: none;
  font-family: inherit;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: #ea580c;
  box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.1);
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

/* ===== PRODUCT CARDS ===== */
.product-card {
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  border: 1px solid #f1f5f9;
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
}

.product-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

.product-image {
  width: 100%;
  height: 180px;
  object-fit: cover;
  background: #f8fafc;
}

.product-info {
  padding: 16px;
}

.product-name {
  font-weight: 700;
  font-size: 14px;
  color: #0f172a;
  margin-bottom: 4px;
  line-height: 1.4;
}

.product-price {
  font-size: 18px;
  font-weight: 800;
  color: #ea580c;
}

.product-unit {
  font-size: 12px;
  color: #94a3b8;
}

.product-stock {
  font-size: 12px;
  color: #64748b;
  margin-top: 4px;
}

/* ===== MODALS ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: white;
  border-radius: 16px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
}

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* ===== CART ===== */
.cart-drawer {
  position: fixed;
  top: 0; right: 0;
  width: 380px;
  height: 100vh;
  background: white;
  box-shadow: -4px 0 24px rgba(0,0,0,0.12);
  z-index: 500;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s ease;
}

.cart-drawer.open {
  transform: translateX(0);
}

.cart-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid #f1f5f9;
}

/* ===== LOGIN PAGE ===== */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: white;
  border-radius: 20px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 25px 50px rgba(0,0,0,0.3);
}

/* ===== NOTIFICATIONS ===== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: white;
  border-radius: 10px;
  padding: 14px 18px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 280px;
  border-left: 4px solid #ea580c;
  animation: slideRight 0.3s ease;
  font-size: 14px;
  font-weight: 500;
}

.toast.success { border-left-color: #22c55e; }
.toast.error { border-left-color: #ef4444; }
.toast.warning { border-left-color: #f59e0b; }

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideRight {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ===== CATALOG PAGE ===== */
.catalog-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: white;
  padding: 48px 0;
}

.search-bar {
  background: white;
  border-radius: 50px;
  display: flex;
  align-items: center;
  padding: 6px 6px 6px 20px;
  gap: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  max-width: 600px;
  margin: 0 auto;
}

.search-bar input {
  border: none;
  outline: none;
  flex: 1;
  font-size: 15px;
  color: #0f172a;
}

/* ===== PUBLIC HEADER ===== */
.public-header {
  background: #0f172a;
  color: white;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .cart-drawer {
    width: 100vw;
  }
  .stat-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* ===== MISC ===== */
.card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  border: 1px solid #f1f5f9;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
}

.card-body {
  padding: 20px;
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: #94a3b8;
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.divider {
  height: 1px;
  background: #e2e8f0;
  margin: 16px 0;
}

.text-primary { color: #ea580c; }
.text-success { color: #22c55e; }
.text-danger { color: #ef4444; }
.text-warning { color: #f59e0b; }
.text-muted { color: #94a3b8; }

.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fw-800 { font-weight: 800; }

.loading-spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid #e2e8f0;
  border-top-color: #ea580c;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.qty-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.qty-control button {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 1.5px solid #e2e8f0;
  background: white;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  color: #334155;
  transition: all 0.2s;
}

.qty-control button:hover {
  background: #ea580c;
  color: white;
  border-color: #ea580c;
}

.qty-control .qty-value {
  min-width: 36px;
  text-align: center;
  font-weight: 700;
  font-size: 15px;
}

.page-title {
  font-size: 22px;
  font-weight: 800;
  color: #0f172a;
}

.breadcrumb {
  font-size: 13px;
  color: #94a3b8;
  margin-bottom: 4px;
}

.steps {
  display: flex;
  gap: 0;
  margin-bottom: 32px;
}

.step {
  flex: 1;
  text-align: center;
  position: relative;
}

.step::after {
  content: '';
  position: absolute;
  top: 20px;
  left: 50%;
  width: 100%;
  height: 2px;
  background: #e2e8f0;
}

.step:last-child::after { display: none; }

.step.active .step-circle { background: #ea580c; color: white; }
.step.done .step-circle { background: #22c55e; color: white; }

.step-circle {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: #e2e8f0;
  color: #64748b;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 15px;
  margin: 0 auto 8px;
  position: relative;
  z-index: 1;
}

.step-label {
  font-size: 12px;
  color: #64748b;
  font-weight: 600;
}

/* Chart container */
.chart-container {
  position: relative;
  height: 250px;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 90;
}

/* ===== LEAFLET OVERRIDES ===== */
.leaflet-container {
  font-family: inherit;
  z-index: 10;
}

.leaflet-control-attribution {
  font-size: 10px !important;
}

/* Pulsation du marqueur de localisation */
@keyframes markerPulse {
  0% { box-shadow: 0 0 0 0 rgba(234, 88, 12, 0.5); }
  70% { box-shadow: 0 0 0 12px rgba(234, 88, 12, 0); }
  100% { box-shadow: 0 0 0 0 rgba(234, 88, 12, 0); }
}

.marker-pulse {
  animation: markerPulse 1.5s infinite;
}

/* Résultats recherche adresse */
#search-results div:hover {
  background: #f8fafc !important;
}

/* Carte checkout responsive */
#delivery-map {
  min-height: 240px;
}

@media (max-width: 640px) {
  #delivery-map {
    height: 220px !important;
  }
}
