/* LogiStock Pro - Styles v2.0 */

:root {
  --sidebar-bg: #1a2332;
  --sidebar-text: #a0aec0;
  --sidebar-active: #3b82f6;
  --primary: #3b82f6;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; }

/* ===================== SIDEBAR ===================== */
#sidebar {
  width: 260px;
  height: 100vh;
  max-height: 100vh;
  background: var(--sidebar-bg);
  position: fixed; left: 0; top: 0; z-index: 200;
  transition: width 0.3s ease, transform 0.3s ease;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex; flex-direction: column;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding-bottom: 36px; /* espace pour le footer fixe */
}
#sidebar.collapsed { width: 60px; }
#sidebar.collapsed .sidebar-text { display: none; }
#sidebar.collapsed .nav-section { display: none; }
#sidebar.collapsed .nav-item { justify-content: center; padding: 12px; }
#sidebar.collapsed .nav-item i { margin-right: 0; }
#main-content { margin-left: 260px; min-height: 100vh; transition: margin-left 0.3s ease; padding-bottom: 36px; }
#main-content.expanded { margin-left: 60px; }

/* Footer fixe bas de page */
#app-footer { left: 260px; transition: left 0.3s ease; }
#sidebar.collapsed ~ * #app-footer,
body.sidebar-collapsed #app-footer { left: 60px; }
@media (max-width: 768px) { #app-footer { left: 0 !important; } }

.nav-item {
  display: flex; align-items: center; padding: 10px 16px; color: var(--sidebar-text);
  text-decoration: none; border-radius: 8px; margin: 2px 8px; cursor: pointer;
  transition: all 0.2s; font-size: 0.875rem; border: none; background: none;
  width: calc(100% - 16px); text-align: left;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active { background: var(--sidebar-active); color: #fff; }
.nav-item i { width: 20px; margin-right: 10px; font-size: 1rem; flex-shrink: 0; }
.nav-section {
  padding: 16px 16px 4px; color: #4a5568; font-size: 0.7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
}

/* ===================== CARDS ===================== */
.stat-card {
  background: #fff; border-radius: 12px; padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  transition: transform 0.2s, box-shadow 0.2s; cursor: pointer;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }

/* ===================== PRODUCT CARD ===================== */
.product-card { transition: all 0.2s; }
.product-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.12); }

/* ===================== TABLES ===================== */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  background: #f8fafc; padding: 12px 16px; text-align: left; font-size: 0.75rem;
  font-weight: 700; color: #64748b; text-transform: uppercase; letter-spacing: 0.05em;
  border-bottom: 2px solid #e2e8f0;
}
.data-table td { padding: 12px 16px; border-bottom: 1px solid #f1f5f9; font-size: 0.875rem; 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; padding: 2px 10px; border-radius: 999px;
  font-size: 0.75rem; font-weight: 600;
}
.badge-draft { background: #f1f5f9; color: #64748b; }
.badge-active, .badge-confirmed, .badge-received { background: #dcfce7; color: #16a34a; }
.badge-pending, .badge-sent, .badge-in_progress { background: #fef3c7; color: #d97706; }
.badge-cancelled, .badge-expired { background: #fee2e2; color: #dc2626; }
.badge-warning { background: #fef3c7; color: #d97706; }
.badge-danger { background: #fee2e2; color: #dc2626; }
.badge-info { background: #dbeafe; color: #2563eb; }
.badge-partial { background: #e0f2fe; color: #0284c7; }
.badge-framework { background: #f3e8ff; color: #7c3aed; }

/* ===================== STOCK BARS ===================== */
.stock-bar { height: 6px; border-radius: 3px; background: #e2e8f0; overflow: hidden; }
.stock-bar-fill { height: 100%; border-radius: 3px; transition: width 0.3s; }
.stock-ok { background: #10b981; }
.stock-low { background: #f59e0b; }
.stock-critical { background: #ef4444; }

/* ===================== FORMS ===================== */
.form-input {
  width: 100%; padding: 8px 12px; border: 1px solid #e2e8f0; border-radius: 8px;
  font-size: 0.875rem; transition: border-color 0.2s; outline: none; background: #fff;
  color: #1e293b;
}
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }
select.form-input { cursor: pointer; }
textarea.form-input { resize: vertical; min-height: 60px; }
.form-label { display: block; margin-bottom: 4px; font-size: 0.8rem; font-weight: 600; color: #374151; }
.form-group { margin-bottom: 16px; }

/* ===================== BUTTONS ===================== */
/* Taille de base = ce que l'ancien btn-sm était : petit, compact, pill */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  padding: 6px 14px; border-radius: 999px;
  font-size: 0.8rem; font-weight: 600; cursor: pointer; border: none;
  transition: all 0.15s ease; text-decoration: none; white-space: nowrap;
  text-align: center; vertical-align: middle; line-height: 1.25;
  box-sizing: border-box; width: auto; letter-spacing: 0.01em;
}
button.btn, a.btn { width: auto; }
button.btn.flex-1, a.btn.flex-1 { width: 0 !important; flex: 1 1 0% !important; min-width: 0; }
button.btn.w-full, a.btn.w-full { width: 100% !important; }

/* Couleurs */
.btn-primary {
  background: #3b82f6; color: #fff;
  box-shadow: 0 2px 8px rgba(59,130,246,0.30);
}
.btn-primary:hover { background: #2563eb; box-shadow: 0 4px 12px rgba(59,130,246,0.40); transform: translateY(-1px); }
.btn-success { background: #10b981; color: #fff; box-shadow: 0 2px 8px rgba(16,185,129,0.25); }
.btn-success:hover { background: #059669; transform: translateY(-1px); }
.btn-warning { background: #f59e0b; color: #fff; }
.btn-warning:hover { background: #d97706; transform: translateY(-1px); }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; transform: translateY(-1px); }
.btn-secondary { background: #f1f5f9; color: #374151; border: 1px solid #e2e8f0; }
.btn-secondary:hover { background: #e2e8f0; transform: translateY(-1px); }

/* Tailles */
/* btn-sm = alias identique à .btn (compatibilité) */
.btn-sm { padding: 6px 14px; font-size: 0.8rem; gap: 5px; }
/* btn-xs : minuscule, dans les cellules de tableau / tuiles stock */
.btn-xs { padding: 3px 9px; font-size: 0.72rem; gap: 4px; }
/* btn-lg : CTA important (ex: "Nouvelle session", login, soumettre) */
.btn-lg { padding: 10px 22px; font-size: 0.9rem; gap: 8px; font-weight: 700;
  box-shadow: 0 4px 14px rgba(59,130,246,0.35); }

.btn-icon {
  padding: 8px; border-radius: 50%; background: #f1f5f9; color: #374151;
  cursor: pointer; border: none; transition: all 0.18s;
  display: inline-flex; align-items: center; justify-content: center;
  width: auto;
}
.btn-icon:hover { background: #e2e8f0; transform: translateY(-1px); }
.w-full { width: 100%; justify-content: center; border-radius: 999px; }

/* Container inventaire non-empty-state avec bouton centré */
.empty-state-box {
  text-align: center; padding: 48px 20px; color: #94a3b8;
  display: block;
}
/* Icône décorative de l'empty-state-box (directe, PAS dans un bouton) */
.empty-state-box > i,
.empty-state-box > p + i { font-size: 2.5rem; margin-bottom: 8px; display: block; }
/* Icône dans un bouton : taille normale */
.empty-state-box .btn i,
.empty-state-box button i { font-size: inherit !important; display: inline !important; margin-bottom: 0 !important; }
.empty-state-box .btn, .empty-state-box button {
  display: inline-flex !important; width: auto !important;
  min-width: 0 !important; max-width: 260px !important;
  align-self: auto !important; margin-top: 8px;
}
/* Boutons dans les modal-footer */
.modal-footer .btn { flex-shrink: 0; width: auto; }
/* Boutons dans les page-header */
.page-header .btn { align-self: center; width: auto; }

/* ===================== MODAL ===================== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 16px;
  animation: fadeIn 0.2s ease;
}
.modal-box {
  background: #fff; border-radius: 16px; max-width: 700px; width: 100%;
  max-height: 92vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  animation: slideUp 0.25s ease;
}
.modal-header {
  padding: 20px 24px; border-bottom: 1px solid #e2e8f0;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: #fff; z-index: 1;
}
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px; border-top: 1px solid #e2e8f0;
  display: flex; gap: 8px; justify-content: flex-end;
  position: sticky; bottom: 0; background: #fff;
}

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

/* ===================== TOASTS ===================== */
.toast {
  padding: 12px 16px; border-radius: 10px; color: #fff; font-size: 0.875rem;
  display: flex; align-items: center; gap: 8px; min-width: 280px; max-width: 400px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2); animation: slideIn 0.3s ease;
  transition: opacity 0.4s ease;
}
.toast.fade-out { opacity: 0; }
.toast-success { background: #10b981; }
.toast-error { background: #ef4444; }
.toast-warning { background: #f59e0b; }
.toast-info { background: #3b82f6; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===================== BARCODE ===================== */
.barcode-container {
  font-family: 'Courier New', monospace; font-size: 1.5rem;
  letter-spacing: 0.1em; background: #f8fafc; padding: 8px 16px;
  border-radius: 8px; border: 2px dashed #e2e8f0; text-align: center;
}

/* ===================== SCANNER ===================== */
.scan-crosshair {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 200px; height: 120px; pointer-events: none;
}
.scan-crosshair::before, .scan-crosshair::after {
  content: ''; position: absolute; border-color: #22d3ee; border-style: solid;
}
.scan-crosshair::before {
  top: 0; left: 0; width: 30px; height: 30px;
  border-width: 3px 0 0 3px;
}
.scan-crosshair::after {
  bottom: 0; right: 0; width: 30px; height: 30px;
  border-width: 0 3px 3px 0;
}
/* Coins supplémentaires via box-shadow simulés */
#scan-video { transform: scaleX(1); }

/* Animation ligne de scan */
@keyframes scanLine {
  0% { top: 10%; }
  100% { top: 90%; }
}
.scan-line {
  position: absolute; left: 10%; right: 10%; height: 2px;
  background: linear-gradient(to right, transparent, #22d3ee, transparent);
  animation: scanLine 2s linear infinite; box-shadow: 0 0 8px #22d3ee;
}

/* ===================== PRINT LABELS ===================== */
@media print {
  #sidebar, #topbar, .no-print, .modal-overlay { display: none !important; }
  #main-content { margin-left: 0 !important; }
  body { background: white; }
  .label-preview {
    float: left; margin: 4px !important;
    box-shadow: none !important;
    border: 1px solid #000 !important;
    page-break-inside: avoid;
  }
}

/* ===================== LABEL PREVIEW ===================== */
.label-preview {
  display: flex; flex-direction: column; align-items: center;
  justify-content: space-between; background: #fff;
  border: 1px solid #ddd; border-radius: 4px; padding: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15); font-family: Arial, sans-serif;
  min-width: 80px; min-height: 50px;
}
.label-preview svg { max-width: 100%; }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 768px) {
  #sidebar { transform: translateX(-260px); width: 260px; }
  #sidebar.mobile-open { transform: translateX(0); }
  #sidebar.collapsed { transform: translateX(-260px); }
  #main-content { margin-left: 0; }
  #main-content.expanded { margin-left: 0; }
  .modal-box { max-width: 100% !important; margin: 8px; border-radius: 12px; }
  .data-table th, .data-table td { padding: 8px 10px; font-size: 0.8rem; }
}

/* ===================== UTILITIES ===================== */
.highlight { background: #fef08a; padding: 0 2px; border-radius: 2px; }

.spinner {
  display: inline-block; width: 20px; height: 20px; border: 3px solid #e2e8f0;
  border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

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

.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: #64748b; flex-wrap: wrap; }
.breadcrumb a { color: var(--primary); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

/* ===================== TABS ===================== */
.tab-bar { display: flex; gap: 4px; border-bottom: 2px solid #e2e8f0; margin-bottom: 20px; overflow-x: auto; }
.tab {
  padding: 8px 16px; cursor: pointer; font-size: 0.875rem; font-weight: 600;
  color: #64748b; border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: all 0.2s; white-space: nowrap;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab:hover:not(.active) { color: #374151; }

/* ===================== LOGIN ===================== */
.login-container {
  min-height: 100vh;
  background: linear-gradient(135deg, #1a2332 0%, #2d3748 50%, #1a365d 100%);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.login-box {
  background: #fff; border-radius: 20px; padding: 40px; width: 100%; max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

/* ===================== PAGE HEADER ===================== */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.page-title { font-size: 1.5rem; font-weight: 800; color: #1e293b; }

/* ===================== EMPTY STATE ===================== */
.empty-state {
  display: block;
  text-align: center;
  padding: 60px 20px;
  color: #94a3b8;
}
/* Icône décorative de l'empty-state (directe, PAS dans un bouton) */
.empty-state > i,
.empty-state > p + i {
  font-size: 3rem; margin-bottom: 16px; display: block;
}
/* Icône dans un bouton : taille normale héritée du btn */
.empty-state .btn i,
.empty-state button i { font-size: inherit !important; display: inline !important; margin-bottom: 0 !important; }
.empty-state p { margin: 0 0 8px; }

/* ===================== SCROLLBAR ===================== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ===================== TOPBAR ===================== */
#topbar { height: 56px; }

/* ===================== PRODUCT IMAGE ===================== */
.product-image-container { position: relative; }

/* ===================== MISC ===================== */
.text-yellow-400 { color: #facc15; }
.text-gray-200 { color: #e5e7eb; }
.mr-1 { margin-right: 4px; }
.mr-2 { margin-right: 8px; }
.hidden { display: none !important; }
.flex-shrink-0 { flex-shrink: 0; }

/* ── Étiquettes : boutons format ── */
.lbl-fmt-btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  cursor: pointer; padding: 10px 6px;
  border: 2px solid #e5e7eb; border-radius: 12px;
  background: #fff; transition: all 0.2s;
}
.lbl-fmt-btn:hover { border-color: #93c5fd; }
.lbl-fmt-btn.selected { border-color: #3b82f6; background: #eff6ff; }
