/* SPI Interventions — thème */
:root {
  --spi-navy: #0f1b2d;
  --spi-navy-2: #1b2b44;
  --spi-red: #c8102e;
  --spi-bg: #f3f5f8;
  --sec-date: #23262b;
  --sec-info: #e85b4f;
  --sec-agent: #2f5d8a;
  --sec-regul: #2f8f84;
  --bs-primary: #1d4ed8;
  --bs-primary-rgb: 29, 78, 216;
}
body { background: var(--spi-bg); -webkit-tap-highlight-color: transparent; }
.min-w-0 { min-width: 0; }
.btn-primary { --bs-btn-bg: #1d4ed8; --bs-btn-border-color: #1d4ed8; --bs-btn-hover-bg: #1e40af; --bs-btn-hover-border-color: #1e40af; }

/* ---- Barre du haut ---- */
.topbar { background: var(--spi-navy); box-shadow: 0 1px 0 rgba(255,255,255,.06); padding-top: max(.5rem, env(safe-area-inset-top)); }
.brand-dot { width: 12px; height: 12px; border-radius: 3px; background: var(--spi-red); display: inline-block; transform: rotate(45deg); }
.badge-float { position: absolute; top: -6px; right: -8px; font-size: .65rem; }
.topbar .nav-link.active { color: #fff; box-shadow: inset 0 -2px 0 var(--spi-red); }

/* ---- Navigation basse (agents, mobile) ---- */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030; display: flex; background: #fff;
  border-top: 1px solid #dfe3ea; padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav a { flex: 1; text-align: center; padding: .45rem 0 .35rem; color: #5b6472; text-decoration: none; font-size: .72rem; position: relative; }
.bottomnav a i { display: block; font-size: 1.35rem; line-height: 1.2; }
.bottomnav a.active { color: var(--spi-red); }
.bottomnav em { position: absolute; top: 2px; left: 55%; background: var(--spi-red); color: #fff; font-style: normal; font-size: .65rem; border-radius: 10px; padding: 0 6px; }
.is-agent .main-pad { padding-bottom: 5.5rem !important; }

/* ---- Pages de connexion ---- */
.auth-body { background: radial-gradient(circle at 20% 0%, #1b2b44, #0f1b2d 60%); min-height: 100vh; }
.auth-wrap { max-width: 460px; margin: 0 auto; padding: 2.5rem 1rem; }
.auth-brand { color: #fff; font-weight: 600; font-size: 1.15rem; display: flex; align-items: center; gap: .6rem; justify-content: center; margin-bottom: 1.2rem; }
.auth-card { border: 0; border-radius: 14px; }
.auth-foot { color: rgba(255,255,255,.6); text-align: center; font-size: .8rem; margin-top: 1rem; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.code-input { letter-spacing: .4em; font-weight: 600; }
.qr { width: 220px; height: 220px; image-rendering: pixelated; background: #fff; }
.form-narrow { max-width: 360px; }
.recovery-codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .3rem; max-width: 320px; }
.recovery-codes code { background: #fff; padding: .2rem .4rem; border-radius: 4px; color: #111; }

/* ---- Listes ---- */
.section-title { margin: 1rem 0 .5rem; font-weight: 700; letter-spacing: .03em; }
.bon-item { border-left: 4px solid transparent; }
.bon-item.status-a_prendre { border-left-color: #dc3545; }
.bon-item.status-en_cours { border-left-color: #ffc107; }
.bon-item.status-a_reguler { border-left-color: #1d4ed8; }
.bon-item.status-cloture { border-left-color: #198754; }
.bon-item.status-annule { border-left-color: #adb5bd; }
.empty { text-align: center; color: #8a93a2; padding: 2.5rem 1rem; background: #fff; border-radius: 10px; border: 1px dashed #d5dae2; }
.empty i { font-size: 2rem; }
.tabs-scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.tabs-scroll .nav-link { white-space: nowrap; }
.stat-card { display: block; background: #fff; border-radius: 10px; padding: .7rem .8rem; text-decoration: none; border-top: 3px solid; }
.stat-card .stat-n { display: block; font-size: 1.6rem; font-weight: 700; color: #111; line-height: 1.1; }
.stat-card .stat-l { font-size: .8rem; color: #5b6472; }
.stat-primary { border-color: #1d4ed8; } .stat-danger { border-color: #dc3545; } .stat-warning { border-color: #ffc107; }

/* ---- Fiche bon ---- */
.bon-address { word-break: break-word; }
.form-card { border: 0; border-radius: 10px; overflow: hidden; box-shadow: 0 1px 2px rgba(15,27,45,.06); }
.section-head { color: #fff; font-weight: 600; text-transform: uppercase; font-size: .85rem; letter-spacing: .04em; border: 0; }
.section-date { background: var(--sec-date); }
.section-info { background: var(--sec-info); }
.section-agent { background: var(--sec-agent); }
.section-regul { background: var(--sec-regul); }
.lock-banner { background: #f6bd60; color: #3b2a00; padding: .5rem 1rem; font-size: .85rem; }
.field { padding: .55rem 0; border-bottom: 1px solid #eef0f3; }
.field:last-child { border-bottom: 0; }
.field-l { font-size: .75rem; font-weight: 700; text-transform: uppercase; color: #3a4250; margin-bottom: .2rem; }
.field-v { word-break: break-word; }
.info-agent { background: #fff8e1; border-radius: 6px; padding: .5rem .6rem; }
.take-btn { padding: 1rem; font-weight: 700; letter-spacing: .02em; box-shadow: 0 6px 18px rgba(200,16,46,.3); }
.check-list { display: flex; flex-direction: column; gap: .35rem; }
.check-item { display: flex; gap: .6rem; align-items: flex-start; padding: .55rem .7rem; border: 1px solid #dfe3ea; border-radius: 8px; background: #fff; cursor: pointer; }
.check-item .form-check-input { margin-top: .2rem; flex-shrink: 0; width: 1.2em; height: 1.2em; }
.check-item:has(input:checked) { border-color: #1d4ed8; background: #eef3ff; }
.photo-slot { padding: .6rem 0; border-bottom: 1px solid #eef0f3; }
.photo-slot:last-of-type { border-bottom: 0; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: .5rem; }
.photo-thumb { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: #e9edf2; }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-time { position: absolute; left: 4px; bottom: 4px; font-size: .62rem; background: rgba(0,0,0,.55); color: #fff; padding: 0 4px; border-radius: 4px; }
.photo-del { position: absolute; top: 4px; right: 4px; border: 0; background: rgba(0,0,0,.6); color: #fff; width: 26px; height: 26px; border-radius: 50%; font-size: .75rem; }
.upload-progress { margin-top: .5rem; color: #1d4ed8; font-size: .9rem; }
.recipients-box { background: #f1f8f7; border: 1px solid #cfe7e3; border-radius: 8px; padding: .6rem .7rem; }
.history .list-group-item { padding: .4rem .75rem; }

/* ---- Messagerie ---- */
.conv-item { display: flex; gap: .75rem; align-items: center; }
.conv-item.unread .fw-semibold { color: #000; }
.conv-avatar { width: 42px; height: 42px; border-radius: 50%; background: #e7ecf3; color: var(--spi-navy-2); display: grid; place-items: center; font-size: 1.2rem; flex-shrink: 0; }
.chat-wrap { display: flex; flex-direction: column; height: calc(100vh - 120px); height: calc(100dvh - 120px); background: #fff; border-radius: 12px; overflow: hidden; box-shadow: 0 1px 2px rgba(15,27,45,.06); }
.is-agent .chat-wrap { height: calc(100dvh - 175px); }
.chat-head { padding: .6rem .75rem; border-bottom: 1px solid #eef0f3; }
.chat-body { flex: 1; overflow-y: auto; padding: .75rem; background: #f7f8fa; display: flex; flex-direction: column; gap: .4rem; }
.msg { max-width: 82%; align-self: flex-start; background: #fff; border: 1px solid #e6e9ef; border-radius: 14px 14px 14px 4px; padding: .45rem .7rem; }
.msg.mine { align-self: flex-end; background: #dbe7ff; border-color: #c7d8fb; border-radius: 14px 14px 4px 14px; }
.msg.externe { border-left: 3px solid #f0a020; }
.msg-author { font-size: .72rem; font-weight: 700; color: #2f5d8a; }
.msg-text { word-break: break-word; white-space: normal; }
.msg-time { font-size: .65rem; color: #7a8291; text-align: right; }
.msg-img { display: block; max-width: 240px; max-height: 240px; border-radius: 8px; margin-top: .3rem; }
.msg-file { display: inline-block; margin-top: .3rem; }
.msg-system { align-self: center; font-size: .75rem; color: #6b7280; background: #eceff4; border-radius: 10px; padding: .2rem .6rem; text-align: center; }
.bon-link { font-weight: 600; }
.externes-banner { background: #ec8a4b; color: #fff; text-align: center; font-size: .82rem; padding: .3rem; }
.chat-form { display: flex; gap: .5rem; align-items: flex-end; padding: .55rem; border-top: 1px solid #eef0f3; }
.chat-form textarea { resize: none; max-height: 160px; }
.chat-attach { margin-bottom: 0; }

/* ---- Administration ---- */
.tile { display: flex; gap: .9rem; align-items: center; background: #fff; border-radius: 10px; padding: 1rem; text-decoration: none; color: inherit; height: 100%; box-shadow: 0 1px 2px rgba(15,27,45,.06); }
.tile:hover { box-shadow: 0 4px 14px rgba(15,27,45,.1); }
.tile > i { font-size: 1.6rem; color: var(--spi-red); }
.ref-name { min-width: 180px; }
.ref-sort { width: 64px; }
.logo-box { height: 72px; border: 1px dashed #cfd5df; border-radius: 8px; display: grid; place-items: center; background: #fff; overflow: hidden; }
.logo-box img { max-height: 64px; max-width: 100%; }
.user-actions { min-width: 320px; }

/* ---- Notifications à l'écran ---- */
.app-toast { position: fixed; left: 50%; bottom: 90px; transform: translate(-50%, 20px); opacity: 0; background: #111827; color: #fff;
  padding: .7rem 1rem; border-radius: 10px; z-index: 2000; max-width: 92vw; transition: all .25s; font-size: .9rem; }
.app-toast.err { background: #b42318; }
.app-toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 575.98px) {
  main.container-xl { padding-left: .75rem; padding-right: .75rem; }
  .user-actions { min-width: 280px; }
}

/* ---- Aide à l'installation (téléphone) ---- */
.install-bar { background: #eef3ff; border: 1px solid #c7d8fb; border-radius: 12px; padding: .8rem .9rem; margin-bottom: 1rem; }
.install-bar .bi-box-arrow-up { font-size: 1rem; }
.mail-log { max-height: 260px; overflow: auto; background: #111827; color: #d1d5db; padding: .6rem; border-radius: 6px; font-size: .72rem; white-space: pre-wrap; }
