/* ============================================================
   Murrplastik · Offres de prix
   Couleurs de marque reprises de LabelOnDemand V4
   (rouge #E20613, bleu marine #1B2F4A), thème clair pour
   une bonne lisibilité sur mobile en extérieur.
   ============================================================ */

:root {
  --red: #E20613;
  --red-dark: #B8040F;
  --navy: #1B2F4A;
  --navy-2: #24405F;
  --silver: #C8CACC;

  --bg: #F4F6F8;
  --surface: #FFFFFF;
  --border: #DDE2E8;
  --border-strong: #C3CBD5;
  --text: #16212E;
  --text-2: #4A5868;
  --muted: #6B7785;

  --success: #0E7A4F;
  --success-bg: #E6F4EE;
  --warning: #8A5A00;
  --warning-bg: #FFF4DB;
  --danger: #B42318;
  --danger-bg: #FDECEA;
  --info: #1D4E89;
  --info-bg: #E8F0FA;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(22, 33, 46, .06), 0 2px 8px rgba(22, 33, 46, .05);
  --focus: 0 0 0 3px rgba(226, 6, 19, .35);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; color: var(--navy); }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
a { color: var(--navy); }
code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }

:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-sm); }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; margin: -1px;
}
.skip-link { position: absolute; left: -999px; top: 8px; background: #fff; padding: 8px 12px; z-index: 100; }
.skip-link:focus { left: 8px; }
.muted { color: var(--muted); font-weight: 400; }

.container { width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 16px; }
main.container { flex: 1; padding-top: 24px; padding-bottom: 40px; }

/* ── Barre supérieure (claire, différente de V4) ─────────── */
.topbar { background: #fff; color: var(--navy); position: sticky; top: 0; z-index: 20; border-bottom: 1px solid var(--border); box-shadow: 0 1px 0 rgba(22,33,46,.02); }
.topbar::before { content: ""; display: block; height: 4px; background: linear-gradient(90deg, var(--red) 0 70%, var(--silver) 70% 100%); }
.topbar-inner { max-width: 1100px; margin: 0 auto; padding: 0 16px; height: 64px; display: flex; align-items: center; gap: 24px; }
.brand { display: flex; align-items: center; gap: 14px; text-decoration: none; color: var(--navy); flex-shrink: 0; }
.brand img { height: 30px; width: auto; display: block; }
.brand-app { font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--red); padding-left: 14px; border-left: 1px solid var(--border-strong); }
.mainnav { display: flex; gap: 4px; flex: 1; height: 100%; }
.mainnav a { display: flex; align-items: center; color: var(--text-2); text-decoration: none; padding: 0 12px; font-weight: 600; font-size: .95rem; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.mainnav a:hover { color: var(--navy); }
.mainnav a[aria-current="page"] { color: var(--navy); border-bottom-color: var(--red); }

.usermenu { position: relative; margin-left: auto; }
.usermenu summary { list-style: none; display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 6px 8px; border-radius: var(--radius-sm); min-height: 44px; }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu summary:hover { background: var(--bg); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--navy); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .9rem; }
.usermenu-name { font-size: .9rem; color: var(--navy); font-weight: 600; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usermenu-panel { position: absolute; right: 0; top: calc(100% + 8px); width: 270px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 28px rgba(22,33,46,.18); padding: 8px; }
.usermenu-head { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; font-size: .875rem; }
.usermenu-head span { color: var(--muted); overflow-wrap: anywhere; }
.usermenu-head .badge { align-self: flex-start; margin-top: 6px; }
.usermenu-link { display: block; width: 100%; text-align: left; padding: 10px; border-radius: var(--radius-sm); color: var(--text); text-decoration: none; font: inherit; font-size: .95rem; background: none; border: 0; cursor: pointer; min-height: 44px; }
.usermenu-link:hover { background: var(--bg); }
.usermenu-logout { color: var(--danger); }
.only-mobile { display: none; }

/* ── Cartes et en-têtes ────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.page-head { margin-bottom: 20px; }
.page-head p { color: var(--text-2); }
.section-title { margin: 28px 0 12px; font-size: 1rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); }

.hero { margin-bottom: 20px; }
.hero p { color: var(--text-2); margin: 0; }

/* ── Recherche ─────────────────────────────────────────────── */
.search-form { display: flex; gap: 10px; margin-top: 8px; }
.search-form input { flex: 1; }

/* ── Tuiles ────────────────────────────────────────────────── */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow); }
.tile p { color: var(--text-2); font-size: .925rem; flex: 1; margin: 0; }
.tile-link { text-decoration: none; color: inherit; border-left: 4px solid var(--red); transition: border-color 150ms ease, box-shadow 150ms ease; }
.tile-link:hover { border-color: var(--red); box-shadow: 0 4px 16px rgba(22,33,46,.10); }
.tile-soon { background: #FAFBFC; box-shadow: none; }
.tile-soon h3 { color: var(--text-2); }
.tile-meta { font-size: .85rem; color: var(--navy); font-weight: 600; }

/* ── Badges ────────────────────────────────────────────────── */
.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; align-self: flex-start; }
.badge-admin { background: #FDE7E8; color: var(--red-dark); }
.badge-commercial { background: var(--info-bg); color: var(--info); }
.badge-on { background: var(--success-bg); color: var(--success); }
.badge-off { background: #ECEEF1; color: var(--muted); }
.badge-warn { background: var(--warning-bg); color: var(--warning); }
.badge-soon { background: #ECEEF1; color: var(--text-2); }

/* ── Formulaires ───────────────────────────────────────────── */
.field { margin-bottom: 16px; }
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; color: var(--text); }
input[type=text], input[type=email], input[type=password], input[type=search], input:not([type]), select {
  width: 100%; min-height: 44px; padding: 10px 12px; font: inherit; font-size: 16px; color: var(--text);
  background: #fff; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
}
input:focus, select:focus { outline: none; border-color: var(--red); box-shadow: var(--focus); }
input:disabled, select:disabled { background: #F0F2F5; color: var(--muted); cursor: not-allowed; }
.field-hint { font-size: .85rem; color: var(--muted); margin: 6px 0 0; }
.field-error { font-size: .85rem; color: var(--danger); margin: 6px 0 0; font-weight: 500; }
.has-error input, .has-error select { border-color: var(--danger); }
.form-narrow { max-width: 480px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

.password-wrap { position: relative; }
.password-wrap input { padding-right: 92px; }
.password-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); height: 36px; padding: 0 12px; border: 0; background: none; color: var(--navy); font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; border-radius: var(--radius-sm); }
.password-toggle:hover { background: var(--bg); }

/* ── Boutons ───────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px; border-radius: var(--radius-sm); font: inherit; font-weight: 600; font-size: .95rem; text-decoration: none; cursor: pointer; border: 1px solid transparent; transition: background-color 150ms ease, border-color 150ms ease; white-space: nowrap; }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); }
.btn-secondary { background: #fff; color: var(--navy); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--bg); }
.btn-danger { background: #fff; color: var(--danger); border-color: #F1B8B3; }
.btn-danger:hover { background: var(--danger-bg); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-small { min-height: 36px; padding: 6px 12px; font-size: .85rem; }

/* ── Alertes ───────────────────────────────────────────────── */
.alert { padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: .95rem; border: 1px solid transparent; }
.alert-success { background: var(--success-bg); color: var(--success); border-color: #B9E2CF; }
.alert-error { background: var(--danger-bg); color: var(--danger); border-color: #F5C2BC; }
.alert-info { background: var(--info-bg); color: var(--info); border-color: #C3D6EE; }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-color: #F0D9A0; }

/* ── Checklist d'installation ──────────────────────────────── */
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: grid; grid-template-columns: 14px minmax(160px, 220px) 1fr; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: .925rem; }
.checklist li:last-child { border-bottom: 0; }
.check-dot { width: 10px; height: 10px; border-radius: 50%; }
.is-ok .check-dot { background: var(--success); }
.is-ko .check-dot { background: var(--danger); }
.check-label { font-weight: 600; }
.check-detail { color: var(--text-2); }
.is-ko .check-detail { color: var(--danger); font-weight: 500; }

/* ── Tableau ───────────────────────────────────────────────── */
.table-card { padding: 0; overflow: hidden; }
.table { width: 100%; border-collapse: collapse; font-size: .925rem; }
.table th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); background: #F8F9FB; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.is-inactive td { color: var(--muted); }
.actions-cell { text-align: right; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.section-gap { margin-top: 28px; }
.row-actions form { margin: 0; }

/* ── Création de compte / mot de passe temporaire ──────────── */
.create-card > summary { list-style: none; cursor: pointer; }
.create-card > summary::-webkit-details-marker { display: none; }
.create-card[open] > summary { margin-bottom: 16px; }
.create-card[open] > summary .btn { background: #fff; color: var(--navy); border-color: var(--border-strong); }
.temp-card { border-left: 4px solid var(--success); }
.temp-grid { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 12px 0 0; }
.temp-grid dt { font-weight: 600; color: var(--text-2); }
.temp-grid dd { margin: 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; overflow-wrap: anywhere; }
.temp-grid code { font-size: 1.1rem; background: var(--bg); padding: 4px 10px; border-radius: var(--radius-sm); letter-spacing: .05em; }

/* ── Page de connexion ─────────────────────────────────────── */
.auth-page { background: var(--bg); position: relative; overflow-x: hidden; }
.auth-page::before, .auth-page::after { content: ""; position: fixed; z-index: 0; pointer-events: none; transform: skewX(-38deg); }
.auth-page::before { width: 220px; height: 120vh; right: 6vw; top: -10vh; background: var(--red); opacity: .9; }
.auth-page::after { width: 160px; height: 120vh; right: calc(6vw - 210px); top: -10vh; background: var(--silver); opacity: .7; }
.auth-wrap { position: relative; z-index: 1; flex: 1; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border-radius: 14px; padding: 32px 28px; box-shadow: 0 12px 40px rgba(22,33,46,.12); border: 1px solid var(--border); }
.auth-logo { display: block; width: 200px; height: auto; margin: 0 0 24px; }
.auth-card h1 { font-size: 1.4rem; }
.auth-sub { color: var(--text-2); margin-bottom: 20px; }
.auth-help { font-size: .85rem; color: var(--muted); margin: 18px 0 0; }

.footer { color: var(--muted); font-size: .8rem; padding: 16px 0 24px; text-align: center; }

/* ── Mobile ────────────────────────────────────────────────── */
@media (max-width: 760px) {
  h1 { font-size: 1.35rem; }
  .topbar-inner { height: 56px; gap: 12px; }
  .auth-page::before { right: -120px; }
  .auth-page::after { right: -260px; }
  .brand img { height: 24px; }
  .brand-app { display: none; }
  .mainnav { display: none; }
  .only-mobile { display: block; }
  .usermenu-name { display: none; }
  .usermenu-panel { position: fixed; left: 12px; right: 12px; top: 68px; width: auto; }
  main.container { padding-top: 18px; }
  .card { padding: 16px; }
  .search-form { flex-direction: column; }
  .tiles { grid-template-columns: 1fr; }
  .checklist li { grid-template-columns: 14px 1fr; }
  .checklist .check-detail { grid-column: 2; }
  .temp-grid { grid-template-columns: 1fr; }
  .temp-grid dt { margin-top: 6px; }

  /* Tableau en cartes */
  .table-responsive thead { display: none; }
  .table-responsive, .table-responsive tbody, .table-responsive tr, .table-responsive td { display: block; width: 100%; }
  .table-responsive tr { padding: 12px 14px; border-bottom: 1px solid var(--border); }
  .table-responsive tr:last-child { border-bottom: 0; }
  .table-responsive td { border: 0; padding: 4px 0; display: flex; gap: 12px; justify-content: space-between; align-items: center; overflow-wrap: anywhere; }
  .table-responsive td[data-label]::before { content: attr(data-label); font-size: .78rem; color: var(--muted); font-weight: 600; flex-shrink: 0; }
  .table-responsive .actions-cell { display: block; }
  .table-responsive .row-actions { justify-content: flex-start; padding-top: 10px; }
  .auth-card { padding: 26px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
