/* Gestion générale — Protection Civile du Loiret, Direction Technique */
:root {
  --pc-blue: #024589;     /* bleu du logo */
  --pc-navy: #023566;
  --pc-navy-2: #01264a;
  --pc-orange: #f78d20;   /* orange du logo */
  --surface: #f5f6f8;
  --card: #ffffff;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --line: #e3e5e9;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --bs-primary: #024589;
  --bs-primary-rgb: 2, 69, 137;
  --bs-link-color: #024589;
  --bs-link-color-rgb: 2, 69, 137;
  --bs-body-font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
body { background: var(--surface); color: var(--ink); }
a { text-decoration: none; }
.btn-primary { --bs-btn-bg: #024589; --bs-btn-border-color: #024589; --bs-btn-hover-bg: #023566; --bs-btn-hover-border-color: #023566; --bs-btn-active-bg: #01264a; }
.btn-outline-primary { --bs-btn-color: #024589; --bs-btn-border-color: #024589; --bs-btn-hover-bg: #024589; --bs-btn-hover-border-color: #024589; }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 268px; flex-shrink: 0; background: var(--pc-navy); color: #c9d4e6; padding: 0 0 1rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .brand { display: flex; gap: .7rem; align-items: center; padding: 1.1rem 1.1rem 1rem; color: #fff; border-bottom: 1px solid rgba(255,255,255,.08); margin-bottom: .4rem; }
.sidebar .brand small, .auth-brand small { display: block; font-size: .75rem; color: #9fb0cc; }
.auth-brand small { color: var(--ink-2); }
.brand-logo { width: 44px; height: 44px; flex-shrink: 0; }
.sidebar .brand strong { font-size: 1.05rem; letter-spacing: .01em; }
.sidebar .brand small { line-height: 1.25; margin-top: 2px; }
.nav-section { text-transform: uppercase; font-size: .68rem; letter-spacing: .08em; color: #8094b6; padding: .9rem 1.1rem .3rem; }
.sidebar .nav-link { display: flex; gap: .6rem; align-items: center; color: #d5deec; padding: .42rem 1.1rem; font-size: .9rem; border-left: 3px solid transparent; }
.sidebar .nav-link.sub { padding-left: 1.5rem; font-size: .86rem; }
.sidebar .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar .nav-link.active { background: rgba(243,146,0,.14); color: #fff; border-left-color: var(--pc-orange); }
.sidebar-foot { padding: 1.25rem 1.1rem 0; font-size: .7rem; line-height: 1.4; color: #7f96bd; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: .75rem; background: #fff; border-bottom: 1px solid var(--line); padding: .55rem 1.5rem; position: sticky; top: 0; z-index: 20; }
.topbar-title { font-weight: 600; color: var(--ink-2); font-size: .92rem; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.content { padding: 1.5rem; max-width: 1500px; width: 100%; }
@media (max-width: 575.98px) { .kpi-row { grid-template-columns: 1fr 1fr; gap: .6rem; } .kpi { flex-direction: column; align-items: flex-start; gap: .5rem; } }
@media (max-width: 991.98px) {
  .sidebar { position: fixed; left: -280px; z-index: 50; transition: left .2s; }
  .sidebar.open { left: 0; box-shadow: 0 0 40px rgba(0,0,0,.35); }
  .content { padding: 1rem; }
}

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; background: linear-gradient(160deg, var(--pc-navy) 0%, var(--pc-navy-2) 60%, #081a36 100%); }
.auth-card { background: #fff; border-radius: 14px; padding: 2rem; width: 100%; max-width: 440px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.auth-brand { display: flex; flex-direction: column; align-items: center; text-align: center; margin-bottom: 1.5rem; }
.auth-logo { width: 96px; height: 96px; margin-bottom: .75rem; }
.auth-app-name { font-size: 1.5rem; font-weight: 700; color: var(--pc-navy); line-height: 1.2; }
.auth-wrap { flex-direction: column; }
.auth-foot { color: #9fb0cc; font-size: .78rem; margin: 1.25rem 0 0; text-align: center; }
.otp-input { letter-spacing: .4em; font-family: ui-monospace, monospace; font-weight: 600; }
.qr-box { display: flex; justify-content: center; margin: .5rem 0; }
.qr-box svg { width: 210px; height: 210px; background: #fff; }
.secret-key { font-size: .95rem; letter-spacing: .05em; background: #f1f3f6; padding: .35rem .6rem; border-radius: 6px; color: var(--ink); word-break: break-all; }
.recovery-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; }
.recovery-grid code { background: #f1f3f6; color: var(--ink); text-align: center; padding: .4rem; border-radius: 6px; font-size: .95rem; }

/* ---------- Page ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head h1 { font-size: 1.45rem; font-weight: 700; margin: 0 0 .15rem; }
.section-title { font-size: 1rem; font-weight: 700; color: var(--ink-2); margin: 0 0 .75rem; }
.card { border-color: var(--line); border-radius: 10px; }
.card-header { background: #fff; font-weight: 600; font-size: .92rem; border-bottom-color: var(--line); }
.form-card { max-width: 1100px; }
.req { color: var(--critical); }
.prewrap { white-space: pre-wrap; word-wrap: break-word; }
.doc-content { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; background: #f8f9fb; border: 1px solid var(--line); border-radius: 8px; padding: 1rem; }
.empty { text-align: center; padding: 3rem 1rem; color: var(--ink-2); }
.empty > i { font-size: 2.6rem; color: #b5bcc8; display: block; margin-bottom: .5rem; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: .65rem; }
.filters .form-control, .filters .form-select { width: auto; min-width: 140px; }
.filters input[type=search] { min-width: 220px; flex: 1; }
.data-table th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); font-weight: 600; background: #fafbfc; white-space: nowrap; }
.row-urgent td:first-child { box-shadow: inset 3px 0 0 var(--critical); }
.thumb-cell { width: 58px; position: relative; }
.thumb-cell img { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; }
.thumb-count { position: absolute; bottom: 6px; right: 6px; background: rgba(0,0,0,.65); color: #fff; font-size: .65rem; padding: 0 4px; border-radius: 4px; }
.seg .btn { font-size: .9rem; }

/* ---------- Badges d'état (icône + libellé, jamais la couleur seule) ---------- */
.badge-status { display: inline-flex; align-items: center; gap: .3rem; font-size: .76rem; font-weight: 600; padding: .22rem .55rem; border-radius: 999px; border: 1px solid; white-space: nowrap; color: var(--ink); background: #fff; }
.badge-status.st-todo { border-color: var(--serious); background: #fdf0ea; }
.badge-status.st-todo i { color: #c4562a; }
.badge-status.st-doing { border-color: var(--warning); background: #fff7e3; }
.badge-status.st-doing i { color: #a87400; }
.badge-status.st-done { border-color: var(--good); background: #eaf7ea; }
.badge-status.st-done i { color: var(--good); }
.badge-status.st-urgent { border-color: var(--critical); background: var(--critical); color: #fff; }
.badge-status.st-normal { border-color: var(--line); color: var(--ink-2); font-weight: 500; }

/* ---------- KPI ---------- */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .9rem; margin-bottom: 1.5rem; }
.kpi { display: flex; gap: .85rem; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: .95rem 1rem; color: var(--ink); transition: border-color .15s, box-shadow .15s; }
a.kpi:hover { border-color: #b9c6dc; box-shadow: 0 2px 10px rgba(18,48,95,.07); color: var(--ink); }
.kpi-icon { width: 42px; height: 42px; border-radius: 10px; background: #edf2fa; color: #024589; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; flex-shrink: 0; }
.kpi-value { font-size: 1.4rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-label { font-size: .8rem; color: var(--ink-2); }
.kpi-sub { font-size: .72rem; color: #7a7a75; }
.kpi.tone-critical { border-color: #f0b4b4; }
.kpi.tone-critical .kpi-icon { background: #fbe7e7; color: var(--critical); }
.kpi.tone-warning .kpi-icon { background: #fff4dc; color: #a87400; }
.kpi.tone-good .kpi-icon { background: #e6f5e6; color: #087a08; }

/* ---------- Graphiques ---------- */
.chart-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.chart-grid .span-2 { grid-column: span 2; }
@media (max-width: 1199.98px) { .chart-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 767.98px) { .chart-grid { grid-template-columns: 1fr; } .chart-grid .span-2 { grid-column: auto; } }
.chart-card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.1rem .75rem; }
.chart-card h3 { font-size: .9rem; font-weight: 650; margin: 0 0 .75rem; color: var(--ink); }
.chart-box { position: relative; height: 260px; }
.chart-table { margin-top: .4rem; font-size: .78rem; }
.chart-table summary { color: var(--ink-2); cursor: pointer; }
.chart-table table { width: 100%; margin-top: .4rem; }
.chart-table td, .chart-table th { padding: .15rem .4rem; border-bottom: 1px solid var(--line); }
.chart-table td:not(:first-child), .chart-table th:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Sites SI ---------- */
.site-card { display: block; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 1.1rem 1.2rem; color: var(--ink); height: 100%; transition: box-shadow .15s, border-color .15s; }
.site-card:hover { color: var(--ink); border-color: #b9c6dc; box-shadow: 0 4px 16px rgba(18,48,95,.08); }
.site-card-head { display: flex; gap: .8rem; align-items: center; margin-bottom: 1rem; }
.site-card-head > i:first-child { font-size: 1.6rem; color: #024589; background: #edf2fa; width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; }
.site-card-head small { display: block; color: var(--ink-2); font-size: .8rem; }
.site-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .6rem; }
.site-stats div { background: #f7f8fa; border-radius: 8px; padding: .5rem .65rem; font-size: .75rem; color: var(--ink-2); }
.site-stats span { display: block; font-size: 1.25rem; font-weight: 700; color: var(--ink); }
.site-stats .warn { background: #fff7e3; }
.site-stats .crit { background: #fbe7e7; }
.site-banner { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 1rem 1.1rem 0; margin-bottom: 1.25rem; }
.site-icon { width: 44px; height: 44px; border-radius: 11px; background: var(--pc-navy); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 1.35rem; }
.site-name { font-weight: 700; font-size: 1.1rem; }
.site-tabs { display: flex; gap: .2rem; overflow-x: auto; margin-top: .8rem; }
.site-tabs a { padding: .55rem .8rem; font-size: .86rem; color: var(--ink-2); border-bottom: 3px solid transparent; white-space: nowrap; }
.site-tabs a:hover { color: var(--ink); }
.site-tabs a.active { color: #024589; border-bottom-color: var(--pc-orange); font-weight: 600; }
.detail-list dt { font-weight: 600; color: var(--ink-2); font-size: .85rem; }
.detail-list dd { margin-bottom: .55rem; }
.progress-line { height: 8px; background: #eceef2; border-radius: 99px; overflow: hidden; }
.progress-line div { height: 100%; background: var(--good); border-radius: 99px; }
.task-mini li { padding: .3rem 0; border-bottom: 1px dashed var(--line); }
.task-mini li:last-child { border-bottom: 0; }

/* ---------- Kanban tâches ---------- */
.kanban { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; align-items: start; }
@media (max-width: 991.98px) { .kanban { grid-template-columns: 1fr; } }
.kanban-col { background: #eceff3; border-radius: 12px; padding: .75rem; min-height: 200px; }
.kanban-col h3 { font-size: .9rem; font-weight: 700; display: flex; align-items: center; gap: .4rem; margin: .1rem .2rem .75rem; }
.kanban-col .count { margin-left: auto; background: #fff; border-radius: 99px; padding: 0 .55rem; font-size: .78rem; color: var(--ink-2); }
.col-a_faire h3 i { color: #c4562a; } .col-en_cours h3 i { color: #a87400; } .col-fait h3 i { color: var(--good); }
.kcard { background: #fff; border-radius: 9px; padding: .7rem .8rem; margin-bottom: .6rem; border: 1px solid var(--line); border-left: 4px solid #c9ced8; position: relative; }
.kcard.prio-haute { border-left-color: var(--critical); }
.kcard.prio-normale { border-left-color: #024589; }
.kcard-title { display: block; font-weight: 600; color: var(--ink); margin-bottom: .25rem; padding-right: 4.5rem; }
.kcard-meta { display: flex; flex-wrap: wrap; gap: .3rem .7rem; font-size: .76rem; color: var(--ink-2); }
.kcard-actions { position: absolute; top: .45rem; right: .45rem; display: flex; gap: .2rem; }
.kcard-actions .btn { padding: .1rem .4rem; }
.col-fait .kcard { opacity: .75; }
.clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; }

/* ---------- Photos ---------- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .6rem; }
.gallery figure { position: relative; margin: 0; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.gallery-del { position: absolute; top: 4px; right: 4px; padding: 0 .35rem; opacity: .85; }
.photo-preview { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; }
.photo-preview img { width: 80px; height: 80px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }

@media print {
  .sidebar, .topbar, .btn, form button { display: none !important; }
  .auth-wrap { background: none; } .auth-card { box-shadow: none; }
}
