/* ============ CosmoStock — Dashboard admin ============ */
/* ---------- Écran de connexion admin ---------- */
.auth-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: linear-gradient(135deg, #0f172a, #1e1b4b);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
body.unlocked .auth-overlay { display: none; }
.auth-card {
  background: var(--surface); border-radius: var(--radius); padding: 32px;
  width: 100%; max-width: 360px; box-shadow: 0 20px 60px rgba(0, 0, 0, .45);
}
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-logo { font-size: 34px; }
.auth-brand h1 { font-size: 22px; margin: 8px 0 2px; }
.auth-brand p { color: var(--text-muted); font-size: 13px; margin-bottom: 20px; }
.field-error {
  background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca;
  padding: 8px 10px; border-radius: 6px; font-size: 12.5px; margin-bottom: 12px;
}
.auth-help { display: block; text-align: center; color: var(--text-muted); font-size: 12px; margin-top: 14px; }
.btn-logout {
  width: 100%; margin-top: 10px; background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .18); color: #fff; font-size: 12.5px; padding: 8px;
}
.btn-logout:hover { background: rgba(239, 68, 68, .85); border-color: transparent; }

:root {
  --primary: #7c3aed;
  --primary-dark: #6d28d9;
  --primary-light: #ede9fe;
  --sidebar-bg: #1e1b2e;
  --sidebar-text: #b9b3d4;
  --sidebar-active: #2a2440;
  --bg: #f4f4f8;
  --surface: #ffffff;
  --border: #e6e6ef;
  --soft: #fbfaff;
  --hover: #faf9ff;
  --text: #1f2333;
  --text-muted: #6b7280;
  --success: #16a34a;
  --success-bg: #dcfce7;
  --warning: #d97706;
  --warning-bg: #fef3c7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(30, 27, 46, .08), 0 4px 16px rgba(30, 27, 46, .06);
  --primary-grad: linear-gradient(135deg, #8b5cf6, #6d28d9);
  --stat-accent: linear-gradient(135deg, #ffffff 55%, #f2ecff);
  --bar-empty: #e5e7eb;
}

body.theme-dark {
  --primary: #a78bfa;
  --primary-dark: #8b5cf6;
  --primary-light: rgba(139, 92, 246, .16);
  --sidebar-bg: #12142a;
  --sidebar-text: #9fa3c8;
  --sidebar-active: #22264a;
  --bg: #0e101f;
  --surface: #181b30;
  --border: #262b46;
  --soft: #1d2138;
  --hover: #22263f;
  --text: #e8eaf5;
  --text-muted: #9aa0be;
  --success: #4ade80;
  --success-bg: rgba(34, 197, 94, .14);
  --warning: #fbbf24;
  --warning-bg: rgba(217, 119, 6, .16);
  --danger: #f87171;
  --danger-bg: rgba(220, 38, 38, .16);
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, .35), 0 6px 20px rgba(0, 0, 0, .3);
  --primary-grad: linear-gradient(135deg, #7c3aed, #5b21b6);
  --stat-accent: linear-gradient(135deg, #181b30 55%, #241d3d);
  --bar-empty: #333a5c;
}
body.theme-dark .brand-icon { background: linear-gradient(135deg, #8b5cf6, #4c1d95); }
body.theme-dark .toast { background: #262b46; }
body.theme-dark .btn-logout { background: rgba(255, 255, 255, .06); }

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

.app { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

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

.brand-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  font-size: 22px;
  background: var(--primary-grad);
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(124, 58, 237, .4);
}

.brand-text { display: flex; flex-direction: column; }
.brand-name { font-weight: 700; font-size: 17px; color: #fff; letter-spacing: .3px; }
.brand-sub { font-size: 11px; color: #8b86a5; text-transform: uppercase; letter-spacing: 1px; }

.sidebar-nav { flex: 1; padding: 14px 10px; display: flex; flex-direction: column; gap: 4px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border: none;
  background: transparent;
  color: var(--sidebar-text);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background .15s, color .15s;
  font-family: inherit;
}

.nav-item:hover { background: rgba(255, 255, 255, .05); color: #fff; }
.nav-item.active { background: var(--sidebar-active); color: #fff; box-shadow: inset 3px 0 0 var(--primary); }
.nav-icon { font-size: 17px; width: 22px; text-align: center; }

.sidebar-footer { padding: 14px 18px; border-top: 1px solid rgba(255, 255, 255, .06); }

.connection-status { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #8b86a5; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--warning); }
.connection-status.connected .status-dot { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .18); }
.connection-status.error .status-dot { background: var(--danger); }

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; padding: 22px 26px; overflow-x: clip; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
  flex-wrap: wrap;
}

.topbar-title { min-width: 0; }
.topbar-title h1 { font-size: 22px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-date { font-size: 13px; color: var(--text-muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary { background: var(--primary-grad); border: none; color: #fff; box-shadow: 0 4px 12px rgba(124, 58, 237, .25); }
.btn-primary:hover { filter: brightness(1.05); color: #fff; transform: translateY(-1px); }

.btn-danger { background: var(--danger-bg); border-color: transparent; color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-refresh { background: var(--surface); }
.btn-refresh.loading { opacity: .6; pointer-events: none; }

.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn-block { width: 100%; justify-content: center; }
.btn-lg { padding: 13px 20px; font-size: 15px; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }

/* ---------- Panels & cards ---------- */
.panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
  min-width: 0;
}

.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-title { font-size: 16px; font-weight: 700; margin-bottom: 14px; }
.panel-head .panel-title { margin-bottom: 0; }
.panel-subtitle { font-size: 14px; font-weight: 600; margin: 18px 0 10px; }
.panel-badge { font-size: 12.5px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; min-width: 0; }
.grid-2 .panel { margin-bottom: 0; min-width: 0; }
@media (max-width: 1000px) { .grid-2 { grid-template-columns: 1fr; } }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  border-left: 4px solid var(--border);
}
.stat-card.accent { border-left-color: var(--primary); background: var(--stat-accent); }
.stat-label { font-size: 12.5px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.stat-value { font-size: 22px; font-weight: 800; margin-top: 6px; }
.stat-value .unit { font-size: 14px; font-weight: 600; color: var(--text-muted); }

.panels-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.panels-grid .panel { margin-bottom: 0; }
@media (max-width: 1000px) { .panels-grid { grid-template-columns: 1fr; } }

/* ---------- Pages ---------- */
.page { display: none; }
.page.active { display: block; }

.page-toolbar { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }

.search-box { flex: 1; min-width: 200px; max-width: 420px; }
.search-box.mb { margin-bottom: 14px; max-width: 100%; }
.filter-select {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font-size: 13.5px; cursor: pointer;
  min-width: 180px; max-width: 240px;
}
.filter-select:focus { outline: none; border-color: var(--primary); }

.search-box input, .form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.search-box input:focus, .form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, .12);
}

.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.boutique-link-row { display: flex; gap: 8px; align-items: stretch; }
.boutique-link-row input { flex: 1; min-width: 0; }
.boutique-link-row .btn { white-space: nowrap; }
.field-help { display: block; margin-top: 5px; font-size: 12px; color: var(--text-muted); }
.field-help code { background: var(--primary-light); padding: 1px 6px; border-radius: 5px; font-size: 11.5px; color: var(--primary-dark); }

.report-period { width: 200px; margin-bottom: 0; }

/* ---------- Tables ---------- */
.table-responsive { overflow-x: auto; }

.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left;
  padding: 10px 12px;
  background: var(--soft);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .4px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover { background: var(--hover); }
.table tbody tr[data-order] { cursor: pointer; }
.table tbody tr[data-order]:hover { background: rgba(var(--accent-rgb, 124, 58, 237), 0.07); }
.table .sub-cell { font-size: 0.78em; color: var(--text-muted); }
.table .r { text-align: right; }
.table .hidden { display: none; }

.sd-meta { margin: 0 0 14px; color: var(--text-muted); font-size: 0.94em; }
.sd-totals { margin-top: 16px; padding-top: 12px; border-top: 1px dashed var(--border); display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.sd-row { display: flex; gap: 18px; font-size: 0.95em; }
.sd-row b { min-width: 90px; text-align: right; }
.sd-remise { color: var(--danger, #dc2626); }
.sd-net { font-size: 1.2em; font-weight: 700; color: var(--accent); }

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-neutral { background: var(--soft); color: var(--text-muted); }

/* ---------- Lists ---------- */
.list-container { display: flex; flex-direction: column; gap: 8px; }
.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 13px;
  background: var(--soft);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.item-name { font-weight: 600; }
.item-sub { font-size: 12.5px; color: var(--text-muted); }

.empty-state { padding: 26px 14px; text-align: center; color: var(--text-muted); font-size: 13.5px; }

/* ---------- Toasts ---------- */
.toast-container { position: fixed; top: 18px; right: 18px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 16px;
  border-radius: 10px;
  background: #1f2333;
  color: #fff;
  font-size: 13.5px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
  animation: slideIn .2s ease;
  max-width: 360px;
}
.toast.success { background: #16a34a; }
.toast.error { background: #dc2626; }
.toast.warning { background: #d97706; }
.toast.fade-out { opacity: 0; transition: opacity .4s; }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Sale preview ---------- */
.sale-preview { background: var(--primary-light); border: 1px solid #ddd6fe; border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; font-size: 13px; }
.preview-row { display: flex; justify-content: space-between; padding: 4px 0; color: var(--text); }
.preview-total { border-top: 1px solid #c4b5fd; margin-top: 6px; padding-top: 8px; font-weight: 700; }

/* ---------- Modals ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 12, 30, .55);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  z-index: 900;
  overflow-y: auto;
}
.modal.hidden { display: none; }

.modal-content {
  background: var(--surface);
  border-radius: 16px;
  width: 100%;
  max-width: 540px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .25);
  padding: 24px;
  animation: fadeUp .18s ease;
}
.modal-sm { max-width: 420px; }
@keyframes fadeUp { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-header h2 { font-size: 18px; }
.modal-close { border: none; background: transparent; font-size: 24px; color: var(--text-muted); cursor: pointer; line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.modal p { color: var(--text-muted); }

/* ---------- Settings status ---------- */
.settings-status { margin-top: 12px; padding: 10px 12px; border-radius: 10px; font-size: 13px; background: var(--success-bg); color: var(--success); font-weight: 600; }
.settings-status.error { background: var(--danger-bg); color: var(--danger); }
.settings-status.hidden { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .sidebar { width: 68px; }
  .sidebar-brand { padding: 14px 10px; justify-content: center; }
  .brand-text, .nav-item span:last-child, .connection-status span:last-child { display: none; }
  .nav-item { justify-content: center; padding: 12px; }
  .sidebar-footer { padding: 10px; display: flex; justify-content: center; }
  .main { padding: 16px; }
}

/* ---------- Photo produit ---------- */
.btn-secondary { background: var(--surface); }
.product-thumb {
  width: 42px; height: 42px; object-fit: cover;
  border-radius: 8px; border: 1px solid var(--border);
}
.thumb-emoji { font-size: 20px; }
.photo-preview {
  width: 84px; height: 84px; object-fit: cover;
  border-radius: 10px; border: 1px solid var(--border);
  display: block; margin-bottom: 8px;
}
.photo-preview.hidden { display: none; }

/* ---------- Catégories ---------- */
.category-add { display: flex; gap: 10px; margin-bottom: 12px; }
.category-add input { flex: 1; }
.categories-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; max-height: 260px; overflow-y: auto; }
.category-item {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 12px;
}
.category-name { font-weight: 600; }

/* ---------- Crop / zoom photo ---------- */
.modal-lg { max-width: 640px; }
.crop-area {
  display: flex; align-items: center; justify-content: center;
  background: #0f0c1e; border-radius: 14px; padding: 12px;
  margin-bottom: 14px;
}
.crop-area canvas {
  max-width: 100%; height: auto; border-radius: 8px;
  cursor: grab; touch-action: none; user-select: none;
}
.crop-area canvas.dragging { cursor: grabbing; }
.crop-controls { display: flex; flex-direction: column; gap: 8px; }
.crop-zoom-row { display: flex; align-items: center; gap: 10px; }
.crop-zoom-row input[type="range"] { flex: 1; accent-color: var(--primary); }

/* ---------- Ventes (aperçu + dates) ---------- */
.sales-toolbar {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.sales-controls { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.date-chip-group { display: flex; gap: 6px; flex-wrap: wrap; }
.date-chip {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: 999px; padding: 6px 12px; font-size: 12.5px; font-weight: 600;
  cursor: pointer; transition: all .15s;
}
.date-chip:hover { border-color: var(--primary); color: var(--primary); }
.date-chip.active { background: var(--primary-grad); border-color: transparent; color: #fff; box-shadow: 0 4px 10px rgba(124, 58, 237, .25); }
.date-range { display: flex; gap: 10px; align-items: flex-end; }
.date-range .form-group { margin: 0; }
.date-range label { font-size: 12px; }
.date-range input[type="date"] { padding: 8px 10px; font-size: 13px; }
.sales-toolbar .search-box { flex: 1; min-width: 220px; max-width: 340px; }
#salesStats { margin-top: 4px; }

/* ---------- Graphique ventes par jour ---------- */
.report-period input[type="month"] { padding: 8px 10px; font-size: 13px; }
.chart-period-label { font-size: 14px; font-weight: 700; color: var(--text-muted); margin-left: 6px; }
.chart-legend { display: flex; gap: 14px; align-items: center; font-size: 12.5px; color: var(--text-muted); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legend-ca { background: var(--primary-grad); }
.legend-profit { background: #10b981; }
.day-chart {
  position: relative; display: flex; align-items: stretch; gap: 2px; height: 240px;
  padding: 8px 6px 0; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); overflow: hidden;
}
.day-col { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100%; }
.day-bars { flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 2px; }
.bar {
  width: 42%; min-width: 3px; max-width: 26px; border-radius: 4px 4px 0 0; transition: filter .15s;
}
.bar-ca { background: var(--primary-grad); }
.bar-profit { background: #10b981; opacity: .85; }
.day-col:hover .bar-ca { filter: brightness(1.12); }
.day-col:hover .bar-profit { filter: brightness(1.15); }
.bar-empty { width: 100%; height: 0; border-top: 2px dashed var(--bar-empty); align-self: flex-end; }
.day-label { font-size: 10.5px; color: var(--text-muted); text-align: center; padding-top: 4px; }
.chart-tooltip {
  position: absolute; left: 4px; top: 4px; z-index: 5; background: #1f2937; color: #fff;
  font-size: 12px; padding: 6px 10px; border-radius: 6px; pointer-events: none;
  white-space: nowrap; box-shadow: 0 4px 12px rgba(0, 0, 0, .25);
}

/* ============================================================
   MODERN UI — animations, stats, login, grille produits, skeleton
   ============================================================ */

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
::selection { background: rgba(124, 58, 237, .25); }

/* ---------- Micro-animations ---------- */
.btn, .nav-item, .stat-card, .date-chip, .list-item, .product-card, .filter-select { transition: transform .18s ease, box-shadow .18s ease, background .18s ease, border-color .18s ease, color .18s ease, opacity .18s ease; }
.btn:active { transform: translateY(1px) scale(.97); }
.panel { transition: box-shadow .2s ease; }
.panel:hover { box-shadow: 0 8px 28px var(--shadow); }
.btn-primary { position: relative; overflow: hidden; }
.btn-primary::after {
  content: ""; position: absolute; top: 0; left: -80%; width: 55%; height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .35), transparent);
  transform: skewX(-20deg);
}
.btn-primary:hover::after { left: 130%; transition: left .55s ease; }
.stat-card { position: relative; }
.stat-card:hover, .product-card:hover { transform: translateY(-3px); box-shadow: 0 12px 28px rgba(30, 27, 46, .12); }
body.theme-dark .stat-card:hover, body.theme-dark .product-card:hover { box-shadow: 0 12px 30px rgba(0, 0, 0, .45); }
@keyframes popIn { from { transform: scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
.stat-card { animation: popIn .3s ease backwards; animation-delay: var(--delay, 0s); }

/* ---------- Cartes stats modernisées ---------- */
.stat-card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stat-ico {
  width: 40px; height: 40px; flex-shrink: 0; border-radius: 12px;
  display: grid; place-items: center; font-size: 19px;
  background: var(--primary-light); color: var(--primary-dark);
}
.stat-ico.green { background: var(--success-bg); color: var(--success); }
.stat-ico.amber { background: var(--warning-bg); color: var(--warning); }
.stat-ico.violet { background: var(--primary-light); color: var(--primary); }
.stat-ico.red { background: var(--danger-bg); color: var(--danger); }
.stat-spark { margin-top: 10px; }
.stat-spark svg { display: block; width: 100%; height: 34px; }
.grad-ring {
  width: 74px; height: 74px; border-radius: 50%; display: grid; place-items: center;
  background: var(--primary-grad); box-shadow: 0 8px 24px rgba(124, 58, 237, .5);
  animation: floatY 3.2s ease-in-out infinite;
}
@keyframes floatY { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

/* ---------- Écran de connexion modernisé ---------- */
.auth-overlay {
  background: linear-gradient(135deg, #0f172a, #1e1b4b, #312e81, #0f172a);
  background-size: 300% 300%;
  animation: gradShift 14s ease infinite;
}
@keyframes gradShift { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
.auth-overlay::before, .auth-overlay::after {
  content: ""; position: absolute; border-radius: 50%; filter: blur(70px); opacity: .5;
  pointer-events: none;
}
.auth-overlay::before { width: 340px; height: 340px; background: rgba(139, 92, 246, .55); top: -80px; left: -60px; }
.auth-overlay::after { width: 320px; height: 320px; background: rgba(34, 211, 238, .4); bottom: -90px; right: -50px; }
.auth-card, .auth-brand { position: relative; z-index: 1; }
.auth-card {
  border: 1px solid rgba(255, 255, 255, .14);
  animation: fadeUp .4s ease;
  backdrop-filter: blur(6px);
}
.auth-logo {
  width: 68px; height: 68px; display: grid; place-items: center; font-size: 32px;
  margin: 0 auto; border-radius: 20px; background: var(--primary-grad);
  box-shadow: 0 10px 28px rgba(124, 58, 237, .45); animation: floatY 3.2s ease-in-out infinite;
}
.auth-brand h1 { color: var(--text); }
.auth-brand p { color: var(--text-muted); margin-bottom: 20px; }

/* ---------- Grille produits ---------- */
.products-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px;
}
.product-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 14px; display: flex; flex-direction: column; gap: 10px;
  animation: popIn .28s ease backwards;
}
.product-card-media {
  height: 96px; border-radius: 10px; overflow: hidden; display: grid; place-items: center;
  background: var(--soft); font-size: 34px; border: 1px solid var(--border);
}
.product-card-media img { width: 100%; height: 100%; object-fit: cover; }
.product-card-name { font-size: 14.5px; font-weight: 700; line-height: 1.3; }
.product-card-ref { font-size: 11.5px; color: var(--text-muted); }
.product-card-prices { font-size: 12.5px; color: var(--text-muted); display: flex; gap: 10px; flex-wrap: wrap; }
.product-card-prices b { color: var(--text); }
.product-card-stock { margin-top: auto; }
.product-card-actions { display: flex; gap: 8px; }
.product-card-actions .btn { flex: 1; justify-content: center; }
.view-toggle-btn { min-width: 40px; justify-content: center; }

/* ---------- Skeleton loading ---------- */
.skel { position: relative; overflow: hidden; background: var(--soft); border-radius: 8px; }
.skel::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(139, 92, 246, .12), transparent);
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.skel-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.skel-card .skel { height: 14px; margin-bottom: 12px; }
.skel-card .skel.w60 { width: 60%; }
.skel-line { height: 14px; margin-bottom: 10px; }
.skel-table-row { height: 40px; margin-bottom: 6px; border-radius: 8px; background: var(--soft); position: relative; overflow: hidden; }
.skel-table-row::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(139, 92, 246, .12), transparent);
  animation: shimmer 1.3s infinite;
}

/* ---------- Caméra (Android) ---------- */
.btn-camera {
  background: linear-gradient(135deg, #10b981, #059669);
  border: none; color: #fff;
  box-shadow: 0 4px 12px rgba(16, 185, 129, .25);
}
.btn-camera:hover { filter: brightness(1.08); transform: translateY(-1px); }
body.theme-dark .btn-camera { color: #fff; }

/* ================== Mobile "app Android" ================== */
* { -webkit-tap-highlight-color: transparent; }
html { overscroll-behavior-y: none; }
body {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  font-family: Roboto, 'Segoe UI', system-ui, -apple-system, sans-serif;
}
input, textarea { -webkit-user-select: text; user-select: text; }

.mobile-nav { display: none; }

@media (max-width: 760px) {
  .sidebar { display: none; }
  .mobile-nav { display: flex; }
  .main { padding: 14px 14px calc(96px + env(safe-area-inset-bottom, 0px)); }
  .topbar { flex-wrap: nowrap; margin-bottom: 14px; }
  .topbar-title h1 { font-size: 18px; }
  .topbar-date { display: none; }
  .btn-refresh { padding: 9px 12px; border-radius: 12px; white-space: nowrap; }
  .search-box { max-width: none; min-width: 0; }
  .page-toolbar .btn { padding: 11px 14px; border-radius: 12px; }
  .form-group input, .form-group select { padding: 12px 14px; border-radius: 12px; }
  .stat-value { font-size: 24px; }
  .modal { padding: 12px; align-items: flex-end; }
  .modal-content {
    border-radius: 20px 20px 0 0;
    max-height: 92vh; overflow-y: auto;
    animation: sheetUpMobile .22s ease;
    border-bottom-left-radius: 0; border-bottom-right-radius: 0;
  }
  .modal-close { font-size: 22px; }
  .toast-container { top: calc(env(safe-area-inset-top, 0px) + 12px); right: 12px; left: 12px; align-items: stretch; }
  .toast { max-width: none; }
}

@keyframes sheetUpMobile { from { transform: translateY(24px); opacity: .5; } to { transform: none; opacity: 1; } }

.mobile-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -6px 24px rgba(0, 0, 0, .08);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
  justify-content: space-around;
  overflow: hidden;
}
.mobile-nav .nav-item {
  flex: 1 0 0; min-width: 0; max-width: none;
  flex-direction: column; gap: 3px; padding: 5px 2px; font-size: 10px; color: var(--text-muted);
  overflow: hidden; white-space: nowrap;
}
.mobile-nav .nav-item span:last-child { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; padding: 0 1px; }
.mobile-nav .nav-icon { font-size: 20px; width: auto; flex: 0 0 auto; }
.mobile-nav .nav-item.active { background: none; color: var(--primary); box-shadow: none; font-weight: 700; }
body.theme-dark .mobile-nav { background: var(--surface); border-top-color: var(--border); }
body.theme-dark .mobile-nav .nav-item.active { color: var(--primary-dark); }

/* ---------- Responsive produit / mobile ---------- */
@media (max-width: 760px) {
  .btn-row { flex-wrap: wrap; }
  .page-toolbar {
    flex-wrap: wrap; gap: 10px; align-items: stretch;
  }
  .page-toolbar .search-box { flex: 1 1 100%; }
  .page-toolbar .filter-select { flex: 1 1 auto; min-width: 0; }
  .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table { min-width: 640px; }
  .products-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .product-card { padding: 10px; gap: 8px; }
  .product-card-media { height: 84px; }
  .product-card-name { font-size: 13px; }
  .product-card-prices { font-size: 11.5px; gap: 6px; }
  .product-card-actions { flex-direction: column; gap: 6px; }
}

/* ---------- Rapports : périodes + calendrier ---------- */
.report-head { align-items: flex-end; flex-wrap: wrap; }
.report-controls { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.report-period { margin-bottom: 0; }
.report-period input[type="month"] { min-width: 165px; }
.month-nav { display: flex; gap: 8px; align-items: flex-end; }
.month-nav .month-nav-btn { height: 44px; padding: 0 14px; font-size: 20px; line-height: 1; font-weight: 700; border-radius: 12px; }
@media (max-width: 760px) {
  .report-controls { flex-direction: column; align-items: stretch; }
  .report-period input[type="month"] { width: 100%; }
  .month-nav { justify-content: center; }
}

/* ---------- RTL (arabe) ---------- */
html[dir="rtl"] .nav-item { text-align: right; }
html[dir="rtl"] .nav-item.active { box-shadow: inset -3px 0 0 var(--primary); }
html[dir="rtl"] .chart-period-label { margin-left: 0; margin-right: 6px; }
html[dir="rtl"] .topbar { text-align: right; }
html[dir="rtl"] .sub-cell,
html[dir="rtl"] code { direction: ltr; unicode-bidi: embed; }
html[dir="rtl"] .btn-primary::after { left: auto; right: 130%; }
html[dir="rtl"] .btn-primary:hover::after { left: auto; right: 130%; transition: right .55s ease; }
html[dir="rtl"] .page-title-wrap { text-align: right; }
html[dir="rtl"] .mobile-nav { direction: ltr; }
html[dir="rtl"] .mobile-nav .nav-item { font-size: 9.5px; }
html[dir="rtl"] .mobile-nav .nav-icon { font-size: 19px; }

/* ---------- Rapports : mise en page mobile compacte ---------- */
@media (max-width: 760px) {
  .report-head { align-items: stretch; }
  .report-controls { display: flex; flex-direction: column; align-items: stretch; gap: 8px; }
  .report-period { display: flex; flex-direction: column; gap: 4px; }
  .report-period select, .report-period input[type="month"] { width: 100%; min-width: 0; }
  .month-nav { justify-content: center; gap: 6px; }
  .month-nav .month-nav-btn { height: 40px; padding: 0 12px; }
  .day-chart { height: 160px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat-card { padding: 12px; }
  .stat-value { font-size: 18px; }
  .stat-value .unit { font-size: 12px; }
  .stat-label { font-size: 10.5px; letter-spacing: .2px; }
  .panel { padding: 14px; }
  .panel-head { flex-wrap: wrap; }
  .chart-legend { font-size: 11px; gap: 10px; }
}
/* ---------- Scanner code-barres ---------- */
.barcode-row { display: flex; gap: 8px; align-items: stretch; }
.barcode-row input { flex: 1; min-width: 0; }
.btn-scan { white-space: nowrap; }
.scanner-content { width: min(440px, 94vw); }
.scanner-frame { position: relative; overflow: hidden; border-radius: 12px; background: #000; aspect-ratio: 4/3; }
.scanner-frame video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanner-line { position: absolute; left: 8%; right: 8%; top: 50%; height: 2px; background: #ff3b30; box-shadow: 0 0 12px rgba(255, 59, 48, .8); animation: scanmove 1.8s ease-in-out infinite; }
@keyframes scanmove { 0%, 100% { transform: translateY(-46%); } 50% { transform: translateY(46%); } }
.scanner-hint { text-align: center; color: var(--text-muted); font-size: 13px; margin-top: 12px; }

/* ---------- Multi-stocks (super-admin) ---------- */
.store-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; background: var(--primary); color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap; margin-left: 8px; }
body.theme-dark .store-pill { background: var(--primary-dark); }
.form-row { display: flex; flex-wrap: wrap; gap: 12px; }
.form-row .form-group { flex: 1 1 200px; min-width: 0; }
.checkbox-row { display: flex; align-items: center; gap: 8px; margin: 6px 0 12px; font-size: 14px; cursor: pointer; }
.store-card { flex-wrap: wrap; }
.store-card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; width: 100%; }
.store-card-id { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.store-code-chip { font-family: ui-monospace, monospace; font-weight: 700; letter-spacing: 1px; padding: 2px 8px; border-radius: 6px; background: rgba(139, 92, 246, .15); color: var(--primary); }
body.theme-dark .store-code-chip { color: var(--primary-dark); }
.store-card-meta { width: 100%; color: var(--text-muted); font-size: 12.5px; }
.store-card-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.store-card.store-active { border-color: var(--success, #10b981); }
.store-card-edit { width: 100%; border-top: 1px solid var(--border, rgba(255,255,255,.1)); padding-top: 12px; margin-top: 4px; }
.toolbar-spacer { height: 8px; }

.back-link { display: block; text-align: center; margin-top: 14px; font-size: 12.5px; color: var(--text-muted); text-decoration: none; }
.back-link:hover { color: var(--primary); }
