/* ============================================================
   Produit dz ORG — Stylesheet complet
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg: #f4f6fb;
  --bg-gradient: linear-gradient(135deg, #eef2f9 0%, #f7f9fc 50%, #e8edf5 100%);
  --card-bg: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --border: #e2e8f0;
  --border-soft: #f1f5f9;
  --primary: #0f172a;
  --primary-hover: #1e293b;
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --success-border: #bbf7d0;
  --warning: #eab308;
  --warning-bg: #fefce8;
  --warning-border: #fef08a;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;
  --radius-xl: 28px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 10px 30px -10px rgba(15, 23, 42, 0.15), 0 4px 12px -4px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 25px 50px -12px rgba(15, 23, 42, 0.22), 0 10px 20px -10px rgba(15, 23, 42, 0.12);
  --shadow-glow: 0 0 0 4px rgba(15, 23, 42, 0.08);
  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  background-image: var(--bg-gradient);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  gap: 20px;
}

/* ---------- Card ---------- */
.card {
  background: var(--card-bg);
  border-radius: var(--radius-xl);
  padding: 40px 32px 34px;
  max-width: 440px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255, 255, 255, 0.8);
  position: relative;
  overflow: hidden;
  animation: cardIn 500ms cubic-bezier(0.16, 1, 0.3, 1);
}

.card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, #16a34a, #eab308, #dc2626);
  background-size: 200% 100%;
  animation: gradientShift 6s ease infinite;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(20px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes gradientShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.brand {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--text);
  margin-bottom: 20px;
  opacity: 0.85;
}

.app-logo {
  width: 110px;
  height: 110px;
  display: block;
  margin: 0 auto 20px;
  border-radius: 24px;
  box-shadow: 0 12px 28px -8px rgba(15, 23, 42, 0.25),
              0 4px 10px -2px rgba(15, 23, 42, 0.1);
}

.shield {
  width: 68px; height: 68px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  margin: 0 auto 18px;
  box-shadow: 0 10px 24px -6px rgba(15, 23, 42, 0.35);
}

h1 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.6px;
  margin: 0 0 10px;
  color: var(--text);
  line-height: 1.25;
}

h2 {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.3px;
  margin: 0 0 12px;
  color: var(--text);
}

h3 {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 10px;
  color: var(--text);
}

p { margin: 0 0 12px; }

.muted {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
}

.small {
  color: var(--text-light);
  font-size: 12px;
  margin-top: 18px;
  line-height: 1.5;
}

/* ---------- Form ---------- */
form { margin: 22px 0 12px; }

input, select, textarea {
  width: 100%;
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: var(--transition);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

input::placeholder { color: var(--text-light); }

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: var(--shadow-glow);
}

#code {
  text-align: center;
  font-family: "SF Mono", "Courier New", monospace;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  padding: 16px;
}

/* ---------- Buttons ---------- */
button {
  display: inline-block;
  width: 100%;
  padding: 14px 22px;
  background: var(--primary);
  color: #fff;
  border: 0;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  margin-top: 10px;
  box-shadow: 0 4px 14px -4px rgba(15, 23, 42, 0.25);
  -webkit-tap-highlight-color: transparent;
}

button:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px -6px rgba(15, 23, 42, 0.35);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
}

/* ---------- Result ---------- */
.result {
  margin: 22px 0 0;
  padding: 22px 20px;
  border-radius: var(--radius-lg);
  text-align: center;
  border: 1.5px solid var(--border);
  background: #fff;
  animation: resultIn 400ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes resultIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.result.hidden { display: none; }

.result h2 {
  margin: 12px 0 8px;
  font-size: 20px;
  font-weight: 800;
}

.result p {
  font-size: 13px;
  color: var(--text-muted);
}

.result .icon {
  width: 56px; height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 6px;
  font-size: 28px;
  font-weight: bold;
  color: #fff;
}

.result.success {
  background: var(--success-bg);
  border-color: var(--success-border);
}
.result.success h2 { color: var(--success); }
.result.success .icon {
  background: linear-gradient(135deg, #16a34a, #22c55e);
  box-shadow: 0 8px 20px -6px rgba(22, 163, 74, 0.5);
  animation: popIn 500ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.result.warning {
  background: var(--warning-bg);
  border-color: var(--warning-border);
}
.result.warning h2 { color: #a16207; }
.result.warning .icon {
  background: linear-gradient(135deg, #eab308, #facc15);
  box-shadow: 0 8px 20px -6px rgba(234, 179, 8, 0.5);
  animation: popIn 500ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.result.danger {
  background: var(--danger-bg);
  border-color: var(--danger-border);
}
.result.danger h2 { color: var(--danger); }
.result.danger .icon {
  background: linear-gradient(135deg, #dc2626, #ef4444);
  box-shadow: 0 8px 20px -6px rgba(220, 38, 38, 0.5);
  animation: shakeIn 500ms cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes popIn {
  0% { transform: scale(0.5); opacity: 0; }
  60% { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(1); }
}

@keyframes shakeIn {
  0% { transform: translateX(0); opacity: 0; }
  20% { transform: translateX(-8px); opacity: 1; }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
  100% { transform: translateX(0); }
}

/* ---------- Product Details ---------- */
.details {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}

.details > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: var(--radius-sm);
  font-size: 13px;
  gap: 12px;
}

.details b {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  flex-shrink: 0;
}

.details span {
  color: var(--text);
  font-weight: 600;
  text-align: right;
  word-break: break-word;
}

.product-image {
  max-width: 160px;
  max-height: 160px;
  border-radius: var(--radius);
  margin: 12px auto;
  display: block;
  object-fit: cover;
  box-shadow: var(--shadow-sm);
}

.description {
  margin-top: 14px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  text-align: left;
}

/* ---------- Social media links ---------- */
.social-links {
  margin-top: 22px;
  padding: 20px 0 0;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  text-align: center;
}

.social-title {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin: 0 0 14px;
  font-weight: 700;
}

.social-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.social-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none !important;
  color: #fff !important;
  transition: all 220ms cubic-bezier(0.34, 1.56, 0.64, 1);
  min-height: 44px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
  cursor: pointer;
}

.social-btn:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.22);
}

.social-icon-img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
  border-radius: 6px;
  background: #fff;
  padding: 3px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.social-btn span { font-size: 13px; font-weight: 700; }

.social-instagram {
  background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
}

.social-facebook {
  background: linear-gradient(135deg, #1877f2 0%, #0a5dc2 100%);
}

.social-tiktok {
  background: linear-gradient(135deg, #2b2b2b 0%, #000 100%);
}

/* ---------- Feedback ---------- */
.feedback-section {
  margin-top: 22px;
  padding: 20px;
  background: linear-gradient(160deg, #f8fafc 0%, #eef2f7 100%);
  border: 1px solid #e2e8f0;
  border-radius: 18px;
  text-align: center;
  animation: fadeIn 400ms ease;
}

.feedback-section h3 {
  font-size: 15px;
  font-weight: 800;
  color: #0f172a;
  margin: 0 0 6px;
}

.feedback-section .muted { font-size: 12px; margin-bottom: 14px; }

.stars {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 12px 0 14px;
}

.stars button {
  background: transparent !important;
  border: 0 !important;
  font-size: 34px;
  color: #cbd5e1;
  cursor: pointer;
  padding: 0 !important;
  margin: 0 !important;
  width: auto !important;
  box-shadow: none !important;
  line-height: 1;
  transition: all 150ms ease;
}

.stars button:hover,
.stars button.active {
  color: #fbbf24;
  transform: scale(1.15);
}

.feedback-section textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
  min-height: 70px;
  margin-bottom: 12px;
  outline: none;
}

.feedback-section textarea:focus {
  border-color: #16a34a;
  box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.12);
}

.feedback-section button {
  width: 100%;
  padding: 12px 18px;
  font-size: 13px;
  border-radius: 12px;
  font-weight: 700;
}

/* ---------- Chatbot ---------- */
.chat-fab {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 60px;
  height: 60px;
  padding: 0 !important;
  margin: 0 !important;
  background: linear-gradient(135deg, #16a34a, #22c55e) !important;
  color: #fff !important;
  border: 0 !important;
  border-radius: 50% !important;
  font-size: 26px !important;
  cursor: pointer;
  z-index: 9998;
  box-shadow: 0 10px 30px -6px rgba(22, 163, 74, 0.5) !important;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-fab:hover { transform: scale(1.12) !important; }

html[dir="rtl"] .chat-fab { right: auto; left: 20px; }

.chat-window {
  position: fixed;
  bottom: 90px;
  right: 20px;
  width: calc(100% - 40px);
  max-width: 380px;
  height: 520px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 22px;
  box-shadow: 0 25px 60px -12px rgba(15, 23, 42, 0.35);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-window.hidden { display: none; }
html[dir="rtl"] .chat-window { right: auto; left: 20px; }

.chat-header {
  background: linear-gradient(135deg, #0f172a, #1e293b);
  color: #fff;
  padding: 16px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.chat-header-info { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }

.chat-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #16a34a, #22c55e);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.chat-title { font-size: 14px; font-weight: 800; }
.chat-status { font-size: 11px; color: #94a3b8; margin-top: 2px; }

.chat-close {
  width: 32px !important;
  height: 32px !important;
  padding: 0 !important;
  margin: 0 !important;
  background: rgba(255, 255, 255, 0.1) !important;
  color: #fff !important;
  border: 0 !important;
  border-radius: 50% !important;
  cursor: pointer;
  font-size: 14px !important;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  background: linear-gradient(160deg, #f8fafc, #f1f5f9);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-msg { display: flex; max-width: 88%; }
.chat-msg-user { align-self: flex-end; justify-content: flex-end; }
.chat-msg-bot { align-self: flex-start; }

.chat-bubble {
  padding: 11px 15px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}

.chat-msg-user .chat-bubble {
  background: linear-gradient(135deg, #16a34a, #22c55e);
  color: #fff;
  border-bottom-right-radius: 6px;
}

.chat-msg-bot .chat-bubble {
  background: #fff;
  color: #0f172a;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 6px;
}

.chat-typing { display: flex; gap: 5px; padding: 14px 18px !important; }
.chat-typing span {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #94a3b8;
  animation: typingBounce 1.2s infinite ease-in-out;
}
.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

.chat-form {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  background: #fff;
  border-top: 1px solid #e2e8f0;
  margin: 0;
}

.chat-input {
  flex: 1;
  padding: 11px 16px !important;
  border: 1.5px solid #e2e8f0 !important;
  border-radius: 24px !important;
  font-size: 14px !important;
  background: #f8fafc !important;
  margin: 0 !important;
}

.chat-send {
  width: 44px !important;
  height: 44px !important;
  padding: 0 !important;
  margin: 0 !important;
  background: linear-gradient(135deg, #16a34a, #22c55e) !important;
  color: #fff !important;
  border: 0 !important;
  border-radius: 50% !important;
  font-size: 16px !important;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Language switcher ---------- */
.lang-switcher {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  gap: 6px;
  z-index: 10;
}

html[dir="rtl"] .lang-switcher { right: auto; left: 16px; }

.lang-btn {
  width: 36px !important;
  height: 32px !important;
  padding: 0 !important;
  margin: 0 !important;
  background: #f1f5f9 !important;
  color: #64748b !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 8px !important;
  font-size: 11px !important;
  font-weight: 800 !important;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lang-btn.active {
  background: #0f172a !important;
  color: #fff !important;
}

.lang-switcher .dark-toggle {
  position: static !important;
  width: 36px !important;
  height: 32px !important;
  border-radius: 8px !important;
  font-size: 14px !important;
  background: #f1f5f9 !important;
  color: #0f172a !important;
  border: 1px solid #e2e8f0 !important;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  margin: 0;
}

/* ---------- RTL ---------- */
html[dir="rtl"] body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter",
               "Noto Kufi Arabic", "Tahoma", "Arial", sans-serif;
}
html[dir="rtl"] .details > div { direction: rtl; }
html[dir="rtl"] .details span { text-align: left; }
html[dir="rtl"] .details b { text-align: right; }
html[dir="rtl"] .description { text-align: right; direction: rtl; }
html[dir="rtl"] .feedback-section textarea { direction: rtl; text-align: right; }

/* ============================================================
   OFFLINE MODE
   ============================================================ */
.offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9990;
  background: linear-gradient(135deg, #dc2626, #ef4444);
  color: #fff;
  padding: 16px 20px;
  box-shadow: 0 4px 24px rgba(220, 38, 38, 0.4);
  animation: slideDown 400ms cubic-bezier(0.16, 1, 0.3, 1);
}

.offline-banner.hidden { display: none; }

.offline-content {
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 500px;
  margin: 0 auto;
}

.offline-icon { font-size: 32px; flex-shrink: 0; }
.offline-text { flex: 1; }
.offline-title { font-size: 14px; font-weight: 800; margin-bottom: 2px; }
.offline-subtitle { font-size: 12px; opacity: 0.9; }

@keyframes slideDown {
  from { transform: translateY(-100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.offline-history {
  max-width: 440px;
  width: 100%;
  padding: 24px 20px;
  background: var(--card-bg);
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
}

.offline-history.hidden { display: none; }

.offline-history-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  margin: 0 0 16px;
  text-align: center;
}

.offline-history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.offline-history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg);
  border-radius: 12px;
  border: 1px solid var(--border);
}

.offline-history-item.success { border-left: 4px solid #16a34a; }
.offline-history-item.warning { border-left: 4px solid #eab308; }
.offline-history-item.danger { border-left: 4px solid #dc2626; }

.offline-history-icon { font-size: 24px; flex-shrink: 0; }
.offline-history-info { flex: 1; min-width: 0; }

.offline-history-code {
  font-family: 'Courier New', monospace;
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: 1px;
  margin-bottom: 2px;
  word-break: break-all;
}

.offline-history-meta { font-size: 11px; color: var(--text-muted); }

.offline-history-status {
  font-size: 10px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 6px;
  text-transform: uppercase;
  flex-shrink: 0;
}

.offline-history-status.success { background: rgba(22, 163, 74, 0.15); color: #16a34a; }
.offline-history-status.warning { background: rgba(234, 179, 8, 0.15); color: #a16207; }
.offline-history-status.danger { background: rgba(220, 38, 38, 0.15); color: #dc2626; }

.offline-history-note {
  font-size: 11px;
  color: var(--text-light);
  text-align: center;
  margin: 16px 0 0;
  font-style: italic;
}

/* ============================================================
   WILAYA MODAL (Fake Report)
   ============================================================ */
.wilaya-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: wilayaIn 300ms cubic-bezier(0.16, 1, 0.3, 1);
}

.wilaya-modal.hidden { display: none; }

.wilaya-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(4px);
}

.wilaya-modal-box {
  position: relative;
  background: var(--card-bg);
  border-radius: 24px;
  padding: 32px 26px 24px;
  max-width: 460px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 30px 60px -12px rgba(15, 23, 42, 0.4);
  animation: wilayaBoxIn 400ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes wilayaIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes wilayaBoxIn {
  from { transform: scale(0.9) translateY(20px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.wilaya-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px !important;
  height: 32px !important;
  padding: 0 !important;
  margin: 0 !important;
  background: #f1f5f9 !important;
  color: #64748b !important;
  border: 0 !important;
  border-radius: 50% !important;
  font-size: 14px !important;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: none !important;
}

.wilaya-icon { font-size: 48px; text-align: center; margin-bottom: 12px; }

.wilaya-title {
  font-size: 22px;
  font-weight: 900;
  text-align: center;
  color: #dc2626;
  margin: 0 0 8px;
}

.wilaya-subtitle {
  text-align: center;
  font-size: 13.5px;
  color: #64748b;
  line-height: 1.6;
  margin: 0 0 22px;
}

.wilaya-label {
  display: block;
  font-size: 11px;
  font-weight: 800;
  color: #64748b;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 8px;
  margin-top: 12px;
}

.wilaya-select,
.wilaya-textarea {
  width: 100%;
  padding: 13px 15px;
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
  font-size: 15px;
  font-family: inherit;
  color: #0f172a;
  background: #fff;
  outline: none;
}

.wilaya-select:focus,
.wilaya-textarea:focus {
  border-color: #16a34a;
  box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.12);
}

.wilaya-textarea { resize: vertical; min-height: 70px; }

.wilaya-submit {
  width: 100%;
  padding: 15px 22px;
  background: linear-gradient(135deg, #dc2626, #ef4444);
  color: #fff;
  border: 0;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 1px;
  cursor: pointer;
  margin-top: 18px;
  box-shadow: 0 8px 24px -6px rgba(220, 38, 38, 0.5);
}

.wilaya-submit:disabled { opacity: 0.6; cursor: not-allowed; }

.wilaya-msg {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

.wilaya-msg.success {
  background: rgba(22, 163, 74, 0.12);
  border: 1px solid rgba(22, 163, 74, 0.3);
  color: #16a34a;
}

.wilaya-msg.error {
  background: rgba(220, 38, 38, 0.12);
  border: 1px solid rgba(220, 38, 38, 0.3);
  color: #dc2626;
}

.wilaya-msg.hidden { display: none; }

.wilaya-note {
  font-size: 11px;
  color: #94a3b8;
  text-align: center;
  margin: 14px 0 0;
  font-style: italic;
}

/* ---------- Wilaya — Image Upload ---------- */
.wilaya-image-section { position: relative; margin-bottom: 8px; }

.wilaya-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.wilaya-file-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 16px;
  background: linear-gradient(160deg, #f8fafc, #eef2f7);
  border: 2px dashed #cbd5e1;
  border-radius: 14px;
  color: #64748b;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
}

.wilaya-file-btn:hover {
  background: linear-gradient(160deg, #f0fdf4, #dcfce7);
  border-color: #16a34a;
  color: #16a34a;
}

.wilaya-file-btn span:first-child { font-size: 22px; }

/* ✅ Prévisualisation RÉDUITE */
.wilaya-image-preview {
  position: relative;
  margin: 12px auto 0;
  max-width: 240px;
  width: 100%;
  border-radius: 14px;
  overflow: hidden;
  border: 2px solid #e2e8f0;
  background: #f8fafc;
  padding: 6px;
}

.wilaya-image-preview.hidden { display: none; }

.wilaya-image-preview img {
  width: 100%;
  max-width: 220px;
  height: 150px;
  object-fit: cover;
  display: block;
  margin: 0 auto;
  border-radius: 10px;
}

.wilaya-image-remove {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px !important;
  height: 28px !important;
  padding: 0 !important;
  margin: 0 !important;
  background: rgba(220, 38, 38, 0.95) !important;
  color: #fff !important;
  border: 0 !important;
  border-radius: 50% !important;
  font-size: 12px !important;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25) !important;
}

/* ---------- AI Analysis UI ---------- */
.wilaya-ai-loading {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.08), rgba(168, 85, 247, 0.08));
  border: 1.5px solid rgba(59, 130, 246, 0.25);
  border-radius: 14px;
  margin-top: 12px;
}

.wilaya-ai-loading.hidden { display: none; }

.wilaya-ai-spinner {
  width: 22px;
  height: 22px;
  border: 3px solid rgba(59, 130, 246, 0.2);
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: aiSpin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes aiSpin { to { transform: rotate(360deg); } }

.wilaya-ai-text {
  font-size: 12.5px;
  color: #3b82f6;
  font-weight: 700;
  line-height: 1.4;
}

.wilaya-ai-result {
  margin-top: 14px;
  padding: 14px 14px 8px;
  background: linear-gradient(160deg, rgba(59, 130, 246, 0.06), rgba(168, 85, 247, 0.05));
  border: 1.5px solid rgba(59, 130, 246, 0.2);
  border-radius: 14px;
}

.wilaya-ai-result.hidden { display: none; }

.wilaya-ai-badge {
  display: inline-block;
  padding: 5px 12px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  color: #fff;
  border-radius: 100px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

/* ============================================================
   ADMIN LAYOUT
   ============================================================ */
.card[style*="max-width:720px"] { text-align: left; }

hr { border: 0; border-top: 1px solid var(--border-soft); margin: 28px 0 !important; }

.panel { display: none; animation: fadeIn 300ms ease; }
.panel.active { display: block; }

.panel > h2 {
  font-size: 22px;
  font-weight: 800;
  margin: 0 0 6px;
  color: var(--text);
}

.panel > .muted { margin-bottom: 20px; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.hidden { display: none !important; }

/* Admin Layout with Sidebar */
.admin-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
  background: #f4f6fb;
}

.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 270px;
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  z-index: 200;
  transform: translateX(-100%);
  transition: transform 280ms cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.open { transform: translateX(0); }

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

.sidebar-logo { width: 42px; height: 42px; border-radius: 12px; }
.sidebar-title { font-size: 14px; font-weight: 800; }
.sidebar-sub { font-size: 10px; color: #94a3b8; letter-spacing: 2px; font-weight: 600; }

.sidebar-nav { flex: 1; padding: 14px 0; overflow-y: auto; }
.sidebar-nav button {
  width: 100%;
  background: transparent !important;
  color: #cbd5e1 !important;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 0 !important;
  padding: 13px 22px;
  text-align: left;
  font-size: 14px;
  cursor: pointer;
  margin: 0 !important;
  box-shadow: none !important;
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-nav button:hover {
  background: rgba(255,255,255,0.06) !important;
  color: #fff !important;
}

.sidebar-nav button.active {
  background: rgba(34,197,94,0.12) !important;
  color: #fff !important;
  border-left-color: #22c55e;
  font-weight: 700;
}

.sidebar-nav button .ico { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-footer button {
  background: rgba(255,255,255,0.08) !important;
  color: #e2e8f0 !important;
  margin: 0 !important;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.55);
  z-index: 150;
  opacity: 0;
  pointer-events: none;
}

.overlay.show { opacity: 1; pointer-events: auto; }

.admin-main {
  flex: 1;
  width: 100%;
  padding: 20px 18px 60px;
  max-width: 900px;
  margin: 0 auto;
}

.mobile-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0 18px;
}

.menu-toggle {
  width: 44px;
  height: 44px;
  padding: 0 !important;
  margin: 0 !important;
  background: #fff !important;
  color: #0f172a !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 12px !important;
  font-size: 20px !important;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mobile-title {
  font-size: 15px;
  font-weight: 800;
  color: #0f172a;
}

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 16px;
}

.stat-card {
  background: linear-gradient(160deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 12px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.stat-num { font-size: 28px; font-weight: 800; color: var(--text); line-height: 1; }
.stat-label { font-size: 10px; color: var(--text-muted); letter-spacing: 1.5px; margin-top: 8px; font-weight: 700; text-transform: uppercase; }

/* Form grid */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 10px;
}
.form-grid input { margin: 0 !important; }
.form-grid .full { grid-column: 1 / -1; }

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

/* Charts */
.chart-box {
  position: relative;
  width: 100%;
  height: 280px;
  margin-top: 14px;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
}

.chart-box canvas { display: block; max-width: 100%; }

/* Log rows */
.log-row {
  background: #fff;
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
}

.log-row.log-success { border-left-color: var(--success); }
.log-row.log-warning { border-left-color: var(--warning); }
.log-row.log-danger  { border-left-color: var(--danger); }

.log-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  gap: 10px;
}

.log-result {
  font-weight: 800;
  font-size: 10px;
  padding: 4px 10px;
  border-radius: 6px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.log-result-success { background: var(--success-bg); color: #166534; border: 1px solid var(--success-border); }
.log-result-warning { background: var(--warning-bg); color: #854d0e; border: 1px solid var(--warning-border); }
.log-result-danger  { background: var(--danger-bg); color: #991b1b; border: 1px solid var(--danger-border); }

.log-date { font-size: 11px; color: var(--text-light); }

.log-code {
  font-family: "SF Mono", "Courier New", monospace;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 2px;
  margin: 6px 0 8px;
  color: var(--text);
  word-break: break-all;
}

.log-meta { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: 11px; color: var(--text-muted); }

/* QR box */
#qr, .qr-box {
  padding: 16px;
  background: linear-gradient(160deg, #f8fafc 0%, #eef2f7 100%);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: inline-flex !important;
  margin: 15px auto !important;
  justify-content: center;
}

#qr img, .qr-box img { border-radius: 8px; }

/* ============================================================
   DARK MODE
   ============================================================ */
html.dark {
  --bg: #0a0f1c;
  --bg-gradient: linear-gradient(135deg, #0a0f1c 0%, #131a2c 50%, #0f1729 100%);
  --card-bg: #131a2c;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-light: #64748b;
  --border: #1e293b;
  --border-soft: #1e293b;
  --primary: #f1f5f9;
  --primary-hover: #e2e8f0;
  --success-bg: rgba(22, 163, 74, 0.15);
  --success-border: rgba(22, 163, 74, 0.4);
  --warning-bg: rgba(234, 179, 8, 0.15);
  --warning-border: rgba(234, 179, 8, 0.4);
  --danger-bg: rgba(220, 38, 38, 0.15);
  --danger-border: rgba(220, 38, 38, 0.4);
}

html.dark body { background: var(--bg); background-image: var(--bg-gradient); }
html.dark .card { background: var(--card-bg); }

html.dark input,
html.dark select,
html.dark textarea {
  background: #0a0f1c;
  color: var(--text);
  border-color: var(--border);
}

html.dark .details > div { background: rgba(255, 255, 255, 0.03); }
html.dark .description { background: rgba(255, 255, 255, 0.03); }

html.dark .feedback-section {
  background: linear-gradient(160deg, #1e293b 0%, #131a2c 100%);
  border-color: #1e293b;
}

html.dark .stat-card {
  background: linear-gradient(160deg, #1e293b 0%, #131a2c 100%);
  border-color: #1e293b;
}

html.dark .log-row { background: #131a2c; border-color: #1e293b; }
html.dark .log-code { color: var(--text); }

html.dark .qr-box, html.dark #qr {
  background: linear-gradient(160deg, #1e293b, #131a2c);
  border-color: #1e293b;
}

html.dark .sidebar { background: linear-gradient(180deg, #0a0f1c 0%, #131a2c 100%); }

html.dark .menu-toggle {
  background: #131a2c !important;
  color: #f1f5f9 !important;
  border-color: #1e293b !important;
}

html.dark .mobile-title { color: var(--text); }

html.dark .log-result-success { background: rgba(22, 163, 74, 0.2); color: #86efac; }
html.dark .log-result-warning { background: rgba(234, 179, 8, 0.2); color: #fde047; }
html.dark .log-result-danger  { background: rgba(220, 38, 38, 0.2); color: #fca5a5; }

html.dark .chart-box { background: #131a2c; border-color: #1e293b; }

html.dark .chat-window { background: #131a2c; }
html.dark .chat-messages { background: linear-gradient(160deg, #0f1729, #131a2c); }
html.dark .chat-msg-bot .chat-bubble { background: #1e293b; color: #f1f5f9; border-color: #334155; }
html.dark .chat-form { background: #131a2c; border-top-color: #1e293b; }
html.dark .chat-input { background: #0a0f1c !important; color: #f1f5f9 !important; }

html.dark .offline-history { background: var(--card-bg); }
html.dark .offline-history-item { background: rgba(255, 255, 255, 0.03); border-color: rgba(255, 255, 255, 0.08); }
html.dark .offline-history-code { color: var(--text); }
html.dark .offline-history-title { color: var(--text); }

html.dark .wilaya-modal-box { background: #131a2c; }
html.dark .wilaya-close { background: #1e293b !important; color: #94a3b8 !important; }
html.dark .wilaya-title { color: #f87171; }
html.dark .wilaya-subtitle,
html.dark .wilaya-label { color: #94a3b8; }
html.dark .wilaya-select,
html.dark .wilaya-textarea { background: #0a0f1c; border-color: #1e293b; color: #f1f5f9; }
html.dark .wilaya-note { color: #64748b; }
html.dark .wilaya-file-btn {
  background: linear-gradient(160deg, #1e293b, #131a2c);
  border-color: #334155;
  color: #94a3b8;
}
html.dark .wilaya-image-preview { background: #0a0f1c; border-color: #1e293b; }
html.dark .wilaya-ai-loading {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(168, 85, 247, 0.12));
  border-color: rgba(59, 130, 246, 0.4);
}
html.dark .wilaya-ai-text { color: #60a5fa; }
html.dark .wilaya-ai-result {
  background: linear-gradient(160deg, rgba(59, 130, 246, 0.12), rgba(168, 85, 247, 0.1));
  border-color: rgba(59, 130, 246, 0.35);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 480px) {
  .page { padding: 16px 12px; }
  .card { padding: 30px 22px 26px; border-radius: var(--radius-lg); }
  h1 { font-size: 21px; }
  h2 { font-size: 17px; }
  .app-logo { width: 92px; height: 92px; }
  .stat-num { font-size: 24px; }

  .chat-window {
    bottom: 0; right: 0; left: 0;
    width: 100%; height: 100vh; max-height: 100vh; max-width: 100%;
    border-radius: 0;
  }
  html[dir="rtl"] .chat-window { right: 0; left: 0; }

  .chat-fab {
    bottom: 16px; right: 16px;
    width: 56px; height: 56px;
    font-size: 22px !important;
  }
  html[dir="rtl"] .chat-fab { right: auto; left: 16px; }

  .social-icon-img { width: 24px; height: 24px; }
  .social-btn { padding: 7px 12px; font-size: 12px; }
}

@media (min-width: 900px) {
  .sidebar { transform: translateX(0); }
  .admin-main {
    margin-left: 270px;
    max-width: calc(100% - 270px);
    padding: 30px 40px 60px;
  }
  .menu-toggle { display: none; }
  .mobile-header { padding: 0 0 24px; }
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

html.dark ::-webkit-scrollbar-thumb { background: #334155; }
html.dark ::-webkit-scrollbar-thumb:hover { background: #475569; }
