:root {
  --canopee-green-dark: #14534a;
  --canopee-green: #1a6b5f;
  --bg: #f5f7f6;
  --card-bg: #ffffff;
  --text: #1f2a28;
  --text-muted: #5c6d69;
  --border: #e0e6e4;
  --error: #b3261e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* Connexion */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  box-shadow: 0 4px 20px rgba(20, 83, 74, 0.08);
}

.login-card h1 {
  margin: 0 0 0.25rem;
  color: var(--canopee-green-dark);
  font-size: 1.4rem;
}

.login-card .subtitle {
  margin: 0 0 1.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.login-card label {
  display: block;
  margin-top: 1rem;
  margin-bottom: 0.3rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.login-card input {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
}

.login-card button {
  width: 100%;
  margin-top: 1.5rem;
  padding: 0.7rem;
  border: none;
  border-radius: 8px;
  background: var(--canopee-green);
  color: white;
  font-size: 1rem;
  cursor: pointer;
}

.login-card button:hover {
  background: var(--canopee-green-dark);
}

.error {
  color: var(--error);
  font-size: 0.85rem;
  margin: 0.5rem 0 0;
}

/* Application */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--canopee-green-dark);
  color: white;
  padding: 0.9rem 1.5rem;
}

.topbar .brand {
  font-weight: 600;
  text-decoration: none;
  color: white;
}

.topbar nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.9rem;
  flex-wrap: wrap;
}

.topbar a {
  color: white;
  text-decoration: underline;
}

.topbar nav a.active {
  text-decoration: none;
  font-weight: 600;
}

.content {
  max-width: 900px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

.content-wide {
  max-width: 1200px;
}

.subtitle {
  color: var(--text-muted);
  margin-top: -0.5rem;
}

/* Filtres catalogue */

.filtres {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin: 1rem 0;
  padding: 1rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.filtres input[type="search"],
.filtres select {
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
}

.filtres input[type="search"] {
  flex: 1 1 220px;
}

.filtre-case {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.vue-toggle {
  display: flex;
  margin-left: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.vue-toggle button {
  padding: 0.5rem 0.9rem;
  border: none;
  background: var(--card-bg);
  cursor: pointer;
  font-size: 0.85rem;
}

.vue-toggle button.active {
  background: var(--canopee-green);
  color: white;
}

.compteur {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0 0 0.5rem;
}

/* Vue grille */

.grille-produits {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}

/* Sans cette règle, l'attribut HTML "hidden" est ignoré : une règle d'auteur
   (display:grid ci-dessus) l'emporte toujours sur la règle par défaut du
   navigateur pour [hidden], donc la grille resterait visible même masquée
   par la bascule Grille/Liste. */
.grille-produits[hidden] {
  display: none;
}

.produit-carte {
  display: block;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  transition: box-shadow 0.15s ease;
}

/* Voir la remarque sur .grille-produits[hidden] : sans ceci, une carte
   masquée par un filtre (attribut "hidden" posé par catalogue.js) resterait
   visible malgré tout. */
.produit-carte[hidden] {
  display: none;
}

.produit-carte:hover {
  box-shadow: 0 4px 16px rgba(20, 83, 74, 0.12);
}

.produit-visuel {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.produit-visuel img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.visuel-absent {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.badge-nouveaute,
.badge-non-commercialise {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  background: var(--canopee-green-dark);
  color: white;
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
}

.badge-non-commercialise {
  background: var(--text-muted);
  left: auto;
  right: 0.5rem;
}

.badge-ma {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: #3d6b8a;
  color: white;
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
}

.badge-nouveaute-inline,
.badge-ma-inline {
  background: var(--canopee-green-dark);
  color: white;
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  margin-left: 0.4rem;
}

.badge-ma-inline {
  background: #3d6b8a;
}

.produit-info {
  padding: 0.7rem 0.8rem;
}

.produit-nom {
  margin: 0 0 0.2rem;
  font-weight: 600;
  font-size: 0.9rem;
}

.produit-ref {
  margin: 0 0 0.4rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.produit-prix {
  margin: 0;
  font-weight: 600;
  color: var(--canopee-green-dark);
}

.prix-detail {
  font-weight: 400;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Vue liste */

.liste-produits {
  width: 100%;
  border-collapse: collapse;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  font-size: 0.85rem;
}

.liste-produits th,
.liste-produits td {
  text-align: left;
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border);
}

.liste-produits th {
  background: var(--bg);
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
}

.liste-produits tbody tr:hover {
  background: var(--bg);
}

/* Fiche produit */

.lien-retour {
  color: var(--canopee-green-dark);
  font-size: 0.85rem;
}

.fiche-produit {
  display: grid;
  grid-template-columns: minmax(240px, 360px) 1fr;
  gap: 2rem;
  align-items: start;
}

.fiche-visuel {
  position: relative;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fiche-visuel img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.visuel-agrandir {
  position: relative;
  width: 100%;
  height: 100%;
  padding: 0;
  border: none;
  background: none;
  cursor: zoom-in;
  display: block;
}

.visuel-agrandir-icone {
  position: absolute;
  bottom: 0.6rem;
  right: 0.6rem;
  background: rgba(20, 83, 74, 0.8);
  color: white;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

/* Visionneuse plein écran */

.visionneuse {
  position: fixed;
  inset: 0;
  background: rgba(10, 20, 18, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 2rem;
}

/* Spécificité supérieure à .visionneuse : sans cette règle, l'attribut HTML
   "hidden" est ignoré car une règle d'auteur (ici display:flex) l'emporte
   toujours sur la règle par défaut du navigateur pour [hidden]. */
.visionneuse[hidden] {
  display: none;
}

.visionneuse img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
}

.visionneuse-fermer {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  background: none;
  border: none;
  color: white;
  font-size: 2.2rem;
  line-height: 1;
  cursor: pointer;
}

.fiche-ref {
  color: var(--text-muted);
  margin-top: -0.5rem;
}

.fiche-grille {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4rem 1rem;
  margin: 1rem 0;
}

.fiche-grille dt {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.fiche-grille dd {
  margin: 0;
}

.tarifs-table {
  border-collapse: collapse;
}

.tarifs-table th,
.tarifs-table td {
  text-align: left;
  padding: 0.4rem 1rem 0.4rem 0;
}

.tarifs-table th {
  color: var(--text-muted);
  font-weight: 400;
}

.tarifs-table td {
  font-weight: 600;
  color: var(--canopee-green-dark);
}

/* Gammes */

.entete-page {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.entete-page h1 {
  margin-bottom: 0.2rem;
}

.bouton,
.bouton-secondaire,
.bouton-danger {
  display: inline-block;
  padding: 0.55rem 1rem;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.bouton {
  background: var(--canopee-green);
  color: white;
}

.bouton:hover {
  background: var(--canopee-green-dark);
}

.bouton-secondaire {
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.bouton-secondaire:hover {
  background: var(--bg);
}

.bouton-danger {
  background: var(--card-bg);
  color: var(--error);
  border: 1px solid var(--border);
}

.bouton-danger:hover {
  background: var(--error);
  color: white;
}

.message-succes {
  color: var(--canopee-green-dark);
  background: rgba(20, 83, 74, 0.08);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  font-size: 0.9rem;
}

.badge-lien {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  white-space: nowrap;
}

.badge-lien-actif {
  background: rgba(20, 83, 74, 0.12);
  color: var(--canopee-green-dark);
}

.badge-lien-expire {
  background: rgba(179, 38, 30, 0.1);
  color: var(--error);
}

.badge-lien-aucun {
  background: var(--bg);
  color: var(--text-muted);
}

.panneau-partage {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.2rem;
  margin-bottom: 1rem;
}

.panneau-partage h2 {
  margin-top: 0;
  font-size: 1rem;
}

.lien-partage-url {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin: 0.6rem 0;
}

.lien-partage-url input {
  flex: 1 1 auto;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
  background: var(--bg);
}

.form-inline {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0.6rem 0;
}

.form-inline select {
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.gamme-champ-nom {
  margin-bottom: 1rem;
}

.gamme-champ-nom label {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.gamme-champ-nom input {
  width: 100%;
  max-width: 480px;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
}

/* Sélection de produits (constructeur de gamme) */

.produit-selectionnable {
  position: relative;
  cursor: pointer;
}

.produit-case {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 1;
  width: 1.2rem;
  height: 1.2rem;
  accent-color: var(--canopee-green);
}

.barre-selection {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
  padding: 0.8rem 1.2rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 -4px 16px rgba(20, 83, 74, 0.08);
}

#compteur-selection {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.barre-selection-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

/* Onglets de section (une gamme = plusieurs sélections nommées, ex.
   Inhumation / Crémation) */

.section-onglets {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.section-onglet {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.5rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
}

.section-onglet.active {
  border-color: var(--canopee-green);
  background: rgba(20, 83, 74, 0.08);
}

.section-onglet-nom {
  border: none;
  background: none;
  font-size: 0.9rem;
  color: var(--text);
  width: 9rem;
  min-width: 4rem;
  padding: 0.1rem 0.2rem;
}

.section-onglet-nom:focus {
  outline: 1px solid var(--canopee-green);
  border-radius: 4px;
}

.section-onglet-compte {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg);
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  white-space: nowrap;
}

.section-onglet-supprimer {
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.2rem;
}

.section-onglet-supprimer:hover {
  color: var(--error);
}

.section-onglet-ajouter {
  padding: 0.4rem 0.8rem;
  border: 1px dashed var(--border);
  border-radius: 999px;
  background: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
}

.section-onglet-ajouter:hover {
  border-color: var(--canopee-green);
  color: var(--canopee-green-dark);
}

/* Liste "ordre de présentation" (réordonnancement manuel, indépendant du prix) */

.selection-liste-bloc {
  margin-bottom: 1rem;
}

.selection-liste-bloc h3 {
  margin-bottom: 0.2rem;
  font-size: 0.95rem;
}

.selection-liste-bloc .subtitle {
  margin-top: 0;
  margin-bottom: 0.6rem;
  font-size: 0.8rem;
}

.selection-liste {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.selection-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.6rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.selection-item-position {
  flex: 0 0 1.4rem;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--canopee-green-dark);
}

.selection-item-vignette {
  flex: 0 0 2.4rem;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg);
}

.selection-item-vignette img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.selection-item-nom {
  flex: 1 1 auto;
  font-size: 0.85rem;
}

.selection-item-actions {
  display: flex;
  gap: 0.3rem;
  flex: 0 0 auto;
}

.selection-item-fleche,
.selection-item-retirer {
  border: 1px solid var(--border);
  background: var(--card-bg);
  border-radius: 6px;
  width: 1.8rem;
  height: 1.8rem;
  cursor: pointer;
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1;
}

.selection-item-fleche:disabled {
  opacity: 0.3;
  cursor: default;
}

.selection-item-fleche:not(:disabled):hover {
  border-color: var(--canopee-green);
}

.selection-item-retirer:hover {
  border-color: var(--error);
  color: var(--error);
}

/* Mode Présentation (lien de partage, page publique sans session) */

.presentation-page {
  background: var(--bg);
}

.presentation-header {
  background: var(--canopee-green-dark);
  color: white;
  padding: 1.5rem;
  text-align: center;
}

.presentation-brand {
  margin: 0;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.8rem;
  opacity: 0.85;
}

.presentation-header h1 {
  margin: 0.3rem 0 0;
  font-size: 1.4rem;
}

.presentation-message {
  color: var(--text-muted);
  text-align: center;
  margin: 3rem 0;
}

.produit-carte-vitrine {
  cursor: default;
}

.section-presentation {
  margin-bottom: 2.5rem;
}

.section-presentation h2 {
  color: var(--canopee-green-dark);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
}

/* Analyse de gamme (marge, quantités estimées) — donnée interne uniquement */

.analyse-grand-total {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin: 1rem 0 1.5rem;
  padding: 1rem 1.2rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.analyse-grand-total > div {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.analyse-grand-total span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.analyse-grand-total strong {
  font-size: 1.1rem;
  color: var(--text);
}

.analyse-mmv-vedette {
  padding: 0.3rem 0.8rem;
  background: rgba(20, 83, 74, 0.08);
  border-radius: 8px;
}

.analyse-mmv-vedette strong {
  color: var(--canopee-green-dark);
  font-size: 1.3rem;
}

.analyse-section {
  margin-bottom: 2rem;
}

.analyse-section h2 {
  margin-bottom: 0.4rem;
}

.analyse-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  font-size: 0.85rem;
}

.analyse-table th,
.analyse-table td {
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
}

.analyse-table th {
  background: var(--bg);
  font-size: 0.72rem;
  text-transform: uppercase;
  color: var(--text-muted);
}

.analyse-input {
  width: 6rem;
  padding: 0.35rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.analyse-input-qte {
  width: 4.5rem;
}

.analyse-nom-bloc {
  width: 8rem;
  padding: 0.35rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.analyse-sous-total,
.analyse-total-section {
  background: rgba(20, 83, 74, 0.06);
  font-weight: 600;
}

.analyse-sous-total td,
.analyse-total-section td {
  color: var(--canopee-green-dark);
}

@media (max-width: 640px) {
  .fiche-produit {
    grid-template-columns: 1fr;
  }
  .vue-toggle {
    margin-left: 0;
  }
  .entete-page {
    flex-direction: column;
  }
  .lien-partage-url {
    flex-wrap: wrap;
  }
  .barre-selection {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }
}
