/* ==========================================================
   Flamme Manager – Base CSS (v1)
   Fondations globales réutilisables pour tout le site
   - Variables, typographie, liens, boutons, formulaires, tables
   - Conteneurs, grilles simples, utilitaires
   - Thème clair/sombre (prefers-color-scheme)
   ========================================================== */

/* ---- Variables de thème ---- */
:root {
  --bg: #f7fafc;           /* fond global */
  --card: #ffffff;         /* fond cartes/éléments */
  --text: #111827;         /* texte principal */
  --muted: #6b7280;        /* texte secondaire */
  --border: #e5e7eb;       /* bordures */
  --accent: #ea580c;       /* couleur d'accent (orange) */
  --accent-weak: #ffedd5;  /* accent léger */
  --positive: #16a34a;     /* vert */
  --warning: #f59e0b;      /* ambre */
  --danger: #dc2626;       /* rouge */
  --link: #2563eb;         /* bleu pour liens */
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 12px rgba(0,0,0,.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --card: #0f172a;
    --text: #e5e7eb;
    --muted: #94a3b8;
    --border: #1f2937;
    --accent: #fb923c;
    --accent-weak: #3b2415;
    --link: #93c5fd;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.35);
  }
}

/* ---- Reset léger & typographie ---- */
* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img, svg, video, canvas { max-width: 100%; height: auto; }
figure { margin: 0; }

h1, h2, h3, h4 { color: var(--text); line-height: 1.25; margin: .5rem 0; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
small, .muted { color: var(--muted); }

/* ---- Liens ---- */
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible { outline: 2px dashed var(--accent); outline-offset: 2px; }

/* ---- Conteneur & layout générique ---- */
.container { max-width: 1200px; margin: 0 auto; padding: 0 1rem; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: .75rem;
  box-shadow: var(--shadow);
}
.card-header { padding: .9rem 1rem; border-bottom: 1px solid var(--border); font-weight: 600; }
.card-body { padding: 1rem; }

/* ---- Boutons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .55rem .9rem;
  border-radius: .6rem;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  transition: background .15s ease, border-color .15s ease, transform .05s ease;
}
.btn:hover { background: var(--accent-weak); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { filter: brightness(0.95); }

.btn-outline { background: transparent; }
.btn-success { background: var(--positive); color: #fff; border-color: var(--positive); }
.btn-warning { background: var(--warning); color: #111; border-color: var(--warning); }
.btn-danger  { background: var(--danger);  color: #fff; border-color: var(--danger); }

/* ---- Formulaires ---- */
.label { display: block; font-size: .9rem; color: var(--muted); margin-bottom: .25rem; }
.input, .select, .textarea {
  width: 100%;
  padding: .55rem .7rem;
  border: 1px solid var(--border);
  border-radius: .6rem;
  background: var(--card);
  color: var(--text);
}
.input:focus, .select:focus, .textarea:focus { outline: 2px solid var(--accent-weak); border-color: var(--accent); }
.input[readonly] { background: rgba(0,0,0,.03); }

.field { margin-bottom: .9rem; }
.field-inline { display: flex; gap: .75rem; align-items: center; }

/* ---- Tables génériques ---- */
.table {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: .75rem;
  overflow: hidden;
  background: var(--card);
}
.table thead { background: #f3f4f6; }
.table th, .table td { padding: .6rem .75rem; text-align: left; }
.table tbody tr + tr { border-top: 1px solid var(--border); }
.table tbody tr:hover { background: rgba(0,0,0,.03); }
@media (prefers-color-scheme: dark) {
  .table thead { background: #111827; }
  .table tbody tr:hover { background: rgba(255,255,255,.02); }
}

/* ---- Grilles utilitaires ---- */
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px)  {
  .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ---- Alertes & badges ---- */
.alert {
  padding: .8rem 1rem;
  border-radius: .6rem;
  border: 1px solid var(--border);
  background: var(--card);
}
.alert-success { border-color: rgba(22,163,74,.25); background: rgba(22,163,74,.08); color: var(--positive); }
.alert-warning { border-color: rgba(245,158,11,.25); background: rgba(245,158,11,.08); color: var(--warning); }
.alert-danger  { border-color: rgba(220,38,38,.25); background: rgba(220,38,38,.08); color: var(--danger); }

.badge { display:inline-block; padding:.15rem .5rem; font-size:.75rem; border-radius:.5rem; }
.badge.ok { background: rgba(22,163,74,.12); color: var(--positive); border: 1px solid rgba(22,163,74,.25); }
.badge.warn { background: rgba(245,158,11,.12); color: var(--warning); border: 1px solid rgba(245,158,11,.25); }
.badge.danger { background: rgba(220,38,38,.12); color: var(--danger); border: 1px solid rgba(220,38,38,.25); }

/* ---- Modale simple ---- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: none; align-items: center; justify-content: center; padding: 1rem;
}
.modal { width: min(640px, 100%); background: var(--card); border: 1px solid var(--border); border-radius: .75rem; box-shadow: var(--shadow); }
.modal.show ~ .modal-backdrop, .modal-backdrop.show { display: flex; }

/* ---- Utilitaires spacing & align ---- */
.mt-0{margin-top:0}.mt-1{margin-top:.25rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-4{margin-top:1rem}
.mb-0{margin-bottom:0}.mb-1{margin-bottom:.25rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}
.p-0{padding:0}.p-1{padding:.25rem}.p-2{padding:.5rem}.p-3{padding:.75rem}.p-4{padding:1rem}
.text-center{text-align:center}.text-right{text-align:right}
.w-100{width:100%}

/* ---- Impression ---- */
@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
}
