/* ===== MARCHÉ SUPERMARCHÉ - Platform Styles ===== */
:root {
  --green: #0F6B3A;
  --green-light: #22c55e;
  --red: #D91C2A;
  --gold: #F2A11B;
  --blue: #3b82f6;
  --sidebar-width: 260px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', system-ui, sans-serif; }

/* RTL Support */
[dir="rtl"] { font-family: 'Segoe UI', 'Tahoma', system-ui, sans-serif; }

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

/* Sidebar */
#sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, #0F6B3A 0%, #0a4d2a 100%);
  position: fixed; top: 0; left: 0; height: 100vh;
  overflow-y: auto; z-index: 100; transition: transform 0.3s;
  display: flex; flex-direction: column;
}
[dir="rtl"] #sidebar { left: auto; right: 0; }
#sidebar.hidden { transform: translateX(-100%); }
[dir="rtl"] #sidebar.hidden { transform: translateX(100%); }

.sidebar-logo { padding: 20px 16px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.sidebar-logo img { height: 48px; object-fit: contain; }
.sidebar-logo .store-name { color: #fff; font-size: 14px; font-weight: 700; margin-top: 6px; }
.sidebar-logo .store-sub { color: rgba(255,255,255,0.6); font-size: 11px; }

.nav-section { padding: 8px 0; }
.nav-section-title { color: rgba(255,255,255,0.4); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; padding: 6px 20px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; color: rgba(255,255,255,0.75);
  cursor: pointer; transition: all 0.2s; font-size: 13px;
  border-left: 3px solid transparent;
  text-decoration: none;
}
[dir="rtl"] .nav-item { border-left: none; border-right: 3px solid transparent; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,0.08); }
.nav-item.active { color: #fff; background: rgba(255,255,255,0.12); border-left-color: var(--gold); }
[dir="rtl"] .nav-item.active { border-left-color: transparent; border-right-color: var(--gold); }
.nav-item i { width: 18px; text-align: center; font-size: 14px; }
.nav-badge { margin-left: auto; background: var(--red); color: #fff; font-size: 10px; padding: 2px 7px; border-radius: 10px; }

/* Main content */
#main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  background: #f1f5f9;
  transition: margin 0.3s;
}
[dir="rtl"] #main-content { margin-left: 0; margin-right: var(--sidebar-width); }

/* Header */
#header {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  padding: 12px 24px;
  display: flex; align-items: center; gap: 12px;
  position: sticky; top: 0; z-index: 50;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
#header h1 { font-size: 18px; font-weight: 700; color: #1e293b; flex: 1; }
.header-actions { display: flex; gap: 8px; align-items: center; }
.header-badge { background: #fef3c7; color: #92400e; font-size: 12px; padding: 4px 10px; border-radius: 20px; font-weight: 600; }

/* Page content */
#page-content { padding: 24px; }

/* Cards */
.card {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  overflow: hidden;
}
.card-header { padding: 16px 20px; border-bottom: 1px solid #f1f5f9; display: flex; align-items: center; justify-content: space-between; }
.card-title { font-size: 15px; font-weight: 700; color: #1e293b; }
.card-body { padding: 20px; }

/* Stats cards */
.stat-card {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  padding: 20px;
  display: flex; align-items: center; gap: 16px;
  transition: box-shadow 0.2s;
}
.stat-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.stat-icon { width: 52px; height: 52px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 22px; }
.stat-value { font-size: 24px; font-weight: 800; color: #1e293b; }
.stat-label { font-size: 12px; color: #64748b; margin-top: 2px; }
.stat-trend { font-size: 11px; margin-top: 4px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px; font-size: 13px; font-weight: 600;
  cursor: pointer; border: none; transition: all 0.2s; text-decoration: none;
}
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: #0a4d2a; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-warning { background: var(--gold); color: #fff; }
.btn-warning:hover { background: #d97706; }
.btn-secondary { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
.btn-secondary:hover { background: #e2e8f0; }
.btn-blue { background: var(--blue); color: #fff; }
.btn-blue:hover { background: #2563eb; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-icon { padding: 8px; border-radius: 8px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th { background: #f8fafc; color: #475569; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; padding: 10px 14px; text-align: left; border-bottom: 1px solid #e2e8f0; }
[dir="rtl"] thead th { text-align: right; }
tbody td { padding: 12px 14px; border-bottom: 1px solid #f1f5f9; font-size: 13px; color: #334155; vertical-align: middle; }
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: none; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: #475569; margin-bottom: 5px; }
.form-control {
  width: 100%; padding: 9px 12px; border: 1px solid #e2e8f0; border-radius: 8px;
  font-size: 13px; color: #1e293b; background: #fff; transition: border-color 0.2s;
  outline: none;
}
.form-control:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(15,107,58,0.1); }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-gray { background: #f1f5f9; color: #475569; }
.badge-purple { background: #f3e8ff; color: #6b21a8; }

/* Status badges */
.status-pending { background: #fef3c7; color: #92400e; }
.status-confirmed { background: #dbeafe; color: #1e40af; }
.status-processing { background: #e0e7ff; color: #3730a3; }
.status-ready { background: #d1fae5; color: #065f46; }
.status-delivering { background: #fce7f3; color: #9d174d; }
.status-delivered { background: #dcfce7; color: #166534; }
.status-cancelled { background: #fee2e2; color: #991b1b; }
.status-paid { background: #dcfce7; color: #166534; }
.status-open { background: #d1fae5; color: #065f46; }
.status-closed { background: #fee2e2; color: #991b1b; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: #fff; border-radius: 16px; max-width: 600px; width: 100%;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 25px 50px rgba(0,0,0,0.25);
  animation: modalIn 0.2s ease;
}
.modal-lg { max-width: 900px; }
.modal-xl { max-width: 1100px; }
.modal-header { padding: 20px 24px; border-bottom: 1px solid #e2e8f0; display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 16px; font-weight: 700; color: #1e293b; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid #e2e8f0; display: flex; gap: 10px; justify-content: flex-end; }

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

/* POS - Caisse Tactile */
#pos-layout { display: grid; grid-template-columns: 1fr 380px; gap: 0; height: calc(100vh - 60px); overflow: hidden; }
#pos-products { overflow-y: auto; padding: 16px; background: #f8fafc; }
#pos-cart { background: #fff; border-left: 1px solid #e2e8f0; display: flex; flex-direction: column; }
[dir="rtl"] #pos-cart { border-left: none; border-right: 1px solid #e2e8f0; }

.pos-category-bar { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 16px; }
.pos-cat-btn { flex-shrink: 0; padding: 7px 14px; border-radius: 20px; border: 1px solid #e2e8f0; background: #fff; font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: all 0.2s; }
.pos-cat-btn.active { background: var(--green); color: #fff; border-color: var(--green); }

.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.product-card {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 10px;
  padding: 12px; cursor: pointer; transition: all 0.2s; text-align: center;
}
.product-card:hover { border-color: var(--green); box-shadow: 0 4px 12px rgba(15,107,58,0.15); transform: translateY(-1px); }
.product-card:active { transform: scale(0.97); }
.product-card .prod-name { font-size: 12px; font-weight: 600; color: #1e293b; margin-top: 8px; line-height: 1.3; }
.product-card .prod-price { font-size: 14px; font-weight: 800; color: var(--green); margin-top: 4px; }
.product-card .prod-stock { font-size: 10px; color: #94a3b8; }
.product-card .prod-img { width: 60px; height: 60px; margin: 0 auto; display: flex; align-items: center; justify-content: center; font-size: 32px; background: #f8fafc; border-radius: 8px; }
.product-card.out-of-stock { opacity: 0.5; cursor: not-allowed; }

/* Cart */
#pos-cart-header { padding: 14px 16px; border-bottom: 1px solid #f1f5f9; }
#pos-cart-items { flex: 1; overflow-y: auto; padding: 8px; }
.cart-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border-radius: 8px; margin-bottom: 4px;
  background: #f8fafc; transition: background 0.2s;
}
.cart-item:hover { background: #f1f5f9; }
.cart-item-name { flex: 1; font-size: 12px; font-weight: 600; color: #1e293b; }
.cart-item-price { font-size: 12px; color: #64748b; }
.qty-btn {
  width: 26px; height: 26px; border-radius: 6px; border: 1px solid #e2e8f0;
  background: #fff; cursor: pointer; font-size: 14px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s; color: var(--green);
}
.qty-btn:hover { background: var(--green); color: #fff; border-color: var(--green); }
.qty-display { font-size: 13px; font-weight: 700; min-width: 20px; text-align: center; }

#pos-cart-footer { padding: 14px 16px; border-top: 1px solid #e2e8f0; }
.cart-total-line { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 13px; }
.cart-total-line.total { font-size: 18px; font-weight: 800; color: var(--green); padding-top: 6px; border-top: 2px solid #f1f5f9; margin-top: 4px; }

/* Numpad */
.numpad { display: grid; grid-template-columns: repeat(3,1fr); gap: 4px; margin: 10px 0; }
.numpad-btn {
  padding: 14px; border: 1px solid #e2e8f0; background: #f8fafc;
  border-radius: 8px; font-size: 18px; font-weight: 700; cursor: pointer;
  transition: all 0.15s; color: #1e293b;
}
.numpad-btn:hover { background: #e2e8f0; }
.numpad-btn:active { transform: scale(0.94); }
.numpad-btn.green { background: var(--green); color: #fff; border-color: var(--green); }
.numpad-btn.red { background: var(--red); color: #fff; border-color: var(--red); }

/* Payment methods */
.payment-method-btn {
  flex: 1; padding: 10px; border: 2px solid #e2e8f0; border-radius: 8px;
  background: #f8fafc; cursor: pointer; font-size: 12px; font-weight: 600;
  text-align: center; transition: all 0.2s;
}
.payment-method-btn.active { border-color: var(--green); background: #f0fdf4; color: var(--green); }

/* Loading */
.loading { display: flex; align-items: center; justify-content: center; padding: 40px; }
.spinner { width: 32px; height: 32px; border: 3px solid #e2e8f0; border-top-color: var(--green); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Empty state */
.empty-state { text-align: center; padding: 60px 20px; color: #94a3b8; }
.empty-state i { font-size: 48px; margin-bottom: 16px; }
.empty-state p { font-size: 14px; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  background: #1e293b; color: #fff; padding: 12px 20px;
  border-radius: 10px; font-size: 13px; font-weight: 500;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  animation: toastIn 0.3s ease;
  max-width: 350px;
}
.toast.success { background: #166534; }
.toast.error { background: #991b1b; }
.toast.warning { background: #92400e; }
@keyframes toastIn { from { opacity:0; transform: translateY(20px); } to { opacity:1; transform: translateY(0); } }

/* Charts */
.chart-container { position: relative; height: 240px; }

/* Tabs */
.tabs { display: flex; border-bottom: 2px solid #e2e8f0; margin-bottom: 20px; }
.tab-btn { padding: 10px 20px; font-size: 13px; font-weight: 600; color: #64748b; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.2s; }
.tab-btn.active { color: var(--green); border-bottom-color: var(--green); }
.tab-btn:hover { color: var(--green); }

/* Search bar */
.search-bar { position: relative; }
.search-bar i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #94a3b8; font-size: 13px; }
[dir="rtl"] .search-bar i { left: auto; right: 12px; }
.search-bar input { padding-left: 36px; }
[dir="rtl"] .search-bar input { padding-left: 12px; padding-right: 36px; }

/* Alerts */
.alert { padding: 12px 16px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fbbf24; }
.alert-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }

/* Receipt */
.receipt { font-family: monospace; font-size: 13px; line-height: 1.8; }
.receipt-divider { border-top: 1px dashed #94a3b8; margin: 6px 0; }

/* Responsive */
@media (max-width: 768px) {
  #sidebar { transform: translateX(-100%); }
  [dir="rtl"] #sidebar { transform: translateX(100%); }
  #sidebar.open { transform: translateX(0); }
  #main-content { margin-left: 0 !important; margin-right: 0 !important; }
  #pos-layout { grid-template-columns: 1fr; }
  #pos-cart { display: none; }
  #pos-cart.mobile-show { display: flex; position: fixed; inset: 0; z-index: 200; }
}

/* Login page */
.login-container {
  min-height: 100vh;
  background: linear-gradient(135deg, #0F6B3A 0%, #0a4d2a 50%, #D91C2A 100%);
  display: flex; align-items: center; justify-content: center;
}
.login-card {
  background: #fff; border-radius: 20px; padding: 40px;
  width: 100%; max-width: 420px;
  box-shadow: 0 25px 50px rgba(0,0,0,0.3);
}
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo img { height: 80px; object-fit: contain; }

/* App client styles */
.app-container { max-width: 430px; margin: 0 auto; background: #fff; min-height: 100vh; position: relative; }
.app-header { background: linear-gradient(135deg, var(--green), #14753e); color: #fff; padding: 16px; position: sticky; top: 0; z-index: 50; }
.app-bottom-nav { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 430px; background: #fff; border-top: 1px solid #e2e8f0; display: flex; z-index: 100; }
.app-nav-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 10px 4px; cursor: pointer; color: #94a3b8; font-size: 10px; gap: 3px; transition: color 0.2s; }
.app-nav-item i { font-size: 20px; }
.app-nav-item.active { color: var(--green); }
.app-content { padding: 16px; padding-bottom: 80px; }
.product-app-card { border: 1px solid #e2e8f0; border-radius: 12px; overflow: hidden; cursor: pointer; transition: box-shadow 0.2s; }
.product-app-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.cart-fab { position: fixed; bottom: 80px; right: 16px; background: var(--green); color: #fff; width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 22px; box-shadow: 0 4px 16px rgba(15,107,58,0.4); cursor: pointer; z-index: 99; }
.cart-fab-badge { position: absolute; top: -4px; right: -4px; background: var(--red); color: #fff; font-size: 11px; min-width: 20px; height: 20px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-weight: 700; }

/* Timeline */
.timeline { position: relative; padding-left: 28px; }
.timeline::before { content: ''; position: absolute; left: 10px; top: 0; bottom: 0; width: 2px; background: #e2e8f0; }
.timeline-item { position: relative; margin-bottom: 16px; }
.timeline-dot { position: absolute; left: -28px; top: 2px; width: 18px; height: 18px; border-radius: 50%; background: #e2e8f0; border: 3px solid #fff; box-shadow: 0 0 0 2px #e2e8f0; }
.timeline-dot.done { background: var(--green); box-shadow: 0 0 0 2px var(--green); }
.timeline-dot.active { background: var(--gold); box-shadow: 0 0 0 2px var(--gold); animation: pulse 1.5s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 2px var(--gold); } 50% { box-shadow: 0 0 0 6px rgba(242,161,27,0.3); } }

/* Print */
@media print {
  #sidebar, #header, .btn, .no-print { display: none !important; }
  #main-content { margin: 0 !important; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}
