/* ============================================================
   app.css — Design System FIRST OPTIC v2.0
   Variables CSS, typographie, scrollbars, utilitaires globaux
   ============================================================ */

/* ─── GOOGLE FONTS IMPORT ─────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ─── DESIGN TOKENS CSS ───────────────────────────────────── */
:root {
  /* Couleurs primaires */
  --fo-primary:          #1D4ED8;
  --fo-primary-hover:    #2563EB;
  --fo-navy:             #0A192F;
  --fo-navy-hover:       #0D2137;
  --fo-tertiary:         #1E293B;

  /* Accent */
  --fo-accent:           #0EA5E9;

  /* Statuts */
  --fo-success:          #059669;
  --fo-success-bg:       #D1FAE5;
  --fo-success-text:     #065F46;
  --fo-warning:          #D97706;
  --fo-warning-bg:       #FEF3C7;
  --fo-warning-text:     #92400E;
  --fo-danger:           #DC2626;
  --fo-danger-hover:     #EF4444;
  --fo-danger-bg:        #FEE2E2;
  --fo-danger-text:      #991B1B;
  --fo-info:             #2563EB;
  --fo-info-bg:          #DBEAFE;
  --fo-info-text:        #1E40AF;

  /* Surfaces Light Mode */
  --fo-background:       #F8FAFC;
  --fo-background-gray:  #F1F5F9;
  --fo-surface:          #FFFFFF;
  --fo-lines:            #E2E8F0;
  --fo-lines-input:      #CBD5E1;

  /* Textes */
  --fo-text-primary:     #0F172A;
  --fo-text-secondary:   #475569;
  --fo-text-disabled:    #94A3B8;
  --fo-text-on-dark:     #F8FAFC;

  /* Espacement (rythme 4px) */
  --fo-space-1:          4px;
  --fo-space-2:          8px;
  --fo-space-3:          12px;
  --fo-space-4:          16px;
  --fo-space-6:          24px;
  --fo-space-8:          32px;

  /* Rayons */
  --fo-radius-sm:        4px;
  --fo-radius:           8px;
  --fo-radius-lg:        12px;
  --fo-radius-full:      9999px;

  /* Transitions */
  --fo-transition:       all 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --fo-transition-color: color 150ms cubic-bezier(0.4, 0, 0.2, 1), background-color 150ms cubic-bezier(0.4, 0, 0.2, 1), border-color 150ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Ombres */
  --fo-shadow-card:      0 1px 3px 0 rgba(10, 25, 47, 0.06), 0 1px 2px -1px rgba(10, 25, 47, 0.06);
  --fo-shadow-dialog:    0 4px 12px 0 rgba(10, 25, 47, 0.08);
  --fo-shadow-appbar:    0 1px 2px 0 rgba(10, 25, 47, 0.12);
}

/* ─── RESET & BASE ────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  font-family: 'Inter', Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--fo-text-primary);
  background-color: var(--fo-background);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── SCROLLBAR PREMIUM ───────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--fo-background-gray);
}

::-webkit-scrollbar-thumb {
  background: var(--fo-lines-input);
  border-radius: var(--fo-radius-full);
  transition: var(--fo-transition-color);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--fo-text-disabled);
}

/* ─── POLICE MONOSPACE (VALEURS CLINIQUES) ────────────────── */
.font-mono {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 500;
}

/* ─── LOADING BLAZOR (requis par le framework) ────────────── */
.loading-progress {
  position: relative;
  display: block;
  width: 8rem;
  height: 8rem;
  margin: 20vh auto 1rem auto;
}

.loading-progress circle {
  fill: none;
  stroke: var(--fo-lines);
  stroke-width: 0.5rem;
  transform-origin: 50% 50%;
  transform: rotate(-90deg);
}

.loading-progress circle:last-child {
  stroke: var(--fo-primary);
  stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
  transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
  position: absolute;
  text-align: center;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  color: var(--fo-text-secondary);
  inset: calc(20vh + 3.5rem) 0 auto 0;
}

.loading-progress-text:after {
  content: var(--blazor-load-percentage-text, "Chargement...");
}

/* ─── BLAZOR ERROR UI ─────────────────────────────────────── */
#blazor-error-ui {
  background: var(--fo-danger-bg);
  border-top: 2px solid var(--fo-danger);
  color: var(--fo-danger-text);
  bottom: 0;
  box-sizing: border-box;
  display: none;
  left: 0;
  padding: 0.6rem 1.25rem 0.7rem 1.25rem;
  position: fixed;
  width: 100%;
  z-index: 1000;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
}

#blazor-error-ui .dismiss {
  cursor: pointer;
  position: absolute;
  right: 0.75rem;
  top: 0.5rem;
}

/* ─── VALIDATION FORMULAIRES ──────────────────────────────── */
.valid.modified:not([type=checkbox]) {
  outline: 1px solid var(--fo-success);
}

.invalid {
  outline: 1px solid var(--fo-danger);
}

.validation-message {
  color: var(--fo-danger);
  font-size: 12px;
  font-weight: 500;
  margin-top: 2px;
}

/* ─── MUDBLAZOR OVERRIDES GLOBAUX ─────────────────────────── */

/* AppBar avec branding Navy */
.mud-appbar {
  box-shadow: var(--fo-shadow-appbar) !important;
}

/* Drawer premium (sidebar) */
.mud-drawer {
  box-shadow: 2px 0 8px 0 rgba(10, 25, 47, 0.08) !important;
}

/* Navbar items — état actif */
.mud-nav-item.active > .mud-nav-link {
  background-color: rgba(29, 78, 216, 0.12) !important;
  color: #3B82F6 !important;
  font-weight: 600;
}

.mud-nav-item.active > .mud-nav-link .mud-nav-link-icon {
  color: #3B82F6 !important;
}

/* Table hover row */
.mud-table-row:hover {
  background-color: rgba(29, 78, 216, 0.04) !important;
  transition: background-color 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Chips status */
.fo-chip-success {
  background-color: var(--fo-success-bg) !important;
  color: var(--fo-success-text) !important;
}

.fo-chip-warning {
  background-color: var(--fo-warning-bg) !important;
  color: var(--fo-warning-text) !important;
}

.fo-chip-danger {
  background-color: var(--fo-danger-bg) !important;
  color: var(--fo-danger-text) !important;
}

.fo-chip-info {
  background-color: var(--fo-info-bg) !important;
  color: var(--fo-info-text) !important;
}

/* ─── UTILITAIRES TYPOGRAPHIE ─────────────────────────────── */
.fo-text-primary    { color: var(--fo-text-primary) !important; }
.fo-text-secondary  { color: var(--fo-text-secondary) !important; }
.fo-text-disabled   { color: var(--fo-text-disabled) !important; }
.fo-text-on-dark    { color: var(--fo-text-on-dark) !important; }

.fo-fw-400 { font-weight: 400; }
.fo-fw-500 { font-weight: 500; }
.fo-fw-600 { font-weight: 600; }
.fo-fw-700 { font-weight: 700; }

/* ─── UTILITAIRES SURFACES ────────────────────────────────── */
.fo-surface {
  background-color: var(--fo-surface);
  border: 1px solid var(--fo-lines);
  border-radius: var(--fo-radius);
}

.fo-surface-elevated {
  background-color: var(--fo-surface);
  border: 1px solid var(--fo-lines);
  border-radius: var(--fo-radius);
  box-shadow: var(--fo-shadow-card);
}

/* ─── ANIMATIONS GLOBALES ─────────────────────────────────── */
@keyframes fo-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fo-slide-in {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes fo-pulse-brand {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

.fo-fade-in {
  animation: fo-fade-in 200ms cubic-bezier(0.4, 0, 0.2, 1) both;
}

.fo-slide-in {
  animation: fo-slide-in 200ms cubic-bezier(0.4, 0, 0.2, 1) both;
}

/* ─── PAGES — LAYOUT STANDARD ─────────────────────────────── */
.fo-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--fo-space-6);
}

.fo-page-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--fo-navy);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.fo-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fo-text-secondary);
  padding: 0 16px;
}

/* ─── SEARCH BAR ──────────────────────────────────────────── */
.fo-search-bar {
  border: 1px solid var(--fo-lines);
  border-radius: var(--fo-radius);
  padding: var(--fo-space-3) var(--fo-space-4);
  background-color: var(--fo-surface);
  transition: border-color 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

.fo-search-bar:focus-within {
  border-color: var(--fo-primary);
}

/* ─── CARD INTERACTIVE ────────────────────────────────── */
.fo-card-interactive {
  cursor: pointer;
  transition: var(--fo-transition-color);
}

.fo-card-interactive:hover {
  border-color: var(--fo-primary) !important;
  box-shadow: 0 2px 8px rgba(29, 78, 216, 0.08) !important;
}

/* ─── COMPOSANTS SEARCH ───────────────────────────────── */
.fo-search-focus:focus-within {
  border-color: var(--fo-primary) !important;
  transition: border-color 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

.fo-search-field .mud-input-slot {
  padding-left: 0;
}

/* ─── MUD OVERRIDES COMPLÉMENTAIRES ──────────────────── */

/* Supprimer les ombres sur les boutons MudFab et MudIconButton */
.mud-button-root:not(.mud-button-fab) {
  letter-spacing: normal !important;
}

/* Style snackbar */
.mud-snackbar {
  border-radius: var(--fo-radius) !important;
  font-family: 'Inter', sans-serif !important;
  font-size: 13px !important;
}

/* Style dialog */
.mud-dialog {
  border-radius: var(--fo-radius-lg) !important;
  box-shadow: var(--fo-shadow-dialog) !important;
}

.mud-dialog-title {
  font-family: 'Inter', sans-serif !important;
  font-weight: 600 !important;
  font-size: 16px !important;
}

/* Overline text dans NavMenu */
.mud-nav-menu .mud-typography-overline {
  font-size: 10px !important;
  letter-spacing: 0.1em !important;
}

/* Table header styling */
.mud-table-head .mud-table-cell {
  background-color: var(--fo-background-gray) !important;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fo-text-secondary);
}

/* Pagination French style */
.mud-table-pagination .mud-input {
  font-size: 13px !important;
}

/* ─── LOADING BLUR OVERLAY ────────────────────────── */
.fo-loading-blur {
  filter: blur(3px);
  opacity: 0.5;
  transition: filter 200ms ease, opacity 200ms ease;
  user-select: none;
  pointer-events: none;
}

