@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;500;600;700;800&family=DM+Sans:ital,wght@0,300;0,400;0,500;1,300&display=swap');

:root {
  --bg: #0a0c0f;
  --bg2: #111418;
  --bg3: #181c22;
  --card: #1a1f27;
  --border: #252b35;
  --accent: #e8a020;
  --accent2: #f0c060;
  --green: #2ecc8a;
  --red: #e85050;
  --blue: #4a9eff;
  --purple: #a78bfa;
  --text: #e8eaf0;
  --text2: #8892a0;
  --text3: #50586a;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
}

h1,h2,h3,h4,h5 { font-family: 'Syne', sans-serif; }

a { color: inherit; text-decoration: none; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

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

/* ── SIDEBAR ── */
.sidebar {
  width: 240px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform 0.3s ease;
}

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

.logo-icon {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}

.logo-text { font-family: 'Syne', sans-serif; font-weight: 800; font-size: 16px; }
.logo-text span { color: var(--accent); }

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }

.nav-section { margin-bottom: 24px; }
.nav-section-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: var(--text3);
  text-transform: uppercase;
  padding: 0 8px;
  margin-bottom: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text2);
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.15s;
  margin-bottom: 2px;
  border: 1px solid transparent;
}

.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active {
  background: rgba(232,160,32,0.12);
  color: var(--accent);
  border-color: rgba(232,160,32,0.2);
}

.nav-item .icon { font-size: 16px; width: 20px; text-align: center; }
.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: var(--bg);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  background: var(--bg3);
  cursor: pointer;
}

.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 12px;
  color: var(--bg);
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 12px; font-weight: 600; }
.user-role { font-size: 11px; color: var(--accent); }

/* ── MAIN ── */
.main {
  margin-left: 240px;
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── TOPBAR ── */
.topbar {
  height: 60px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left { display: flex; align-items: center; gap: 16px; }
.page-title { font-family: 'Syne', sans-serif; font-size: 17px; font-weight: 700; }
.breadcrumb { color: var(--text3); font-size: 12px; }

.topbar-right { display: flex; align-items: center; gap: 12px; }

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 14px;
  width: 240px;
  transition: border-color 0.2s;
}

.search-box:focus-within { border-color: var(--accent); }
.search-box input {
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  width: 100%;
}
.search-box input::placeholder { color: var(--text3); }

.icon-btn {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--bg3);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.15s;
  position: relative;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }

.notif-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 7px; height: 7px;
  background: var(--accent);
  border-radius: 50%;
  border: 2px solid var(--bg2);
}

/* ── CONTENT ── */
.content { flex: 1; padding: 24px; overflow: hidden; }

/* ── PAGE ── */
.page { display: none; }
.page.active { display: block; }

/* ── KPI CARDS ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s, border-color 0.2s;
}

.kpi-card:hover { transform: translateY(-2px); border-color: var(--accent); }

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--kpi-color, var(--accent));
}

.kpi-label { font-size: 11px; font-weight: 600; color: var(--text2); letter-spacing: 0.5px; text-transform: uppercase; margin-bottom: 8px; }
.kpi-value { font-family: 'Syne', sans-serif; font-size: 26px; font-weight: 800; margin-bottom: 6px; }
.kpi-sub { font-size: 12px; color: var(--text2); display: flex; align-items: center; gap: 6px; }
.kpi-trend { font-size: 11px; font-weight: 600; }
.kpi-trend.up { color: var(--green); }
.kpi-trend.down { color: var(--red); }
.kpi-icon {
  position: absolute;
  bottom: 16px; right: 16px;
  font-size: 28px;
  opacity: 0.15;
}

/* ── SECTION HEADER ── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-title { font-family: 'Syne', sans-serif; font-size: 16px; font-weight: 700; }

/* ── BTN ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}

.btn-primary { background: var(--accent); color: var(--bg); }
.btn-primary:hover { background: var(--accent2); }

.btn-secondary {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-danger { background: rgba(232,80,80,0.15); color: var(--red); border: 1px solid rgba(232,80,80,0.3); }
.btn-success { background: rgba(46,204,138,0.15); color: var(--green); border: 1px solid rgba(46,204,138,0.3); }

/* ── TABLE ── */
.table-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.table-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text3);
  border-bottom: 1px solid var(--border);
  background: var(--bg3);
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg3); }

tbody td {
  padding: 13px 16px;
  font-size: 13px;
  vertical-align: middle;
}

/* ── BADGE ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.badge-france { background: rgba(74,158,255,0.15); color: var(--blue); }
.badge-transit { background: rgba(232,160,32,0.15); color: var(--accent); }
.badge-douane { background: rgba(167,139,250,0.15); color: var(--purple); }
.badge-maroc { background: rgba(46,204,138,0.15); color: var(--green); }
.badge-vendu { background: rgba(80,88,106,0.3); color: var(--text2); }
.badge-neuf { background: rgba(46,204,138,0.12); color: var(--green); }
.badge-bon { background: rgba(74,158,255,0.12); color: var(--blue); }
.badge-recond { background: rgba(232,160,32,0.12); color: var(--accent); }
.badge-defect { background: rgba(232,80,80,0.12); color: var(--red); }

/* ── PIPELINE ── */
.pipeline {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 24px;
}

.pipeline-step {
  flex: 1;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  text-align: center;
  cursor: pointer;
  position: relative;
  transition: all 0.2s;
}

.pipeline-step:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.pipeline-step:last-child { border-radius: 0 var(--radius) var(--radius) 0; }

.pipeline-step:not(:last-child)::after {
  content: '→';
  position: absolute;
  right: -12px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  font-size: 14px;
  color: var(--text3);
}

.pipeline-step.active {
  background: rgba(232,160,32,0.1);
  border-color: var(--accent);
}

.pipeline-count {
  font-family: 'Syne', sans-serif;
  font-size: 22px;
  font-weight: 800;
}

.pipeline-label { font-size: 11px; color: var(--text2); margin-top: 2px; }

/* ── FORM ── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1/-1; }
.form-label { font-size: 12px; font-weight: 600; color: var(--text2); }

.form-input, .form-select, .form-textarea {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 13px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent);
}

.form-select option { background: var(--card); }
.form-textarea { resize: vertical; min-height: 80px; }

/* ── MODAL ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 640px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95);
  transition: transform 0.2s;
}

.modal-overlay.open .modal { transform: scale(1); }

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

.modal-title { font-family: 'Syne', sans-serif; font-size: 17px; font-weight: 700; }
.modal-close {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--bg3);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 16px;
  color: var(--text2);
}
.modal-close:hover { color: var(--text); border-color: var(--text); }

.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* ── TIMELINE ── */
.timeline { position: relative; }

.timeline::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 0; bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  display: flex;
  gap: 16px;
  padding-bottom: 20px;
  position: relative;
}

.timeline-dot {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--bg3);
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  z-index: 1;
}

.timeline-dot.active { border-color: var(--accent); background: rgba(232,160,32,0.1); }

.timeline-content { flex: 1; padding-top: 4px; }
.timeline-title { font-weight: 600; font-size: 13px; }
.timeline-meta { font-size: 11px; color: var(--text2); margin-top: 2px; }
.timeline-detail {
  margin-top: 8px;
  padding: 10px 14px;
  background: var(--bg3);
  border-radius: 8px;
  font-size: 12px;
  color: var(--text2);
  border-left: 3px solid var(--accent);
}

/* ── CHARTS (CSS-based) ── */
.chart-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 120px;
  padding: 0 4px;
}

.chart-bar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: 100%;
  justify-content: flex-end;
}

.chart-bar-fill {
  width: 100%;
  background: linear-gradient(180deg, var(--accent), rgba(232,160,32,0.3));
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  transition: height 0.5s ease;
}

.chart-bar-label { font-size: 10px; color: var(--text3); }

/* ── PRODUCT CARD ── */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.product-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s;
}

.product-card:hover { transform: translateY(-3px); border-color: var(--accent); box-shadow: 0 8px 32px rgba(232,160,32,0.1); }

.product-img {
  height: 160px;
  background: var(--bg3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  position: relative;
  overflow: hidden;
}

.product-img::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 40px;
  background: linear-gradient(transparent, var(--card));
}

.product-status-badge {
  position: absolute;
  top: 10px; right: 10px;
}

.product-body { padding: 14px; }
.product-name { font-family: 'Syne', sans-serif; font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.product-ref { font-size: 11px; color: var(--text3); margin-bottom: 10px; font-family: monospace; }

.product-price {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.price-buy { font-size: 11px; color: var(--text2); }
.price-sell { font-family: 'Syne', sans-serif; font-size: 15px; font-weight: 700; color: var(--accent); }
.price-margin { font-size: 11px; color: var(--green); }

/* ── STATS ROW ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.stat-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.stat-data .stat-val { font-family: 'Syne', sans-serif; font-size: 20px; font-weight: 700; }
.stat-data .stat-lbl { font-size: 12px; color: var(--text2); }

/* ── TABS ── */
.tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--border); padding-bottom: 0; }

.tab-btn {
  padding: 10px 18px;
  border-radius: 8px 8px 0 0;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text2);
  border: 1px solid transparent;
  border-bottom: none;
  margin-bottom: -1px;
  transition: all 0.15s;
}

.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  color: var(--accent);
  background: var(--card);
  border-color: var(--border);
  border-bottom-color: var(--card);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── QR CODE ── */
.qr-display {
  width: 100px; height: 100px;
  background: #fff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: #000;
  padding: 8px;
  position: relative;
}

/* ── FILTER BAR ── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-chip {
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  transition: all 0.15s;
}

.filter-chip:hover { border-color: var(--accent); color: var(--accent); }
.filter-chip.active { background: rgba(232,160,32,0.12); border-color: var(--accent); color: var(--accent); }

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

.toast {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 280px;
  max-width: 360px;
  animation: slideIn 0.3s ease;
  box-shadow: var(--shadow);
  border-left: 3px solid var(--accent);
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.toast.success { border-left-color: var(--green); }
.toast.error { border-left-color: var(--red); }

.toast-icon { font-size: 18px; }
.toast-text { flex: 1; }
.toast-title { font-size: 13px; font-weight: 600; }
.toast-msg { font-size: 11px; color: var(--text2); }

/* ── DIVIDER ── */
.divider { height: 1px; background: var(--border); margin: 20px 0; }

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text2);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state p { font-size: 14px; }

/* ── 2-COL GRID ── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

.box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

/* ── MOBILE ── */
.hamburger {
  display: none;
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--bg3);
  border: 1px solid var(--border);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
}

@media (max-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(2,1fr); }
  .two-col { grid-template-columns: 1fr; }
  .three-col { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .hamburger { display: flex; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .product-grid { grid-template-columns: 1fr 1fr; }
  .pipeline { flex-wrap: wrap; }
  .pipeline-step { border-radius: 8px; flex: calc(50% - 8px); }
  .pipeline-step::after { display: none; }
  .search-box { width: 160px; }
}

@media (max-width: 480px) {
  .kpi-grid, .product-grid { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .three-col { grid-template-columns: 1fr; }
}

/* ── CATALOG PUBLIC ── */
.catalog-hero {
  background: linear-gradient(135deg, #111418 0%, #1a1f27 50%, #111418 100%);
  border-radius: var(--radius);
  padding: 48px;
  text-align: center;
  margin-bottom: 32px;
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.catalog-hero::before {
  content: '';
  position: absolute;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: radial-gradient(circle at center, rgba(232,160,32,0.06) 0%, transparent 60%);
}

.catalog-hero h1 { font-size: 40px; font-weight: 800; position: relative; }
.catalog-hero h1 span { color: var(--accent); }
.catalog-hero p { color: var(--text2); margin-top: 12px; font-size: 16px; position: relative; }

/* ── PRINT / EXPORT ── */
@media print {
  .sidebar, .topbar, .btn, .modal-overlay { display: none !important; }
  .main { margin-left: 0; }
}

/* ── ANIMATIONS ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-up { animation: fadeUp 0.3s ease forwards; }

.skeleton {
  background: linear-gradient(90deg, var(--bg3) 25%, var(--border) 50%, var(--bg3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
