/* Cadre de l'application v2 : sidebar claire, barre supérieure, zone de contenu.
   Chargé en dernier : remplace les règles de cadre de main.css / mobile-improvements.css. */
:root { --sidebar-w: 256px; --sidebar-w-mini: 76px; --topbar-h: 60px; }

/* ---------- Sidebar ---------- */
#sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 50;
  width: var(--sidebar-w); display: flex; flex-direction: column;
  background: var(--color-surface); color: var(--ink-700);
  border-right: 1px solid var(--ink-200); box-shadow: none;
  transition: width .2s ease, transform .2s ease;
}
#sidebar.hidden { display: none; }
.sidebar-brand {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  height: var(--topbar-h); padding: 0 12px 0 18px; border-bottom: 1px solid var(--ink-100); flex-shrink: 0;
}
.sidebar-logo { display: flex; align-items: center; min-width: 0; }
.sidebar-logo-full { height: 34px; width: auto; max-width: 150px; object-fit: contain; }
.sidebar-logo-mini { display: none; height: 32px; width: 32px; object-fit: cover; object-position: 88% 50%; border-radius: 50%; }
.sidebar-toggle .ico { transition: transform .2s ease; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 10px 16px; }
.sidebar-nav .sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; margin: 1px 0; border-radius: 8px;
  font-size: 14px; font-weight: 500; color: var(--ink-600); text-decoration: none;
  background: none; box-shadow: none; transform: none; position: relative;
  transition: background-color .12s ease, color .12s ease;
}
.sidebar-nav .sidebar-link:not(.active):hover { background: var(--ink-50); color: var(--ink-900); transform: none; }
.sidebar-nav .sidebar-link.active {
  background: var(--brand-50); color: var(--brand-800); font-weight: 600; box-shadow: none;
}
.sidebar-nav .sidebar-link.active::before {
  content: ''; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--brand-600); transform: none; height: auto;
}
.sidebar-icon { width: 19px; height: 19px; flex-shrink: 0; color: var(--ink-400); }
.sidebar-link:hover .sidebar-icon { color: var(--ink-600); }
.sidebar-link.active .sidebar-icon { color: var(--brand-600); }
.sidebar-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Groupes (js/sidebar.js) */
.sidebar-nav .sidebar-group + .sidebar-group { margin-top: 6px; }
.sidebar-nav .sidebar-group-header {
  padding: 8px 10px 4px; font-size: 11px; letter-spacing: .07em; color: var(--ink-400); background: none;
}
.sidebar-nav .sidebar-group-header:hover { color: var(--ink-700); background: none; }
.sidebar-nav .sidebar-group-body > .sidebar-link + .sidebar-link { margin-top: 1px; }

.sidebar-footer { padding: 12px 18px; font-size: 11.5px; color: var(--ink-400); border-top: 1px solid var(--ink-100); }

/* Sidebar réduite (ordinateur) */
#sidebar.minimized { width: var(--sidebar-w-mini); }
#sidebar.minimized .sidebar-brand { justify-content: center; padding: 0; flex-direction: column; height: auto; gap: 6px; padding: 12px 0; }
#sidebar.minimized .sidebar-logo-full { display: none; }
#sidebar.minimized .sidebar-logo-mini { display: block; }
#sidebar.minimized .sidebar-toggle .ico { transform: rotate(180deg); }
#sidebar.minimized .sidebar-text { display: none; }
#sidebar.minimized .sidebar-nav { padding: 10px 12px; }
#sidebar.minimized .sidebar-nav .sidebar-link { justify-content: center; padding: 10px; }
#sidebar.minimized .sidebar-nav .sidebar-link.active::before { left: -12px; }
#sidebar.minimized .sidebar-footer { display: none; }

/* ---------- Barre supérieure ---------- */
#topbar {
  position: fixed; top: 0; right: 0; left: var(--sidebar-w); z-index: 40;
  height: var(--topbar-h); display: flex; align-items: center; gap: 12px; padding: 0 20px;
  background: rgba(255, 255, 255, .92); backdrop-filter: saturate(1.4) blur(8px); -webkit-backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--ink-200); box-shadow: none; transition: left .2s ease;
}
#topbar.hidden { display: none !important; }
#sidebar.minimized ~ #topbar { left: var(--sidebar-w-mini); }
.topbar-burger { display: none; }
.topbar-titre { min-width: 0; flex: 1; }
.topbar-fil { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-400); line-height: 1.2; }
.topbar-fil:empty { display: none; }
.topbar-page { font-size: 16px; font-weight: 600; color: var(--ink-900); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar-recherche { position: relative; width: 260px; }
.topbar-recherche .input { min-height: 36px; background: var(--ink-50); border-color: var(--ink-200); }
.topbar-recherche .input:focus { background: var(--color-surface); }
.topbar-recherche .dropdown-menu { left: 0; right: 0; max-height: 360px; overflow-y: auto; }
.topbar-recherche .dropdown-item[aria-selected="true"] { background: var(--brand-50); color: var(--brand-800); }
.topbar-resultat-groupe { font-size: 11.5px; color: var(--ink-400); margin-left: auto; }
.topbar-agence { display: flex; align-items: center; gap: 6px; color: var(--ink-500); }
.topbar-agence.hidden { display: none; }
.topbar-agence .select { min-height: 36px; width: auto; min-width: 170px; padding-top: 6px; padding-bottom: 6px; }
.topbar-user-btn {
  display: flex; align-items: center; gap: 10px; padding: 4px 8px 4px 4px;
  border: 1px solid transparent; border-radius: 10px; background: none; cursor: pointer; text-align: left;
}
.topbar-user-btn:hover { background: var(--ink-50); border-color: var(--ink-200); }
.topbar-user-texte { display: flex; flex-direction: column; line-height: 1.2; }
.topbar-user-nom { font-size: 13.5px; font-weight: 600; color: var(--ink-900); max-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-user-role { font-size: 12px; color: var(--ink-500); }
.topbar-user-chevron { color: var(--ink-400); }
.topbar-user .dropdown-menu { min-width: 220px; }

/* ---------- Contenu ---------- */
#content { min-height: 100vh; padding-top: var(--topbar-h); margin-left: 0; transition: margin-left .2s ease; }
body.shell-actif #content { margin-left: var(--sidebar-w); }
body.shell-actif #sidebar.minimized ~ #content { margin-left: var(--sidebar-w-mini); }
body:not(.shell-actif) #content { padding-top: 0; }
/* Largeur maximale et marges homogènes pour les écrans existants */
/* Pleine largeur et marges uniformes pour toutes les pages (remplace les px-8 / py-8 des gabarits et
   les marges de main.css au-delà de 1280 px) */
#content > div:first-child { max-width: none; margin-left: 0; margin-right: 0; }
@media (min-width: 1024px) { body.shell-actif #content > div:first-child { padding: 20px 24px 28px !important; } }
@media (max-width: 1023px) { body.shell-actif #content > div:first-child { padding: 16px !important; } }

/* ---------- Mobile et tablette ---------- */
@media (max-width: 1023px) {
  #sidebar { transform: translateX(-100%); z-index: 1001; box-shadow: var(--shadow-overlay); }
  #sidebar.open { transform: none; }
  #sidebar.minimized { width: var(--sidebar-w); }
  #topbar, #sidebar.minimized ~ #topbar { left: 0; padding: 0 12px; }
  .topbar-burger { display: inline-flex; }
  body.shell-actif #content, body.shell-actif #sidebar.minimized ~ #content { margin-left: 0; }
  .topbar-recherche { display: none; }
  .topbar-user-texte, .topbar-user-chevron { display: none; }
}
@media (max-width: 640px) {
  .topbar-agence .select { min-width: 0; max-width: 130px; }
  .topbar-fil { display: none; }
}

/* ---------- Écran de connexion ---------- */
.login-page { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: var(--color-surface); }
.login-marque {
  position: relative; overflow: hidden; display: flex; align-items: center;
  padding: 56px; color: var(--brand-800);
  background: radial-gradient(120% 90% at 0% 0%, var(--leaf-100) 0%, transparent 55%),
              linear-gradient(160deg, var(--brand-50) 0%, #F3F9EE 55%, var(--leaf-100) 100%);
}
.login-marque-contenu { position: relative; z-index: 1; max-width: 460px; }
.login-marque-logo { height: 56px; width: auto; margin-bottom: 40px; }
.login-marque-titre { font-size: 30px; line-height: 1.2; font-weight: 700; letter-spacing: -0.02em; color: var(--ink-900); }
.login-marque-texte { margin-top: 14px; font-size: 15px; line-height: 1.6; color: var(--ink-600); }
.login-atouts { margin-top: 28px; display: grid; gap: 12px; list-style: none; }
.login-atouts li { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--ink-700); }
.login-atouts .ico {
  width: 34px; height: 34px; padding: 8px; border-radius: 10px;
  background: rgba(255, 255, 255, .75); color: var(--brand-600); box-shadow: var(--shadow-card);
}
.login-feuille { position: absolute; right: -60px; bottom: -40px; width: 420px; height: 420px; color: var(--brand-600); }
.login-formulaire { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.login-carte { width: 100%; max-width: 380px; }
.login-logo-mobile { display: none; height: 44px; width: auto; margin-bottom: 28px; }
.login-titre { font-size: 26px; font-weight: 700; letter-spacing: -0.01em; color: var(--ink-900); }
.login-sous-titre { margin: 6px 0 24px; font-size: 14px; color: var(--ink-500); }
.login-mdp { padding-right: 42px; }
.login-voir {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  display: flex; align-items: center; justify-content: center; width: 32px; height: 32px;
  border: none; border-radius: 6px; background: none; color: var(--ink-400); cursor: pointer;
}
.login-voir:hover { color: var(--ink-700); background: var(--ink-50); }
.login-voir .ico { position: static; transform: none; }
.login-options { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 20px; font-size: 13px; }
.login-souvenir { display: flex; align-items: center; gap: 8px; color: var(--ink-700); cursor: pointer; }
.login-souvenir input { width: 16px; height: 16px; accent-color: var(--brand-600); }
.login-aide { color: var(--ink-500); }
.login-spinner { width: 18px; height: 18px; border-color: rgba(255, 255, 255, .4); border-top-color: #fff; }
.login-pied { margin-top: 32px; font-size: 12px; color: var(--ink-400); text-align: center; }
@media (max-width: 1023px) {
  .login-page { grid-template-columns: 1fr; background: linear-gradient(180deg, var(--brand-50), #fff 40%); }
  .login-marque { display: none; }
  .login-logo-mobile { display: block; }
}
body:not(.shell-actif) #content > div:first-child { max-width: none; }

/* Le titre de la page est affiché dans la barre supérieure : pas de grand titre répété dans la page */
body.shell-actif .titre-page { display: none; }
body.shell-actif .titre-page + p { margin-top: 0; font-size: 14px; color: var(--ink-500); }
