/* ==========================================================
   FasoFit — style.css
   Palette inspirée du logo : marron (#8a5a2b), vert (#3f7d3f),
   orange/or (#e08a1e), fond sombre pour les zones d'accent.
   ========================================================== */

:root {
  --brun: #8a5a2b;
  --brun-fonce: #6b4520;
  --vert: #3f7d3f;
  --vert-fonce: #2e5c2e;
  --or: #e08a1e;
  --or-clair: #f5b556;
  --texte: #2b2420;
  --texte-clair: #6b6058;
  --fond: #faf7f2;
  --carte: #ffffff;
  --bordure: #e8dfd2;
  --rouge: #c0392b;
  --radius: 12px;
}

[data-theme="dark"] {
  --brun: #d19a5c;
  --brun-fonce: #b9853f;
  --vert: #5fae5f;
  --vert-fonce: #4a9a4a;
  --or: #f0a83e;
  --or-clair: #f7c479;
  --texte: #ece5da;
  --texte-clair: #a89f92;
  --fond: #16110c;
  --carte: #221a12;
  --bordure: #3a2e20;
  --rouge: #e0574a;
}

body, .card, input, select, textarea, .site-header {
  transition: background-color .2s ease, color .2s ease, border-color .2s ease;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--fond);
  color: var(--texte);
  line-height: 1.5;
  overflow-x: hidden;
}
.container { max-width: 1140px; margin: 0 auto; padding: 0 16px; }
a { color: var(--vert-fonce); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Header */
.site-header {
  background: #1b140d;
  border-bottom: 3px solid var(--or);
  position: sticky; top: 0; z-index: 50;
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.logo { font-size: 1.5rem; font-weight: 800; color: var(--or-clair); }
.logo span { color: var(--vert); }
.nav-user, .nav-guest { display: flex; align-items: center; gap: 16px; }
.nav-user a, .nav-guest a, .nav-name { color: #f2e9dc; }
.nav-name { opacity: .8; font-size: .9rem; }
.cloche-badge {
  position: absolute; top: -8px; right: -10px; background: var(--rouge); color: #fff;
  font-size: .65rem; font-weight: 800; border-radius: 10px; padding: 1px 5px; line-height: 1.3;
}

/* Boutons */
.btn {
  display: inline-block; padding: 10px 18px; border-radius: 8px;
  border: none; cursor: pointer; font-weight: 600; font-size: .95rem;
  text-decoration: none; text-align: center;
}
.btn-primary { background: var(--or); color: #1b140d; }
.btn-primary:hover { background: var(--or-clair); text-decoration: none; }
.btn-secondary { background: var(--vert); color: #fff; }
.btn-secondary:hover { background: var(--vert-fonce); text-decoration: none; }
.btn-outline { background: transparent; border: 1.5px solid var(--brun); color: var(--brun); }
.btn-outline-clair { background: transparent; border: 1.5px solid var(--or-clair); color: var(--or-clair); }
.btn-outline-clair:hover { background: var(--or-clair); color: #1b140d; text-decoration: none; }
.btn-danger { background: var(--rouge); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: .85rem; }
.btn-lg { padding: 14px 28px; font-size: 1.05rem; }
.btn-block { display: block; width: 100%; }
.btn-link { background: none; border: none; cursor: pointer; }

/* Cartes / mise en page */
.main-content { min-height: 70vh; padding: 24px 16px 60px; }
.card {
  background: var(--carte); border: 1px solid var(--bordure); border-radius: var(--radius);
  padding: 20px; margin-bottom: 16px;
}
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(260px,1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); }

/* Formulaires */
label { display: block; font-weight: 600; margin-bottom: 4px; font-size: .9rem; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--bordure);
  border-radius: 8px; font-size: .95rem; margin-bottom: 14px; font-family: inherit;
  background: var(--carte); color: var(--texte);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--vert); }
.form-narrow { max-width: 420px; margin: 0 auto; }
.form-row { display: flex; gap: 12px; }
.form-row > * { flex: 1; }

/* Alertes */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: .9rem; }
.alert-success { background: #e4f3e4; color: var(--vert-fonce); border: 1px solid var(--vert); }
.alert-error { background: #fbe6e3; color: var(--rouge); border: 1px solid var(--rouge); }
.alert-info { background: #fdf1de; color: var(--brun-fonce); border: 1px solid var(--or); }

/* Badges de statut */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: .78rem; font-weight: 700; }
.badge-gris { background: #eee; color: #555; }
.badge-bleu { background: #dbeafe; color: #1e40af; }
.badge-orange { background: #fde3c4; color: #9a5a0d; }
.badge-violet { background: #ede0fb; color: #6b21a8; }
.badge-jaune { background: #fff3c4; color: #8a6d00; }
.badge-vert { background: #dcf5dc; color: var(--vert-fonce); }
.badge-rouge { background: #fbe0dc; color: var(--rouge); }

/* Dashboard layout */
.dash-layout { display: grid; grid-template-columns: 220px 1fr; gap: 24px; align-items: start; }
.dash-sidebar {
  background: var(--carte); border: 1px solid var(--bordure); border-radius: var(--radius);
  padding: 12px; position: sticky; top: 80px;
}
.dash-sidebar a {
  display: block; padding: 10px 12px; border-radius: 8px; color: var(--texte); margin-bottom: 2px; font-size: .92rem;
}
.dash-sidebar a:hover, .dash-sidebar a.active { background: var(--fond); text-decoration: none; color: var(--vert-fonce); font-weight: 700; }
@media (max-width: 800px) {
  .dash-layout { grid-template-columns: 1fr; }
  .dash-sidebar {
    position: static; display: flex; flex-wrap: nowrap; overflow-x: auto;
    -webkit-overflow-scrolling: touch; gap: 6px; padding: 8px 4px;
  }
  .dash-sidebar a { flex: 0 0 auto; white-space: nowrap; text-align: center; }
}

/* Stat cards */
.stat-card { text-align: center; padding: 18px; }
.stat-card .valeur { font-size: 1.9rem; font-weight: 800; color: var(--brun); }
.stat-card .libelle { color: var(--texte-clair); font-size: .85rem; }

/* Catalogue — cartes modèle enrichies */
.modele-card { overflow: hidden; padding: 0; transition: transform .15s ease, box-shadow .15s ease; position: relative; }
.modele-card:hover { transform: translateY(-4px); box-shadow: 0 12px 28px rgba(0,0,0,.15); }
.modele-card .img-wrap { position: relative; overflow: hidden; background: #f0ebe4; }
.modele-card .img-wrap img {
  width: 100%; height: 260px; object-fit: cover; display: block;
  transition: transform .4s ease; loading: lazy;
}
.modele-card:hover .img-wrap img { transform: scale(1.06); }

/* Skeleton loading */
.modele-card .img-wrap.chargement { background: linear-gradient(90deg, #f0ebe4 25%, #e8dfd2 50%, #f0ebe4 75%); background-size: 200% 100%; animation: skeleton-anim 1.4s infinite; }
@keyframes skeleton-anim { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Quick view bouton apparaissant au survol */
.modele-card .quick-view-btn {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: rgba(27,20,13,.82); color: var(--or-clair); border: none; cursor: pointer;
  padding: 10px; font-size: .85rem; font-weight: 700; letter-spacing: .04em;
  transform: translateY(100%); transition: transform .22s ease;
  text-align: center; backdrop-filter: blur(4px);
}
.modele-card:hover .quick-view-btn { transform: translateY(0); }
.modele-card .contenu { padding: 14px; }
.modele-card h3 { margin: 0 0 6px; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Lightbox modale */
#lightbox-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.9); z-index: 1000;
  align-items: center; justify-content: center; cursor: zoom-out;
}
#lightbox-overlay.actif { display: flex; }
#lightbox-overlay img { max-width: 92vw; max-height: 90vh; border-radius: 8px; box-shadow: 0 8px 40px rgba(0,0,0,.5); cursor: default; }
#lightbox-fermer { position: absolute; top: 16px; right: 20px; color: #fff; font-size: 2rem; background: none; border: none; cursor: pointer; }
#lightbox-prev, #lightbox-next {
  position: absolute; top: 50%; transform: translateY(-50%); color: #fff; font-size: 2rem;
  background: rgba(0,0,0,.4); border: none; cursor: pointer; border-radius: 50%; width: 48px; height: 48px; line-height: 1;
}
#lightbox-prev { left: 12px; }
#lightbox-next { right: 12px; }

/* Modal quick view */
#quickview-modal {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 900;
  align-items: center; justify-content: center; padding: 16px;
}
#quickview-modal.actif { display: flex; }
#quickview-inner {
  background: var(--carte); border-radius: var(--radius); max-width: 720px; width: 100%;
  max-height: 90vh; overflow-y: auto; position: relative;
}
#quickview-fermer { position: absolute; top: 12px; right: 14px; background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--texte-clair); }
#quickview-inner .qv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
#quickview-inner .qv-img { background: #f0ebe4; border-radius: var(--radius) 0 0 var(--radius); overflow: hidden; min-height: 300px; }
#quickview-inner .qv-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
#quickview-inner .qv-info { padding: 24px; }
@media (max-width: 600px) { #quickview-inner .qv-grid { grid-template-columns: 1fr; } #quickview-inner .qv-img { min-height: 220px; border-radius: var(--radius) var(--radius) 0 0; } }
.prix { color: var(--brun); font-weight: 800; font-size: 1.1rem; }

/* Table simple */
.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: 16px; }
table { width: 100%; min-width: 560px; border-collapse: collapse; background: var(--carte); border-radius: var(--radius); overflow: hidden; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--bordure); font-size: .9rem; }
th { background: var(--fond); }

@media (max-width: 700px) {
  .header-inner { height: auto; flex-direction: column; align-items: flex-start; gap: 8px; padding: 10px 0; }
  .logo { font-size: 1.2rem; }
  .nav-user, .nav-guest { width: 100%; justify-content: space-between; gap: 8px; font-size: .85rem; }
  .nav-name { display: none; }
  .hero { padding: 32px 18px; }
  .hero h1 { font-size: 1.6rem; }
  .form-row { flex-direction: column; gap: 0; }
  .main-content { padding: 16px 12px 40px; }
  .grid-3, .grid-4 { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
  .stat-card { padding: 12px 8px; }
  .stat-card .valeur { font-size: 1.4rem; }
  .stat-card .libelle { font-size: .75rem; }
}

/* Landing hero */
.hero {
  background: linear-gradient(135deg, #1b140d, #3a2513);
  color: #fff; border-radius: var(--radius); padding: 48px 32px; margin-bottom: 32px;
  text-align: center;
}
.hero h1 { font-size: 2.2rem; margin-bottom: 10px; }
.hero p { color: #e6d8c3; margin-bottom: 24px; }

.text-muted { color: var(--texte-clair); }

/* Contrôle de mesure interactif (glissière façon mètre-ruban) */
.regle-mesure { margin-bottom: 20px; }
.regle-controle { display: flex; align-items: center; gap: 10px; }
.regle-btn {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%; border: 1.5px solid var(--brun);
  background: #fff; color: var(--brun); font-size: 1.2rem; font-weight: 800; cursor: pointer; line-height: 1;
}
.regle-btn:active { background: var(--brun); color: #fff; }
.regle-piste-wrap { flex: 1 1 auto; position: relative; }
.regle-range {
  width: 100%; margin: 0; appearance: none; -webkit-appearance: none; height: 6px;
  border-radius: 4px; background: var(--bordure); outline: none;
}
.regle-range::-webkit-slider-thumb {
  appearance: none; -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%;
  background: var(--or); border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.3); cursor: pointer; margin-top: -8px;
}
.regle-range::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%; background: var(--or); border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.3); cursor: pointer;
}
.regle-graduations {
  height: 8px; margin-top: 2px;
  background-image: repeating-linear-gradient(90deg, var(--brun) 0, var(--brun) 1px, transparent 1px, transparent 10%);
  opacity: .5;
}
.regle-valeur { flex: 0 0 auto; min-width: 64px; text-align: right; font-weight: 800; color: var(--brun); font-size: 1.05rem; }
.mt-16 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
