/* style.css - thème global modernisé */

/* --- Global --- */
body {
  background-color: #093E51; /* Fond bleu profond */
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  color: #f7f7fb; /* Texte clair par défaut */
  margin: 0;
  padding: 0;
  line-height: 1.5;
}

/* Container central */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
}

/* --- Cartes --- */
.card {
  background: #fff;
  color: #333;
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
  margin-bottom: 1.5rem;
  transition: transform 0.2s, box-shadow 0.2s;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(0,0,0,0.2);
}

/* --- Tables --- */
.table-wrapper {
  overflow-x: auto;
  border-radius: 0.75rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  color: #333;
  font-size: 0.9rem;
  border-radius: 0.75rem;
  overflow: hidden;
}
thead {
  background: #e6eef1;
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
}
th, td {
  padding: 0.85rem;
  border-bottom: 1px solid #d0d6d9;
  text-align: left;
}
tr:hover { background: #f9fafa; }

/* --- Badges --- */
.badge {
  display: inline-block;
  padding: 0.35rem 0.8rem;
  font-size: 0.75rem;
  border-radius: 9999px;
  font-weight: 600;
  line-height: 1;
}
.badge-valid  { background: #d1fae5; color: #065f46; }
.badge-reject { background: #fee2e2; color: #991b1b; }
.badge-pending{ background: #fef3c7; color: #92400e; }

/* --- Boutons --- */
.btn {
  display: inline-block;
  padding: 0.6rem 1.2rem;
  border-radius: 0.5rem;
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.2s, transform 0.2s;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary  { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1e40af; }
.btn-secondary { background: #4b5563; color: #fff; }
.btn-secondary:hover { background: #374151; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #991b1b; }

/* --- Pastilles de légende (camembert, etc.) --- */
.dot{display:inline-block;width:10px;height:10px;border-radius:9999px;margin-right:6px;vertical-align:middle}
.dot-yellow{background:#f59e0b}
.dot-green{background:#10b981}
.dot-red{background:#ef4444}
.dot-indigo{background:#6366f1}
.dot-gray{background:#9ca3af}

/* --- Responsive global --- */
@media (max-width: 640px) {
  table, thead, tbody, th, td, tr { font-size: 0.8rem; }
  th, td { padding: 0.6rem; }
  .btn { font-size: 0.8rem; padding: 0.5rem 0.9rem; }
  .card { padding: 1rem; }
}

/* ===== Tables responsives (opt-in) ===== */
@media (max-width: 640px) {
  /* Activer sur une table via data-responsive="stack" */
  table[data-responsive="stack"] {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
  }
  table[data-responsive="stack"] thead { display: none; }
  table[data-responsive="stack"] tbody tr {
    display: block;
    background: #fff;
    color: #333;
    border: 1px solid #e5e7eb;       /* gray-200 */
    border-radius: 0.75rem;           /* rounded-xl */
    padding: .6rem .8rem;
    margin: .5rem 0;
  }
  table[data-responsive="stack"] tbody tr:hover { background: #fff; }
  table[data-responsive="stack"] tbody td {
    display: grid;
    grid-template-columns: 9.5rem 1fr; /* Libellé | Valeur */
    gap: .5rem;
    padding: .45rem 0 !important;
    border: 0 !important;
    align-items: center;
  }
  table[data-responsive="stack"] tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: #374151; /* gray-700 */
  }
  /* Alignements utiles */
  table[data-responsive="stack"] td.text-right { justify-items: end; }
  table[data-responsive="stack"] td.text-center { justify-items: center; }

  /* Boutons d’action sur une ligne qui se replient proprement */
  .btn-row { display: flex; flex-wrap: wrap; gap: .5rem; }

  /* Barre d’avancement compacte (éviter de surcharger .w-40 de Tailwind) */
  .bar-compact { width: 110px; }
}

/* Accessibilité & petits plus */
@media (prefers-reduced-motion: reduce) { .card, .btn { transition: none; } }
.btn:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
  border-radius: 0.5rem;
}
/* ===== MOBILE FIX PACK (ajouter en bas de style.css) ===== */

/* 0) Base mobile : éviter les débordements */
@media (max-width: 640px) {
  html, body { overflow-x: hidden; }
  img, canvas, video { max-width: 100%; height: auto; }
  .overflow-x-auto { -webkit-overflow-scrolling: touch; }
}

/* 1) Cartes (cadres) plus compactes et pleines largeur */
@media (max-width: 640px) {
  .card, .bg-white.rounded, .bg-white.rounded-2xl, .bg-white.rounded-lg,
  .bg-white.p-4, .bg-white.p-6 {
    padding: 0.9rem !important;
    border-radius: 0.75rem !important;
    box-shadow: 0 2px 8px rgba(0,0,0,.10) !important;
  }
  /* Les blocs “groupe” avec bordure: adoucir */
  .border.rounded, .border.rounded-lg, .border.rounded-xl {
    border-radius: 0.75rem !important;
  }
}

/* 2) Textes longs (noms chantier/adresse) : couper proprement */
@media (max-width: 640px) {
  td, th, .card, .bg-white, .text-sm, .text-base {
    overflow-wrap: anywhere;
    word-break: break-word;
  }
}

/* 3) Boutons d’action : se replient correctement */
@media (max-width: 640px) {
  .btn-row,
  .inline-flex,
  .flex.gap-2,
  .flex.items-center.gap-2,
  .inline-flex.gap-2 {
    flex-wrap: wrap !important;
    gap: .5rem .5rem !important;
  }
  .btn, a.btn, button.btn,
  .px-2.py-1, .px-3.py-1\.5, .px-4.py-2 {
    line-height: 1.2;
  }
}

/* 4) Tableaux : empilage par défaut en mobile (sauf opt-out) */
@media (max-width: 640px) {
  /* Si tu veux TOUT empiler : enlève le :not(...) ci-dessous. */
  table:not([data-responsive="no-stack"]) {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
  }
  table:not([data-responsive="no-stack"]) thead { display: none; }
  table:not([data-responsive="no-stack"]) tbody tr {
    display: block;
    background: #fff;
    color: #333;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    padding: .65rem .8rem;
    margin: .55rem 0;
  }
  table:not([data-responsive="no-stack"]) tbody tr:hover { background: #fff; }

  /* Cellules = grille "Libellé | Valeur" */
  table:not([data-responsive="no-stack"]) tbody td {
    display: grid;
    grid-template-columns: minmax(8.5rem, 40%) 1fr;
    gap: .5rem;
    padding: .45rem 0 !important;
    border: 0 !important;
    align-items: start;
    text-align: left !important;
  }
  table:not([data-responsive="no-stack"]) tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: #374151; /* gray-700 */
  }

  /* Alignements utiles conservés */
  table:not([data-responsive="no-stack"]) td.text-right { justify-items: end; }
  table:not([data-responsive="no-stack"]) td.text-center { justify-items: center; }
}

/* 5) Si tu utilises déjà data-responsive="stack", garde la priorité */
@media (max-width: 640px) {
  table[data-responsive="stack"] tbody td {
    grid-template-columns: minmax(8.5rem, 40%) 1fr;
    align-items: start;
  }
}

/* 6) Jauges / graphs plus petits en mobile */
@media (max-width: 640px) {
  .w-40, .bar-compact { width: 110px !important; }   /* jauges “progress” */
  .pie-box, .pie-box-sm, .chart-wrap canvas {
    width: 160px !important;
    height: 160px !important;
  }
}

/* 7) Espaces sup inutiles sous le header sticky */
@media (max-width: 640px) {
  main .p-6 { padding: 1rem !important; }
  main .p-4 { padding: 0.9rem !important; }
}
