/* ============================================
   MARCHÉ SUPERMARCHÉ - CSS PRINCIPAL
   Couleurs: Vert #006633, Rouge #CC0000, Blanc
   ============================================ */

:root {
  --green: #006633;
  --green-light: #008844;
  --green-pale: #e8f5ee;
  --red: #CC0000;
  --red-light: #e53935;
  --red-pale: #fdecea;
  --gold: #f9a825;
  --white: #ffffff;
  --gray-50: #f8f9fa;
  --gray-100: #f1f3f4;
  --gray-200: #e8eaed;
  --gray-300: #dadce0;
  --gray-500: #9aa0a6;
  --gray-700: #5f6368;
  --gray-900: #202124;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.12);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.15);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --font-ar: 'Cairo', 'Noto Sans Arabic', sans-serif;
  --font-fr: 'Inter', 'Segoe UI', sans-serif;
}

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

body {
  font-family: var(--font-fr);
  background: var(--gray-50);
  color: var(--gray-900);
  min-height: 100vh;
  overflow-x: hidden;
}

body.rtl {
  direction: rtl;
  font-family: var(--font-ar);
}

/* ====== SCROLLBAR ====== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--gray-100); }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-500); }

/* ====== LAYOUT ====== */
.platform-layout {
  display: flex;
  min-height: 100vh;
}

/* ====== SIDEBAR ====== */
.sidebar {
  width: 260px;
  background: linear-gradient(180deg, var(--green) 0%, #004d26 100%);
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 1000;
  transition: transform 0.3s ease, width 0.3s ease;
  overflow-y: auto;
  overflow-x: hidden;
}

body.rtl .sidebar { left: auto; right: 0; }

.sidebar.collapsed { width: 70px; }

.sidebar-logo {
  padding: 20px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  min-height: 80px;
}

.sidebar-logo img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  border-radius: 8px;
  background: white;
  padding: 2px;
  flex-shrink: 0;
}

.sidebar-logo .brand-text {
  overflow: hidden;
  transition: opacity 0.3s;
}

.sidebar.collapsed .brand-text { opacity: 0; width: 0; }

.sidebar-logo h2 {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.sidebar-logo p {
  font-size: 10px;
  opacity: 0.7;
  white-space: nowrap;
}

.sidebar-nav { flex: 1; padding: 12px 0; }

.nav-section {
  padding: 8px 16px 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  opacity: 0.5;
  letter-spacing: 0.5px;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 0.3s;
}

.sidebar.collapsed .nav-section { opacity: 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  transition: all 0.2s;
  border-radius: 0;
  position: relative;
  white-space: nowrap;
  text-decoration: none;
  color: rgba(255,255,255,0.8);
  font-size: 13.5px;
}

.nav-item:hover {
  background: rgba(255,255,255,0.1);
  color: white;
}

.nav-item.active {
  background: rgba(255,255,255,0.15);
  color: white;
  border-right: 3px solid var(--gold);
}

body.rtl .nav-item.active {
  border-right: none;
  border-left: 3px solid var(--gold);
}

.nav-item i {
  font-size: 16px;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}

.nav-item span {
  overflow: hidden;
  transition: opacity 0.3s;
}

.sidebar.collapsed .nav-item span { opacity: 0; width: 0; }

.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: white;
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  text-align: center;
  transition: opacity 0.3s;
}

.sidebar.collapsed .nav-badge { opacity: 0; }

/* ====== MAIN CONTENT ====== */
.main-content {
  margin-left: 260px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin 0.3s;
}

body.rtl .main-content { margin-left: 0; margin-right: 260px; }
.sidebar.collapsed ~ .main-content { margin-left: 70px; }
body.rtl .sidebar.collapsed ~ .main-content { margin-right: 70px; margin-left: 0; }

/* ====== TOP BAR ====== */
.topbar {
  background: white;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: 0;
  z-index: 900;
  box-shadow: var(--shadow-sm);
}

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

.btn-toggle-sidebar {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  color: var(--gray-700);
  font-size: 18px;
  transition: background 0.2s;
}

.btn-toggle-sidebar:hover { background: var(--gray-100); }

.topbar-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--gray-900);
}

.topbar-search {
  display: flex;
  align-items: center;
  background: var(--gray-100);
  border-radius: 20px;
  padding: 6px 14px;
  gap: 8px;
  flex: 1;
  max-width: 300px;
}

.topbar-search input {
  border: none;
  background: none;
  outline: none;
  font-size: 13px;
  color: var(--gray-900);
  width: 100%;
}

.topbar-search i { color: var(--gray-500); font-size: 14px; }

/* ====== LANGUAGE TOGGLE ====== */
.lang-toggle {
  display: flex;
  background: var(--gray-100);
  border-radius: 20px;
  padding: 2px;
  gap: 2px;
}

.lang-btn {
  padding: 4px 12px;
  border-radius: 18px;
  border: none;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  background: none;
  color: var(--gray-700);
  transition: all 0.2s;
}

.lang-btn.active {
  background: var(--green);
  color: white;
}

/* ====== CURRENCY TOGGLE ====== */
.currency-toggle {
  display: flex;
  background: var(--gray-100);
  border-radius: 20px;
  padding: 2px;
}

.currency-btn {
  padding: 4px 10px;
  border-radius: 18px;
  border: none;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  background: none;
  color: var(--gray-700);
  transition: all 0.2s;
}

.currency-btn.active {
  background: var(--gold);
  color: white;
}

/* ====== PAGE CONTENT ====== */
.page-content {
  padding: 24px;
  flex: 1;
}

.page { display: none; }
.page.active { display: block; }

/* ====== CARDS ====== */
.card {
  background: white;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--gray-900);
}

.card-body { padding: 20px; }

/* ====== STAT CARDS ====== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: white;
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-icon.green { background: var(--green-pale); color: var(--green); }
.stat-icon.red { background: var(--red-pale); color: var(--red); }
.stat-icon.blue { background: #e3f2fd; color: #1976d2; }
.stat-icon.gold { background: #fff8e1; color: var(--gold); }
.stat-icon.purple { background: #f3e5f5; color: #7b1fa2; }
.stat-icon.teal { background: #e0f2f1; color: #00796b; }

.stat-info { flex: 1; }
.stat-label { font-size: 12px; color: var(--gray-500); margin-bottom: 4px; }
.stat-value { font-size: 22px; font-weight: 700; color: var(--gray-900); line-height: 1; }
.stat-sub { font-size: 11px; color: var(--gray-500); margin-top: 3px; }
.stat-up { color: #43a047; }
.stat-down { color: var(--red); }

/* ====== TABLES ====== */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius-md);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  background: var(--gray-50);
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--gray-700);
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}

body.rtl thead th { text-align: right; }

tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-900);
  vertical-align: middle;
}

tbody tr:hover { background: var(--gray-50); }

tbody tr:last-child td { border-bottom: none; }

/* ====== BADGES ====== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  gap: 4px;
}

.badge-success { background: var(--green-pale); color: var(--green); }
.badge-danger { background: var(--red-pale); color: var(--red); }
.badge-warning { background: #fff8e1; color: #f57f17; }
.badge-info { background: #e3f2fd; color: #1565c0; }
.badge-gray { background: var(--gray-200); color: var(--gray-700); }
.badge-purple { background: #f3e5f5; color: #6a1b9a; }

/* ====== BUTTONS ====== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-xl { padding: 16px 32px; font-size: 16px; }

.btn-primary { background: var(--green); color: white; }
.btn-primary:hover { background: var(--green-light); }

.btn-danger { background: var(--red); color: white; }
.btn-danger:hover { background: var(--red-light); }

.btn-warning { background: var(--gold); color: white; }
.btn-warning:hover { background: #f57f17; }

.btn-outline { background: white; border: 1.5px solid var(--gray-300); color: var(--gray-700); }
.btn-outline:hover { background: var(--gray-50); border-color: var(--green); color: var(--green); }

.btn-ghost { background: transparent; color: var(--gray-700); padding: 6px 10px; }
.btn-ghost:hover { background: var(--gray-100); }

.btn-icon { padding: 7px; border-radius: var(--radius-sm); }

/* ====== FORMS ====== */
.form-group { margin-bottom: 16px; }

label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}

input, select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--gray-900);
  background: white;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(0,102,51,0.1);
}

textarea { resize: vertical; min-height: 80px; }

.input-group {
  display: flex;
  gap: 0;
}

.input-group input {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  border-right: none;
}

.input-group-addon {
  padding: 9px 12px;
  background: var(--gray-100);
  border: 1.5px solid var(--gray-300);
  border-left: none;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 12px;
  color: var(--gray-700);
  font-weight: 600;
  white-space: nowrap;
}

/* ====== MODAL ====== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(3px);
}

.modal-overlay.active { display: flex; }

.modal {
  background: white;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.25s ease;
}

.modal-lg { max-width: 800px; }
.modal-xl { max-width: 1000px; }

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(-10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

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

.modal-title { font-size: 16px; font-weight: 700; }

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 20px;
  color: var(--gray-500);
  padding: 4px;
  border-radius: 4px;
  transition: color 0.2s;
}

.modal-close:hover { color: var(--gray-900); }

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

/* ====== TOAST NOTIFICATIONS ====== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

body.rtl .toast-container { right: auto; left: 24px; }

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: white;
  box-shadow: var(--shadow-md);
  border-left: 4px solid var(--green);
  min-width: 280px;
  animation: slideIn 0.3s ease;
  font-size: 13px;
  font-weight: 500;
}

.toast.error { border-left-color: var(--red); }
.toast.warning { border-left-color: var(--gold); }

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

/* ====== GRID LAYOUTS ====== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* ====== PRODUCT CARDS ====== */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}

.product-card {
  background: white;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  transition: all 0.2s;
  cursor: pointer;
}

.product-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--green);
}

.product-card img {
  width: 100%;
  height: 130px;
  object-fit: cover;
}

.product-card-body { padding: 12px; }
.product-card-name { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.product-card-price { font-size: 15px; font-weight: 700; color: var(--green); }
.product-card-stock { font-size: 11px; color: var(--gray-500); }

/* ====== STATUS INDICATORS ====== */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}

.status-dot.green { background: #43a047; }
.status-dot.red { background: var(--red); }
.status-dot.orange { background: #fb8c00; }
.status-dot.blue { background: #1976d2; }

/* ====== TABS ====== */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--gray-200);
  margin-bottom: 20px;
}

.tab-btn {
  padding: 10px 20px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-500);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tab-btn:hover { color: var(--green); }
.tab-btn.active { color: var(--green); border-bottom-color: var(--green); }

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

/* ====== AVATAR ====== */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--green);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ====== SEARCH BAR ====== */
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  border: 1.5px solid var(--gray-200);
}

.search-bar input {
  border: none;
  background: none;
  outline: none;
  font-size: 13px;
  flex: 1;
  padding: 0;
}

.search-bar i { color: var(--gray-500); }

/* ====== EMPTY STATE ====== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-500);
}

.empty-state i {
  font-size: 48px;
  margin-bottom: 12px;
  display: block;
  opacity: 0.4;
}

.empty-state h3 { font-size: 16px; margin-bottom: 6px; color: var(--gray-700); }
.empty-state p { font-size: 13px; }

/* ====== PROGRESS ====== */
.progress {
  height: 8px;
  background: var(--gray-200);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: 4px;
  background: var(--green);
  transition: width 0.5s ease;
}

.progress-bar.danger { background: var(--red); }
.progress-bar.warning { background: var(--gold); }

/* ====== CHIP ====== */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--gray-200);
  color: var(--gray-700);
  font-size: 12px;
  font-weight: 500;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.chip:hover, .chip.active { background: var(--green); color: white; }

/* ====== DIVIDER ====== */
.divider {
  height: 1px;
  background: var(--gray-200);
  margin: 16px 0;
}

/* ====== UTILS ====== */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.w-full { width: 100%; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-lg { font-size: 16px; }
.text-xl { font-size: 20px; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-gold { color: var(--gold); }
.text-gray { color: var(--gray-500); }
.hidden { display: none !important; }

/* ====== RESPONSIVE ====== */
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); }
  body.rtl .sidebar { transform: translateX(100%); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-content { margin-left: 0 !important; }
  body.rtl .main-content { margin-right: 0 !important; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .page-content { padding: 16px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .topbar-search { display: none; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: 1fr; }
}
