/* ============================================================
   MonShop — Feuille de style principale
   Thème clair / sombre, variables de couleur configurables
   ============================================================ */

:root {
  --primary: #6c5ce7;
  --secondary: #00cec9;
  --bg: #f5f6fa;
  --bg-card: #ffffff;
  --text: #1e2233;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --danger: #e74c3c;
  --success: #27ae60;
  --warning: #f39c12;
  --radius: 14px;
  --shadow: 0 4px 20px rgba(15, 17, 23, 0.07);
}

html[data-theme="dark"] {
  --bg: #0f1117;
  --bg-card: #1a1d28;
  --text: #eef0f6;
  --text-muted: #9aa0b0;
  --border: #2a2e3d;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

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

body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background 0.25s, color 0.25s;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; }

/* ---------- Bandeau annonce ---------- */
.announcement {
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  color: #fff;
  text-align: center;
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: 600;
}
.announcement a { color: #fff; text-decoration: underline; }

/* ---------- Barre de navigation ---------- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.navbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.brand { font-size: 1.35rem; font-weight: 800; color: var(--text); display: flex; align-items: center; gap: 8px; }
.brand:hover { text-decoration: none; }
.brand .logo {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 900; font-size: 1rem;
}
.nav-links { display: flex; gap: 4px; flex: 1; }
.nav-links a {
  color: var(--text); padding: 8px 12px; border-radius: 8px;
  font-weight: 500; font-size: 0.95rem;
}
.nav-links a:hover { background: var(--bg); text-decoration: none; }
.nav-actions { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  background: none; border: none; cursor: pointer; font-size: 1.15rem;
  padding: 8px; border-radius: 8px; color: var(--text); position: relative;
}
.icon-btn:hover { background: var(--bg); }

.cart-badge {
  position: absolute; top: 2px; right: 2px;
  background: var(--danger); color: #fff; font-size: 0.65rem;
  min-width: 17px; height: 17px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; padding: 0 4px;
}
.cart-badge.hidden { display: none; }

.menu-toggle { display: none; }

/* ---------- Flash messages ---------- */
.flashes { max-width: 1200px; margin: 14px auto 0; padding: 0 20px; }
.flash {
  padding: 12px 16px; border-radius: 10px; margin-bottom: 10px;
  font-size: 0.95rem; font-weight: 500;
  border: 1px solid transparent;
}
.flash.success { background: rgba(39, 174, 96, 0.12); color: var(--success); border-color: rgba(39, 174, 96, 0.35); }
.flash.danger { background: rgba(231, 76, 60, 0.12); color: var(--danger); border-color: rgba(231, 76, 60, 0.35); }
.flash.warning { background: rgba(243, 156, 18, 0.12); color: var(--warning); border-color: rgba(243, 156, 18, 0.35); }

/* ---------- Bannière héro ---------- */
.hero {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff; padding: 64px 20px; text-align: center;
}
.hero h1 { font-size: clamp(1.8rem, 4vw, 2.8rem); margin-bottom: 12px; }
.hero p { font-size: clamp(1rem, 2vw, 1.2rem); opacity: 0.95; max-width: 700px; margin: 0 auto 24px; }
.hero .btn { background: #fff; color: var(--primary); }
.hero .btn:hover { transform: translateY(-2px); }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 22px; border-radius: 10px; border: none; cursor: pointer;
  font-size: 0.95rem; font-weight: 600; transition: all 0.2s;
  background: var(--primary); color: #fff; text-decoration: none !important;
}
.btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.btn-lg { padding: 14px 30px; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn-outline { background: transparent; border: 2px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-success { background: #25d366; }
.btn-danger { background: var(--danger); }
.btn-secondary { background: var(--text-muted); }
.btn-whatsapp { background: #25d366; }
.btn-sm { padding: 7px 14px; font-size: 0.85rem; border-radius: 8px; }

/* ---------- Sections ---------- */
.container { max-width: 1200px; margin: 0 auto; padding: 30px 20px; flex: 1; width: 100%; }
.section-title { font-size: 1.5rem; font-weight: 800; margin-bottom: 20px; display: flex; align-items: center; gap: 10px; }
.section-title .accent { color: var(--primary); }

/* ---------- Grille produits ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; }
.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; transition: transform 0.2s, box-shadow 0.2s; display: flex; flex-direction: column;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.card-img { width: 100%; aspect-ratio: 3/2; object-fit: cover; display: block; background: var(--bg); }
.card-body { padding: 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-title { font-weight: 700; font-size: 1.02rem; color: var(--text); }
.card-title:hover { text-decoration: none; color: var(--primary); }
.card-desc { color: var(--text-muted); font-size: 0.85rem; flex: 1; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-price { display: flex; align-items: baseline; gap: 8px; }
.price { font-weight: 800; font-size: 1.15rem; color: var(--primary); }
.old-price { color: var(--text-muted); text-decoration: line-through; font-size: 0.9rem; }
.card-footer { display: flex; gap: 8px; margin-top: 4px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: 0.72rem; font-weight: 700; background: var(--bg); border: 1px solid var(--border);
}
.badge-promo { background: var(--danger); color: #fff; border: none; }
.badge-new { background: var(--success); color: #fff; border: none; }

/* ---------- Étoiles ---------- */
.stars { color: var(--warning); letter-spacing: 2px; font-size: 1.05rem; }
.stars .empty { opacity: 0.25; }

/* ---------- Panier ---------- */
.cart-item {
  display: flex; gap: 16px; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; margin-bottom: 12px; align-items: center;
}
.cart-item img { width: 72px; height: 56px; object-fit: cover; border-radius: 8px; }
.cart-item-info { flex: 1; }
.qty-control { display: flex; align-items: center; gap: 10px; }
.qty-btn {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text); font-size: 1rem; cursor: pointer; font-weight: 700;
}
.qty-btn:hover { border-color: var(--primary); color: var(--primary); }
.cart-summary {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; position: sticky; top: 90px;
}
.cart-empty { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.cart-empty .big { font-size: 3rem; margin-bottom: 12px; }

/* ---------- Formulaires ---------- */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 0.9rem; }
.form-group small { color: var(--text-muted); }
.form-control, input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="color"], select, textarea {
  width: 100%; padding: 11px 14px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg-card); color: var(--text); font-size: 0.95rem; font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-control:focus, input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.15);
}
textarea { resize: vertical; min-height: 100px; }

.auth-card {
  max-width: 430px; margin: 30px auto; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 30px;
  box-shadow: var(--shadow);
}
.auth-card h1 { font-size: 1.4rem; margin-bottom: 20px; text-align: center; }
.auth-links { text-align: center; margin-top: 16px; font-size: 0.9rem; color: var(--text-muted); }

/* ---------- Fiche produit ---------- */
.product-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
@media (max-width: 768px) { .product-layout { grid-template-columns: 1fr; } }
.product-img {
  width: 100%; border-radius: var(--radius); border: 1px solid var(--border);
  aspect-ratio: 3/2; object-fit: cover; background: var(--bg-card);
}
.product-info h1 { font-size: 1.7rem; margin-bottom: 8px; }
.product-meta { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 14px; }
.product-price { display: flex; align-items: baseline; gap: 12px; margin-bottom: 18px; }
.product-price .price { font-size: 2rem; }
.product-desc { margin-bottom: 22px; }
.review { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.review-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; font-size: 0.9rem; }
.review-author { font-weight: 700; }
.review-date { color: var(--text-muted); font-size: 0.8rem; }
.review-text { color: var(--text); font-size: 0.95rem; }
.rate-select { display: flex; gap: 4px; font-size: 1.6rem; }
.rate-select span { cursor: pointer; color: var(--border); transition: color 0.15s; }
.rate-select span.on { color: var(--warning); }

/* ---------- Chat IA ---------- */
.chat-widget { position: fixed; bottom: 90px; right: 20px; z-index: 60; width: 330px; max-width: calc(100vw - 40px); }
.chat-box {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow); overflow: hidden; display: none; flex-direction: column;
  max-height: 430px;
}
.chat-box.open { display: flex; }
.chat-head {
  background: linear-gradient(135deg, var(--primary), var(--secondary)); color: #fff;
  padding: 12px 16px; font-weight: 700; display: flex; justify-content: space-between; align-items: center;
}
.chat-head button { background: none; border: none; color: #fff; font-size: 1.2rem; cursor: pointer; }
.chat-messages { padding: 12px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.chat-msg { max-width: 85%; padding: 8px 12px; border-radius: 12px; font-size: 0.88rem; }
.chat-msg.bot { background: var(--bg); border-top-left-radius: 4px; align-self: flex-start; }
.chat-msg.user { background: var(--primary); color: #fff; border-top-right-radius: 4px; align-self: flex-end; }
.chat-input-row { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); }
.chat-input-row input { flex: 1; }
.chat-fab {
  position: fixed; bottom: 20px; right: 20px; z-index: 60;
  width: 56px; height: 56px; border-radius: 50%; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--primary), var(--secondary)); color: #fff;
  font-size: 1.5rem; box-shadow: var(--shadow);
}
.chat-fab:hover { transform: scale(1.06); }

/* ---------- Footer ---------- */
.footer {
  background: var(--bg-card); border-top: 1px solid var(--border);
  padding: 28px 20px; margin-top: auto; text-align: center; color: var(--text-muted); font-size: 0.88rem;
}
.footer a { color: var(--text); }
.footer-links { display: flex; justify-content: center; gap: 20px; margin-bottom: 10px; flex-wrap: wrap; }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: var(--bg); font-weight: 700; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(108, 92, 231, 0.04); }

/* ---------- Admin ---------- */
.admin-body { flex-direction: row; }
.admin-sidebar {
  width: 230px; flex-shrink: 0; background: var(--bg-card); border-right: 1px solid var(--border);
  min-height: calc(100vh - 57px); padding: 18px 12px; position: sticky; top: 57px; height: calc(100vh - 57px);
  overflow-y: auto;
}
.admin-sidebar a {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 10px;
  color: var(--text); font-weight: 500; font-size: 0.92rem; margin-bottom: 2px;
}
.admin-sidebar a:hover { background: var(--bg); text-decoration: none; }
.admin-sidebar a.active { background: rgba(108, 92, 231, 0.12); color: var(--primary); font-weight: 700; }
.admin-main { flex: 1; padding: 24px 28px; min-width: 0; }
.admin-title { font-size: 1.4rem; font-weight: 800; margin-bottom: 20px; }
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.stat-card .num { font-size: 1.7rem; font-weight: 800; color: var(--primary); }
.stat-card .lbl { color: var(--text-muted); font-size: 0.83rem; }
.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.toolbar .form-control { width: auto; }

.status-pill { padding: 3px 12px; border-radius: 20px; font-size: 0.75rem; font-weight: 700; }
.status-En_attente { background: rgba(243, 156, 18, 0.15); color: var(--warning); }
.status-Confirmée { background: rgba(52, 152, 219, 0.15); color: #3498db; }
.status-Payée { background: rgba(39, 174, 96, 0.15); color: var(--success); }
.status-Livrée { background: rgba(39, 174, 96, 0.15); color: var(--success); }
.status-Annulée { background: rgba(231, 76, 60, 0.15); color: var(--danger); }

/* ---------- Divers ---------- */
.flex { display: flex; gap: 12px; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 16px; } .mt-4 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 16px; } .mb-4 { margin-bottom: 24px; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.mono { font-family: "Courier New", monospace; font-size: 0.9rem; word-break: break-all; }
.alert-box {
  background: rgba(108, 92, 231, 0.08); border: 1px solid rgba(108, 92, 231, 0.3);
  border-radius: 10px; padding: 14px 16px; margin-bottom: 16px; font-size: 0.92rem;
}
.twofa-demo { font-family: monospace; letter-spacing: 6px; font-size: 1.4rem; background: var(--bg); padding: 10px; border-radius: 8px; text-align: center; }
.recovery-code { font-family: monospace; font-weight: 700; background: var(--bg); padding: 4px 10px; border-radius: 6px; display: inline-block; margin: 3px; }
.promo-bar {
  background: linear-gradient(90deg, var(--danger), #e67e22); color: #fff;
  text-align: center; padding: 10px 16px; font-weight: 700; font-size: 0.95rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .menu-toggle { display: block; }
  .nav-links {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    background: var(--bg-card); flex-direction: column; padding: 10px 16px;
    border-bottom: 1px solid var(--border); box-shadow: var(--shadow);
  }
  .nav-links.open { display: flex; }
  .admin-sidebar { display: none; }
  .admin-sidebar.open { display: block; position: fixed; left: 0; top: 57px; bottom: 0; z-index: 40; width: 240px; }
  .admin-main { padding: 18px 14px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
}


/* Fix debordement navbar mobile */
@media (max-width: 480px) {
  html, body { overflow-x: hidden; }
  .navbar-inner { flex-wrap: wrap; row-gap: 8px; }
  .nav-actions { flex-basis: 100%; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
  .nav-actions .btn-sm { padding: 6px 8px; font-size: 0.82rem; }
}
