/* Projet : Larallegria — Version V01-058 */
/* ==========================================================================
   Module de gestion — Espace admin / membre
   S'appuie sur les variables définies dans style.css
   ========================================================================== */

.app-body { background: var(--paper); min-height: 100vh; }

.app-topbar {
  background: var(--noir);
  color: var(--white);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: var(--shadow-soft);
  border-bottom: 3px solid var(--rouge);
}

.app-topbar .app-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
}
.app-topbar .app-title small {
  display: block;
  font-family: var(--font-body);
  font-size: 0.72rem;
  color: var(--or-light);
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.app-home-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  color: var(--white);
  text-decoration: none;
  font-size: 1.1rem;
  flex: none;
}
.app-home-link:hover { background: rgba(255,255,255,0.22); }

.app-main { max-width: 980px; margin: 0 auto; padding: 24px 16px 60px; }

/* Login card */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, var(--noir) 0%, var(--noir-dark) 100%);
}

.login-card {
  background: var(--white);
  border-radius: 10px;
  box-shadow: var(--shadow-card);
  padding: 36px 30px;
  width: 100%;
  max-width: 380px;
}

.login-card .login-logo {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 2px solid var(--or-light);
  margin: 0 auto 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.login-card .login-logo img { width: 100%; height: 100%; object-fit: cover; }

.login-card h1 {
  text-align: center;
  font-size: 1.3rem;
  margin-bottom: 4px;
}
.login-card .login-sub {
  text-align: center;
  color: var(--terre);
  font-size: 0.9rem;
  margin-bottom: 24px;
}

.field { margin-bottom: 16px; width: 100%; }
.field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--noir-dark);
  margin-bottom: 6px;
}
.field .hint { font-weight: 400; color: var(--terre); text-transform: none; letter-spacing: 0; }
.field .field-input-row {
  position: relative;
  width: 100%;
}
.field input, .field select, .field textarea {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 11px 12px;
  border: 1px solid #DCCBA8;
  border-radius: var(--radius);
  font-size: 0.96rem;
  font-family: var(--font-body);
  background: var(--white);
  color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--or);
  box-shadow: 0 0 0 3px rgba(184,132,44,0.18);
}
/* Les cases à cocher (ex: sélection de plusieurs membres pour un message)
   ne doivent pas hériter du style "champ texte pleine largeur" ci-dessus. */
.field input[type="checkbox"] {
  width: 16px;
  max-width: 16px;
  height: 16px;
  padding: 0;
  border: 1px solid #DCCBA8;
  flex-shrink: 0;
  accent-color: var(--rouge-dark);
}
.field .toggle-pw {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--terre);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 4px 6px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0 16px;
  width: 100%;
}

.login-error {
  background: #FBEAEA;
  border: 1px solid #E3B4B4;
  color: #8A2E2E;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  margin-bottom: 16px;
  display: none;
}
.login-error.show { display: block; }

.form-success {
  background: #E9F4EA;
  border: 1px solid #B9DABD;
  color: #235A2E;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  margin-bottom: 16px;
  display: none;
}
.form-success.show { display: block; }

.btn-block { width: 100%; justify-content: center; }

/* Tab bar */
.tab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}
.tab-btn {
  flex: 1 1 calc(33.333% - 8px);
  min-width: 100px;
  text-align: center;
  padding: 10px 8px;
  border-radius: var(--radius);
  border: 1px solid #DCCBA8;
  background: var(--white);
  color: var(--noir-dark);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.tab-btn.active { background: var(--noir); color: var(--white); border-color: var(--noir); }

.tab-btn.has-unread { position: relative; }
.tab-btn.has-unread::after {
  content: "";
  position: absolute;
  top: 4px;
  right: 8px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--rouge);
}

@media (max-width: 480px) {
  .tab-btn { flex: 1 1 calc(50% - 8px); }
}

.app-panel {
  background: var(--white);
  border: 1px solid #E9DEC8;
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 22px;
  margin-bottom: 20px;
}
.app-panel h2 {
  font-size: 1.2rem;
  margin-bottom: 16px;
}
.app-panel h3 {
  font-size: 1rem;
  margin-bottom: 10px;
  color: var(--noir);
}

.hidden { display: none !important; }

/* Data list / cards instead of wide tables (mobile-friendly) */
.data-list { display: flex; flex-direction: column; gap: 10px; }

.data-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid #E9DEC8;
  border-radius: var(--radius);
  background: var(--paper);
  flex-wrap: wrap;
}
.data-row .data-main { min-width: 0; flex: 1; }
.data-row .data-title { font-weight: 600; color: var(--noir-dark); font-size: 0.95rem; }
.data-row .data-sub { color: var(--terre); font-size: 0.82rem; margin-top: 2px; }
.data-row .data-actions { display: flex; gap: 6px; flex-wrap: wrap; flex: none; }

.btn-sm {
  padding: 7px 12px;
  font-size: 0.82rem;
  border-radius: var(--radius);
  border: 1px solid #DCCBA8;
  background: var(--white);
  color: var(--noir-dark);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.btn-sm:hover { background: var(--paper-warm); }
.btn-sm.danger { color: #A23B3B; border-color: #E3B4B4; }
.btn-sm.primary { background: var(--or); color: var(--noir-dark); border-color: var(--or); font-weight: 600; }
.btn-sm.rouge { background: var(--rouge); color: var(--white); border-color: var(--rouge); font-weight: 600; }
.btn-sm:disabled { opacity: 0.4; cursor: not-allowed; background: var(--white); }
.btn-sm:disabled:hover { background: var(--white); }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-ok { background: #E1F0E5; color: #2C6E3F; }
.badge-warn { background: #FBEFDA; color: #92620E; }
.badge-danger { background: #FBEAEA; color: #8A2E2E; }
.badge-neutral { background: #EDE3D0; color: var(--terre); }

.empty-state {
  text-align: center;
  color: var(--terre-light);
  padding: 30px 10px;
  font-size: 0.92rem;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(27,15,12,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px 16px;
  overflow: hidden;
  z-index: 100;
}
.modal-box {
  background: var(--white);
  border-radius: 10px;
  padding: 26px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-card);
}
.modal-box h3 { margin-bottom: 18px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

.banner-alert {
  background: #FBEFDA;
  border: 1px solid #E9C98B;
  color: #7A5410;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  margin-bottom: 18px;
}
.banner-alert.danger { background: #FBEAEA; border-color: #E3B4B4; color: #8A2E2E; }
.banner-alert.info { background: #EFE4F3; border-color: #D3B9DC; color: #5A3466; }

.presence-btns { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}

/* Chat */
.chat-thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 420px;
  overflow-y: auto;
  padding: 14px;
  background: var(--paper);
  border-radius: var(--radius);
  border: 1px solid #E9DEC8;
  margin-bottom: 14px;
}
.chat-bubble {
  max-width: 78%;
  padding: 9px 13px;
  border-radius: 12px;
  font-size: 0.92rem;
  line-height: 1.4;
}
.chat-bubble.moi {
  align-self: flex-end;
  background: var(--or);
  color: var(--noir-dark);
  border-bottom-right-radius: 3px;
}
.chat-bubble.autre {
  align-self: flex-start;
  background: var(--white);
  border: 1px solid #E9DEC8;
  border-bottom-left-radius: 3px;
}
.chat-meta {
  font-size: 0.68rem;
  opacity: 0.7;
  margin-top: 4px;
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: flex-end;
}
.chat-check { color: rgba(43,28,21,0.5); }
.chat-check.lu { color: #2E7BD6; }
.chat-input-row { display: flex; gap: 8px; }
.chat-input-row input { flex: 1; }

/* Cartes cheval (fiche membre) */
.horse-card {
  background: var(--paper);
  border: 1px solid #E9DEC8;
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
}
.horse-card .horse-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.horse-card .horse-title { font-weight: 600; color: var(--noir-dark); }
.horse-card .horse-sub { color: var(--terre); font-size: 0.82rem; margin-top: 2px; }

/* Liste de sélection de membres */
.membre-check-list {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid #DCCBA8;
  border-radius: var(--radius);
  padding: 6px;
  background: var(--white);
}
.membre-check-row {
  display: flex !important;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  font-size: 0.92rem !important;
  font-weight: 400 !important;
  color: var(--ink);
  margin: 0 !important;
  border-radius: 4px;
  cursor: pointer;
}
.membre-check-row:hover { background: var(--paper); }
.membre-check-row input[type="checkbox"] {
  width: 17px;
  height: 17px;
  flex: none;
  margin: 0;
  accent-color: var(--or);
}
.membre-check-row span { flex: 1; }

/* Alerte nouveau message */
.alerte-message {
  background: #FBEFDA;
  border: 2px solid var(--or);
  color: #7A5410;
  padding: 14px 18px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  cursor: pointer;
}
.alerte-message:hover { background: #F7E5C6; }

/* ---------- Grille de réservation (piste / cours) ---------- */
.resa-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 10px;
}
.resa-nav h3 { margin: 0; }
.resa-jours {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}
.resa-jour {
  border: 1px solid #E9DEC8;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--white);
}
.resa-jour-titre {
  background: var(--paper-warm);
  padding: 8px 10px;
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--noir-dark);
  text-align: center;
  border-bottom: 1px solid #E9DEC8;
}
.resa-jour-titre .meteo { display: block; font-weight: 400; font-size: 0.76rem; color: var(--terre); margin-top: 2px; }
/* Calendrier admin sur 15 jours : exactement 5 colonnes × 3 lignes sur les
   écrans larges (la 1ère case en haut à gauche = aujourd'hui), et un
   repli progressif sur les petits écrans pour rester lisible. */
#calendrierDeuxSemaines {
  grid-template-columns: repeat(5, 1fr);
}
@media (max-width: 900px) {
  #calendrierDeuxSemaines { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 560px) {
  #calendrierDeuxSemaines { grid-template-columns: repeat(2, 1fr); }
}
.resa-creneaux { display: flex; flex-direction: column; gap: 4px; padding: 8px; }
.creneau-btn {
  border: 1px solid #DCCBA8;
  background: var(--white);
  border-radius: 4px;
  padding: 7px 6px;
  font-size: 0.8rem;
  cursor: pointer;
  text-align: center;
  color: var(--ink);
}
.creneau-btn:hover { background: var(--paper-warm); }
.creneau-btn.pris { background: #EDE3D0; color: var(--terre-light); cursor: not-allowed; border-style: dashed; }
.creneau-btn.valide { background: #E1F0E5; color: #2C6E3F; border-color: #B9DABD; font-weight: 700; cursor: default; }
.creneau-btn.attente { background: #FBEFDA; color: #92620E; border-color: #E9C98B; font-weight: 700; cursor: default; }
.creneau-btn.mine { outline: 2px solid var(--rouge); outline-offset: 1px; }
.creneau-btn.passe { opacity: 0.4; cursor: not-allowed; }

/* Cases nettoyage box */
.box-card {
  border: 1px solid #E9DEC8;
  border-radius: var(--radius);
  background: var(--white);
  padding: 14px;
}
.box-card.fait { border-left: 4px solid #2C6E3F; }
.box-card.a-faire { border-left: 4px solid var(--rouge); }

/* Dans le calendrier 2 semaines de l'admin, les créneaux occupés restent
   cliquables (pour annuler directement), contrairement à la grille membre
   où ils sont juste informatifs. */
#calendrierDeuxSemaines .creneau-btn.valide,
#calendrierDeuxSemaines .creneau-btn.attente {
  cursor: pointer;
}
#calendrierDeuxSemaines .creneau-btn {
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.25;
  width: 100%;
}

/* Météo des prochains jours : nombre de colonnes qui s'adapte à la largeur
   d'écran disponible (PC : les 7 jours sur une ligne si la place le permet ;
   tablette/smartphone : passage automatique à plusieurs lignes, sans
   défilement horizontal forcé). */
.meteo-resume-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 8px;
}
.meteo-resume-grid .data-row { justify-content: center; text-align: center; }
.meteo-resume-grid .data-main { flex: none; }

/* Panneaux repliables (flèche pour afficher/masquer une section). */
.collapse-toggle {
  border: 1px solid #DCCBA8;
  background: var(--white);
  color: var(--noir-dark);
  width: 32px; height: 32px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  flex: none;
}
.collapse-toggle:hover { background: var(--paper-warm); }

/* Sur petit écran, les lignes de liste (membres, demandes, réservations...)
   passent le texte et les boutons en colonne au lieu de les compresser
   côte à côte — sinon le texte se retrouve écrasé sur une colonne étroite
   et les boutons se chevauchent avec lui. */
@media (max-width: 640px) {
  .data-row {
    flex-wrap: wrap;
  }
  .data-row .data-main {
    flex-basis: 100%;
  }
  .data-row .data-actions {
    flex-basis: 100%;
    justify-content: flex-start;
  }
}

/* Livre de caisse (onglet Comptabilité) */
.compta-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; min-width: 720px; }
.compta-table th {
  text-align: left; padding: 8px 10px; background: var(--paper-warm);
  border-bottom: 2px solid #DCCBA8; font-size: 0.76rem; text-transform: uppercase;
  letter-spacing: 0.03em; color: var(--terre);
}
.compta-table td { padding: 8px 10px; border-bottom: 1px solid #EDE3D0; vertical-align: top; }
.compta-table tr:hover td { background: rgba(232,162,48,0.06); }
.compta-table td.montant-recette { color: #2C6E3F; font-weight: 600; white-space: nowrap; }
.compta-table td.montant-depense { color: #8A2E2E; font-weight: 600; white-space: nowrap; }
.compta-table td.solde { font-weight: 700; white-space: nowrap; }

/* Point rouge "à recommander" (stock) */
.point-rouge {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  background: #D93A3A; margin-right: 7px; vertical-align: middle;
  box-shadow: 0 0 0 2px rgba(217,58,58,0.18);
}

/* Croix de fermeture des fenêtres */
.modal-box { position: relative; }
.modal-close-x {
  position: absolute; top: 10px; right: 12px;
  width: 32px; height: 32px; border: 0; border-radius: 50%;
  background: transparent; color: var(--terre); font-size: 1.1rem; line-height: 1;
  cursor: pointer; z-index: 2;
}
.modal-close-x:hover { background: var(--paper-warm); color: var(--rouge-dark); }
.modal-box h3 { padding-right: 34px; }

/* Carte de fidélité — abonnement 10 + 1 gratuit */
.carte-fidelite { background: linear-gradient(135deg, #FFF8EC, #F6E7C8); border: 2px solid #D9B76A; border-radius: 16px; padding: 18px 18px 14px; box-shadow: var(--shadow-card); max-width: 520px; }
.carte-entete { display:flex; justify-content:space-between; align-items:center; gap:12px; margin-bottom:14px; }
.carte-titre { font-family: 'Yeseva One', serif; font-size: 1.25rem; color: var(--rouge-dark); }
.carte-sous { font-size: 0.85rem; color: var(--terre); letter-spacing: .04em; text-transform: uppercase; }
.carte-solde { text-align:center; background:#fff; border:1px solid #E3CD98; border-radius:12px; padding:6px 12px; line-height:1.1; }
.carte-solde strong { display:block; font-size:1.6rem; color: var(--rouge-dark); }
.carte-solde span { font-size:0.72rem; color: var(--terre); }
.carte-solde.bas strong { color:#B3261E; }
.carte-grille { display:grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap:10px; }
.carte-case { aspect-ratio: 1; border:2px dashed #CDB27A; border-radius:50%; background:rgba(255,255,255,.65); display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center; min-width:0; }
.carte-case .carte-num { font-size:1.2rem; color:#B9A272; font-weight:700; }
.carte-case.tampon { border-style:solid; border-color:#B07B2C; background:#fff; }
.carte-tampon { font-size:1.5rem; line-height:1; }
.carte-date { font-size:0.68rem; color: var(--terre); margin-top:2px; font-weight:600; }
.carte-case.offert { border-color:#D4A017; background:#FFF3C4; }
.carte-case.offert .carte-cadeau { font-size:1.5rem; line-height:1; }
.carte-case.offert .carte-date { color:#8A6500; }
.carte-case.offert.tampon { background:#FFE58A; }
.carte-pied { display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; gap:8px; margin-top:14px; font-size:0.82rem; color: var(--terre); }

#calendrierDeuxSemaines .creneau-btn.passe-resa { opacity: 0.85; cursor: default; }

/* Sous-onglets (Comptabilité, Paramètres) */
.subtab-bar { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 18px; padding-bottom: 10px; border-bottom: 1px solid #DCCBA8; }
.subtab-btn { padding: 7px 14px; border-radius: 999px; border: 1px solid #DCCBA8; background: var(--white); color: var(--noir-dark); font-size: 0.82rem; font-weight: 600; cursor: pointer; }
.subtab-btn.active { background: var(--rouge-dark, #8B2E2E); border-color: var(--rouge-dark, #8B2E2E); color: var(--white); }
.subtab-btn.hidden { display: none; }
.sub-panel.hidden { display: none; }
