/* =========================================================
   ASHL — Pahéko (Garradin) CSS COMPLET FINAL
   - Police: Barlow
   - Palette: logo ASHL
   - Lisibilité écran + compta + états
   - Impression/PDF standard + MODE AUDIT
   - Grand livre : paysage AUTO en impression (hack fiable)
   ========================================================= */

/* 1) Police Barlow */
@import url('https://fonts.googleapis.com/css2?family=Barlow:wght@300;400;500;600;700;800&display=swap');

/* 2) Variables ASHL */
:root{
  --ashl-blue: #0096B1;
  --ashl-blue-dark: #00758A;
  --ashl-yellow: #FEBC59;
  --ashl-ink: #0F0E0D;
  --ashl-muted: #3E4A4F;
  --ashl-border: #DCE5E8;
  --ashl-bg: #FAFBFC;
  --ashl-card: #FFFFFF;
  --ashl-radius: 14px;
  --ashl-shadow: 0 10px 26px rgba(0,0,0,.08);
}

/* 3) Base & lisibilité */
html, body{
  font-family: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif !important;
  background: var(--ashl-bg) !important;
  color: var(--ashl-ink) !important;
}
*{ text-rendering: geometricPrecision; }

/* Titres */
h1,h2,h3{
  font-family: "Barlow", system-ui, sans-serif !important;
  letter-spacing: .2px;
  color: var(--ashl-ink) !important;
}
h1{ font-weight: 800; }
h2{ font-weight: 700; border-bottom: 1px solid var(--ashl-border); padding-bottom: .35rem; }
h3{ font-weight: 600; color: var(--ashl-muted) !important; }

/* Texte */
p, li, label, th, td, small{ color: var(--ashl-ink) !important; }
.help, .hint, .notice, .muted, .small, small{ color: var(--ashl-muted) !important; }

/* Liens */
a{ color: var(--ashl-blue-dark) !important; }
a:hover{ color: var(--ashl-blue) !important; text-decoration: underline; }

/* 4) Encarts / cartes */
.box, .card, .panel, .content, .main .block, fieldset{
  background: var(--ashl-card) !important;
  border: 1px solid var(--ashl-border) !important;
  border-radius: var(--ashl-radius) !important;
  box-shadow: var(--ashl-shadow);
}

/* 5) Formulaires */
input[type="text"], input[type="email"], input[type="url"], input[type="number"],
input[type="date"], input[type="password"], select, textarea{
  font-family: "Barlow", system-ui, sans-serif !important;
  border-radius: 12px !important;
  border: 1px solid var(--ashl-border) !important;
  background: #fff !important;
  padding: .55rem .7rem !important;
  color: var(--ashl-ink) !important;
}
input::placeholder, textarea::placeholder{ color: rgba(15,14,13,.55) !important; }
input:focus, select:focus, textarea:focus{
  outline: none !important;
  border-color: rgba(0,150,177,.70) !important;
  box-shadow: 0 0 0 4px rgba(0,150,177,.14) !important;
}

/* 6) Boutons */
button, .btn, input[type="submit"], input[type="button"]{
  font-family: "Barlow", system-ui, sans-serif !important;
  border-radius: 12px !important;
  border: 1px solid rgba(0,150,177,.35) !important;
  background: linear-gradient(180deg, var(--ashl-blue), var(--ashl-blue-dark)) !important;
  color: #fff !important;
  font-weight: 700 !important;
  padding: .55rem .9rem !important;
  box-shadow: 0 8px 18px rgba(0,150,177,.22);
  transition: transform .05s ease, filter .15s ease;
}
button:hover, .btn:hover, input[type="submit"]:hover, input[type="button"]:hover{ filter: brightness(1.05); }
button:active, .btn:active, input[type="submit"]:active, input[type="button"]:active{ transform: translateY(1px); }

/* Boutons secondaires */
.btn.secondary, .btn-alt, button.secondary{
  background: #fff !important;
  color: var(--ashl-blue-dark) !important;
  border: 1px solid var(--ashl-border) !important;
  box-shadow: none !important;
}
.btn.secondary:hover, .btn-alt:hover, button.secondary:hover{ background: rgba(0,150,177,.06) !important; }

/* 7) Tables (base) */
table.list, .list table{
  border-collapse: separate !important;
  border-spacing: 0 !important;
  overflow: hidden;
  border-radius: var(--ashl-radius) !important;
  border: 1px solid var(--ashl-border) !important;
  background: #fff !important;
}

/* 8) Messages */
.confirm, .ok, .success{
  border-left: 5px solid var(--ashl-blue) !important;
  background: rgba(0,150,177,.10) !important;
  padding: .7rem .85rem !important;
  border-radius: 12px !important;
  color: var(--ashl-ink) !important;
}
.error, .alert, .fail{
  border-left: 5px solid #B00020 !important;
  background: rgba(176,0,32,.08) !important;
  padding: .7rem .85rem !important;
  border-radius: 12px !important;
  color: var(--ashl-ink) !important;
}

/* 9) Badges / tags */
.badge, .tag{
  border-radius: 999px !important;
  padding: .2rem .55rem !important;
  border: 1px solid var(--ashl-border) !important;
  background: rgba(254,188,89,.18) !important;
  color: var(--ashl-ink) !important;
  font-weight: 700 !important;
}

/* 10) Menu latéral (forcer lisibilité) */
#menu, .sidebar, nav{
  background: linear-gradient(180deg, rgba(0,150,177,.12), rgba(0,150,177,.04)) !important;
  border-right: 1px solid var(--ashl-border) !important;
}
#menu a, .sidebar a, nav a{
  color: var(--ashl-ink) !important;
  opacity: 1 !important;
  font-weight: 600 !important;
}
#menu a:hover, .sidebar a:hover, nav a:hover{
  background: rgba(0,150,177,.10) !important;
  border-radius: 10px !important;
}
#menu a.active, .sidebar a.active, nav a.active{
  background: rgba(254,188,89,.25) !important;
  border-radius: 10px !important;
  font-weight: 800 !important;
}
#menu svg, .sidebar svg, nav svg{ opacity: 1 !important; }

/* 11) Confort */
hr{ border: 0 !important; border-top: 1px solid var(--ashl-border) !important; }
code, pre{ border-radius: 12px !important; }

/* 12) Mobile */
@media (max-width: 900px){
  .box, .card, .panel, .content, .main .block, fieldset{ box-shadow: none !important; }
}

/* =========================================================
   PATCH LISIBILITÉ — Listes compta (tableau + onglets + boutons)
   ========================================================= */

/* A) En-tête plus contrasté */
table.list thead th,
.list table thead th,
table thead th {
  background: linear-gradient(90deg, rgba(0,150,177,.18), rgba(254,188,89,.12)) !important;
  color: #0F0E0D !important;
  font-weight: 800 !important;
  border-bottom: 1px solid rgba(15,14,13,.15) !important;
}

/* B) Alternance douce (on vire le rose) */
table.list tbody tr,
.list table tbody tr { background: #fff !important; }
table.list tbody tr:nth-child(even),
.list table tbody tr:nth-child(even) { background: rgba(0,150,177,.04) !important; }
table.list tbody tr:hover,
.list table tbody tr:hover { background: rgba(254,188,89,.20) !important; }

/* C) Cellules */
table.list td, table.list th,
.list table td, .list table th{
  padding-top: .55rem !important;
  padding-bottom: .55rem !important;
  vertical-align: middle !important;
}

/* D) Libellés */
td, .list td{ line-height: 1.25 !important; }

/* E) Onglets */
.tabs a, .tab a, ul.tabs a, .tabs li a, ul.tabs li a{
  background: #fff !important;
  border: 1px solid rgba(15,14,13,.12) !important;
  color: #0F0E0D !important;
  font-weight: 700 !important;
  border-radius: 10px 10px 0 0 !important;
}
.tabs a:hover, .tab a:hover, ul.tabs a:hover{ background: rgba(0,150,177,.08) !important; }
.tabs .current a, .tabs .active a,
ul.tabs .current a, ul.tabs .active a,
.tabs a[aria-selected="true"]{
  background: linear-gradient(180deg, rgba(0,150,177,.22), rgba(0,150,177,.10)) !important;
  border-color: rgba(0,150,177,.40) !important;
  color: #0F0E0D !important;
  font-weight: 800 !important;
}

/* F) Petits boutons / Détails */
a.btn, .btn{ text-decoration: none !important; }

/* =========================================================
   FIX — Affichage des numéros (#xxxx) dans les listes
   (robuste : on cible td.num + numéros de colonnes)
   ========================================================= */

/* 1) Le badge numéro dans les tables (listes) */
td.num a, td.num a span, td.num span{
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0.18rem 0.55rem !important;
  border-radius: 999px !important;
  background: var(--ashl-blue-dark) !important;
  color: #ffffff !important;
  font-weight: 800 !important;
  line-height: 1.05 !important;
  letter-spacing: .2px !important;
  opacity: 1 !important;
  mix-blend-mode: normal !important;
  filter: none !important;
  text-shadow: none !important;
  white-space: nowrap !important;
  min-width: 2.4em !important;
}
td.num a:hover span{ background: var(--ashl-blue) !important; }

/* 2) Si N° est la 2e colonne sur certaines pages */
table.list td:nth-child(2) a,
.list table td:nth-child(2) a{
  white-space: nowrap !important;
}

/* =========================================================
   FIX — Compte de résultat (table.statement)
   ========================================================= */

/* Pastilles 601/701 etc */
main#content table.statement td.num a span{
  display: inline-block !important;
  padding: 0.15rem 0.45rem !important;
  border-radius: 999px !important;
  background: var(--ashl-blue-dark) !important;
  color: #ffffff !important;
  font-weight: 800 !important;
  line-height: 1.05 !important;
  border: 1px solid rgba(0,0,0,.12) !important;
  text-decoration: none !important;
}
main#content table.statement td.num a{ text-decoration: none !important; color: inherit !important; }
main#content table.statement td.num a:hover span{ background: var(--ashl-blue) !important; }

/* Alternance douce */
main#content table.statement tbody tr.odd{ background: #ffffff !important; }
main#content table.statement tbody tr.even{ background: rgba(0,150,177,.04) !important; }
main#content table.statement tbody tr:hover{ background: rgba(254,188,89,.18) !important; }

/* Montants */
main#content table.statement td.money{
  text-align: right !important;
  font-variant-numeric: tabular-nums !important;
  font-weight: 700 !important;
  color: #0F0E0D !important;
}

/* Bordures */
main#content table.statement,
main#content table.statement td,
main#content table.statement th{
  border-color: rgba(15,14,13,.12) !important;
}

/* =========================================================
   PRINT / PDF — MODE AUDIT (ultra sobre + compact)
   - Ajoute "MODE AUDIT" dans le titre imprimé
   ========================================================= */

@media print {

  /* --- Global : noir & blanc + compact --- */
  *{
    color: #000 !important;
    background: transparent !important;
    box-shadow: none !important;
    text-shadow: none !important;
    filter: none !important;
  }

  html, body{
    -webkit-print-color-adjust: economy !important;
    print-color-adjust: economy !important;
    font-family: Arial, Helvetica, sans-serif !important;
    font-size: 9pt !important;
    line-height: 1.15 !important;
  }

  /* Masquer UI */
  nav, #menu, .menu, .sidebar, .header, .topbar,
  .buttons, .actions, .search, .filter, .pagination,
  .help, .noprint, .year-header, .export, .print-btn,
  button, .btn, .button, .tabs, ul.tabs{
    display: none !important;
  }

  /* Bandeau audit en tête */
  main#content::before{
    content: "MODE AUDIT / FINANCEUR — Document comptable (export PDF)";
    display: block !important;
    font-size: 9pt !important;
    font-weight: 700 !important;
    margin: 0 0 6pt 0 !important;
    padding: 0 0 4pt 0 !important;
    border-bottom: 1px solid #000 !important;
  }

  /* Ajout MODE AUDIT dans le titre */
  h1::after{
    content: " — MODE AUDIT";
    font-weight: 700 !important;
  }

  /* Tables compactes */
  table{
    width: 100% !important;
    border-collapse: collapse !important;
    border-spacing: 0 !important;
  }
  thead th{ font-weight: 700 !important; background: transparent !important; }
  th, td{
    padding: 2pt 3pt !important;
    vertical-align: top !important;
    border: 1px solid #000 !important;
  }

  /* Alternances : off */
  tr, tr.odd, tr.even{ background: transparent !important; }

  /* Numériques */
  .money, td.money, th.money, .num, td.num, th.num{
    text-align: right !important;
    white-space: nowrap !important;
    font-variant-numeric: tabular-nums !important;
  }

  /* Pastilles => texte simple */
  td.num a, td.num a span, td.num span,
  .badge, .pill, .tag,
  a.badge, a.pill, a.tag{
    display: inline !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    background: transparent !important;
    color: #000 !important;
    border-radius: 0 !important;
    text-decoration: none !important;
    font-weight: 700 !important;
    min-width: auto !important;
  }

  a, a:visited{ color: #000 !important; text-decoration: none !important; }

  tr{ page-break-inside: avoid !important; }
  thead{ display: table-header-group !important; }
  tfoot{ display: table-footer-group !important; }

  @page{
    margin: 8mm 8mm 10mm 8mm;
  }
}

/* =========================================================
   PRINT — GRAND LIVRE UNIQUEMENT : PAYSAGE AUTO (FIABLE)
   URL détectée via html[data-url*="ledger.php"]
   -> On simule le paysage en tournant la page imprimée.
   ========================================================= */

@media print {

  /* On cible UNIQUEMENT la page "Grand livre" */
  html[data-url*="ledger.php"] body{
    /* page en portrait, mais contenu tourné */
    transform: rotate(90deg) !important;
    transform-origin: top left !important;

    /* dimensions: on "déplie" la page */
    width: 100vh !important;
    height: 100vw !important;

    /* repositionnement */
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
  }

  /* Sur Grand livre : titre spécifique */
  html[data-url*="ledger.php"] main#content::before{
    content: "MODE AUDIT / FINANCEUR — GRAND LIVRE (PAYSAGE AUTO)";
  }

  /* Sur Grand livre : police encore plus compacte */
  html[data-url*="ledger.php"] html,
  html[data-url*="ledger.php"] body{
    font-size: 8.5pt !important;
    line-height: 1.12 !important;
  }
}