/* =========================================================
   Blitech Facturation — style.css (refactor)
   Objectif : simple, lisible, moderne, sans framework
   ========================================================= */

/* ---------------------------
   1) Tokens / variables
---------------------------- */
:root{
  /* Ces variables doivent exister chez toi ; on garde tes noms */
  /* --clr-primary: #092660; */
  /* --clr-secondary: #f4d793; */
  /* --clr-accent: #54bbf1; */

  --bg: #f7f7f7;
  --panel: #ffffff;
  --text: #1c1c1c;
  --muted: #555;

  --border: #dddddd;
  --border-soft: #eeeeee;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 2px 6px rgba(0,0,0,0.08);
  --shadow-btn: 0 2px 4px rgba(0,0,0,0.15);

  --space-1: 6px;
  --space-2: 10px;
  --space-3: 14px;
  --space-4: 18px;

  --container: 1100px;

  --fs-base: 0.95rem;
  --fs-small: 0.85rem;
}

/* ---------------------------
   2) Reset léger
---------------------------- */
*,
*::before,
*::after{ box-sizing: border-box; }

body, h1, h2, h3, h4, p, ul, li{ margin:0; padding:0; }

body{
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: var(--fs-base);
}

a{ color: var(--clr-primary); text-decoration:none; }
a:hover{ text-decoration: underline; }

/* ---------------------------
   3) Layout
---------------------------- */
main{
  width: min(95%, var(--container));
  margin: 0 auto 40px auto;
}

/* ---------------------------
   4) Header / nav
---------------------------- */
.site-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  background: var(--clr-primary);
  padding: 10px 20px;
  margin-bottom: 20px;
}

.logo-link{ display:flex; align-items:center; }
.site-logo{ height: 40px; width:auto; display:block; }

.site-nav a{
  color: var(--clr-secondary);
  font-weight: 600;
  margin-left: 15px;
  font-size: 0.95rem;
}
.site-nav a:hover{ color: var(--clr-accent); }

/* ---------------------------
   5) Typo
---------------------------- */
h1,h2,h3{
  font-weight: 700;
  color: var(--clr-primary);
}
h2{ margin-bottom: 6px; }
h3{ margin-bottom: 4px; }

section{ margin-bottom: 20px; }

/* ---------------------------
   6) Boutons
---------------------------- */
.btn, button{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap: 8px;
  background: var(--clr-primary);
  color: #fff;
  padding: 8px 16px;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration:none;
  box-shadow: var(--shadow-btn);
  transition: transform .08s ease, box-shadow .15s ease, background .15s ease;
}

.btn:hover, button:hover{
  background: var(--clr-accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.18);
}

.btn:active, button:active{
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.btn-small{
  padding: 6px 12px;
  font-size: 0.85rem;
}

.btn-secondary{
  background: #ffffff;
  color: var(--clr-primary);
  border: 1px solid #ccc;
  box-shadow: none;
}
.btn-secondary:hover{
  background: #f0f0f0;
  color: var(--clr-primary);
}

.btn-danger{ background:#b42318; }
.btn-danger:hover{ background:#d92d20; }

/* ---------------------------
   7) Inputs (éviter form global trop lourd)
---------------------------- */
.input, input, select, textarea{
  font: inherit;
  border: 1px solid #ccc;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: #fff;
}

textarea{
  resize: vertical;
  min-height: 70px;
}

/* Form “card” (utiliser .form-card quand tu veux un bloc blanc) */
.form-card{
  background: var(--panel);
  padding: 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

/* Labels */
label{
  display:block;
  font-weight: 700;
  margin-bottom: 4px;
}

/* Accessibilité : label caché */
.sr-only{
  position:absolute;
  width:1px; height:1px;
  padding:0; margin:-1px;
  overflow:hidden; clip:rect(0,0,0,0);
  white-space:nowrap; border:0;
}

/* ---------------------------
   8) Page header (titre + actions)
---------------------------- */
.page-header{
  display:flex;
  justify-content:space-between;
  gap: 16px;
  align-items:flex-start;
  margin: 10px 0 20px 0;
}

.page-header-title p{
  margin-top: 6px;
  font-size: 0.9rem;
  color: var(--muted);
}

/* Bloc actions : pleine largeur (évite l’effet “petit bloc à droite”) */
.page-header-actions{
  width: 100%;
  max-width: none;
  display:block;
}

/* Carte actions */
.header-actions-card{
  width:100%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--space-2);
  display:flex;
  flex-direction:column;
  gap: var(--space-2);
}

/* ---------------------------------------------------------
   Option B : boutons au-dessus, filtre en dessous
   - Boutons : alignés à droite, compacts
   - Filtre : ligne dédiée, plus stable visuellement
---------------------------------------------------------- */

/* toolbar boutons */
.actions-toolbar{
  display:flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content:flex-end;
}

/* filtre : ligne dédiée sous les boutons */
.filter-compact{
  display:flex;
  gap: 10px;
  align-items:center;
  justify-content:flex-end;
  border: 0;
  padding: 0;
  background: transparent;
}

/* Champ : flexible (prend l’espace), mais avec une largeur mini */
.filter-compact input[type="text"]{
  flex: 1;
  min-width: 320px;
  max-width: 520px;
  border-radius: 999px;
}

/* Boutons filtre : taille stable, pas “plein écran” sur desktop */
.filter-compact .btn{
  white-space: nowrap;
}

/* ---------------------------
   9) Flash messages
---------------------------- */
.flash{
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 15px;
  font-size: 0.95rem;
}

.flash-success{
  background: #e4f6e9;
  border: 1px solid #89c997;
  color: #236436;
}

.flash-error{
  background: #fde4e4;
  border: 1px solid #e18a8a;
  color: #842029;
}

/* ---------------------------
   10) Tables
---------------------------- */
table{
  width:100%;
  border-collapse: collapse;
  margin-top: 15px;
  background: var(--panel);
  border-radius: var(--radius-sm);
  overflow:hidden;
  font-size: 0.95rem;
}

th, td{
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th{
  background: var(--clr-primary);
  color: #fff;
  text-align:left;
  font-weight: 800;
}

/* En-têtes triables */
th a{
  color: inherit;
  text-decoration:none;
  display:inline-flex;
  align-items:center;
  gap: 6px;
}
th a:hover{ text-decoration: underline; }

/* ---------------------------
   11) “Cards” clients (inchangé)
---------------------------- */
.clients-list{
  display:flex;
  flex-direction:column;
  gap: 10px;
  margin-bottom: 20px;
}

.client-card{
  background: var(--panel);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  border: 1px solid var(--border);
}

.client-card-header{
  display:flex;
  justify-content:space-between;
  align-items:center;
  margin-bottom: 6px;
  font-size: 0.9rem;
}

.client-no{ font-weight: 800; color: var(--clr-primary); }

.client-type{
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--clr-secondary);
  font-size: 0.8rem;
}

.client-card-body{ font-size: 0.95rem; }
.client-address{ color: var(--muted); }

/* ---------------------------
   12) Footer
---------------------------- */
footer{
  margin-top: 30px;
  padding: 10px 0;
  text-align:center;
  color: #777;
  font-size: 0.85rem;
}

/* ---------------------------
   13) Responsive
   - Breakpoint volontairement à 960px (tablette + petits laptops)
---------------------------- */
@media (max-width: 960px){

  .site-header{
    flex-direction: column;
    align-items:flex-start;
    gap: 8px;
  }

  .page-header{
    flex-direction: column;
    align-items: stretch;
  }

  /* Boutons : passent en pile (plus accessible au pouce) */
  .actions-toolbar{
    justify-content: stretch;
  }
  .actions-toolbar .btn{
    width: 100%;
  }

  /* Filtre : en colonne */
  .filter-compact{
    flex-direction: column;
    align-items: stretch;
    justify-content: stretch;
  }

  .filter-compact input[type="text"]{
    width: 100%;
    min-width: 0;
    max-width: none;
  }

  .filter-compact .btn{
    width: 100%;
  }

  /* --- Table -> cartes (mobile) ---
     Requiert data-label="" sur chaque <td>
     Option 2 : masque période + total HT si classes présentes
  */
  td.col-periode,
  td.col-ht{ display:none; }

  thead{ display:none; }

  tbody tr{
    display:block;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--panel);
    overflow:hidden;
  }

  tbody td{
    display:flex;
    justify-content:space-between;
    gap: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-soft);
    text-align: right;
  }

  tbody td:last-child{ border-bottom:0; }

  tbody td::before{
    content: attr(data-label);
    font-weight: 800;
    color: var(--muted);
    flex: 0 0 42%;
    text-align:left;
  }

  tbody td[data-label="Actions"]{
    gap: 8px;
  }
}
