/* ===========================================================================
   style.css — Feuille de style unique du site.
   Palette : verts naturels + crème, gros boutons lisibles (utilisable
   au doigt sur tablette, y compris côté admin).
   =========================================================================== */

:root {
  --green-dark: #2e5d34;
  --green: #3f7d46;
  --green-light: #e7f2e4;
  --cream: #faf7f0;
  --text: #2b2b2b;
  --muted: #6b6b5e;
  --border: #ddd8c8;
  --red: #b03a2e;
  --red-light: #fdeceb;
  --orange-light: #fdf3e0;
  --blue-light: #e8f0fb;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.55;
  color: var(--text);
  background: var(--cream);
}

.container { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
main.container { min-height: 65vh; padding-bottom: 48px; }

h1 { font-size: 1.7rem; color: var(--green-dark); }
h2 { font-size: 1.25rem; color: var(--green-dark); margin-top: 2rem; }
a { color: var(--green-dark); }
.muted { color: var(--muted); font-size: 0.95em; }
.text-right { text-align: right; }
.inline { display: inline; }

/* --- En-tête et menus ----------------------------------------------------- */

.site-header {
  background: var(--green-dark);
  padding: 10px 0;
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-inner { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; }
.brand { color: #fff; font-size: 1.25rem; font-weight: 700; text-decoration: none; margin-right: auto; }
.main-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; }
.main-nav a { color: #f0f6ee; text-decoration: none; padding: 6px 0; }
.main-nav a:hover { text-decoration: underline; }
.nav-admin { font-weight: 600; }

.admin-nav {
  display: flex; flex-wrap: wrap; gap: 4px 18px;
  background: var(--green-light);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 16px;
  margin-top: 16px;
}
.admin-nav a { text-decoration: none; font-weight: 600; padding: 4px 0; }
.admin-nav a:hover { text-decoration: underline; }

.badge {
  background: #fff; color: var(--green-dark);
  border-radius: 999px; padding: 1px 8px; font-size: 0.8em; font-weight: 700;
}
.badge-alert { background: var(--red); color: #fff; }

/* --- Messages flash (confirmation, erreurs) -------------------------------- */

.flash { padding: 12px 16px; border-radius: 10px; margin: 16px 0; border: 1px solid; }
.flash-success { background: var(--green-light); border-color: var(--green); color: var(--green-dark); }
.flash-error { background: var(--red-light); border-color: var(--red); color: var(--red); }
.flash-info { background: var(--blue-light); border-color: #7ba2d6; color: #2b4d7d; }

/* --- Catalogue --------------------------------------------------------------- */

.hero { background: var(--green-light); border-radius: 14px; padding: 24px 28px; margin-top: 20px; }
.hero h1 { margin: 0 0 8px; }
.hero p { margin: 0; max-width: 60ch; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 18px;
  margin: 16px 0 32px;
}

.card {
  background: #fff; border: 1px solid var(--border); border-radius: 14px;
  overflow: hidden; display: flex; flex-direction: column;
}
.card-image { display: block; }
.card-image img, .img-placeholder { width: 100%; height: 150px; object-fit: cover; display: block; }
.img-placeholder {
  display: flex; align-items: center; justify-content: center;
  font-size: 3rem; background: var(--green-light);
}
.img-placeholder-large { height: 320px; border-radius: 14px; }
.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card-body h3 { margin: 0; font-size: 1.05rem; }
.card-body h3 a { text-decoration: none; }

.price { font-weight: 700; color: var(--green-dark); margin: 0; }
.price-big { font-size: 1.4rem; }
.unit { font-weight: 400; color: var(--muted); font-size: 0.9em; }

.stock { margin: 0; font-size: 0.9rem; }
.stock-ok { color: var(--green); }
.stock-low { color: #b9770e; font-weight: 600; }
.stock-out { color: var(--red); font-weight: 700; }

.add-form { display: flex; gap: 8px; margin-top: auto; padding-top: 8px; }
.add-form input[type="number"] { width: 70px; }

/* --- Fiche produit ----------------------------------------------------------- */

.product-page { display: grid; grid-template-columns: 1fr 1.2fr; gap: 28px; align-items: start; }
.product-image img { width: 100%; border-radius: 14px; }
.description { white-space: pre-line; }
.composition { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 12px 12px 12px 32px; }
@media (max-width: 700px) { .product-page { grid-template-columns: 1fr; } }

/* --- Formulaires ------------------------------------------------------------- */

label { display: block; font-weight: 600; margin: 14px 0 4px; }
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], select, textarea {
  width: 100%; max-width: 480px;
  padding: 10px 12px; font-size: 1rem;
  border: 1px solid var(--border); border-radius: 8px; background: #fff;
}
input[type="number"] { max-width: 110px; }
textarea { max-width: 640px; }

.btn {
  display: inline-block;
  background: #fff; color: var(--green-dark);
  border: 1.5px solid var(--green); border-radius: 8px;
  padding: 9px 16px; font-size: 1rem; font-weight: 600;
  text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--green-light); }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); }
.btn-danger { border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: var(--red-light); }
.btn-small { padding: 5px 10px; font-size: 0.9rem; }
.btn-large { padding: 13px 26px; font-size: 1.1rem; margin-top: 16px; }

.linklike {
  background: none; border: none; padding: 0;
  color: inherit; font: inherit; text-decoration: underline; cursor: pointer;
}
.main-nav .linklike { color: #f0f6ee; }

.auth-box { max-width: 480px; margin: 32px auto; background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 8px 28px 28px; }

.form-row { display: flex; flex-wrap: wrap; gap: 0 20px; }
.form-row > div { flex: 1; min-width: 140px; }
.form-row .grow { flex: 2; }
.product-form { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 8px 24px 24px; max-width: 720px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* --- Tableaux ------------------------------------------------------------------ */

.table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table thead th { background: var(--green-light); color: var(--green-dark); }
.table tfoot td { background: var(--green-light); }
.table-compact th, .table-compact td { padding: 6px 10px; }
.row-today { background: var(--orange-light); }
.row-inactive { opacity: 0.55; }

.thumb { width: 56px; height: 42px; object-fit: cover; border-radius: 6px; font-size: 1.4rem; height: 42px; }
.cell-thumb { width: 64px; }
.cell-actions { white-space: nowrap; }
.cell-preview { color: var(--muted); }
.stock-form { display: flex; gap: 6px; align-items: center; }
.stock-form input { max-width: 90px; }

.tag { font-size: 0.78rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--green-light); color: var(--green-dark); }
.tag-off { background: #eee; color: #555; }
.tag-alert { background: var(--red-light); color: var(--red); }

/* --- Statuts de commande --------------------------------------------------------- */

.status { font-size: 0.85rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.status-en_attente { background: var(--orange-light); color: #9c6508; }
.status-preparee { background: var(--blue-light); color: #2b4d7d; }
.status-recuperee { background: var(--green-light); color: var(--green-dark); }
.status-annulee { background: #eee; color: #555; }

/* --- Commande / confirmation -------------------------------------------------------- */

.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 20px 0; }
.checkout-form { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 8px 24px 24px; max-width: 720px; }
.location-choice {
  display: flex; gap: 10px; align-items: flex-start;
  border: 1px solid var(--border); border-radius: 10px;
  padding: 12px; margin: 8px 0; font-weight: 400; cursor: pointer;
}
.location-choice input { margin-top: 5px; }
.confirmation { max-width: 640px; margin: 24px auto; }
.order-card { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 16px 20px; margin: 16px 0; }
.order-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.order-detail { max-width: 760px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; justify-content: space-between; }

/* --- Tableau de bord admin ------------------------------------------------------------ */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin: 20px 0; }
.stat-card {
  background: #fff; border: 1px solid var(--border); border-radius: 14px;
  padding: 18px; text-align: center; text-decoration: none; color: var(--text);
}
.stat-card:hover { border-color: var(--green); }
.stat-warning { border-color: #e0a800; background: var(--orange-light); }
.stat-number { display: block; font-size: 2.2rem; font-weight: 800; color: var(--green-dark); }

.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.tabs a { text-decoration: none; padding: 7px 14px; border: 1px solid var(--border); border-radius: 999px; background: #fff; }
.tabs .tab-active { background: var(--green); color: #fff; border-color: var(--green); font-weight: 700; }

/* --- Messagerie ------------------------------------------------------------------------ */

.chat { display: flex; flex-direction: column; gap: 10px; margin: 20px 0; max-width: 720px; }
.bubble { border-radius: 14px; padding: 10px 14px; max-width: 85%; }
.bubble-me { background: var(--green-light); align-self: flex-end; }
.bubble-them { background: #fff; border: 1px solid var(--border); align-self: flex-start; }
.bubble-meta { margin: 0; font-size: 0.8rem; font-weight: 700; color: var(--muted); }
.bubble-body { margin: 4px 0 0; white-space: pre-line; }
.message-form { max-width: 720px; }

/* --- Lieux de retrait --------------------------------------------------------------------- */

.location-card { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 8px 20px 16px; margin: 14px 0; }
.weekdays { border: 1px solid var(--border); border-radius: 10px; margin-top: 14px; }
.weekdays legend { font-weight: 600; padding: 0 6px; }
.day-check { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; margin: 4px 14px 4px 0; }
.date-choice { margin: 8px 0; }

/* --- Pied de page ----------------------------------------------------------------------------- */

.site-footer { background: var(--green-dark); color: #e8f0e4; padding: 22px 0; margin-top: 40px; }
.site-footer p { margin: 4px 0; }

/* --- Page « Notre ferme » -------------------------------------------------------- */

.farm-page { max-width: 760px; }
.farm-photo { width: 100%; border-radius: 14px; margin: 12px 0 20px; }
.farm-story { white-space: pre-line; background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 20px 24px; }

/* --- Paiement -------------------------------------------------------------------- */

.tag-paid { background: var(--green); color: #fff; }

/* --- Fiche de préparation et impression ------------------------------------------- */

.prep-card { page-break-inside: avoid; }
.prep-items { margin: 8px 0; }
.print-header { display: none; }
.thumb-large { width: 220px; height: auto; border-radius: 10px; }

@media print {
  /* À l'impression : on ne garde que le contenu utile de la fiche. */
  .site-header, .site-footer, .admin-nav, .no-print, .flash { display: none !important; }
  .print-header { display: block; }
  body { background: #fff; font-size: 13px; }
  .order-card, .table { border-color: #999; }
  a { text-decoration: none; color: inherit; }
}

/* --- Page Statistiques ------------------------------------------------------------ */

.help-text { color: #666; font-size: 0.92rem; margin-top: -6px; }
.stats-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 0 28px; }
/* Petite barre horizontale : compare les ventes d'un coup d'œil. */
.bar-cell { width: 30%; min-width: 90px; }
.bar { height: 14px; border-radius: 7px; background: var(--green); min-width: 3px; }
