/* ============================================================
   GESTION STOCK FIRE STICK — Interface Premium
   Design : glassmorphism, dégradés, typographie système
   Tous les assets sont intégrés (aucun CDN externe requis)
   ============================================================ */

:root {
  --brand: #4f46e5;
  --brand-dark: #4338ca;
  --brand-light: #818cf8;
  --bg: #0f172a;
  --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  --card: rgba(30, 41, 59, 0.6);
  --card-border: rgba(255, 255, 255, 0.08);
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.15);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.15);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.15);
  --info: #3b82f6;
  --shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.2);
  --radius: 16px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-gradient);
  color: var(--text);
  margin: 0;
  padding: 0;
  line-height: 1.6;
  min-height: 100vh;
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--card-border);
  color: #fff;
  padding: 0.9rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #fff;
  text-decoration: none;
}

.brand .mark {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #818cf8, #c4b5fd);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.nav-links {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.55rem 1rem;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  transition: var(--transition);
  border: 1px solid transparent;
}

.nav-links a:hover {
  color: #fff;
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.12);
}

.nav-links a.active {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  border-color: rgba(127, 127, 255, 0.4);
  box-shadow: 0 4px 12px -2px rgba(79, 70, 229, 0.4);
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.88rem;
  opacity: 0.9;
}

.nav-user span {
  background: rgba(255,255,255,0.08);
  padding: 0.35rem 0.8rem;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.12);
}

.btn-logout {
  background: rgba(239, 68, 68, 0.12);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
  padding: 0.45rem 0.9rem;
  border-radius: 10px;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  transition: var(--transition);
}

.btn-logout:hover {
  background: rgba(239, 68, 68, 0.25);
  color: #fecaca;
  border-color: rgba(239, 68, 68, 0.5);
}

/* ---------- Container ---------- */
.container {
  max-width: 1300px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ---------- Flash messages ---------- */
.flash-messages {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.75rem;
}

.alert {
  padding: 1rem 1.25rem;
  border-radius: 12px;
  font-size: 0.92rem;
  font-weight: 500;
  animation: slideIn 0.4s ease;
  border: 1px solid;
  backdrop-filter: blur(8px);
}

.alert-success { background: var(--success-bg); color: #86efac; border-color: rgba(16,185,129,0.4); }
.alert-danger   { background: var(--danger-bg); color: #fca5a5; border-color: rgba(239,68,68,0.4); }
.alert-info     { background: rgba(59,130,246,0.12); color: #bfdbfe; border-color: rgba(59,130,246,0.4); }
.alert-warning  { background: var(--warning-bg); color: #fcd34d; border-color: rgba(245,158,11,0.4); }

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Page header ---------- */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
}

.page-header h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(to right, #fff, #cbd5e1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.page-header .sub {
  margin: 0.35rem 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* ---------- Stats grid ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1rem;
  margin-bottom: 2.5rem;
}

.card.stat {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 1.5rem 1.25rem;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
  backdrop-filter: blur(12px);
}

.card.stat::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, var(--brand), var(--info));
  opacity: 0.9;
}

.card.stat:hover {
  transform: translateY(-4px);
  border-color: rgba(255,255,255,0.18);
  box-shadow: var(--shadow);
}

.stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.stat-value {
  font-size: 2.1rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.1;
}

.card.stat.danger .stat-value { color: #fca5a5; }
.card.stat.success .stat-value { color: #86efac; }
.card.stat.info .stat-value { color: #bfdbfe; }

/* ---------- Dashboard row ---------- */
.dashboard-row {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

@media (max-width: 900px) {
  .dashboard-row { grid-template-columns: 1fr; }
}

/* ---------- Panels ---------- */
.panel {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  backdrop-filter: blur(12px);
  transition: var(--transition);
}

.panel:hover { border-color: rgba(255,255,255,0.12); }

.panel-title {
  font-size: 1rem;
  font-weight: 800;
  color: #fff;
  margin: 0 0 1.25rem 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  letter-spacing: -0.3px;
}

.empty {
  color: var(--text-muted);
  font-style: italic;
  padding: 1.5rem;
  text-align: center;
  border: 1px dashed rgba(255,255,255,0.1);
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
}

/* ---------- Widgets stock ---------- */
.widget-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.stock-widget {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 1.1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.stock-widget::before {
  content: "";
  position: absolute;
  top: 0; left: 0; width: 4px; height: 100%;
  transition: var(--transition);
}

.stock-widget.critique::before { background: var(--danger); }
.stock-widget.faible::before    { background: var(--warning); }
.stock-widget.ok::before        { background: var(--success); }

.stock-widget:hover {
  transform: translateY(-3px);
  border-color: rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.06);
}

.stock-widget .widget-ref {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--brand-light);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.stock-widget .widget-nom {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
}

.stock-widget .widget-status {
  font-size: 1.05rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.stock-widget.critique .widget-status { color: #fca5a5; }
.stock-widget.faible    .widget-status { color: #fcd34d; }
.stock-widget.ok        .widget-status { color: #86efac; }

.stock-widget .widget-details {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: auto;
}

.stock-widget .widget-btn {
  margin-top: auto;
  padding: 0.45rem 0.75rem;
  font-size: 0.8rem;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  transition: var(--transition);
  text-align: center;
  width: fit-content;
}

.stock-widget .widget-btn:hover {
  background: var(--brand-dark);
  transform: scale(1.03);
}

/* ---------- Vente rapide ---------- */
.vente-panel { padding: 1.5rem 1.25rem; }

.quick-form .row2 { gap: 1rem; }
.quick-form .field { margin-bottom: 0.9rem; }
.quick-form .field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.quick-form input,
.quick-form select {
  width: 100%;
  padding: 0.7rem 0.9rem;
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  color: #fff;
  font-size: 0.92rem;
  transition: var(--transition);
}

.quick-form input:focus,
.quick-form select:focus {
  outline: none;
  border-color: var(--brand-light);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
  background: rgba(0,0,0,0.35);
}

.quick-form select {
  cursor: pointer;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #cbd5e1 50%), linear-gradient(135deg, #cbd5e1 50%, transparent 50%);
  background-position: calc(100% - 12px) 14px, calc(100% - 8px) 14px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 2rem;
}

.total-box {
  background: linear-gradient(135deg, rgba(16,185,129,0.18), rgba(16,185,129,0.06));
  border: 1px solid rgba(16,185,129,0.3);
  color: #86efac;
  padding: 0.9rem 1.1rem;
  border-radius: 10px;
  font-size: 1.1rem;
  font-weight: 800;
  text-align: center;
  margin: 1rem 0;
}

.reappro {
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 1.25rem;
  margin-top: 1.5rem;
}

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
  margin-bottom: 1.5rem;
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  overflow: hidden;
  backdrop-filter: blur(12px);
}

.table th {
  background: rgba(0,0,0,0.2);
  color: var(--text-muted);
  text-align: left;
  padding: 0.95rem 1.1rem;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--card-border);
}

.table td {
  padding: 1rem 1.1rem;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 0.92rem;
  color: #e2e8f0;
}

.table tr:last-child td { border-bottom: none; }
.table tr:hover { background: rgba(255,255,255,0.03); }

.table tr.danger td { background: rgba(239,68,68,0.08); }
.table tr.warning td { background: rgba(245,158,11,0.08); }
.table tr.success td { background: rgba(16,185,129,0.06); }

/* ---------- Actions ---------- */
.actions {
  display: flex;
  gap: 0.5rem;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  padding: 0.75rem 1.4rem;
  border: none;
  border-radius: 10px;
  font-size: 0.92rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  line-height: 1.2;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  box-shadow: 0 4px 14px -2px rgba(79, 70, 229, 0.4);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--brand-dark), #3730a3);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px -4px rgba(79, 70, 229, 0.5);
}

.btn-success {
  background: linear-gradient(135deg, var(--success), #047857);
  color: #fff;
  box-shadow: 0 4px 14px -2px rgba(16, 185, 129, 0.4);
}

.btn-success:hover {
  background: linear-gradient(135deg, #047857, #065f46);
  transform: translateY(-2px);
}

.btn-outline {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.18);
}

.btn-outline:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.35);
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger), #b91c1c);
  color: #fff;
}

.btn-danger:hover {
  background: linear-gradient(135deg, #b91c1c, #7f1d1d);
  transform: translateY(-2px);
}

.btn-sm { padding: 0.45rem 0.8rem; font-size: 0.82rem; }

.btn-block { width: 100%; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.badge-ok { background: var(--success-bg); color: #86efac; border: 1px solid rgba(16,185,129,0.3); }
.badge-attente { background: var(--warning-bg); color: #fcd34d; border: 1px solid rgba(245,158,11,0.3); }
.badge-partiel { background: rgba(59,130,246,0.15); color: #bfdbfe; border: 1px solid rgba(59,130,246,0.3); }

/* ---------- Forms ---------- */
.form-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 2rem;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
  max-width: 700px;
  margin: 0 auto;
}

.field {
  margin-bottom: 1.25rem;
}

.field label {
  display: block;
  font-weight: 700;
  font-size: 0.85rem;
  color: #cbd5e1;
  margin-bottom: 0.4rem;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 0.8rem 1rem;
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  color: #fff;
  font-size: 0.95rem;
  transition: var(--transition);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--brand-light);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
  background: rgba(0,0,0,0.35);
}

.field textarea { resize: vertical; min-height: 90px; }

.req { color: #fca5a5; }

.row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 560px) {
  .row2 { grid-template-columns: 1fr; }
}

/* ---------- Auth ---------- */
.auth-page {
  min-height: calc(100vh - 4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: var(--bg-gradient);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 24px;
  padding: 2.5rem 2rem;
  backdrop-filter: blur(24px);
  box-shadow: 0 32px 64px -12px rgba(0,0,0,0.5);
}

.auth-header {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-header .mark {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, #818cf8, #c4b5fd);
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  margin-bottom: 1rem;
}

.auth-header h2 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.auth-header p {
  color: var(--text-muted);
  margin: 0.5rem 0 0;
  font-size: 0.92rem;
}

.auth-footer {
  margin-top: 1.75rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 0.88rem;
  color: var(--text-muted);
  text-align: center;
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .container { padding: 1rem; }
  .topbar { flex-direction: column; align-items: stretch; gap: 0.75rem; }
  .nav-links { justify-content: center; }
  .nav-user { justify-content: center; order: -1; width: 100%; justify-content: flex-end; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .panel { padding: 1.25rem; }
  .form-card { padding: 1.5rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ---------- Alerte text ---------- */
.alerte {
  padding: 0.9rem 1.1rem;
  border-radius: 10px;
  margin-bottom: 0.75rem;
  font-size: 0.92rem;
  font-weight: 600;
  border: 1px solid;
  backdrop-filter: blur(6px);
}

.alerte.critique  { background: var(--danger-bg); color: #fca5a5; border-color: rgba(239,68,68,0.3); }
.alerte.faible    { background: var(--warning-bg); color: #fcd34d; border-color: rgba(245,158,11,0.3); }
.alerte.ok        { background: var(--success-bg); color: #86efac; border-color: rgba(16,185,129,0.3); }

.last-sale {
  font-size: 1rem;
  line-height: 1.7;
  color: #e2e8f0;
}
