/* ==========================================================================
   Freda Workspace — feuille de style partagée
   Complète Tailwind (CDN) avec les composants de la marque.
   Couleurs : voir 07-Koule-ak-Polis/freda-colors.css du pack d'identité.
   ========================================================================== */

:root {
  /* Marque */
  --fw-midnight: #061137;
  --fw-navy: #071653;
  --fw-marine: #1E3A8A;
  --fw-deep: #173A9E;
  --fw-blue: #2B64E4;
  --fw-royal: #2563EB;
  --fw-sky: #4A95F5;
  --fw-mist: #EEF3FD;
  --fw-gold: #F5B83D;

  /* Interface */
  --fw-canvas: #F8FAFC;
  --fw-surface: #FFFFFF;
  --fw-ink: #0B1533;
  --fw-text: #334155;
  --fw-muted: #5B6478;
  --fw-line: #E3E8F2;
  --fw-line-strong: #CBD5E6;

  /* États */
  --fw-cta: #10B981;
  --fw-cta-dark: #059669;
  --fw-success-bg: #E7F8F1;
  --fw-warn: #B45309;
  --fw-warn-bg: #FEF5E3;
  --fw-danger: #DC2626;
  --fw-danger-bg: #FDECEC;

  --fw-gradient: linear-gradient(135deg, #071653 0%, #173A9E 42%, #2B64E4 78%, #4A95F5 100%);
  --fw-radius: 14px;
  --fw-shadow: 0 1px 2px rgba(7, 22, 83, .06), 0 8px 24px -12px rgba(7, 22, 83, .18);
  --fw-shadow-lg: 0 2px 4px rgba(7, 22, 83, .05), 0 24px 48px -20px rgba(7, 22, 83, .35);

  color-scheme: light;
}

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  background: var(--fw-canvas);
  color: var(--fw-text);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
h1, h2, h3, h4 { font-family: 'Manrope', 'Inter', system-ui, sans-serif; color: var(--fw-ink); text-wrap: balance; }
.font-display { font-family: 'Manrope', 'Inter', system-ui, sans-serif; }
.tabular { font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, Consolas, monospace; }

/* Gouttière latérale (respecte les encoches des téléphones) */
.gutter {
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
@media (min-width: 768px) { .gutter { padding-left: max(32px, env(safe-area-inset-left, 0px)); padding-right: max(32px, env(safe-area-inset-right, 0px)); } }

.text-gradient { background: var(--fw-gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.bg-brand-gradient { background: var(--fw-gradient); }
.eyebrow { font-size: .75rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--fw-blue); }

/* Trame de fond « grille DNS » */
/* Trame retirée à la demande : fond uni. */
.bg-grid { background-image: none; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font-weight: 600; font-size: .9375rem; line-height: 1.25rem;
  padding: .75rem 1.25rem; border-radius: 10px; border: 1px solid transparent;
  transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s, transform .15s;
  cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:focus-visible, .focus-ring:focus-visible { outline: 3px solid rgba(43, 100, 228, .45); outline-offset: 2px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.btn-sm { padding: .5rem .875rem; font-size: .875rem; border-radius: 8px; }
.btn-sm svg { width: 16px; height: 16px; }
.btn-lg { padding: 1rem 1.5rem; font-size: 1rem; }

.btn-cta { background: var(--fw-cta); color: #fff; box-shadow: 0 6px 16px -8px rgba(16, 185, 129, .8); }
.btn-cta:hover:not(:disabled) { background: var(--fw-cta-dark); }
.btn-primary { background: var(--fw-blue); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--fw-deep); }
.btn-navy { background: var(--fw-navy); color: #fff; }
.btn-navy:hover:not(:disabled) { background: var(--fw-deep); }
.btn-outline { background: var(--fw-surface); color: var(--fw-ink); border-color: var(--fw-line-strong); }
.btn-outline:hover:not(:disabled) { border-color: var(--fw-blue); color: var(--fw-blue); }
.btn-ghost { background: transparent; color: var(--fw-text); }
.btn-ghost:hover:not(:disabled) { background: var(--fw-mist); color: var(--fw-blue); }
.btn-danger { background: var(--fw-danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #B91C1C; }
.btn-white { background: #fff; color: var(--fw-navy); }
.btn-white:hover:not(:disabled) { background: var(--fw-mist); }
.btn-icon { padding: .5rem; border-radius: 8px; }

/* ---------- Cartes & surfaces ---------- */
.card { background: var(--fw-surface); border: 1px solid var(--fw-line); border-radius: var(--fw-radius); }
.card-elevated { background: var(--fw-surface); border: 1px solid var(--fw-line); border-radius: var(--fw-radius); box-shadow: var(--fw-shadow); }

/* ---------- Formulaires ---------- */
.label { display: block; font-size: .875rem; font-weight: 600; color: var(--fw-ink); margin-bottom: .375rem; }
.hint { font-size: .8125rem; color: var(--fw-muted); margin-top: .375rem; }
.input, .select, .textarea {
  width: 100%; background: #fff; color: var(--fw-ink);
  border: 1px solid var(--fw-line-strong); border-radius: 10px;
  padding: .7rem .875rem; font-size: .9375rem; line-height: 1.4;
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder, .textarea::placeholder { color: #94A0B8; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--fw-blue); box-shadow: 0 0 0 4px rgba(43, 100, 228, .14); }
.input.is-invalid { border-color: var(--fw-danger); box-shadow: 0 0 0 4px rgba(220, 38, 38, .1); }
.field-error { font-size: .8125rem; color: var(--fw-danger); margin-top: .375rem; display: none; }
.field-error.show { display: block; }
.input-group { position: relative; }
.input-group > .input { padding-left: 2.6rem; }
.input-group > .input-icon { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: var(--fw-muted); width: 18px; height: 18px; pointer-events: none; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%235B6478' stroke-width='2' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .75rem center; padding-right: 2.25rem; }
.checkbox { width: 18px; height: 18px; accent-color: var(--fw-blue); flex-shrink: 0; }

/* Interrupteur */
.switch { position: relative; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; background: var(--fw-line-strong); border-radius: 999px; transition: background .2s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; background: #fff; border-radius: 50%; transition: transform .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--fw-cta); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 3px solid rgba(43, 100, 228, .45); outline-offset: 2px; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: .3rem; font-size: .75rem; font-weight: 600; padding: .2rem .55rem; border-radius: 999px; white-space: nowrap; line-height: 1.2; }
.badge svg { width: 13px; height: 13px; }
.badge-success { background: var(--fw-success-bg); color: #047857; }
.badge-warn { background: var(--fw-warn-bg); color: var(--fw-warn); }
.badge-danger { background: var(--fw-danger-bg); color: var(--fw-danger); }
.badge-info { background: var(--fw-mist); color: var(--fw-deep); }
.badge-neutral { background: #EEF1F6; color: var(--fw-muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

/* ---------- Onglets segmentés ---------- */
.segmented { display: inline-flex; background: #EAF0FB; border-radius: 12px; padding: 4px; gap: 4px; }
.segmented button { padding: .5rem 1rem; border-radius: 9px; font-weight: 600; font-size: .875rem; color: var(--fw-muted); transition: all .15s; display: inline-flex; align-items: center; gap: .4rem; }
.segmented button[aria-selected="true"] { background: #fff; color: var(--fw-ink); box-shadow: 0 1px 3px rgba(7, 22, 83, .12); }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--fw-line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button, .tabs a { padding: .75rem 1rem; font-weight: 600; font-size: .9rem; color: var(--fw-muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; align-items: center; gap: .45rem; }
.tabs button svg, .tabs a svg { width: 16px; height: 16px; }
.tabs [aria-selected="true"] { color: var(--fw-blue); border-bottom-color: var(--fw-blue); }

/* ---------- Tableaux ---------- */
.table-wrap { position: relative; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table th { text-align: left; font-weight: 600; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--fw-muted); padding: .75rem 1rem; background: #F6F8FC; border-bottom: 1px solid var(--fw-line); white-space: nowrap; }
.table td { padding: .875rem 1rem; border-bottom: 1px solid var(--fw-line); vertical-align: middle; color: var(--fw-ink); }
.table tbody tr:hover { background: #FAFBFE; }
.table tbody tr:last-child td { border-bottom: none; }

/* Barre de progression */
.meter { height: 6px; background: #E8EDF6; border-radius: 999px; overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 999px; background: var(--fw-blue); }

/* ---------- Modale ---------- */
.modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; padding: 16px; }
@media (min-width: 640px) { .modal { align-items: center; } }
.modal[hidden] { display: none !important; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(6, 17, 55, .55); backdrop-filter: blur(3px); animation: fw-fade .2s ease; }
.modal-panel { position: relative; width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow-y: auto; background: #fff; border-radius: 18px; box-shadow: var(--fw-shadow-lg); animation: fw-rise .25s ease; }
.modal-panel.wide { max-width: 680px; }
.modal-panel { overflow-x: hidden; }
.modal-panel .grid { grid-template-columns: minmax(0, 1fr); }
.modal-panel .grid > * { min-width: 0; }
@media (min-width: 640px) { .modal-panel .grid.sm\:grid-cols-\[140px_1fr\] { grid-template-columns: 140px minmax(0, 1fr); } .modal-panel .grid.sm\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- Notifications (toast) ---------- */
#fw-toasts { position: fixed; z-index: 80; top: calc(14px + env(safe-area-inset-top, 0px)); left: 14px; right: 14px; display: flex; flex-direction: column; align-items: center; gap: .6rem; pointer-events: none; }
@media (min-width: 640px) { #fw-toasts { left: auto; right: 20px; top: 84px; align-items: flex-end; } }
.toast { position: relative; overflow: hidden; pointer-events: auto; display: flex; align-items: center; gap: .75rem; width: 100%; max-width: 380px; background: #fff; color: var(--fw-ink); padding: .7rem .6rem .8rem .7rem; border-radius: 16px; border: 1px solid var(--fw-line); box-shadow: 0 14px 34px -10px rgba(6, 17, 55, .3), 0 2px 6px rgba(6, 17, 55, .06); font-size: .875rem; animation: fw-toast-in .4s cubic-bezier(.2, .9, .3, 1.15); }
.toast.out { animation: fw-toast-out .25s ease forwards; }
.toast .t-ico { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; }
.toast .t-ico svg { width: 20px; height: 20px; }
.toast.success .t-ico { background: #ECFDF5; color: #059669; }
.toast.error .t-ico { background: #FEF2F2; color: #DC2626; }
.toast.info .t-ico { background: var(--fw-mist); color: var(--fw-blue); }
.toast .t-body { min-width: 0; flex: 1; }
.toast .t-title { font-weight: 700; color: var(--fw-ink); line-height: 1.3; word-break: break-word; }
.toast .t-title.t-solo { font-weight: 600; }
.toast .t-msg { margin-top: 1px; color: #475569; line-height: 1.3; word-break: break-word; font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8125rem; }
.toast .t-close { flex-shrink: 0; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; color: #94A0B8; }
.toast .t-close:hover { background: var(--fw-mist); color: var(--fw-ink); }
.toast .t-close svg { width: 16px; height: 16px; }
.toast .t-bar { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; transform-origin: left; animation: fw-toast-bar 3.8s linear forwards; }
.toast.success .t-bar { background: #10B981; }
.toast.error .t-bar { background: #DC2626; }
.toast.info .t-bar { background: var(--fw-blue); }
@keyframes fw-toast-in { from { opacity: 0; transform: translateY(-14px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes fw-toast-out { to { opacity: 0; transform: translateY(-8px) scale(.97); } }
@keyframes fw-toast-bar { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@media (prefers-reduced-motion: reduce) { .toast, .toast.out { animation: none; } .toast .t-bar { animation-duration: 3.8s; } }

/* Accordéon */
.accordion-item summary { list-style: none; cursor: pointer; }
.accordion-item summary::-webkit-details-marker { display: none; }
.accordion-item[open] .acc-icon { transform: rotate(45deg); }
.acc-icon { transition: transform .2s; }

/* Chargement */
.spinner { width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: fw-spin .7s linear infinite; display: inline-block; }
.skeleton { background: linear-gradient(90deg, #EDF1F8 25%, #F6F8FC 50%, #EDF1F8 75%); background-size: 200% 100%; animation: fw-shimmer 1.2s infinite; border-radius: 8px; }

/* Animations */
@keyframes fw-spin { to { transform: rotate(360deg); } }
@keyframes fw-fade { from { opacity: 0; } }
@keyframes fw-rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes fw-shimmer { to { background-position: -200% 0; } }
@keyframes fw-pulse-ring { 0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, .5); } 100% { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); } }
.pulse-ring { animation: fw-pulse-ring 1.8s infinite; }
.fade-in { animation: fw-rise .35s ease both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ---------- Espace client (layout) ---------- */
.espace-layout { display: grid; grid-template-columns: minmax(0, 1fr); min-height: 100vh; }
@media (min-width: 1024px) { .espace-layout { grid-template-columns: 264px minmax(0, 1fr); } }
.espace-sidebar { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 50; transform: translateX(-100%); transition: transform .25s ease; background: var(--fw-midnight); color: #C7D2EA; display: flex; flex-direction: column; padding-top: env(safe-area-inset-top, 0px); padding-left: env(safe-area-inset-left, 0px); }
.espace-sidebar.open { transform: none; }
@media (min-width: 1024px) { .espace-sidebar { position: sticky; top: 0; height: 100vh; width: auto; transform: none; } }
.side-link { display: flex; align-items: center; gap: .75rem; padding: .65rem .85rem; border-radius: 10px; font-weight: 500; font-size: .9rem; color: #B9C5E0; transition: background .15s, color .15s; }
.side-link svg { width: 18px; height: 18px; }
.side-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.side-link[aria-current="page"] { background: rgba(74, 149, 245, .16); color: #fff; }
.side-link[aria-current="page"] svg { color: var(--fw-sky); }
.espace-topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 40; background: rgba(248, 250, 252, .9); backdrop-filter: blur(10px); border-bottom: 1px solid var(--fw-line); }
.sidebar-overlay { position: fixed; inset: 0; background: rgba(6, 17, 55, .5); z-index: 45; }

/* Maquette de téléphone (section App mobile) */
.phone { width: 260px; max-width: 100%; aspect-ratio: 9 / 19; border-radius: 40px; background: #0B1533; padding: 10px; box-shadow: var(--fw-shadow-lg); position: relative; }
.phone-screen { width: 100%; height: 100%; border-radius: 31px; overflow: hidden; background: #fff; display: flex; flex-direction: column; }
.phone-notch { position: absolute; top: 18px; left: 50%; transform: translateX(-50%); width: 84px; height: 22px; border-radius: 999px; background: #0B1533; z-index: 2; }

[hidden] { display: none !important; }

/* ==========================================================================
   Écran de chargement des pages (anneau dégradé + halo).
   Masqué par monitor.js à la fin du chargement ; disparaît tout seul après 6 s
   si JavaScript est indisponible.
   ========================================================================== */
#page-loader {
  position: fixed; inset: 0; z-index: 9999; display: grid; place-items: center;
  background: #fff; opacity: 1; transition: opacity .35s ease, visibility .35s ease;
  animation: fw-loader-failsafe .35s ease 6s forwards;
}
#page-loader.done { opacity: 0; visibility: hidden; pointer-events: none; }
#page-loader::before {   /* halo */
  content: ""; position: absolute; width: 190px; height: 190px; border-radius: 50%;
  background: radial-gradient(circle, rgba(47, 155, 255, .14) 0%, rgba(47, 155, 255, .06) 40%, rgba(47, 155, 255, 0) 70%);
  animation: fw-loader-glow 1.8s ease-in-out infinite;
}
#page-loader .fw-ring {   /* anneau animé : assets/img/loader.svg (s'ouvre, se rétracte, se referme avec des étincelles) */
  position: relative; width: 72px; height: 72px;
  filter: drop-shadow(0 0 7px rgba(47, 155, 255, .4));
  animation: fw-loader-in .3s ease .15s backwards;
}
@keyframes fw-loader-glow { 0%, 100% { transform: scale(.92); opacity: .75; } 50% { transform: scale(1.08); opacity: 1; } }
@keyframes fw-loader-in { from { opacity: 0; } }
@keyframes fw-loader-failsafe { to { opacity: 0; visibility: hidden; pointer-events: none; } }
@media (prefers-reduced-motion: reduce) {
  #page-loader::before { animation: none; }
}
