@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&family=Inter:wght@400;500;600;700;800&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  --navy: #16233B;
  --navy-light: #22345A;
  --navy-lighter: #2E4470;
  --parchment: #F5F3EE;
  --parchment-deep: #EBE7DC;
  --surface: #FFFFFF;
  --gold: #C6A24D;
  --gold-deep: #9C7C2F;
  --teal: #1E5C4F;
  --teal-light: #E4EFEC;
  --clay: #A8432B;
  --clay-light: #F5E4DE;
  --ink: #21201B;
  --muted: #6E6A5C;
  --line: #E4DECB;

  --f-display: 'Fraunces', serif;
  --f-body: 'Inter', sans-serif;
  --f-mono: 'IBM Plex Mono', monospace;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(22,35,59,0.06);
  --shadow: 0 4px 16px rgba(22,35,59,0.08);
  --shadow-lg: 0 12px 32px rgba(22,35,59,0.14);
  --transition: 160ms cubic-bezier(.4,0,.2,1);
}

* { box-sizing: border-box; }

body {
  background: var(--parchment);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 14.5px;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .display-font {
  font-family: var(--f-display);
  color: var(--navy);
  font-weight: 700;
}

.mono { font-family: var(--f-mono); }

a { text-decoration: none; }

/* ---------------- Layout ---------------- */
.app-shell { min-height: 100vh; }
.app-main { background: var(--parchment); min-height: 100vh; }
.app-content { max-width: 1240px; margin: 0 auto; padding: 28px 28px 48px; }
@media (max-width: 767px) {
  .app-content { padding: 18px 16px 40px; }
}

/* ---------------- Topbar ---------------- */
.page-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.page-topbar .page-icon {
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  background: var(--teal-light); color: var(--teal);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.page-topbar .page-title { font-size: 21px; font-weight: 700; color: var(--navy); line-height: 1.2; }
.page-topbar .page-subtitle { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.page-topbar .page-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------------- Sidebar ---------------- */
.sidebar {
  background: linear-gradient(180deg, var(--navy) 0%, #101b30 100%);
  color: #fff;
  min-height: 100vh;
  position: sticky;
  top: 0;
}
@media (min-width: 992px) {
  .sidebar { max-width: 260px; }
}
.sidebar .brand-title {
  font-family: var(--f-display);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.sidebar .brand-sub {
  font-size: 10.5px;
  color: #8492AC;
  text-transform: uppercase;
  letter-spacing: 0.09em;
}
.sidebar .nav-link {
  color: #C7D0E3;
  font-weight: 500;
  font-size: 13.5px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background var(--transition), color var(--transition);
}
.sidebar .nav-link i { font-size: 15px; width: 18px; text-align: center; opacity: 0.85; }
.sidebar .nav-link:hover { color: #fff; background: rgba(255,255,255,0.06); }
.sidebar .nav-link.active {
  background: rgba(198,162,77,0.16);
  color: var(--gold);
  border-color: rgba(198,162,77,0.22);
}
.sidebar .nav-link.active i { opacity: 1; }
.sidebar .switch-btn {
  background: rgba(198,162,77,0.12); color: var(--gold);
  border: 1px solid rgba(198,162,77,0.28);
  transition: background var(--transition);
}
.sidebar .switch-btn:hover { background: rgba(198,162,77,0.2); color: var(--gold); }
.sidebar .nav-footer {
  border-top: 1px solid rgba(255,255,255,0.08);
  color: #8492AC;
  font-size: 11px;
}
.sidebar .user-bar { border-top: 1px solid rgba(255,255,255,0.08); }

/* ---------------- Cards ---------------- */
.card-avek {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}
.kpi-card {
  position: relative;
  overflow: hidden;
  padding: 18px 20px;
}
.kpi-card .accent-bar {
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
}
.kpi-label {
  font-size: 11.5px; color: var(--muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.045em;
}
.kpi-value {
  font-family: var(--f-display);
  font-size: 27px; color: var(--navy); font-weight: 700; margin-top: 4px;
  line-height: 1.15;
}
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* ---------------- Stamp (badge ID) ---------------- */
.stamp {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; height: 30px; padding: 0 9px; border-radius: 9999px;
  border: 1.5px solid var(--gold-deep); color: var(--gold-deep);
  background: rgba(198,162,77,0.09);
  font-family: var(--f-mono); font-size: 11.5px; font-weight: 600;
  letter-spacing: 0.02em;
}

/* ---------------- Tables ---------------- */
.table-avek thead tr { background: var(--parchment-deep); color: var(--navy); }
.table-avek thead th {
  font-weight: 600; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em;
  border-bottom: none; padding: 12px;
}
.table-avek tbody tr { transition: background var(--transition); }
.table-avek tbody tr:hover { background: #FAF7EF; }
.table-avek td, .table-avek th { vertical-align: middle; padding: 10px 12px; }
.table-avek input.form-control, .table-avek select.form-select {
  font-size: 13px; padding: 5px 9px;
}
.table-card { border-radius: var(--radius); overflow: hidden; }

/* ---------------- Buttons ---------------- */
.btn { border-radius: var(--radius-sm); font-weight: 600; font-size: 13.5px; transition: all var(--transition); }
.btn-navy { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn-navy:hover { background: var(--navy-light); color: #fff; }
.btn-teal { background: var(--teal); color: #fff; border-color: var(--teal); }
.btn-teal:hover { background: #17493f; color: #fff; }
.btn-clay-outline { color: var(--clay); border-color: var(--clay-light); }
.btn-clay-outline:hover { color: #fff; background: var(--clay); border-color: var(--clay); }
.btn:focus, .form-control:focus, .form-select:focus {
  box-shadow: 0 0 0 0.18rem rgba(198,162,77,0.18);
}
.form-control:focus, .form-select:focus { border-color: var(--gold); }
.form-control, .form-select { border-radius: var(--radius-sm); border-color: var(--line); }
.form-control::placeholder { color: #B5AF9C; }

/* ---------------- Toggle (Oui/Non) ---------------- */
.toggle-group { display: inline-flex; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--line); }
.toggle-group button {
  font-size: 12px; font-weight: 600; padding: 5px 11px; border: none; background: #fff; color: var(--muted); cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.toggle-group button.active-oui { background: var(--teal); color: #fff; }
.toggle-group button.active-oui.clay { background: var(--clay); }
.toggle-group button.active-non { background: var(--navy); color: #fff; }

/* ---------------- Empty state ---------------- */
.empty-state {
  color: var(--muted); text-align: center; padding: 48px 16px;
  font-size: 13.5px;
}
.empty-state i { color: #C9C2AA; }

/* ---------------- Modals ---------------- */
.modal-content { border-radius: var(--radius-lg); border: none; box-shadow: var(--shadow-lg); }
.modal-header { border-bottom: 1px solid var(--line); padding: 18px 22px; }
.modal-body { padding: 22px; }
.modal-footer { border-top: 1px solid var(--line); padding: 14px 22px; }

/* ---------------- Toasts ---------------- */
.toast-container { z-index: 1080; }
.avek-toast {
  border-radius: var(--radius-sm); border: none; box-shadow: var(--shadow-lg);
  font-size: 13.5px; font-weight: 500; min-width: 260px;
}
.avek-toast.text-bg-success { background: var(--teal) !important; }
.avek-toast.text-bg-danger { background: var(--clay) !important; }

/* ---------------- Misc ---------------- */
.badge-statut-ok { color: var(--teal); font-weight: 700; font-size: 11px; }
.badge-statut-warn { color: var(--gold-deep); font-weight: 700; font-size: 11px; }
.badge-statut-danger { color: var(--clay); font-weight: 700; font-size: 11px; }
.save-note { font-size: 12px; color: var(--teal); font-weight: 600; min-width: 90px; text-align: right; }

/* ---------------- Admin navbar (pages hors sidebar) ---------------- */
.admin-navbar {
  background: linear-gradient(90deg, var(--navy) 0%, #101b30 100%);
  box-shadow: var(--shadow);
}
.admin-navbar .admin-brand { font-family: var(--f-display); color: #fff; font-size: 17px; font-weight: 700; }
.admin-navbar .admin-back { color: #B9C2D6; transition: color var(--transition); }
.admin-navbar .admin-back:hover { color: #fff; }
.admin-navbar .admin-user { color: #B9C2D6; font-size: 12.5px; }

.icon-tile {
  width: 44px; height: 44px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 19px; flex-shrink: 0;
}

@media (max-width: 991px) {
  .sidebar { min-height: auto; position: static; }
}

/* ============================================================
   RESPONSIVE — laptop / tablette / mobile
   Sur mobile, les tableaux marqués .responsive-cards se
   transforment en cartes empilées (une carte par ligne),
   grâce aux attributs data-label posés sur chaque <td>.
   ============================================================ */

/* Tablette : resserre un peu les espacements */
@media (max-width: 991px) {
  .app-content { padding: 22px 18px 40px; }
  .kpi-value { font-size: 23px; }
  .page-topbar { gap: 12px; }
}

/* Mobile : bascule tableau -> cartes */
@media (max-width: 767px) {
  table.responsive-cards { border: none; }
  table.responsive-cards thead { display: none; }
  table.responsive-cards,
  table.responsive-cards tbody,
  table.responsive-cards tr,
  table.responsive-cards td {
    display: block;
    width: 100%;
  }
  table.responsive-cards tfoot { display: block; width: 100%; }
  table.responsive-cards tfoot tr {
    display: block;
    background: var(--teal-light) !important;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 4px 14px;
    margin-top: 4px;
  }
  table.responsive-cards tfoot td { display: block; }

  table.responsive-cards tbody tr {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 4px 14px;
    margin-bottom: 12px;
  }
  table.responsive-cards tbody tr:hover { background: var(--surface); }

  table.responsive-cards td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    text-align: right;
    padding: 9px 0;
    border: none !important;
    border-bottom: 1px solid var(--parchment-deep) !important;
  }
  table.responsive-cards td:last-child { border-bottom: none !important; }
  table.responsive-cards td::before {
    content: attr(data-label);
    flex-shrink: 0;
    text-align: left;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
  }
  /* Première cellule de chaque ligne = identité de la carte (ID/nom) : mise en avant */
  table.responsive-cards tbody tr td:first-child {
    padding-top: 13px;
    padding-bottom: 13px;
    border-bottom: 1px solid var(--line) !important;
    font-weight: 600;
  }
  table.responsive-cards tbody tr td:first-child::before { content: none; }
  /* Cellules d'actions : boutons pleine largeur, pas de label */
  table.responsive-cards td.card-actions {
    justify-content: flex-end;
    flex-wrap: wrap;
    padding-top: 12px;
  }
  table.responsive-cards td.card-actions::before { display: none; }
  /* Cellules contenant une barre de progression : passent en colonne */
  table.responsive-cards td.card-progress {
    flex-direction: column;
    align-items: stretch;
    text-align: left;
  }
  table.responsive-cards td.card-progress::before { margin-bottom: 4px; }

  /* Modals plein écran sur mobile pour plus de confort de saisie */
  .modal-dialog { margin: 10px; }
}

