/* ── Variables ────────────────────────────────────────────── */
:root {
  --sidebar-w: 240px;
  --primary: #1E3A5F;
  --accent: #2E86AB;
  --accent-bright: #FF9F43;
  --bg: #F8FAFB;
  --card-bg: #ffffff;
  --text: #1a1a2e;
  --text-muted: #6c757d;
  --border: #e1e8ed;
  --radius: 12px;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.1);
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset & base ─────────────────────────────────────────── */
* { box-sizing: border-box; }
html {
  scroll-behavior: smooth;
  -webkit-user-select: none;
  user-select: none;
}
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  margin: 0;
  padding-bottom: 50px;
  -webkit-font-smoothing: antialiased;
  -webkit-touch-callout: none;
  overflow-x: hidden;
}

/* ── Layout ───────────────────────────────────────────────── */

/* ── Sidebar ──────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #1E3A5F 0%, #152038 100%);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  flex-shrink: 0;
  z-index: 1050;
  will-change: transform;
  backface-visibility: hidden;
  box-shadow: 2px 0 8px rgba(0,0,0,0.15);
}

/* Sidebar fermée par défaut (mobile/tablette) */
@media (max-width: 1024px) {
  #sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  #sidebar.open {
    transform: translateX(0);
  }
}

#app-wrapper {
  min-height: 100vh;
}

.sidebar-header {
  padding: 20px 16px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-brand {
  font-size: 1.2rem;
  font-weight: 800;
  color: white !important;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.sidebar-user {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.6);
}

.sidebar-nav {
  padding: 12px 8px;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 140px;
}

@media (min-width: 1025px) {
  .sidebar-nav {
    padding-bottom: 12px;
  }
}

.nav-section {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.4);
  padding: 0 8px;
  margin-bottom: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: rgba(255,255,255,0.8) !important;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  transition: all var(--transition);
  margin-bottom: 2px;
  cursor: pointer;
  position: relative;
}
.nav-item:hover {
  background: rgba(255,255,255,0.15);
  color: white !important;
  transform: translateX(2px);
}
.nav-item.active {
  background: linear-gradient(90deg, var(--accent), rgba(46,134,171,0.8));
  color: white !important;
  font-weight: 600;
  box-shadow: 0 0 12px rgba(46,134,171,0.3);
}

.nav-boutique { padding: 8px 12px; }
.nav-boutique-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav-sub { padding-left: 16px; margin-bottom: 4px; }
.nav-sub-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 6px;
  color: rgba(255,255,255,0.65) !important;
  text-decoration: none;
  font-size: 0.82rem;
  transition: all 0.15s;
  margin-bottom: 1px;
}
.nav-sub-item:hover { background: rgba(255,255,255,0.1); color: white !important; }
.nav-sub-item.active { color: white !important; font-weight: 600; background: rgba(255,255,255,0.08); }

.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid rgba(255,255,255,0.1);
  background: linear-gradient(180deg, #1E3A5F 0%, #152038 100%);
  z-index: 10;
  margin-top: auto;
  flex-shrink: 0;
  min-height: auto;
  position: relative;
}

/* Sur mobile/tablette, s'assurer que le footer est visible */
@media (max-width: 1024px) {
  .sidebar-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: var(--sidebar-w);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    padding-bottom: 20px;
  }
  #sidebar.open .sidebar-footer {
    transform: translateX(0);
  }
}
.text-danger-soft { color: rgba(255, 100, 100, 0.85) !important; }
.text-danger-soft:hover { color: #ff6b6b !important; }

/* ── Main content ─────────────────────────────────────────── */
#main-content { flex: 1; min-width: 0; }

/* ── Page header ──────────────────────────────────────────── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--border);
  animation: fadeIn 0.3s ease-in;
}
.page-title {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--primary);
  margin: 0;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.page-subtitle {
  color: var(--text-muted);
  margin: 4px 0 0;
  font-size: 0.9rem;
  font-weight: 500;
}
.page-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* ── Cards ────────────────────────────────────────────────── */
.card-panel {
  background: linear-gradient(135deg, #ffffff 0%, #f9fafb 100%);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
}
.card-panel:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--accent-bright);
  transform: translateY(-2px);
}

.card-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  font-weight: 600;
  color: var(--primary);
  font-size: 0.95rem;
}

/* ── KPI Cards ────────────────────────────────────────────── */
.kpi-card {
  background: linear-gradient(135deg, #ffffff 0%, #f8fafb 100%);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
  cursor: pointer;
}
.kpi-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
}
.kpi-card.border-warning {
  border-color: #ffc107 !important;
  background: linear-gradient(135deg, #fffbf0 0%, #fff9f0 100%);
}

.kpi-icon {
  width: 48px; height: 48px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}
.bg-primary-soft { background: rgba(30,58,95,0.1); color: var(--primary); }
.bg-success-soft { background: rgba(25,135,84,0.1); color: #198754; }
.bg-info-soft { background: rgba(46,134,171,0.1); color: var(--accent); }
.bg-warning-soft { background: rgba(255,193,7,0.15); color: #856404; }
.bg-secondary-soft { background: rgba(108,117,125,0.1); color: #6c757d; }

.kpi-value { font-size: 1.4rem; font-weight: 800; color: var(--primary); line-height: 1; }
.kpi-label { font-size: 0.78rem; color: var(--text-muted); margin-top: 3px; }

/* ── Charts ───────────────────────────────────────────────── */
.chart-container { position: relative; height: 220px; }

/* ── Quick links ──────────────────────────────────────────── */
.quick-link-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: linear-gradient(135deg, #ffffff 0%, #f9fafb 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--primary);
  font-weight: 600;
  transition: all var(--transition);
  font-size: 0.9rem;
  box-shadow: var(--shadow-sm);
}
.quick-link-card i {
  font-size: 1.3rem;
  color: var(--accent-bright);
  transition: all var(--transition);
}
.quick-link-card:hover {
  border-color: var(--accent-bright);
  background: linear-gradient(135deg, #fff8f0 0%, #fff5eb 100%);
  color: var(--accent-bright);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}
.quick-link-card:hover i {
  transform: translateX(4px);
}

/* ── Boutique list (dashboard) ────────────────────────────── */
.boutique-card-link { text-decoration: none; }
.boutique-mini-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-bottom: 8px;
  transition: all 0.15s;
}
.boutique-mini-card:hover { border-color: var(--accent); background: rgba(46,134,171,0.04); }
.boutique-mini-icon {
  width: 38px; height: 38px;
  background: rgba(30,58,95,0.08);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--primary); font-size: 1.1rem; flex-shrink: 0;
}
.boutique-mini-name { font-weight: 600; color: var(--primary); font-size: 0.9rem; }
.boutique-mini-info { font-size: 0.78rem; color: var(--text-muted); }
.boutique-mini-arrow { color: var(--text-muted); margin-left: auto; }

/* ── Tables ───────────────────────────────────────────────── */
.table {
  border-collapse: collapse;
}
.table th {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  background: linear-gradient(180deg, #f9fafb 0%, #f5f7fa 100%);
}
.table td {
  vertical-align: middle;
  font-size: 0.9rem;
  border-color: var(--border);
  transition: all var(--transition);
}
.table tbody tr {
  transition: all var(--transition);
}
.table tbody tr:hover {
  background-color: rgba(46,134,171,0.04) !important;
  box-shadow: inset 0 0 8px rgba(46,134,171,0.05);
}
.btn-xs {
  padding: 4px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  min-height: 32px;
}

/* ── Empty state ──────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
  background: linear-gradient(135deg, rgba(248,250,251,0.5) 0%, rgba(244,246,249,0.3) 100%);
  border-radius: var(--radius);
  border: 1px dashed var(--border);
  animation: fadeIn 0.3s ease-in;
}
.empty-state i {
  font-size: 4rem;
  display: block;
  margin-bottom: 16px;
  opacity: 0.15;
  animation: float 3s ease-in-out infinite;
}
.empty-state h4, .empty-state h5 {
  color: var(--primary);
  font-weight: 600;
}
.empty-state p {
  margin-bottom: 24px;
  font-size: 0.95rem;
  line-height: 1.6;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* ── Auth ─────────────────────────────────────────────────── */
.auth-bg {
  background: linear-gradient(135deg, #1E3A5F 0%, #2E86AB 50%, #FF9F43 100%);
  min-height: 100vh;
  position: relative;
  overflow: hidden;
}
.auth-bg::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -10%;
  width: 500px;
  height: 500px;
  background: rgba(255,255,255,0.05);
  border-radius: 50%;
  animation: float 6s ease-in-out infinite;
}
.auth-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  position: relative;
  z-index: 1;
}
.auth-card {
  background: linear-gradient(180deg, #ffffff 0%, #f9fafb 100%);
  border-radius: 20px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 25px 60px rgba(0,0,0,0.25);
  animation: slideUp 0.4s ease-out;
}
.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 8px;
}
.auth-logo i {
  font-size: 2.2rem;
  color: var(--accent-bright);
  animation: pulse 2s ease-in-out infinite;
}
.auth-subtitle {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 28px;
  font-size: 0.9rem;
  line-height: 1.6;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}
.auth-divider {
  text-align: center; color: var(--text-muted); margin: 16px 0;
  position: relative; font-size: 0.85rem;
}
.auth-divider::before, .auth-divider::after {
  content: ''; position: absolute; top: 50%;
  width: 42%; height: 1px; background: var(--border);
}
.auth-divider::before { left: 0; }
.auth-divider::after { right: 0; }

/* ── Identifiants boutique ────────────────────────────────── */
.boutique-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.boutique-id-pill {
  font-size: 0.62rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.65);
  letter-spacing: 0.5px;
  margin-left: auto;
  white-space: nowrap;
}

.page-id-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: white;
  vertical-align: middle;
  margin-right: 10px;
}

.boutique-color-bar {
  width: 4px;
  border-radius: 4px;
  align-self: stretch;
  flex-shrink: 0;
}

.boutique-mini-id {
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 5px;
  color: white;
  letter-spacing: 1px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Alertes flash ────────────────────────────────────────── */
.alert { border-radius: 10px; }

/* ── Quick link card ──────────────────────────────────────── */
.quick-link-card { box-shadow: 0 1px 3px rgba(0,0,0,.04); }
.quick-link-card .text-muted { font-weight: 400; }

/* ── Sidebar — pas de pill ID visible ───────────────────────── */
.nav-boutique .boutique-id-pill { display: none; }

/* ── Buttons & Micro-interactions ─────────────────────────── */
.btn {
  font-weight: 600;
  letter-spacing: 0.3px;
  transition: all var(--transition);
  border: none;
  position: relative;
  overflow: hidden;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* Primary button */
.btn-primary {
  background: linear-gradient(135deg, var(--primary), #0f2438);
  box-shadow: 0 4px 12px rgba(30,58,95,0.2);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #0f2438, var(--primary));
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(30,58,95,0.3);
}
.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(30,58,95,0.2);
}

/* Success button */
.btn-success {
  background: linear-gradient(135deg, #198754, #0d543a);
  box-shadow: 0 4px 12px rgba(25,135,84,0.2);
}
.btn-success:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(25,135,84,0.3);
}

/* Outline button */
.btn-outline-secondary {
  border: 2px solid var(--border);
  color: var(--text-muted);
  font-weight: 600;
}
.btn-outline-secondary:hover {
  border-color: var(--accent-bright);
  background: rgba(255,159,67,0.05);
  color: var(--accent-bright);
}

/* Danger button */
.btn-danger {
  background: linear-gradient(135deg, #dc3545, #a02834);
}
.btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(220,53,69,0.3);
}

/* Disabled state */
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed !important;
  transform: none !important;
}

/* Link buttons */
.btn-link {
  color: var(--accent-bright);
  text-decoration: none;
  font-weight: 600;
  transition: all var(--transition);
}
.btn-link:hover {
  color: var(--primary);
  transform: translateX(2px);
}

/* ── Accessibilité & defaults ─────────────────────────────── */
button, input, select, textarea {
  font-size: 16px !important;
}
/* ── Formulaires ──────────────────────────────────────────── */
.form-control,
.form-select {
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.95rem;
  font-weight: 500;
  transition: all var(--transition);
  background: linear-gradient(135deg, #ffffff, #f9fafb);
}
.form-control:focus,
.form-select:focus {
  border-color: var(--accent-bright);
  box-shadow: 0 0 0 3px rgba(255,159,67,0.1);
  background: #ffffff;
}
.form-label {
  font-weight: 600;
  color: var(--primary);
  font-size: 0.9rem;
  margin-bottom: 8px;
}
.form-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ── Links ────────────────────────────────────────────────── */
a {
  color: var(--accent-bright);
  text-decoration: none;
  transition: all var(--transition);
  font-weight: 500;
}
a:hover {
  color: var(--primary);
  text-decoration: underline;
}

/* ── Utils ────────────────────────────────────────────────── */
.no-wrap { white-space: nowrap; }
.text-ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shadow-sm { box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.shadow-md { box-shadow: 0 4px 12px rgba(0,0,0,0.1); }

/* ── Topbar mobile ────────────────────────────────────────── */
#topbar-mobile {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: auto;
  height: 52px;
  background: var(--primary);
  z-index: 1100;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  will-change: transform;
  backface-visibility: hidden;
  -webkit-transform: translate3d(0, 0, 0);
  transform: translate3d(0, 0, 0);
}
#sidebar-toggle {
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}
.topbar-title {
  color: white;
  font-weight: 800;
  font-size: 1.1rem;
}

/* ── Overlay sidebar mobile ───────────────────────────────── */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 1199;
}
#sidebar-overlay.visible { display: block; }

/* ── Responsive mobile & tablet (< 1025px) ──────────────────── */
@media (max-width: 1024px) {
  /* Topbar et sidebar overlay */
  #topbar-mobile { display: flex; }
  #app-wrapper { padding-top: 52px; margin-left: 0; }

  #sidebar {
    position: fixed !important;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--sidebar-w);
    z-index: 1200;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  #sidebar.open { transform: translateX(0); }
  #main-content { overflow-x: hidden; }

  /* Page layout */
  .page-title { font-size: 1.2rem !important; }
  .page-header { margin-bottom: 16px; }
  .page-actions { width: 100%; justify-content: flex-end; gap: 6px; }
  .page-actions .btn { min-height: 40px; font-size: 0.85rem; padding: 8px 12px !important; }

  /* Cards et spacing */
  .card-panel { padding: 12px; }
  .container-fluid.py-4.px-4 { padding: 12px !important; }

  /* KPI Cards */
  .kpi-card { flex-direction: column; text-align: center; padding: 12px; }
  .kpi-icon { width: 40px; height: 40px; font-size: 1.1rem; }
  .kpi-value { font-size: 1.2rem; }
  .kpi-label { font-size: 0.7rem; }

  /* Charts */
  .chart-container { height: 180px; }

  /* Formulaires */
  .form-control, .form-select { min-height: 44px; font-size: 16px; }
  input[type="number"] { min-width: 64px; min-height: 44px; }
  label { font-size: 0.9rem; margin-bottom: 4px; }

  /* Boutons */
  .btn { min-height: 40px; }
  .btn-xs { padding: 8px 12px !important; font-size: 0.75rem !important; }
  .btn-sm { min-height: 36px; }
  .btn-lg { font-size: 0.95rem; }

  /* Tables */
  .table { font-size: 0.8rem; }
  .table th { padding: 8px 4px !important; font-size: 0.7rem; }
  .table td { padding: 8px 4px !important; }

  /* Login page */
  .login-left { width: 100% !important; max-width: 100% !important; }
  .auth-card { padding: 24px !important; }

  /* Panier */
  #panier-body input[type="number"] { min-width: 64px !important; min-height: 44px !important; }

  /* Espacement réglé */
  .row.g-3 { --bs-gutter-x: 12px; --bs-gutter-y: 12px; }
  .row.g-2 { --bs-gutter-x: 8px; --bs-gutter-y: 8px; }

  /* Quick links */
  .quick-link-card { flex-direction: column; text-align: center; padding: 12px; }
  .quick-link-card i { font-size: 1.5rem; }
}

/* ── Responsive desktop (≥ 1025px) ──────────────────────────── */
@media (min-width: 1025px) {
  .page-title { font-size: 1.6rem; }
  .sidebar-brand { font-size: 1.2rem; }

  /* Sidebar visible et fixed sur desktop */
  #topbar-mobile { display: none !important; }

  #sidebar {
    transform: translateX(0) !important;
    position: fixed !important;
    top: 0;
    left: 0;
    z-index: 1050;
  }

  #app-wrapper {
    padding-top: 0 !important;
    margin-left: var(--sidebar-w);
  }

  #main-content { overflow-x: visible; }
}
