/* Administration — O'brico by Delingette */
:root {
  --red: #e30613; --red-dark: #b8000c; --red-soft: #fdecec;
  --ink: #16181d; --ink-2: #3b3f47; --muted: #6b707a;
  --line: #e4e2df; --bg: #f5f4f2; --panel: #fff;
  --ok: #15803d; --ok-soft: #e8f6ed; --warn: #b45309; --warn-soft: #fef5e7;
  --radius: 14px; --shadow: 0 1px 2px rgba(22,24,29,.05), 0 4px 16px rgba(22,24,29,.05);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--ink-2); background: var(--bg); }
a { color: var(--red); }
h1, h2, h3 { color: var(--ink); line-height: 1.2; margin: 0 0 .6em; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.1rem; } h3 { font-size: 1rem; }
img { max-width: 100%; }
code { background: var(--bg); padding: 1px 6px; border-radius: 5px; font-size: .88em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
.muted { color: var(--muted); } .small { font-size: .86rem; } .right { text-align: right; } .nowrap { white-space: nowrap; }
:focus-visible { outline: 3px solid rgba(227,6,19,.45); outline-offset: 2px; }

/* Boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 16px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; transition: background .15s, border-color .15s, box-shadow .15s; white-space: nowrap; }
.btn:hover { border-color: #c9c6c1; background: #fafafa; color: var(--ink); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: .88rem; border-radius: 8px; }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); border-color: var(--red-dark); color: #fff; }
.btn-block { width: 100%; }
.btn-danger-ghost { color: var(--red); border-color: transparent; background: transparent; }
.btn-danger-ghost:hover { background: var(--red-soft); color: var(--red-dark); border-color: transparent; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--ink-2); font-size: 1rem; cursor: pointer; line-height: 1; }
.icon-btn:hover:not(:disabled) { background: var(--bg); border-color: var(--line); }
.icon-btn:disabled { opacity: .3; cursor: default; }
.icon-btn.danger:hover { background: var(--red-soft); color: var(--red); }

/* Formulaires */
.form label, label { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; font-weight: 600; color: var(--ink); font-size: .92rem; }
label small, .field-label small { font-weight: 400; color: var(--muted); }
input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font: inherit; font-weight: 400; color: var(--ink); transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px rgba(227,6,19,.12); }
textarea { resize: vertical; line-height: 1.55; min-height: 70px; }
input[type=file] { font: inherit; margin-bottom: 12px; max-width: 100%; }
label.check { flex-direction: row; align-items: center; gap: 10px; font-weight: 500; cursor: pointer; }
label.check input { width: 18px; height: 18px; accent-color: var(--red); }
.check-pad { padding-top: 28px; }
.field { margin-bottom: 18px; }
.field-label { display: block; font-weight: 600; color: var(--ink); font-size: .92rem; margin-bottom: 8px; }
.counter { color: var(--muted); font-weight: 400; }
.input-prefix { display: flex; align-items: stretch; }
.input-prefix span { display: grid; place-items: center; padding: 0 10px; border: 1px solid var(--line); border-right: 0; border-radius: 10px 0 0 10px; background: var(--bg); color: var(--muted); }
.input-prefix input { border-radius: 0 10px 10px 0 !important; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 8px; }
.inline, .inline-form { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.inline-form input { width: 240px !important; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.hint { margin: -4px 0 14px; color: var(--muted); font-size: .88rem; }

/* Alertes */
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-weight: 500; border: 1px solid transparent; transition: opacity .5s; }
.alert-success { background: var(--ok-soft); color: var(--ok); border-color: #c6e9d3; }
.alert-error { background: var(--red-soft); color: var(--red-dark); border-color: #f7c9cc; }
.alert-warning { background: var(--warn-soft); color: var(--warn); border-color: #f6dfb5; }
.alert.fade { opacity: 0; }

/* Mise en page */
.app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--ink); color: rgba(255,255,255,.75); padding: 18px 14px; overflow-y: auto; }
.side-brand { display: flex; gap: 12px; align-items: center; padding: 6px 8px 22px; color: #fff; text-decoration: none; }
.side-brand img { width: 32px; height: 32px; }
.side-brand span { display: flex; flex-direction: column; line-height: 1.25; }
.side-brand small { color: rgba(255,255,255,.55); }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: rgba(255,255,255,.78); text-decoration: none; font-weight: 500; }
.sidebar nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar nav a[aria-current="page"] { background: var(--red); color: #fff; }
.sidebar nav svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.side-footer .btn { background: transparent; color: #fff; border-color: rgba(255,255,255,.2); }
.side-footer .btn:hover { background: rgba(255,255,255,.08); }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 16px; height: 64px; padding: 0 28px; background: rgba(255,255,255,.9); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar-title { flex: 1; font-weight: 600; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-user { display: flex; align-items: center; gap: 12px; }
.topbar-user form { margin: 0; }
.user-chip { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.user-name { display: flex; flex-direction: column; line-height: 1.2; font-weight: 600; font-size: .9rem; }
.user-name small { color: var(--muted); font-weight: 400; }
.avatar { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--red-soft); color: var(--red); font-weight: 800; flex: none; }
.menu-btn { display: none; }
.content { padding: 28px; max-width: 1360px; width: 100%; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { margin-bottom: 4px; }
.page-head p { margin: 0; }
.sticky-head { position: sticky; top: 64px; z-index: 20; background: var(--bg); padding: 14px 0; margin-top: -14px; border-bottom: 1px solid transparent; }
.head-actions { display: flex; gap: 10px; }
.section-title { margin: 28px 0 14px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 18px; box-shadow: var(--shadow); }
.panel.no-pad { padding: 0; overflow: hidden; }
.panel .pad, .no-pad > h2 { padding: 18px 22px 0; }
.panel.narrow { max-width: 560px; }
.panel.help ul { margin: 0; padding-left: 18px; }
.panel.help li { margin-bottom: 4px; }
.row-title { display: flex; justify-content: space-between; align-items: center; }
.empty { color: var(--muted); text-align: center; padding: 28px; }

/* Tableau de bord */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat { display: flex; flex-direction: column; padding: 18px 20px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--muted); box-shadow: var(--shadow); transition: border-color .15s, transform .15s; }
.stat:hover { border-color: var(--red); transform: translateY(-2px); color: var(--muted); }
.stat strong { font-size: 1.9rem; color: var(--ink); line-height: 1.1; }
.dash-grid { gap: 18px; align-items: start; }
.quick-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.quick-list a, .page-cell { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 10px; text-decoration: none; color: var(--ink); }
.quick-list a:hover { background: var(--bg); }
.quick-list img, .page-cell img, .ph { width: 56px; height: 42px; object-fit: cover; border-radius: 8px; background: var(--bg); flex: none; }
.quick-list span, .page-cell span { display: flex; flex-direction: column; line-height: 1.3; }
.quick-list small { color: var(--muted); }
.shortcuts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.shortcuts .btn { justify-content: flex-start; }
.log-list { list-style: none; margin: 0 0 12px; padding: 0; }
.log-list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.log-list li:last-child { border-bottom: 0; }
.log-list li > small { white-space: nowrap; }

/* Tableaux */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 12px 18px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: #fbfbfa; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fcfcfb; }
.table .right { text-align: right; }

.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .76rem; font-weight: 700; background: var(--bg); color: var(--ink-2); white-space: nowrap; }
.tag-ok { background: var(--ok-soft); color: var(--ok); }
.tag-red { background: var(--red-soft); color: var(--red); }
.tag-muted { background: var(--bg); color: var(--muted); }
.tag-text { background: #eef2ff; color: #4338ca; } .tag-cards { background: #ecfeff; color: #0e7490; } .tag-gallery { background: #fdf4ff; color: #a21caf; }
.tag-logos { background: #f5f5f4; color: #57534e; } .tag-cta { background: var(--red-soft); color: var(--red); } .tag-rayons, .tag-stores, .tag-catalogues { background: #fef9c3; color: #854d0e; }

/* Éditeur de page */
.editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.editor-side { position: sticky; top: 150px; }
.sections-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 26px 0 12px; }
.sections-head h2 { margin: 0; }
.add-section { display: flex; gap: 8px; }
.add-section select { width: auto; }
.section-editor { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; box-shadow: var(--shadow); transition: box-shadow .3s, border-color .3s; }
.section-editor.flash { border-color: var(--red); box-shadow: 0 0 0 4px rgba(227,6,19,.12); }
.section-editor.is-hidden { opacity: .7; }
.section-editor > summary { display: flex; align-items: center; gap: 10px; padding: 12px 14px 12px 16px; cursor: pointer; list-style: none; border-radius: var(--radius); }
.section-editor > summary::-webkit-details-marker { display: none; }
.section-editor > summary::after { content: "▾"; color: var(--muted); transition: transform .2s; }
.section-editor[open] > summary { border-bottom: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; }
.section-editor[open] > summary::after { transform: rotate(180deg); }
.section-editor > summary:hover { background: #fcfcfb; }
.section-editor > summary strong { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.drag-hint { color: #c9c6c1; letter-spacing: -3px; }
.section-actions { display: flex; gap: 2px; }
.section-body { padding: 18px 18px 4px; }
.section-options { padding-top: 14px; border-top: 1px dashed var(--line); }
.section-options label.check { padding-top: 24px; }

.rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.row-link { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 8px; align-items: center; }
.row-card { padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #fcfcfb; }
.row-card-head { display: grid; grid-template-columns: 36px 1fr 170px auto auto auto; gap: 6px; align-items: center; margin-bottom: 8px; }
.icon-preview { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--red-soft); color: var(--red); }
.icon-preview svg { width: 20px; height: 20px; }
.rows > .panel { margin-bottom: 0; }

/* Sélecteur d'images */
.picker { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.picker-items { display: flex; flex-wrap: wrap; gap: 10px; }
.picker-item { position: relative; margin: 0; width: 120px; height: 90px; border-radius: 10px; overflow: hidden; background: var(--bg); border: 1px solid var(--line); }
.picker-single .picker-item { width: 220px; height: 130px; }
.picker-item img { width: 100%; height: 100%; object-fit: cover; }
.picker-item:first-child::before { content: "Principale"; position: absolute; left: 6px; top: 6px; padding: 1px 7px; border-radius: 999px; background: var(--red); color: #fff; font-size: .68rem; font-weight: 700; }
.picker-single .picker-item::before { display: none; }
.picker-tools { position: absolute; inset: auto 0 0 0; display: flex; justify-content: flex-end; gap: 4px; padding: 4px; background: linear-gradient(transparent, rgba(0,0,0,.6)); opacity: 0; transition: opacity .15s; }
.picker-item:hover .picker-tools, .picker-item:focus-within .picker-tools { opacity: 1; }
.picker-tools button { width: 26px; height: 26px; border: 0; border-radius: 6px; background: rgba(255,255,255,.92); color: var(--ink); cursor: pointer; font-weight: 700; }
.picker-tools button[data-remove]:hover { background: var(--red); color: #fff; }
@media (hover: none) { .picker-tools { opacity: 1; } }

/* Fenêtre médiathèque */
.media-dialog { width: min(1040px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 0; border-radius: 18px; box-shadow: 0 30px 80px rgba(0,0,0,.3); display: none; flex-direction: column; }
.media-dialog[open] { display: flex; }
.media-dialog::backdrop { background: rgba(22,24,29,.55); backdrop-filter: blur(3px); }
.media-dialog.is-over { outline: 4px dashed var(--red); outline-offset: -10px; }
.md-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); margin: 0; }
.md-head h2 { margin: 0; }
.md-toolbar { display: flex; gap: 10px; padding: 14px 20px 0; }
.upload-btn { flex-direction: row; margin: 0; color: #fff; }
.md-status { padding: 8px 20px 0; min-height: 30px; font-size: .9rem; color: var(--muted); }
.md-grid { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); grid-auto-rows: max-content; gap: 10px; padding: 10px 20px 20px; align-content: start; }
.md-item { position: relative; display: flex; flex-direction: column; padding: 0; border: 2px solid transparent; border-radius: 12px; background: var(--bg); overflow: hidden; cursor: pointer; text-align: left; font: inherit; }
.md-item img { display: block; flex: none; width: 100%; height: auto; aspect-ratio: 4/3; object-fit: cover; background: #fff; }
.md-item span { padding: 6px 8px; font-size: .78rem; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.md-item:hover { border-color: #c9c6c1; }
.md-item.is-selected { border-color: var(--red); box-shadow: 0 0 0 3px rgba(227,6,19,.18); }
.md-item b { position: absolute; top: 6px; right: 6px; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--red); color: #fff; font-size: .8rem; }
.md-foot { display: flex; justify-content: flex-end; align-items: center; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); }
.md-foot span { margin-right: auto; color: var(--muted); }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--red); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Médiathèque */
.dropzone { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 28px; border: 2px dashed var(--line); border-radius: var(--radius); text-align: center; transition: border-color .15s, background .15s; margin: 0; }
.dropzone svg { width: 40px; height: 40px; fill: none; stroke: var(--red); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.dropzone p { margin: 0; }
.dropzone label { flex-direction: row; margin: 6px 0; color: #fff; }
.dropzone.is-over { border-color: var(--red); background: var(--red-soft); }
.dropzone.is-loading { opacity: .6; pointer-events: none; }
.dropzone.is-loading::after { content: "Envoi et optimisation en cours…"; font-weight: 700; color: var(--red); }
.toolbar { display: flex; gap: 8px; margin: 0 0 16px; }
.toolbar input { max-width: 420px; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.media-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.media-thumb { display: block; aspect-ratio: 4/3; background: var(--bg) repeating-conic-gradient(#eee 0 25%, #fff 0 50%) 0 0 / 16px 16px; }
.media-thumb img { width: 100%; height: 100%; object-fit: contain; }
.media-info { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.media-info p { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-info form { margin: 0; }
.media-info form:last-child { margin-top: auto; padding-top: 6px; }
.alt-form { display: flex; gap: 4px; }
.alt-form input { padding: 7px 9px !important; font-size: .88rem !important; }
.file-list { list-style: none; margin: 0; padding: 0; }
.file-list li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.file-list li a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Utilisateurs */
.user-panel { padding: 0; }
.user-panel > summary { display: flex; align-items: center; gap: 14px; padding: 16px 20px; cursor: pointer; list-style: none; }
.user-panel > summary::-webkit-details-marker { display: none; }
.user-panel[open] > summary { border-bottom: 1px solid var(--line); }
.user-sum { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.user-panel > form { padding: 18px 20px 4px; }
.danger-zone { padding: 0 20px 16px !important; }

/* Connexion / installation */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 10%, #fff 0, var(--bg) 60%); }
.login-card { width: 100%; max-width: 420px; background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 36px; box-shadow: 0 20px 60px rgba(22,24,29,.08); }
.install-card { max-width: 560px; }
.login-logo { display: block; height: 56px; width: auto; margin: 0 auto 18px; }
.login-card h1 { text-align: center; font-size: 1.35rem; margin-bottom: 22px; }
.login-card h2 { margin-top: 24px; }
.checks { list-style: none; padding: 0; margin: 0 0 16px; }
.checks li { padding: 7px 0 7px 30px; position: relative; border-bottom: 1px solid var(--line); }
.checks li::before { position: absolute; left: 4px; font-weight: 800; }
.checks .ok::before { content: "✓"; color: var(--ok); }
.checks .ko::before { content: "✕"; color: var(--red); } .checks .ko { color: var(--red-dark); font-weight: 600; }
.checks .warn::before { content: "!"; color: var(--warn); left: 8px; }

/* Responsive */
@media (max-width: 1100px) {
  .editor-grid { grid-template-columns: 1fr; }
  .editor-side { position: static; }
  .stats { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 60; left: 0; top: 0; width: 270px; transform: translateX(-100%); transition: transform .25s; box-shadow: 20px 0 60px rgba(0,0,0,.25); }
  .menu-open .sidebar { transform: none; }
  .menu-btn { display: inline-grid; }
  .topbar { padding: 0 14px; }
  .user-name { display: none; }
  .content { padding: 18px 14px; }
  .grid-2, .dash-grid { grid-template-columns: 1fr; }
  .quick-list, .shortcuts { grid-template-columns: 1fr; }
  .row-link { grid-template-columns: 1fr auto; }
  .row-link input:nth-child(2) { grid-column: 1; }
  .row-card-head { grid-template-columns: 36px 1fr auto; }
  .row-card-head select { grid-column: 1 / -1; grid-row: 2; }
  .table th:nth-child(2), .table td:nth-child(2) { display: none; }
  .inline-form { width: 100%; } .inline-form input { flex: 1; width: auto !important; }
  .sticky-head { top: 64px; }
  .check-pad, .section-options label.check { padding-top: 0; }
}
