/* ===== CAP 26-07 — Back-office styles ===== */
:root {
  --green: #15807c;
  --green-dark: #0e5f5c;
  --green-light: #e3f1ef;
  --coral: #ec8a6d;
  --coral-dark: #d96a49;
  --ink: #23343a;
  --muted: #6b7d7a;
  --border: #e0ece9;
  --bg: #f2f8f6;
  --danger: #d64545;
  --radius: 12px;
  --font: 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
body.admin { margin: 0; font-family: var(--font); background: var(--bg); color: var(--ink); }
a { color: var(--green-dark); }

/* ---- Buttons (shared) ---- */
.btn { display: inline-block; cursor: pointer; border: 0; text-decoration: none; font-weight: 600;
  font-size: .95rem; padding: .6rem 1.1rem; border-radius: 8px; font-family: inherit; transition: .15s; }
.btn:hover { filter: brightness(.95); }
.btn-primary { background: var(--green); color: #fff; }
.btn-ghost { background: #fff; color: var(--green-dark); border: 1px solid var(--border); }
.btn-sm { padding: .4rem .8rem; font-size: .85rem; }
.btn-danger { background: #fff; color: var(--danger); border: 1px solid #f0c4c4; }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-block { display: block; width: 100%; text-align: center; }

/* ---- Login ---- */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { background: #fff; border: 1px solid var(--border); border-radius: 16px; padding: 2.5rem; width: 100%; max-width: 380px; box-shadow: 0 20px 50px rgba(20,80,70,.12); }
.login-brand { text-align: center; margin-bottom: 1.5rem; }
.login-brand span { display: block; font-size: 1.6rem; font-weight: 800; color: var(--green); }
.login-brand small { color: var(--muted); }
.login-back { display: block; text-align: center; margin-top: 1.2rem; color: var(--muted); text-decoration: none; }

/* ---- Shell ---- */
.admin-shell { display: flex; min-height: 100vh; }
.admin-sidebar { width: 250px; background: var(--ink); color: #cfe0dc; display: flex; flex-direction: column; padding: 1.2rem; position: sticky; top: 0; height: 100vh; }
.admin-brand { margin-bottom: 1.5rem; }
.admin-brand span { display: block; font-size: 1.3rem; font-weight: 800; color: #fff; }
.admin-brand small { color: #7fbcae; }
.admin-sidebar nav { display: flex; flex-direction: column; gap: .2rem; flex: 1; }
.admin-sidebar nav a { color: #cfe0dc; text-decoration: none; padding: .7rem .9rem; border-radius: 8px; font-weight: 500; }
.admin-sidebar nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.admin-sidebar nav a.active { background: var(--green); color: #fff; }
.admin-logout { border-top: 1px solid rgba(255,255,255,.12); padding-top: 1rem; display: flex; flex-direction: column; gap: .5rem; }
.admin-logout span { font-size: .85rem; color: #7fbcae; }
.admin-logout button { background: transparent; border: 1px solid rgba(255,255,255,.25); color: #cfe0dc; padding: .5rem; border-radius: 8px; cursor: pointer; }
.admin-logout button:hover { background: rgba(255,255,255,.1); }

.admin-main { flex: 1; min-width: 0; }
.admin-topbar { background: #fff; border-bottom: 1px solid var(--border); padding: 1.2rem 2rem; }
.admin-topbar h1 { margin: 0; font-size: 1.4rem; }
.admin-content { padding: 2rem; }

/* ---- Dashboard ---- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1.3rem; margin-bottom: 2rem; }
.stat-card {
  position: relative; border-radius: 16px; padding: 1.5rem 1.5rem 1.4rem; text-decoration: none;
  color: #fff; display: flex; flex-direction: column; gap: .1rem; overflow: hidden;
  transition: transform .15s ease, box-shadow .15s ease; box-shadow: 0 8px 20px rgba(20,70,66,.12);
}
.stat-card:hover { transform: translateY(-4px); box-shadow: 0 14px 30px rgba(20,70,66,.22); }
.stat-ico { font-size: 1.9rem; line-height: 1; margin-bottom: .3rem; }
.stat-num { font-size: 2.9rem; font-weight: 800; line-height: 1; }
.stat-label { color: rgba(255,255,255,.92); font-size: 1rem; font-weight: 600; }
/* Dégradés de couleurs par tuile */
.sc-1 { background: linear-gradient(135deg, #15807c, #1c9a8f); }
.sc-2 { background: linear-gradient(135deg, #ec8a6d, #d9694a); }
.sc-3 { background: linear-gradient(135deg, #f2b34e, #e59622); }
.sc-4 { background: linear-gradient(135deg, #4f8ac9, #2f5fb5); }
.sc-5 { background: linear-gradient(135deg, #7b6cd1, #5b47c0); }
.sc-6 { background: linear-gradient(135deg, #2fa46a, #1c7a4b); }
.sc-7 { background: linear-gradient(135deg, #ef6f8b, #d64570); }
.quick-actions { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; }
.qa-buttons { display: flex; gap: 1rem; flex-wrap: wrap; margin-top: 1rem; }

/* ---- Lists / tables ---- */
.list-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; flex-wrap: wrap; gap: 1rem; }
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); }
.admin-table { width: 100%; border-collapse: collapse; min-width: 640px; }
.admin-table th, .admin-table td { padding: .9rem 1rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.admin-table th { background: var(--green-light); font-size: .82rem; text-transform: uppercase; letter-spacing: .5px; color: var(--green-dark); }
.admin-table tr:last-child td { border-bottom: 0; }
.ta-right { text-align: right; }
.actions { display: flex; gap: .5rem; justify-content: flex-end; align-items: center; }
.actions form { margin: 0; }
.badge { display: inline-block; padding: .25rem .7rem; border-radius: 20px; font-size: .78rem; font-weight: 700; }
.badge-green { background: #e3f6ec; color: #1c7a4b; }
.badge-gray { background: #eceff0; color: #6b7d7a; }
.badge-blue { background: #e4eefb; color: #2f5fb5; }
.hint { margin-top: 1rem; color: var(--muted); font-size: .9rem; background: var(--green-light); padding: 1rem; border-radius: 10px; }
.muted { color: var(--muted); }

/* ---- Forms ---- */
.form-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem; max-width: 860px; }
.form .field { margin-bottom: 1.3rem; }
.field label { display: block; font-weight: 600; margin-bottom: .4rem; }
.field input[type=text], .field input[type=email], .field input[type=password],
.field input[type=date], .field input[type=datetime-local], .field input[type=tel],
.field input[type=number], .field select, .field textarea {
  width: 100%; padding: .7rem .9rem; border: 1px solid var(--border); border-radius: 8px;
  font-family: inherit; font-size: 1rem;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px var(--green-light); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.form-actions { display: flex; gap: 1rem; margin-top: 1.5rem; }
.back-link { display: inline-block; margin-bottom: 1rem; color: var(--muted); text-decoration: none; font-weight: 600; }

/* Switch (toggle de statut) — structure robuste : la pastille ne peut pas s'écraser */
.field-switch { display: flex; flex-direction: column; align-items: flex-start; }
.switch {
  display: flex; align-items: center; gap: 14px; cursor: pointer;
  user-select: none; -webkit-user-select: none; padding: .3rem 0; width: max-content;
  max-width: 100%;
}
.switch input {
  position: absolute; opacity: 0; width: 1px; height: 1px; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); pointer-events: none;
}
.switch .slider {
  display: inline-block; box-sizing: border-box; flex: 0 0 auto;
  width: 52px; height: 30px; background: #c6d3d0; border-radius: 30px; position: relative;
  transition: background .2s ease;
}
.switch .slider::before {
  content: ''; position: absolute; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; top: 3px; left: 3px; transition: transform .2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::before { transform: translateX(22px); }
.switch input:focus-visible + .slider { box-shadow: 0 0 0 3px var(--green-light); }
/* Libellé dynamique selon l'état, sans JavaScript */
.switch .switch-label { display: inline-block; font-weight: 600; color: var(--muted); white-space: nowrap; }
.switch .switch-label::after { content: 'Brouillon — non visible sur le site'; }
.switch input:checked ~ .switch-label { color: var(--green-dark); }
.switch input:checked ~ .switch-label::after { content: 'Publié — visible sur le site'; }
.switch-hint { margin: .5rem 0 0; font-size: .85rem; color: var(--muted); }

/* Redimensionnement des images dans l'éditeur */
#editor .ql-editor img { cursor: pointer; max-width: 100%; }
.img-resizer {
  position: absolute; box-sizing: border-box; border: 2px solid var(--green);
  pointer-events: none; z-index: 40; display: none;
}
.img-resizer-handle {
  position: absolute; right: -7px; bottom: -7px; width: 14px; height: 14px;
  background: var(--green); border: 2px solid #fff; border-radius: 3px;
  pointer-events: auto; cursor: nwse-resize; box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.img-resizer-size {
  position: absolute; left: 0; top: -22px; background: var(--green); color: #fff;
  font-size: .72rem; padding: 1px 6px; border-radius: 4px; white-space: nowrap;
}

/* Quill editor sizing */
#editor { min-height: 260px; background: #fff; border-radius: 0 0 8px 8px; }
.ql-toolbar.ql-snow, .ql-container.ql-snow { border-color: var(--border) !important; }
.ql-toolbar.ql-snow { border-radius: 8px 8px 0 0; }
.ql-container.ql-snow { border-radius: 0 0 8px 8px; font-family: inherit; font-size: 1rem; }

/* Logos partenaires (BO) */
.logo-thumb {
  display: inline-flex; align-items: center; justify-content: center;
  width: 96px; height: 52px; background: #fff; border: 1px solid var(--border);
  border-radius: 8px; padding: 4px;
}
.logo-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-preview {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 140px; height: 90px; background: #fff; border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 16px; margin-bottom: .8rem;
}
.logo-preview img { max-width: 240px; max-height: 70px; object-fit: contain; }

/* Documents (BO) */
.doc-cards { display: grid; gap: 1.2rem; }
.doc-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 1.4rem 1.6rem; }
.doc-head { display: flex; gap: 1rem; align-items: flex-start; margin-bottom: 1rem; }
.doc-icon { font-size: 1.8rem; line-height: 1; }
.doc-head > div { flex: 1; }
.doc-current { margin: .5rem 0 0; font-size: .9rem; }
.doc-card .field { margin-bottom: .9rem; }

/* Galerie (BO) */
.gallery-add { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; margin-bottom: 1.5rem; }
.gallery-add h2 { margin-top: 0; font-size: 1.2rem; }
.gallery-add-form { display: grid; grid-template-columns: 1.2fr 1.6fr auto auto; gap: 1rem; align-items: end; }
.gallery-count { font-size: 1.15rem; margin: 1.5rem 0 1rem; }
.gallery-manage { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1.2rem; }
.gallery-item { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.gallery-thumb { aspect-ratio: 16 / 10; background: #eef2f1; }
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-item-form { padding: 1rem; }
.gallery-item-form .field { margin-bottom: .7rem; }
.gallery-item-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.gallery-switch { margin-top: 1.2rem; }
.gallery-item-actions { margin-top: .6rem; }
.gallery-item > form:last-child { padding: 0 1rem 1rem; }
@media (max-width: 760px) { .gallery-add-form { grid-template-columns: 1fr; } }

/* Messages */
.message-list { display: grid; gap: 1rem; }
.message-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 1.3rem; }
.message-card header { display: flex; gap: 1rem; align-items: baseline; flex-wrap: wrap; margin-bottom: .5rem; }
.msg-subject { font-weight: 600; margin: .3rem 0; }
.msg-body { white-space: pre-wrap; margin: .3rem 0 0; }

/* Flash */
.flash { padding: 1rem 1.2rem; border-radius: 10px; margin-bottom: 1.5rem; font-weight: 500; }
.flash-success { background: #e3f6ec; color: #1c7a4b; border: 1px solid #b6e6c9; }
.flash-error { background: #fdeaea; color: #b52a2a; border: 1px solid #f5c2c2; }

@media (max-width: 760px) {
  .admin-shell { flex-direction: column; }
  .admin-sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; gap: .5rem; }
  .admin-sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .admin-logout { border-top: 0; padding-top: 0; flex-direction: row; }
  .admin-content { padding: 1.2rem; }
  .grid-2 { grid-template-columns: 1fr; }
}
