@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,500;12..96,700&family=Inter:wght@400;500;600&display=swap');

:root {
  --bg: #f4f1ea;
  --surface: #ffffff;
  --ink: #1f2a27;
  --muted: #6b726f;
  --line: #e3ddd1;
  --brand: #1e3a34;
  --accent: #e85d2c;
  --accent-ink: #ffffff;
  --ok: #157f4b;
  --ok-bg: #e6f4ec;
  --warn-bg: #fff4dc;
  --err: #b42318;
  --err-bg: #fdecea;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: Inter, system-ui, sans-serif; font-size: 15px; color: var(--ink); background: var(--bg); line-height: 1.45; }
h1, h2, h3, .brand { font-family: 'Bricolage Grotesque', Inter, sans-serif; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; margin: 0 0 .6em; }
h2 { font-size: 1.2rem; margin: 0 0 .5em; }
h3 { font-size: 1rem; margin: 1.2em 0 .4em; }
a { color: var(--brand); }
code { background: #eee8dc; padding: 1px 5px; border-radius: 4px; }

/* --- Barre du haut ---------------------------------------------------- */
.topbar { display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: var(--brand); color: #fff; }
.topbar .brand { color: #fff; text-decoration: none; font-size: 1.15rem; font-weight: 700; }
.topbar nav { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; }
.topbar nav a { color: #d7e4df; text-decoration: none; padding: 6px 10px; border-radius: 6px; font-size: .92rem; }
.topbar nav a:hover, .topbar nav a.active { background: rgba(255,255,255,.12); color: #fff; }
.topbar .sub { color: #b9cdc6; font-size: .9rem; }

/* --- Boutons & formulaires ------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { border-color: #cfc6b5; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(.95); }
.btn.dark { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.danger { color: var(--err); }
.btn.small { padding: 5px 10px; font-size: .85rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 4px; font-weight: 500; font-size: .92rem; }
.form label.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; }
.form .req { color: var(--accent); }
input, select, textarea { font: inherit; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); width: 100%; }
input[type=checkbox], input[type=radio] { width: auto; margin-top: 3px; accent-color: var(--accent); }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); border-color: var(--accent); }
textarea { min-height: 80px; resize: vertical; }
.field-error { color: var(--err); font-size: .82rem; font-weight: 500; }
.invalid { border-color: var(--err) !important; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-2 > .full { grid-column: 1 / -1; }

.alert { padding: 10px 14px; border-radius: 8px; background: var(--warn-bg); margin: 0 0 12px; }
.alert.ok { background: var(--ok-bg); color: #0d5132; }
.alert.err { background: var(--err-bg); color: var(--err); }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card.narrow { max-width: 560px; margin: 40px auto; }
.muted { color: var(--muted); }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.public-msg main { margin: 40px 16px; }
@media (min-width: 600px) { .public-msg main { margin: 40px auto; } }

/* --- Page publique : carte + panneau --------------------------------- */
.booking { display: grid; grid-template-columns: 1fr 400px; height: calc(100vh - 52px); height: calc(100dvh - 52px); }
.booking #map { height: 100%; }
.panel { background: var(--surface); border-left: 1px solid var(--line); overflow-y: auto; display: flex; flex-direction: column; }
.panel section { padding: 16px 18px; border-bottom: 1px solid var(--line); }
.panel .intro p { margin: .3em 0; }
.zone-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.zone-list li { display: grid; grid-template-columns: 14px 1fr auto; gap: 10px; align-items: center; font-size: .9rem; }
.zone-list .sw { width: 14px; height: 14px; border-radius: 4px; }
.zone-list .closed { color: var(--muted); }
.zone-list .closed .sw { opacity: .35; }
.zone-list .tag { font-size: .75rem; padding: 2px 8px; border-radius: 99px; background: var(--ok-bg); color: var(--ok); white-space: nowrap; }
.zone-list .closed .tag { background: #eee; color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: .8rem; color: var(--muted); margin-top: 10px; }
.legend span::before { content: ''; display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 5px; background: var(--c); border: 2px solid var(--b, transparent); }

.cart-empty { color: var(--muted); }
.cart-spots { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; border-radius: 99px; background: #fdebe3; color: #8a2d0c; font-weight: 600; font-size: .88rem; }
.chip button { border: 0; background: rgba(0,0,0,.08); width: 20px; height: 20px; border-radius: 50%; cursor: pointer; line-height: 1; color: inherit; }
.chip button[disabled] { opacity: .3; cursor: default; }
.total { display: flex; justify-content: space-between; align-items: baseline; font-weight: 600; margin-top: 8px; }
.total strong { font-size: 1.3rem; font-family: 'Bricolage Grotesque', sans-serif; }
.hint { font-size: .85rem; color: var(--muted); margin: 6px 0 0; }
.type-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: #f1ede4; padding: 4px; border-radius: 10px; margin-bottom: 14px; }
.type-switch button { border: 0; background: transparent; padding: 8px; border-radius: 7px; font: inherit; font-weight: 600; cursor: pointer; color: var(--muted); }
.type-switch button.on { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.closed-banner { padding: 14px 18px; background: var(--warn-bg); }
.closed-banner.info { background: var(--ok-bg); color: #0d5132; font-size: .9rem; padding: 10px 18px; }
.booking-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; background: var(--warn-bg); }
.booking-bar.open { background: var(--ok-bg); color: #0d5132; }
.booking-bar .dot { width: 10px; height: 10px; border-radius: 50%; background: #b7791f; }
.booking-bar.open .dot { background: var(--ok); }
.booking-bar form { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 2000; box-shadow: var(--shadow); max-width: calc(100vw - 32px); font-size: .92rem; }
.toast.err { background: var(--err); }

.spot-label { background: transparent; border: 0; box-shadow: none; font-weight: 700; font-size: 10px; color: #1f2a27; text-shadow: 0 0 3px #fff, 0 0 3px #fff; padding: 0; }
.spot-label::before { display: none; }
.leaflet-container { font-family: Inter, system-ui, sans-serif; }

@media (max-width: 860px) {
  .booking { grid-template-columns: 1fr; grid-template-rows: 55vh auto; height: auto; }
  .booking #map { height: 55vh; }
  .panel { border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
  .grid-2 { grid-template-columns: 1fr; }
}

/* --- Backend ----------------------------------------------------------- */
.admin-main { padding: 20px 16px 60px; max-width: 1280px; margin: 0 auto; }
.admin-login main { margin-top: 10vh; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 16px; }
.page-head h1 { margin: 0; }
.page-head .row-actions { margin-left: auto; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--surface); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); text-decoration: none; color: inherit; }
.stat b { display: block; font-size: 1.5rem; font-family: 'Bricolage Grotesque', sans-serif; }
.stat span { color: var(--muted); font-size: .85rem; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.filters input, .filters select { width: auto; }
.filters input[type=search] { min-width: 220px; flex: 1; }
.table-wrap { overflow-x: auto; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
table.list { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.list th, table.list td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.list th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #faf8f3; }
table.list tr:hover td { background: #fcfaf6; }
table.list td.wrap { white-space: normal; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .78rem; font-weight: 600; background: #eee; color: #444; }
.badge.pending_payment { background: #e9eefc; color: #2948a8; }
.badge.pending_validation { background: #fff1d6; color: #8a5300; }
.badge.awaiting_payment { background: #fde8dc; color: #9a3a0f; }
.badge.paid { background: var(--ok-bg); color: var(--ok); }
.badge.refused, .badge.cancelled, .badge.expired { background: #f1f1f1; color: #777; }
.detail-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; align-items: start; }
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 6px 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; word-break: break-word; }
.log { list-style: none; padding: 0; margin: 0; font-size: .86rem; }
.log li { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.log time { color: var(--muted); margin-right: 6px; }
.stack { display: grid; gap: 16px; }
details.action { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
details.action summary { cursor: pointer; font-weight: 600; }
details.action form { margin-top: 10px; }
.mini-map { height: 260px; border-radius: 8px; }
@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } .kv { grid-template-columns: 1fr; } }

/* --- Éditeur de plan ------------------------------------------------- */
.editor { display: grid; grid-template-columns: 330px 1fr; height: calc(100vh - 52px); height: calc(100dvh - 52px); }
.editor .side { background: var(--surface); border-right: 1px solid var(--line); overflow-y: auto; padding: 14px; display: grid; gap: 14px; align-content: start; }
.editor #map { height: 100%; }
.editor .side h2 { font-size: 1rem; margin: 0 0 6px; }
.editor .zone-row { display: grid; grid-template-columns: 34px 1fr auto; gap: 6px; align-items: center; padding: 6px; border-radius: 8px; border: 1px solid transparent; cursor: pointer; }
.editor .zone-row.current { border-color: var(--accent); background: #fff8f4; }
.editor .zone-row input[type=color] { padding: 0; height: 30px; width: 34px; border: 0; background: none; }
.editor .zone-row .meta { font-size: .78rem; color: var(--muted); }
.editor .tools { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.editor .tools .btn.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.editor .box { border: 1px solid var(--line); border-radius: 8px; padding: 10px; display: grid; gap: 8px; font-size: .9rem; }
.editor .box label { display: grid; gap: 3px; font-size: .85rem; }
.editor .box .grid-2 { gap: 8px; }
.editor .status { font-size: .85rem; color: var(--muted); }
.editor .dirty { color: var(--accent); font-weight: 600; }
@media (max-width: 860px) { .editor { grid-template-columns: 1fr; grid-template-rows: auto 70vh; height: auto; } .editor .side { border-right: 0; } }

.new-res { display: grid; grid-template-columns: 1fr 420px; gap: 16px; }
.new-res #map { height: 70vh; border-radius: var(--radius); }
@media (max-width: 960px) { .new-res { grid-template-columns: 1fr; } .new-res #map { height: 50vh; } }

/* Poignées de l'éditeur */
.ed-handle { display: flex; align-items: center; justify-content: center; border-radius: 50%; font-size: 15px; line-height: 1; cursor: grab; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.ed-handle.move { background: #fff; color: var(--brand); border: 2px solid var(--brand); }
.ed-handle.rotate { background: var(--accent); color: #fff; border: 2px solid #fff; }
.ed-handle.corner { width: 14px !important; height: 14px !important; margin-left: -7px !important; margin-top: -7px !important; background: #fff; border: 2px solid #7a2a0b; border-radius: 3px; }
.leaflet-control-layers { font-size: .82rem; }
