/* ============================================================
   FAJD milo89 — Styles applicatifs
   Palette officielle ML : #2698d3 #8ec44a #f49231 #d8225d #9b2363
   ============================================================ */

:root {
  --ml-bleu:    #2698d3;
  --ml-vert:    #8ec44a;
  --ml-orange:  #f49231;
  --ml-rouge:   #d8225d;
  --ml-violet:  #9b2363;

  /* Bootstrap overrides */
  --bs-primary:         var(--ml-bleu);
  --bs-primary-rgb:     38, 152, 211;
  --bs-success:         var(--ml-vert);
  --bs-success-rgb:     142, 196, 74;
  --bs-warning:         var(--ml-orange);
  --bs-warning-rgb:     244, 146, 49;
  --bs-danger:          var(--ml-rouge);
  --bs-danger-rgb:      216, 34, 93;

  /* Sidebar */
  --sidebar-width:    240px;
  --sidebar-bg:       #1a1f2e;
  --sidebar-text:     rgba(255,255,255,.82);
  --sidebar-active:   var(--ml-bleu);
  --sidebar-hover-bg: rgba(255,255,255,.08);

  /* Densité affichage */
  --cell-padding-y:   0.35rem;
  --cell-padding-x:   0.55rem;
  --table-font-size:  0.825rem;
}

/* -------------------------------------------------------
   Layout global (sidebar + contenu)
   ------------------------------------------------------- */
body.has-sidebar {
  background: #f4f6f9;
}

/* SIDEBAR */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 1040;
  transition: transform .25s ease;
}

/* En-tête sidebar */
.sidebar-header {
  padding: 1.2rem 1rem 1rem;
  text-align: center;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-app-logo {
  height: 50px;
  width: auto;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
  padding: 4px 8px;
  display: block;
  margin: 0 auto 0.75rem;
}
.sidebar-ml-logo-wrap {
  margin-bottom: 0.5rem;
}
.sidebar-ml-logo {
  height: 44px;
  width: auto;
  object-fit: contain;
  background: #fff;
  border-radius: 6px;
  padding: 3px 6px;
  max-width: 180px;
}
.sidebar-ml-name {
  font-size: .75rem;
  color: rgba(255,255,255,.6);
  line-height: 1.3;
  word-wrap: break-word;
  padding: 0 0.25rem;
}

/* Navigation links */
.sidebar-nav {
  flex: 1;
  padding: 0.5rem 0;
}
.sidebar-section {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(255,255,255,.35);
  padding: 1rem 1rem 0.25rem;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 1rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: .875rem;
  border-left: 3px solid transparent;
  transition: background .15s, border-color .15s, color .15s;
  cursor: pointer;
}
.sidebar-link i {
  width: 18px;
  text-align: center;
  flex-shrink: 0;
  font-size: 1rem;
}
.sidebar-link:hover {
  background: var(--sidebar-hover-bg);
  color: #fff;
  border-left-color: rgba(255,255,255,.25);
}
.sidebar-link.active {
  background: rgba(38,152,211,.18);
  color: #fff;
  border-left-color: var(--sidebar-active);
  font-weight: 600;
}

/* Pied de sidebar */
.sidebar-footer {
  padding: 0.5rem 0 0.75rem;
  border-top: 1px solid rgba(255,255,255,.1);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 1rem;
  font-size: .82rem;
  color: rgba(255,255,255,.7);
  flex-wrap: wrap;
}
.sidebar-user i { font-size: 1.1rem; }

.badge-role {
  background: rgba(255,255,255,.15);
  color: #fff;
  font-size: .65rem;
}

/* Bouton hamburger mobile */
.sidebar-toggle {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 1050;
  background: var(--sidebar-bg);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.3rem 0.55rem;
  display: none;
}
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1039;
}

/* CONTENU PRINCIPAL */
.main-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.main-wrapper.with-sidebar {
  margin-left: var(--sidebar-width);
}
.app-main {
  flex: 1;
  max-width: 1440px;
}

/* -------------------------------------------------------
   Responsive — mobile
   ------------------------------------------------------- */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-toggle {
    display: flex;
    align-items: center;
  }
  .main-wrapper.with-sidebar {
    margin-left: 0;
    padding-top: 3rem;
  }
}

/* -------------------------------------------------------
   Palette boutons Bootstrap
   ------------------------------------------------------- */
.btn-primary   { background-color: var(--ml-bleu);   border-color: var(--ml-bleu); }
.btn-primary:hover,
.btn-primary:focus { background-color: #1e7aab; border-color: #1e7aab; }

.btn-success   { background-color: var(--ml-vert);   border-color: var(--ml-vert); color: #fff; }
.btn-success:hover  { background-color: #74a33c; border-color: #74a33c; color: #fff; }

.btn-warning   { background-color: var(--ml-orange); border-color: var(--ml-orange); color: #fff; }
.btn-warning:hover  { background-color: #d4791e; border-color: #d4781e; color: #fff; }

.btn-danger    { background-color: var(--ml-rouge);  border-color: var(--ml-rouge); }
.btn-danger:hover   { background-color: #b01a4b; border-color: #b01a4b; }

.btn-outline-primary { color: var(--ml-bleu); border-color: var(--ml-bleu); }
.btn-outline-primary:hover { background-color: var(--ml-bleu); border-color: var(--ml-bleu); color: #fff; }

/* -------------------------------------------------------
   Couleurs de fond et texte
   ------------------------------------------------------- */
.bg-primary { background-color: var(--ml-bleu)   !important; }
.bg-success { background-color: var(--ml-vert)   !important; }
.bg-warning { background-color: var(--ml-orange) !important; }
.bg-danger  { background-color: var(--ml-rouge)  !important; }
.bg-info    { background-color: var(--ml-bleu)   !important; }

.text-primary { color: var(--ml-bleu)  !important; }
.text-success { color: var(--ml-vert)  !important; }
.text-warning { color: var(--ml-orange)!important; }
.text-danger  { color: var(--ml-rouge) !important; }
.text-info    { color: var(--ml-bleu)  !important; }

/* Badges FAJD */
.badge-urgence   { background-color: var(--ml-orange); color: #fff; }
.badge-insertion { background-color: var(--ml-bleu);   color: #fff; }

.badge-admin  { background-color: var(--ml-violet); color: #fff; }

a { color: var(--ml-bleu); }
a:hover { color: #1e7aab; }

/* -------------------------------------------------------
   Badges statuts aides
   ------------------------------------------------------- */
.badge-brouillon   { background-color: #6c757d; }
.badge-enregistree { background-color: var(--ml-vert); }
.badge-cloture     { background-color: #5c6e82; }

/* -------------------------------------------------------
   Formulaires — focus
   ------------------------------------------------------- */
.form-control:focus,
.form-select:focus {
  border-color: var(--ml-bleu);
  box-shadow: 0 0 0 0.2rem rgba(38,152,211,.25);
}
.form-check-input:checked {
  background-color: var(--ml-bleu);
  border-color: var(--ml-bleu);
}

/* -------------------------------------------------------
   Densification des tableaux
   ------------------------------------------------------- */
.table { font-size: var(--table-font-size); }
.table > :not(caption) > * > * {
  padding: var(--cell-padding-y) var(--cell-padding-x);
}
.table-hover tbody tr:hover { background-color: #e8f4fb; }

/* -------------------------------------------------------
   Cards
   ------------------------------------------------------- */
.card-header.bg-primary { background-color: var(--ml-bleu) !important; }

/* -------------------------------------------------------
   Barre de progression budget
   ------------------------------------------------------- */
.budget-bar .progress { height: 8px; border-radius: 6px; }
.budget-ok      .progress-bar { background-color: var(--ml-vert); }
.budget-warning .progress-bar { background-color: var(--ml-orange); }
.budget-danger  .progress-bar { background-color: var(--ml-rouge); }

/* -------------------------------------------------------
   Niveaux suivi à 3 mois
   ------------------------------------------------------- */
.suivi-1 { color: var(--ml-rouge); }
.suivi-2 { color: var(--ml-orange); }
.suivi-3 { color: var(--ml-bleu); }
.suivi-4 { color: var(--ml-vert); }

/* -------------------------------------------------------
   Alertes
   ------------------------------------------------------- */
.suivi-alerte-bandeau {
  background: #fff3cd;
  border-left: 4px solid var(--ml-orange);
  padding: .65rem 1rem;
  border-radius: 4px;
  margin-bottom: 1rem;
}

/* -------------------------------------------------------
   Page d'authentification (pas de sidebar)
   ------------------------------------------------------- */
.auth-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 12px;
  padding: 2.5rem;
  box-shadow: 0 4px 24px rgba(0,0,0,.10);
}

/* -------------------------------------------------------
   Icônes d'action
   ------------------------------------------------------- */
.btn-action {
  padding: .2rem .45rem;
  font-size: .8rem;
  line-height: 1.2;
}

/* -------------------------------------------------------
   États vides
   ------------------------------------------------------- */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: #6c757d;
}
.empty-state i {
  font-size: 3rem;
  opacity: .4;
  display: block;
  margin-bottom: .75rem;
}

/* -------------------------------------------------------
   Tooltips
   ------------------------------------------------------- */
.tooltip-inner { background-color: var(--ml-bleu); font-size: .8rem; }
.bs-tooltip-auto[data-popper-placement^=top] .tooltip-arrow::before,
.bs-tooltip-top .tooltip-arrow::before { border-top-color: var(--ml-bleu); }

/* -------------------------------------------------------
   Footer
   ------------------------------------------------------- */
.app-footer {
  background: #fff;
  border-top: 1px solid #dee2e6;
  padding: 0.75rem 1rem;
  text-align: center;
}
.footer-logos {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 0.5rem;
}
.footer-logo {
  height: 40px;
  width: auto;
  object-fit: contain;
  filter: grayscale(20%);
  opacity: .85;
  transition: opacity .2s, filter .2s;
}
.footer-logo:hover { opacity: 1; filter: none; }
.footer-text {
  font-size: .75rem;
  color: #6c757d;
}

/* -------------------------------------------------------
   Print
   ------------------------------------------------------- */

/* L'en-tête d'impression est masqué à l'écran, visible uniquement à l'impression */
.print-header { display: none; }

@media print {
  /* Format A4 paysage */
  @page { size: A4 landscape; margin: 1cm; }

  /* Éléments à masquer */
  .sidebar, .sidebar-toggle, .app-footer,
  .no-print, form.no-print, .modal,
  .alert-dismissible .btn-close { display: none !important; }

  /* Pleine largeur sans sidebar */
  .main-wrapper, .main-wrapper.with-sidebar {
    margin-left: 0 !important;
    width: 100% !important;
    padding: 0 !important;
  }

  /* Conserver les couleurs de fond (en-têtes tableaux) */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* En-tête d'impression */
  .print-header {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .6cm;
    padding-bottom: .3cm;
    border-bottom: 2px solid var(--ml-bleu, #1a6eb5);
    page-break-inside: avoid;
  }
  .print-header img {
    max-height: 45px;
    max-width: 120px;
    object-fit: contain;
  }
  .print-header-center {
    text-align: center;
    flex: 1;
    padding: 0 .5cm;
  }
  .print-header-center .ph-title {
    font-size: 11pt;
    font-weight: 700;
    color: var(--ml-bleu, #1a6eb5);
  }
  .print-header-center .ph-sub {
    font-size: 8.5pt;
    color: #444;
  }

  /* Tableaux */
  .table-responsive { overflow: visible !important; }
  table { font-size: .62rem !important; min-width: unset !important; }
  th, td { padding: 2px 5px !important; }

  /* Sauts de page entre sections URGENCE / INSERTION */
  .print-section-break { page-break-before: always; }
}
