/* ── Reset & variables ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bleu:       #0f3460;
  --accent:     #e94560;
  --gris-bg:    #f0f2f7;
  --gris-card:  #ffffff;
  --gris-bord:  #e2e8f0;
  --texte:      #1a202c;
  --texte-doux: #64748b;
  --danger:     #e53e3e;
  --succes:     #38a169;
  --or:         #f5a623;
  --radius-sm:  8px;
  --radius:     16px;
  --ombre:      0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -1px rgba(0,0,0,.04);
  --transition: .25s cubic-bezier(.4,0,.2,1);
}

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--gris-bg);
  color: var(--texte);
  min-height: 100vh;
  line-height: 1.5;
  background-image: url('./bima.jpg');
  background-size: cover;
  background-attachment: fixed;
  background-position: center;
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(15, 33, 62, .45);
  z-index: 0;
  pointer-events: none;
}

/* ── Header ────────────────────────────────────────────────── */
header {
  background: linear-gradient(135deg, rgba(15,52,96,.92) 0%, rgba(22,33,62,.95) 60%, rgba(15,52,96,.92) 100%);
  color: #fff;
  padding: 1.25rem 2rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(15,52,96,.5);
  backdrop-filter: blur(6px);
}
.logo-img { height: 56px; width: auto; flex-shrink: 0; border-radius: 8px; object-fit: contain; }
.header-text { flex: 1; min-width: 0; }
.header-text .logo-text { font-size: 1.15rem; font-weight: 700; letter-spacing: -.2px; }
.header-text .subtitle { font-size: .78rem; opacity: .75; margin-top: 3px; line-height: 1.6; }

.header-status {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-shrink: 0;
}

.btn-menu {
  font-size: .74rem;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  padding: .4rem .8rem;
  border-radius: 20px;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.3);
  white-space: nowrap;
  transition: all var(--transition);
}
.btn-menu:hover { background: rgba(255,255,255,.24); border-color: rgba(255,255,255,.55); }

.badge-mode {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: .3rem .7rem;
  border-radius: 20px;
  white-space: nowrap;
}
.badge-mode.demo { background: rgba(245,166,35,.2); color: #ffd28a; border: 1px solid rgba(245,166,35,.5); }
.badge-mode.live { background: rgba(56,161,105,.2); color: #9ae6b4; border: 1px solid rgba(56,161,105,.5); }

/* ── Conteneur ─────────────────────────────────────────────── */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1rem 3rem;
  position: relative;
  z-index: 1;
}

/* ── Carte ─────────────────────────────────────────────────── */
.card {
  background: var(--gris-card);
  border-radius: var(--radius);
  box-shadow: var(--ombre);
  padding: 2rem;
  margin-bottom: 1.25rem;
  border: 1px solid rgba(255,255,255,.8);
  animation: slideUp .3s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--bleu);
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: .5rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--gris-bord);
}
.card-title .icon {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, #e8f0fe, #d2e3fc);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: .95rem;
  flex-shrink: 0;
}
.card-title-date {
  margin-left: auto;
  font-size: .78rem;
  font-weight: 600;
  color: var(--texte-doux);
}

/* ── Champs ────────────────────────────────────────────────── */
.field { margin-bottom: 1.25rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }

.field label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--texte-doux);
  margin-bottom: .45rem;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.field label .req { color: var(--accent); margin-left: 2px; }

.field input,
.field select {
  width: 100%;
  padding: .75rem 1rem;
  border: 1.5px solid var(--gris-bord);
  border-radius: var(--radius-sm);
  font-size: .95rem;
  color: var(--texte);
  background: #fafbfd;
  transition: all var(--transition);
  font-family: inherit;
}
.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--bleu);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(15,52,96,.1);
}
.field.has-error input,
.field.has-error select { border-color: var(--danger); background: #fff5f5; }

.field .err-msg {
  font-size: .76rem;
  color: var(--danger);
  margin-top: .3rem;
  display: none;
  font-weight: 500;
}
.field.has-error .err-msg { display: block; }

/* ── Boutons ───────────────────────────────────────────────── */
.btn-row { display: flex; gap: .75rem; justify-content: flex-end; margin-top: 1.5rem; }
.btn {
  padding: .8rem 1.75rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: .9rem;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  font-family: inherit;
  letter-spacing: .2px;
}
.btn-primary {
  background: linear-gradient(135deg, var(--bleu) 0%, #1a4a7a 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(15,52,96,.35);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(15,52,96,.45); }
.btn-primary:active { transform: translateY(0); }
.btn-ghost { background: transparent; color: var(--texte-doux); border: 1.5px solid var(--gris-bord); }
.btn-ghost:hover { background: var(--gris-bg); color: var(--texte); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }

/* ── Alertes ───────────────────────────────────────────────── */
.alert {
  padding: .9rem 1.1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: .88rem;
  font-weight: 500;
  display: none;
  animation: slideUp .2s ease;
}
.alert.show { display: block; }
.alert-success { background: #f0fff4; border: 1.5px solid #9ae6b4; color: #276749; }
.alert-error   { background: #fff5f5; border: 1.5px solid #feb2b2; color: #9b2c2c; }
.alert-info    { background: #ebf8ff; border: 1.5px solid #90cdf4; color: #2a4365; }

/* ── Filtre / recherche ────────────────────────────────────── */
.filtre-row {
  display: flex;
  gap: .75rem;
  margin-bottom: 1.25rem;
}
.filtre-row input[type="search"] {
  flex: 1;
  min-width: 0;
  padding: .7rem 1rem;
  border: 1.5px solid var(--gris-bord);
  border-radius: var(--radius-sm);
  font-size: .9rem;
  background: #fafbfd;
  font-family: inherit;
  color: var(--texte);
}
.filtre-row input[type="search"]:focus {
  outline: none; border-color: var(--bleu); background: #fff;
  box-shadow: 0 0 0 3px rgba(15,52,96,.1);
}
.filtre-etage {
  flex-shrink: 0;
  padding: .7rem .9rem;
  border: 1.5px solid var(--gris-bord);
  border-radius: var(--radius-sm);
  font-size: .9rem;
  background: #fafbfd;
  font-family: inherit;
  color: var(--texte);
}

/* ── Ligne de prêt en cours ────────────────────────────────── */
.pret-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .95rem 0;
  border-bottom: 1px solid var(--gris-bord);
}
.pret-row:last-child { border-bottom: none; }

.pret-emp {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 76px;
  font-weight: 800;
  color: var(--bleu);
  background: #f0f5ff;
  border: 1px solid #d2e3fc;
  border-radius: var(--radius-sm);
  padding: .5rem .5rem;
  text-align: center;
  flex-shrink: 0;
}
.pret-emp .etage { font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--texte-doux); }
.pret-emp .lieu { font-size: .82rem; line-height: 1.15; }

.pret-info { flex: 1; min-width: 0; }
.pret-nom { font-weight: 700; font-size: .95rem; }
.pret-meta { font-size: .77rem; color: var(--texte-doux); margin-top: 3px; }

.pill {
  display: inline-block;
  font-size: .7rem;
  font-weight: 700;
  padding: .12rem .5rem;
  border-radius: 20px;
  background: #fff0f3;
  color: #b3243c;
  border: 1px solid #f7c4cf;
  margin-right: .35rem;
  vertical-align: middle;
}

.btn-retour {
  flex-shrink: 0;
  padding: .6rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: .82rem;
  cursor: pointer;
  border: none;
  background: linear-gradient(135deg, var(--succes) 0%, #2f855a 100%);
  color: #fff;
  box-shadow: 0 3px 10px rgba(56,161,105,.35);
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-retour:hover { transform: translateY(-1px); box-shadow: 0 5px 14px rgba(56,161,105,.45); }

.btn-suppr {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 1.5px solid var(--gris-bord);
  background: #fff;
  color: var(--texte-doux);
  font-size: .85rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: all .15s;
}
.btn-suppr:hover { border-color: var(--danger); background: #fff5f5; color: var(--danger); }

.vide {
  font-size: .85rem;
  color: var(--texte-doux);
  font-style: italic;
  padding: .75rem 0;
  text-align: center;
}

/* ── Statistiques ──────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .75rem;
  margin-bottom: 1.25rem;
}
.stat-tile {
  background: #fafbfd;
  border: 1px solid var(--gris-bord);
  border-radius: var(--radius-sm);
  padding: 1rem .75rem;
  text-align: center;
}
.stat-num { font-size: 1.7rem; font-weight: 800; color: var(--bleu); line-height: 1; }
.stat-lib { font-size: .72rem; font-weight: 600; color: var(--texte-doux); margin-top: .4rem; text-transform: uppercase; letter-spacing: .03em; }
.stat-tile.accent .stat-num { color: var(--accent); }

.stats-repartition h4 {
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--texte-doux);
  margin: 1rem 0 .6rem;
  font-weight: 700;
}
.bar-line { display: flex; align-items: center; gap: .6rem; margin-bottom: .5rem; font-size: .82rem; }
.bar-lib { width: 130px; flex-shrink: 0; color: var(--texte); font-weight: 600; }
.bar-track { flex: 1; height: 12px; background: #edf2f7; border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(135deg, var(--bleu), #1a4a7a); border-radius: 6px; }
.bar-val { width: 34px; flex-shrink: 0; text-align: right; font-weight: 700; color: var(--texte-doux); }

.footer-note {
  text-align: center;
  font-size: .75rem;
  color: rgba(255,255,255,.75);
  padding: .5rem 0 1.5rem;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 560px) {
  header { padding: 1rem; gap: .75rem; }
  .logo-img { height: 42px; }
  .header-text .logo-text { font-size: .95rem; }
  .container { padding: 1rem .75rem 2rem; }
  .card { padding: 1.25rem; }
  .grid-2 { grid-template-columns: 1fr; }
  .btn-row { flex-direction: column-reverse; }
  .btn-row .btn { width: 100%; }
  .card-title-date { flex-basis: 100%; margin-left: 0; }
  .pret-row { flex-wrap: wrap; }
  .pret-info { flex-basis: 60%; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .bar-lib { width: 96px; }
}
