/* ==========================================================================
   Administration — La Sauvegarde de Crépy
   Réutilise les variables et styles de base de assets/css/style.css
   ========================================================================== */

.admin-login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--olive), var(--brown-dark));
  padding: 1.5rem;
}
.admin-login-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2.5rem;
  width: 100%;
  max-width: 380px;
}
.admin-login-logo { height: 64px; width: auto; display: block; margin: 0 auto 1rem; }
.admin-login-card h1 { text-align: center; font-size: 1.5rem; margin-bottom: .2rem; }

/* ---------- Layout général ---------- */
.admin-body { background: var(--cream); min-height: 100vh; }
.admin-shell { display: flex; min-height: 100vh; }

.admin-sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--brown-dark);
  color: var(--tan);
  padding: 1.5rem 0;
  display: flex;
  flex-direction: column;
  /* Bandeau fixé à l'écran : menu et liens du bas restent visibles quand la page défile
     (position fixed plutôt que sticky, que Safari n'appliquait pas ici). */
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  overflow-y: auto;
  z-index: 10;
}
.admin-sidebar .brand-mini {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 0 1.5rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,.12);
  margin-bottom: 1rem;
}
.admin-sidebar a.brand-mini { text-decoration: none; }
.admin-sidebar .brand-mini img { height: 36px; width: auto; background: #fff; border-radius: 6px; padding: 2px; }
.admin-sidebar .brand-mini span { font-family: var(--font-title); font-weight: 700; color: var(--white); font-size: .95rem; line-height: 1.2; }
.admin-nav { list-style: none; margin: 0; padding: 0; flex: 1; }
.admin-nav a {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .75rem 1.5rem;
  color: var(--tan);
  text-decoration: none;
  font-size: .9rem;
  font-weight: 600;
  border-left: 3px solid transparent;
}
.admin-nav a:hover { background: rgba(255,255,255,.06); color: var(--white); }
.admin-nav a.active { background: rgba(255,255,255,.1); color: var(--white); border-left-color: var(--sage); }
.admin-sidebar-foot { padding: 1rem 1.5rem 0; border-top: 1px solid rgba(255,255,255,.12); margin-top: 1rem; }
.admin-sidebar-foot .who { font-size: .82rem; color: var(--white); margin-bottom: .6rem; }
.admin-sidebar-foot a { color: var(--tan); font-size: .82rem; text-decoration: none; }
.admin-sidebar-foot a:hover { color: var(--white); }

.admin-main { flex: 1; min-width: 0; padding: 2rem 2.5rem 4rem; margin-left: 240px; }
.admin-topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.8rem; flex-wrap: wrap; gap: 1rem; }
.admin-topbar h1 { margin: 0; font-size: 1.6rem; }
.admin-topbar p { margin: .2rem 0 0; color: var(--ink-soft); font-size: .9rem; }
.admin-topbar-actions { display: flex; gap: .6rem; flex-wrap: wrap; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Cartes dashboard ---------- */
.admin-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1.2rem; margin-bottom: 2rem; }
.admin-stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
  box-shadow: var(--shadow-sm);
}
.admin-stat-card .num { font-family: var(--font-title); font-size: 2rem; font-weight: 700; color: var(--brown-dark); }
.admin-stat-card .lbl { font-size: .85rem; color: var(--ink-soft); margin-top: .2rem; }
.admin-stat-card a { font-size: .82rem; color: var(--sage); font-weight: 600; text-decoration: none; display: inline-block; margin-top: .6rem; }
.admin-stat-card a:hover { text-decoration: underline; }

/* ---------- Tables ---------- */
.admin-table-wrap { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.admin-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.admin-table th, .admin-table td { padding: .8rem 1.1rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin-table th { background: var(--cream-deep); font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: var(--cream); }
.admin-thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); background: var(--tan); }
.admin-row-actions { display: flex; gap: .6rem; white-space: nowrap; }
.admin-row-actions a, .admin-row-actions button {
  font-size: .82rem; font-weight: 600; text-decoration: none; cursor: pointer;
  border: none; background: none; padding: 0; font-family: inherit;
}
.admin-row-actions .edit { color: var(--sage); }
.admin-row-actions .delete { color: var(--red, #b3261e); }
.admin-row-actions a:hover, .admin-row-actions button:hover { text-decoration: underline; }
.admin-empty { padding: 3rem; text-align: center; color: var(--ink-soft); }

/* ---------- Formulaires admin ---------- */
.admin-form-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem; max-width: 640px; box-shadow: var(--shadow-sm); }
.admin-form-card .field { margin-bottom: 1.2rem; }
.admin-form-card textarea { min-height: 100px; }
.admin-form-actions { display: flex; gap: .8rem; margin-top: 1.6rem; }
.admin-current-photo { display: flex; align-items: center; gap: 1rem; margin-bottom: .8rem; }
.admin-current-photo img { width: 80px; height: 80px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.admin-checkbox { display: flex; align-items: center; gap: .5rem; }
.admin-checkbox input { width: auto; }

.badge-off { display: inline-block; background: var(--amber-light, #fbf1de); color: var(--amber, #b8770b); font-size: .72rem; font-weight: 700; padding: .2rem .55rem; border-radius: 999px; text-transform: uppercase; }
.badge-on { display: inline-block; background: var(--sage-light); color: var(--olive); font-size: .72rem; font-weight: 700; padding: .2rem .55rem; border-radius: 999px; text-transform: uppercase; }

/* ---------- Messages reçus ---------- */
.messages-table a { color: inherit; text-decoration: none; display: block; }
.messages-table .msg-date { white-space: nowrap; color: var(--ink-soft); }
.messages-table .msg-nom { font-weight: 600; }
.messages-table .msg-actions { width: 1%; }
.messages-table tbody tr { cursor: pointer; }
.message-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 1.4rem; }
.message-meta { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; margin: 0 0 1.2rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border); }
.message-meta dt { color: var(--ink-soft); font-size: .85rem; }
.message-meta dd { margin: 0; overflow-wrap: anywhere; }
.message-body { line-height: 1.6; overflow-wrap: anywhere; }
.message-actions { display: flex; gap: .8rem; flex-wrap: wrap; margin-top: 1.2rem; }
.message-actions form { margin: 0; }
.message-delete { color: var(--red, #b3261e); }
@media (max-width: 600px) {
  .messages-table th, .messages-table td { padding: .7rem .5rem; }
  .messages-table .msg-date { font-size: .78rem; }
  .messages-table .msg-heure { display: block; }
  .messages-table .msg-suppr-texte { display: none; }
  .messages-table .delete { font-size: 1.1rem; }
}

@media (max-width: 860px) {
  .admin-shell { flex-direction: column; }
  .admin-sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; align-items: center; padding: .8rem 1rem; position: static; }
  .admin-sidebar .brand-mini { border: none; padding: 0; margin: 0 1rem 0 0; flex-shrink: 0; }
  .admin-nav { display: flex; flex-wrap: wrap; flex: 1 1 100%; margin-top: .5rem; }
  .admin-nav a { border-left: none; border-bottom: 3px solid transparent; padding: .5rem .7rem; white-space: nowrap; }
  .admin-nav a.active { border-left: none; border-bottom-color: var(--sage); }
  /* Liens de sortie (voir le site, espace Administration, déconnexion) : sur une 2e ligne, toujours visibles. */
  .admin-sidebar-foot { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; width: 100%; margin-top: .6rem; padding: .6rem 0 0; }
  .admin-sidebar-foot .who, .admin-sidebar-foot br { display: none; }
  .admin-sidebar-foot a { font-size: .9rem; padding: .2rem 0; }
  .admin-main { padding: 1.5rem; margin-left: 0; }
}

/* Téléphone : tableaux en fiches (une par ligne) au lieu de colonnes coupées par le cadre
   (le tableau des Actualités / Réalisations, 8 colonnes, ne montrait que les vignettes). */
@media (max-width: 700px) {
  .admin-table:not(.messages-table) thead { display: none; }
  .admin-table:not(.messages-table), .admin-table:not(.messages-table) tbody,
  .admin-table:not(.messages-table) tr, .admin-table:not(.messages-table) td { display: block; width: auto; }
  .admin-table:not(.messages-table) tr { padding: .85rem 1rem; border-bottom: 1px solid var(--border); overflow: hidden; }
  .admin-table:not(.messages-table) tr:last-child { border-bottom: none; }
  .admin-table:not(.messages-table) td { padding: .12rem 0; border: none; overflow-wrap: anywhere; }
  .admin-table:not(.messages-table) td:empty, .admin-table:not(.messages-table) td.cell-vide { display: none; }
  .admin-table:not(.messages-table) td:has(> .admin-thumb) { float: right; margin: 0 0 .4rem .8rem; }
  .admin-table:not(.messages-table) td.cell-titre { font-weight: 700; font-size: 1rem; padding-bottom: .3rem; }
  .admin-table:not(.messages-table) td[data-label]::before { content: attr(data-label) " : "; color: var(--ink-soft); font-size: .8rem; }
  .admin-table:not(.messages-table) td:has(.admin-row-actions) { padding-top: .45rem; clear: both; }
  .admin-table:not(.messages-table) td:has(.admin-row-actions)::before { content: none; }
  .admin-table:not(.messages-table) tr:hover td { background: none; }
}

/* Fil d'Ariane de la gestion du site (styles de base dans assets/css/style.css) */
.fil-ariane-admin { background: none; border: none; margin: -.4rem 0 1.1rem; }
.fil-ariane-admin ol { padding: 0; }

/* ---------- Déambulations : fiche d'un site (deambulation_form.php) ---------- */
.deamb-titre { font-size: 1.05rem; margin: 1.8rem 0 .7rem; padding-top: 1.1rem; border-top: 1px solid var(--border); }
.deamb-carte { position: relative; height: 340px; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--tan); touch-action: none; cursor: crosshair; user-select: none; -webkit-user-select: none; margin-bottom: .9rem; }
.deamb-carte-couche { position: absolute; inset: 0; }
.deamb-tuile { position: absolute; left: 0; top: 0; width: 256px; height: 256px; max-width: none; pointer-events: none; }
.deamb-voisin, .deamb-depart, .deamb-marque { position: absolute; left: 0; top: 0; display: flex; align-items: center; justify-content: center; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.4); color: #fff; font-weight: 700; pointer-events: none; }
.deamb-voisin { width: 24px; height: 24px; margin: -12px 0 0 -12px; border-radius: 50%; background: #8b8f96; font-size: .7rem; }
.deamb-depart { width: 52px; height: 22px; margin: -11px 0 0 -26px; border-radius: 11px; background: #5E8A63; font-size: .7rem; }
.deamb-marque { width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; background: #B3261E; box-shadow: 0 0 0 6px rgba(179,38,30,.25), 0 1px 3px rgba(0,0,0,.4); z-index: 3; }
.deamb-carte-zoom { position: absolute; right: .5rem; top: .5rem; display: grid; gap: .3rem; z-index: 5; }
.deamb-carte-zoom button { width: 38px; height: 38px; border: 1px solid var(--border); border-radius: 8px; background: #fff; font-size: 1.3rem; line-height: 1; cursor: pointer; }
.deamb-carte-credit { position: absolute; right: 0; bottom: 0; z-index: 5; background: rgba(255,255,255,.85); color: #333; font-size: .7rem; padding: .1rem .4rem; text-decoration: none; }
.deamb-position { display: flex; gap: .8rem; align-items: flex-end; flex-wrap: wrap; }
.deamb-position .field { flex: 1 1 8rem; margin-bottom: 0; }
.deamb-photo { display: flex; gap: 1rem; align-items: flex-start; margin-bottom: 1rem; }
.deamb-photo img { width: 90px; height: 90px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); flex: none; }
.deamb-photo > div { flex: 1; min-width: 0; }
.deamb-audio { display: block; width: 100%; height: 40px; margin: .3rem 0 .2rem; }
.deamb-retirer { display: flex; align-items: center; gap: .4rem; margin-top: .4rem; font-weight: 400; font-size: .88rem; }
.deamb-retirer input { width: auto; }
.admin-row-actions button[disabled] { opacity: .3; cursor: default; text-decoration: none; }
/* Une liste déroulante au libellé long ne doit pas élargir la page sur téléphone. */
.admin-form-card select { max-width: 100%; }
/* Rang d'un site : on tape le numéro voulu, « OK » le place là. */
.deamb-rang { display: flex; align-items: center; gap: .3rem; }
.deamb-rang input { width: 3.4rem; min-height: 38px; padding: .2rem .3rem; text-align: center; font-weight: 700; border: 1px solid var(--border); border-radius: 8px; background: var(--white); font: inherit; font-weight: 700; }
.deamb-rang button { min-height: 38px; padding: 0 .6rem; border: 1px solid var(--border); border-radius: 8px; background: var(--white); color: var(--sage); font: inherit; font-size: .8rem; font-weight: 700; cursor: pointer; }
.deamb-rang button:hover { border-color: var(--sage); }
/* Flèches d'ordre : de vrais boutons, assez grands pour le doigt sur téléphone. */
.admin-row-actions { flex-wrap: wrap; align-items: center; }
.admin-row-actions form { display: inline-flex !important; align-items: center; gap: .5rem; }
/* Listes des Déambulations : beaucoup de colonnes, donc des actions sur deux lignes si besoin. */
.deamb-liste .admin-row-actions { white-space: normal; }
.deamb-liste .admin-row-actions form { flex-wrap: wrap; }
.deamb-liste th, .deamb-liste td { padding-left: .7rem; padding-right: .7rem; }
.admin-table-wrap:has(.deamb-liste) { overflow-x: auto; }
.admin-row-actions .deamb-fleche { min-width: 38px; min-height: 38px; padding: 0; border: 1px solid var(--border); border-radius: 8px; background: var(--white); font-size: 1.1rem; line-height: 1; }
.admin-row-actions .deamb-fleche:hover { text-decoration: none; border-color: var(--sage); }
@media (max-width: 700px) {
  .admin-row-actions { gap: .5rem .9rem; white-space: normal; }
  .admin-row-actions a, .admin-row-actions button:not(.deamb-fleche) { padding: .45rem 0; }
  .deamb-carte { height: 300px; }
  .admin-form-card { padding: 1.2rem; }
}
