/* =============================================================================
   SUIVI ANNUALISATION — Feuille de style
   Palette : navy (structure), orange (accent principal), teal (accent 2nd).
   Mode sombre complet via variables CSS + attribut [data-theme].
   ========================================================================== */

:root {
  --navy: #1b2a4a;
  --navy-dark: #131f38;
  --navy-light: #2a3d63;
  --orange: #f0742d;
  --orange-hover: #d95f1a;
  --teal: #12968b;
  --teal-light: #e0f2f0;

  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --border: #d9dfe8;
  --text: #21283b;
  --text-muted: #6b7487;
  --sidebar-bg: var(--navy);
  --sidebar-text: #c9d2e4;
  --sidebar-active: var(--orange);

  --success: #2e9e5b;
  --danger: #d54141;
  --warning: #e3a008;
  --info: #3474d4;

  /* Code couleur par type de jour */
  --c-normal: #12968b;
  --c-repos: #9aa3b5;
  --c-cp: #e8b90c;
  --c-cpanc: #8e5bd4;
  --c-recup: #3474d4;
  --c-evenement: #2e9e5b;
  --c-maladie: #d54141;
  --c-formation: #e07b26;
  --c-autre: #5d6572;

  --shadow: 0 2px 10px rgba(16, 24, 46, 0.08);
  --radius: 10px;
  --font-display: "Raleway", sans-serif;
  --font-text: "DM Sans", sans-serif;
}

[data-theme="dark"] {
  --bg: #12161f;
  --surface: #1b2130;
  --surface-2: #232b3d;
  --border: #333d54;
  --text: #e5e9f2;
  --text-muted: #96a0b5;
  --sidebar-bg: #10151f;
  --sidebar-text: #9daac4;
  --teal-light: #143733;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: var(--font-text);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
h1, h2, h3, h4, .kpi-value { font-family: var(--font-display); }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; }
a { color: var(--info); }
[hidden] { display: none !important; }

/* --- Écran de connexion ---------------------------------------------------- */
#login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  padding: 1rem;
}
.login-card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 2.2rem; width: 100%; max-width: 400px;
}
.login-card h1 { color: var(--navy); margin-bottom: .3rem; }
[data-theme="dark"] .login-card h1 { color: var(--text); }
.login-card .subtitle { color: var(--text-muted); margin-bottom: 1.5rem; font-size: .9rem; }
.demo-banner {
  background: var(--teal-light); border: 1px solid var(--teal); color: var(--teal);
  border-radius: 8px; padding: .6rem .8rem; font-size: .82rem; margin-bottom: 1rem;
}

/* --- Structure générale ------------------------------------------------------ */
#app { display: flex; min-height: 100vh; }

#sidebar {
  width: 250px; background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0;
  z-index: 50; overflow-y: auto; transition: transform .25s ease;
}
.sidebar-brand {
  padding: 1.1rem 1rem; font-family: var(--font-display); font-weight: 800;
  font-size: 1.05rem; color: #fff; border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand small { display: block; color: var(--orange); font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; }
.nav-section { margin-top: .6rem; }
.nav-section-title {
  width: 100%; text-align: left; background: none; border: none; cursor: pointer;
  color: var(--sidebar-text); opacity: .65; font-size: .72rem; letter-spacing: .08em;
  text-transform: uppercase; padding: .5rem 1rem .3rem; font-family: var(--font-text);
  display: flex; justify-content: space-between; align-items: center;
}
.nav-section-title .chev { transition: transform .2s; }
.nav-section.collapsed .chev { transform: rotate(-90deg); }
.nav-section.collapsed .nav-item { display: none; }
.nav-item {
  display: flex; align-items: center; gap: .6rem; width: 100%; text-align: left;
  background: none; border: none; color: var(--sidebar-text); cursor: pointer;
  padding: .55rem 1rem; font-size: .88rem; font-family: var(--font-text);
  border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: rgba(240,116,45,.14); color: #fff; border-left-color: var(--sidebar-active); }
.nav-item .icon { width: 1.2rem; text-align: center; }
.nav-badge {
  margin-left: auto; background: var(--orange); color: #fff; border-radius: 999px;
  font-size: .68rem; font-weight: 700; padding: .05rem .45rem; min-width: 1.3rem; text-align: center;
}

#main { flex: 1; margin-left: 250px; display: flex; flex-direction: column; min-width: 0; }
#topbar {
  display: flex; align-items: center; gap: .8rem; padding: .7rem 1.2rem;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 40;
}
#burger { display: none; background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--text); }
#topbar .page-title { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; flex: 1; }
.topbar-user { font-size: .85rem; color: var(--text-muted); }
.icon-btn {
  background: none; border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
  padding: .35rem .55rem; font-size: 1rem; color: var(--text);
}
.icon-btn:hover { border-color: var(--orange); }

#page { padding: 1.3rem; max-width: 1250px; width: 100%; }

.saving-indicator {
  font-size: .8rem; color: var(--text-muted); opacity: 0; transition: opacity .2s;
}
.saving-indicator.visible { opacity: 1; }
.saving-indicator.saved { color: var(--success); }

/* --- Composants ---------------------------------------------------------------- */
.card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.1rem 1.2rem; margin-bottom: 1.1rem;
}
.card h2, .card h3 { margin-bottom: .7rem; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-kpi { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 1.1rem; }

.kpi {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: .9rem 1rem; border-top: 3px solid var(--teal);
}
.kpi.accent { border-top-color: var(--orange); }
.kpi.danger { border-top-color: var(--danger); }
.kpi.warning { border-top-color: var(--warning); }
.kpi-label { font-size: .75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.kpi-value { font-size: 1.6rem; font-weight: 800; margin-top: .2rem; }
.kpi-sub { font-size: .78rem; color: var(--text-muted); margin-top: .15rem; }
.kpi.clickable { cursor: pointer; }
.kpi.clickable:hover { outline: 2px solid var(--orange); }

.progress-bar { background: var(--surface-2); border-radius: 999px; height: 10px; overflow: hidden; margin-top: .4rem; }
.progress-fill { background: linear-gradient(90deg, var(--teal), var(--orange)); height: 100%; border-radius: 999px; transition: width .4s; }

.btn {
  display: inline-flex; align-items: center; gap: .4rem; cursor: pointer;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: .5rem .9rem; font-size: .87rem; font-family: var(--font-text); font-weight: 500;
}
.btn:hover { border-color: var(--orange); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn-primary:hover { background: var(--orange-hover); }
.btn-secondary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-sm { padding: .25rem .55rem; font-size: .78rem; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

.input, .select, textarea.input {
  width: 100%; padding: .5rem .65rem; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font-family: var(--font-text); font-size: .88rem;
}
.input:focus, .select:focus, textarea.input:focus { outline: 2px solid var(--orange); border-color: var(--orange); }
.field { margin-bottom: .8rem; }
.field label { display: block; font-size: .8rem; font-weight: 600; margin-bottom: .25rem; color: var(--text-muted); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .8rem; }
.checkbox-label { display: flex; align-items: center; gap: .45rem; font-size: .88rem; cursor: pointer; }

/* --- Tableaux ------------------------------------------------------------------ */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .86rem; }
table.data th {
  text-align: left; padding: .5rem .6rem; border-bottom: 2px solid var(--border);
  font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted);
  white-space: nowrap;
}
table.data td { padding: .45rem .6rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:hover td { background: var(--surface-2); }
table.data tr.row-active td { background: rgba(240,116,45,.12); box-shadow: inset 3px 0 0 var(--orange); }
table.data tr.row-sunday td { background: rgba(154,163,181,.12); }
table.data tr.row-today td { box-shadow: inset 3px 0 0 var(--teal); }

/* --- Badges types / statuts ------------------------------------------------------ */
.day-badge {
  display: inline-block; padding: .12rem .5rem; border-radius: 999px; font-size: .72rem;
  font-weight: 700; color: #fff; white-space: nowrap;
}
.type-normal { background: var(--c-normal); } .type-repos { background: var(--c-repos); }
.type-cp { background: var(--c-cp); color: #4a3b00; } .type-cpanc { background: var(--c-cpanc); }
.type-recup { background: var(--c-recup); } .type-evenement { background: var(--c-evenement); }
.type-maladie { background: var(--c-maladie); } .type-formation { background: var(--c-formation); }
.type-autre { background: var(--c-autre); }

.status-badge {
  display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .73rem; font-weight: 700;
}
.status-pending { background: rgba(227,160,8,.15); color: var(--warning); }
.status-waiting { background: rgba(52,116,212,.15); color: var(--info); }
.status-approved { background: rgba(46,158,91,.15); color: var(--success); }
.status-rejected { background: rgba(213,65,65,.15); color: var(--danger); }
.status-cancelled { background: rgba(93,101,114,.15); color: var(--text-muted); }
.status-archived { background: var(--surface-2); color: var(--text-muted); }

/* --- Alertes ---------------------------------------------------------------------- */
.alert-item {
  border-left: 4px solid var(--border); border-radius: 8px; background: var(--surface);
  box-shadow: var(--shadow); padding: .7rem .9rem; margin-bottom: .6rem;
  display: flex; gap: .7rem; align-items: flex-start;
}
.alert-critical { border-left-color: var(--danger); }
.alert-warning { border-left-color: var(--warning); }
.alert-info { border-left-color: var(--info); }
.alert-ok { border-left-color: var(--success); }
.banner {
  border-radius: 8px; padding: .65rem .9rem; margin-bottom: .9rem; font-size: .87rem;
  border: 1px solid transparent;
}
.banner-warning { background: rgba(227,160,8,.12); border-color: var(--warning); color: var(--warning); }
.banner-danger { background: rgba(213,65,65,.1); border-color: var(--danger); color: var(--danger); }
.banner-info { background: rgba(52,116,212,.1); border-color: var(--info); color: var(--info); }
.banner-locked { background: rgba(93,101,114,.12); border-color: var(--text-muted); color: var(--text-muted); }

/* --- Onglets mois ------------------------------------------------------------------ */
.month-tabs { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: 1rem; }
.month-tab {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 8px; padding: .35rem .65rem; cursor: pointer; font-size: .8rem; font-family: var(--font-text);
}
.month-tab.active { background: var(--navy); border-color: var(--navy); color: #fff; }
[data-theme="dark"] .month-tab.active { background: var(--orange); border-color: var(--orange); }
.month-tab.locked::after { content: " 🔒"; }

/* --- Planning équipe ----------------------------------------------------------------- */
.team-grid-wrap { overflow-x: auto; }
.team-grid { border-collapse: collapse; font-size: .72rem; }
.team-grid th, .team-grid td { border: 1px solid var(--border); padding: .15rem .25rem; text-align: center; min-width: 26px; }
.team-grid th.name-col, .team-grid td.name-col { text-align: left; min-width: 130px; position: sticky; left: 0; background: var(--surface); z-index: 2; }
.team-cell { display: block; border-radius: 4px; color: #fff; font-weight: 700; padding: .1rem 0; }

/* --- Mini calendrier admin -------------------------------------------------------------- */
.mini-cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: .3rem; max-width: 480px; }
.mini-cal .mc-head { font-size: .7rem; color: var(--text-muted); text-align: center; }
.mc-day {
  border: 1px solid var(--border); border-radius: 6px; min-height: 46px; cursor: pointer;
  font-size: .72rem; padding: .2rem; background: var(--surface); color: var(--text); font-family: var(--font-text);
}
.mc-day:hover { border-color: var(--orange); }
.mc-day .mc-mark { display: block; font-size: .62rem; font-weight: 700; color: var(--orange); }
.mc-day.mc-empty { visibility: hidden; }

/* --- Toasts -------------------------------------------------------------------------------- */
#toast-container { position: fixed; bottom: 1rem; right: 1rem; z-index: 200; display: flex; flex-direction: column; gap: .5rem; }
.toast {
  display: flex; align-items: center; gap: .6rem; background: var(--surface); color: var(--text);
  border-radius: 8px; box-shadow: 0 4px 18px rgba(0,0,0,.18); padding: .65rem .9rem;
  font-size: .86rem; max-width: 360px; opacity: 0; transform: translateY(8px); transition: all .25s;
  border-left: 4px solid var(--info);
}
.toast.show { opacity: 1; transform: none; }
.toast-icon { font-weight: 800; }
.toast-success { border-left-color: var(--success); } .toast-success .toast-icon { color: var(--success); }
.toast-error { border-left-color: var(--danger); } .toast-error .toast-icon { color: var(--danger); }
.toast-warning { border-left-color: var(--warning); } .toast-warning .toast-icon { color: var(--warning); }
.toast-info .toast-icon { color: var(--info); }

/* --- Modales --------------------------------------------------------------------------------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(12,17,29,.55); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.modal {
  background: var(--surface); border-radius: var(--radius); box-shadow: 0 10px 40px rgba(0,0,0,.3);
  width: 100%; max-width: 520px; max-height: 90vh; display: flex; flex-direction: column;
}
.modal-wide { max-width: 820px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.2rem .6rem; }
.modal-close { background: none; border: none; font-size: 1rem; cursor: pointer; color: var(--text-muted); }
.modal-body { padding: .4rem 1.2rem; overflow-y: auto; font-size: .9rem; }
.modal-body p { margin-bottom: .6rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; padding: .9rem 1.2rem 1.1rem; }

/* --- Divers ------------------------------------------------------------------------------------ */
.kbd-hint { font-size: .74rem; color: var(--text-muted); margin-top: .5rem; }
.kbd-hint kbd {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px;
  padding: 0 .3rem; font-size: .72rem; font-family: monospace;
}
.muted { color: var(--text-muted); font-size: .85rem; }
.spinner {
  width: 26px; height: 26px; border: 3px solid var(--border); border-top-color: var(--orange);
  border-radius: 50%; animation: spin .8s linear infinite; margin: 1.5rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
.filters-row { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .8rem; align-items: center; }
.chip {
  border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer;
  border-radius: 999px; padding: .25rem .7rem; font-size: .78rem; font-family: var(--font-text);
}
.chip.active { background: var(--navy); color: #fff; border-color: var(--navy); }
[data-theme="dark"] .chip.active { background: var(--orange); border-color: var(--orange); }
.sig-canvas { border: 2px dashed var(--border); border-radius: 8px; background: #fff; touch-action: none; cursor: crosshair; width: 100%; }
.collapsible-head { cursor: pointer; user-select: none; display: flex; justify-content: space-between; align-items: center; }
.month-lock-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; }
.today-list { display: flex; flex-direction: column; gap: .35rem; font-size: .88rem; }
.info-page h3 { margin-top: 1.1rem; color: var(--orange); }
.info-page p, .info-page li { margin-bottom: .5rem; line-height: 1.55; }
.info-page ul { padding-left: 1.3rem; }

/* --- Responsive ----------------------------------------------------------------------------------- */
@media (max-width: 900px) {
  #sidebar { transform: translateX(-100%); }
  #sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  #main { margin-left: 0; }
  #burger { display: block; }
  #page { padding: .8rem; }
}

/* --- Impression ------------------------------------------------------------------------------------- */
@media print {
  #sidebar, #topbar, #toast-container, .no-print { display: none !important; }
  #main { margin-left: 0; }
  body { background: #fff; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}
