/* =============================================
   PARAMÈTRES GÉNÉRAUX
   ============================================= */
html, body {
  margin: 0;
  padding: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: #f4f6f8;
  color: #222;
}

/* =============================================
   EN-TÊTE BLEU
   ============================================= */
.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #2563eb;
  color: #fff;
  padding: 0.8rem 1rem;
  margin: 0;
  border-bottom: none;
  line-height: 1;
  position: relative;
  z-index: 10;
}

.main-header .entreprise-nom {
  font-weight: bold;
  font-size: 1rem;
  min-width: 180px;
}

.main-header .page-title {
  flex: 1;
  text-align: center;
  margin: 0;
  font-size: 1.4rem;
}

/* =============================================
   BARRE DE NAVIGATION
   ============================================= */
.nav {
  background: #e8edf3;
  display: flex;
  justify-content: center;
  gap: 1rem;
  padding: 0.6rem;
  margin: 0;
  border-top: none;
  position: relative;
  top: -4px;   /* colle visuellement sous le header bleu */
  z-index: 5;
}

.nav a {
  text-decoration: none;
  color: #2563eb;
  font-weight: bold;
  padding: 2px 4px;
  border-radius: 3px;
  transition: background 0.15s;
}

.nav a:hover { background: #d1d9e6; }

.nav a.active {
  text-decoration: underline;
  color: #1d4ed8;
}

/* =============================================
   SECTIONS / CARTES
   ============================================= */
section {
  background: #fff;
  margin: 1rem;
  padding: 1rem;
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* =============================================
   BOUTONS
   ============================================= */
button {
  border: none;
  border-radius: 4px;
  padding: 0.5rem 1rem;
  font-weight: bold;
  cursor: pointer;
  color: #fff;
  transition: opacity 0.15s;
}
button:hover { opacity: 0.88; }

.btn-primary { background: #2563eb; }
.btn-success { background: #16a34a; }
.btn-danger  { background: #dc2626; }
.btn-warning { background: #f59e0b; color: #000; }

/* =============================================
   INPUTS / SELECTS
   ============================================= */
input, select, textarea {
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 5px 8px;
  font-family: inherit;
  font-size: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid #93c5fd;
  border-color: #2563eb;
}

/* =============================================
   UTILITAIRES
   ============================================= */
.flex   { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; }
.hidden { display: none; }

/* =============================================
   TABLEAUX (global)
   ============================================= */
table {
  border-collapse: collapse;
  width: 100%;
  margin-top: 1rem;
  font-size: 0.9rem;
}
th, td {
  border: 1px solid #ccc;
  padding: 6px 8px;
  text-align: left;
}
th { background: #e8edf3; font-weight: 700; color: #374151; }
tbody tr:hover td { background: #f8fafc; }

/* =============================================
   TABLE SALARIÉS
   ============================================= */
#table-salaries th, #table-salaries td {
  padding: 6px 4px;
  font-size: 0.85rem;
  text-align: center;
}
#table-salaries th:first-child,
#table-salaries td:first-child,
#table-salaries th:nth-child(2),
#table-salaries td:nth-child(2) { text-align: left; }

#table-salaries th:nth-child(3),
#table-salaries td:nth-child(3),
#table-salaries th:nth-child(4),
#table-salaries td:nth-child(4) { width: 160px; }

#table-salaries input[type="date"] {
  width: 100%;
  padding: 4px 6px;
  box-sizing: border-box;
  text-align: center;
}

/* =============================================
   TABLE PLANNING
   ============================================= */
#planning-table input     { font-size: 0.8rem; padding: 2px 3px; }
#planning-table th,
#planning-table td        { padding: 4px; text-align: center; }

.tab-jour tbody tr:nth-child(even) { background-color: #f9fafb; }
.tab-jour tbody tr:nth-child(odd)  { background-color: #ffffff; }

/* Colonnes masquables à l'impression */
.col-abs, .col-prevu, .col-ecart { width: 55px; text-align: center; }
.col-salarie { width: 150px; }
.col-ch      { width: 160px; }

/* =============================================
   TOTAUX PLANNING
   ============================================= */
#totaux {
  position: relative;
  z-index: 20;
  background: #e0e7ff;
  border-top: 2px solid #2563eb;
  font-weight: bold;
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.8rem;
  font-size: 0.9rem;
}
#totaux th { padding: 6px; color: #111827; }

/* =============================================
   JAUGE HORIZONTALE (ancienne, page planning)
   ============================================= */
.gauge-bar-wrapper {
  width: 80%;
  max-width: 600px;
  margin: 1rem auto;
  text-align: center;
}
.gauge-bar {
  position: relative;
  display: flex;
  width: 100%;
  height: 30px;
  border-radius: 15px;
  overflow: hidden;
}
.bar-segment         { height: 100%; }
.bar-segment.red     { background: red; }
.bar-segment.orange  { background: orange; }
.bar-segment.green   { background: green; }

#gauge-cursor {
  position: absolute;
  top: -8px;
  width: 0; height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 10px solid #111;
  transition: left 0.4s ease;
}
.gauge-value {
  margin-top: 0.4rem;
  font-weight: bold;
}

/* =============================================
   BADGES (page Chantiers)
   ============================================= */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}
.badge-actif   { background: #dcfce7; color: #15803d; }
.badge-termine { background: #f3f4f6; color: #6b7280; }
.badge-depasse { background: #fee2e2; color: #b91c1c; }
.badge-pause   { background: #fef9c3; color: #92400e; }

/* =============================================
   JAUGE CHANTIERS (barre de progression)
   ============================================= */
.jauge-wrapper {
  width: 100%;
  background: #e5e7eb;
  border-radius: 999px;
  height: 12px;
  overflow: hidden;
  margin-top: 3px;
}
.jauge-barre {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
}
.jauge-ok   { background: #16a34a; }
.jauge-warn { background: #f59e0b; }
.jauge-over { background: #dc2626; }

/* =============================================
   CARTES STATISTIQUES (page Chantiers / Rapports)
   ============================================= */
.stat-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 0.8rem 1.2rem;
  min-width: 150px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
}
.stat-card .val {
  font-size: 1.7rem;
  font-weight: 800;
  color: #2563eb;
  line-height: 1.1;
}
.stat-card .lbl {
  font-size: 0.8rem;
  color: #6b7280;
  margin-top: 3px;
}

/* =============================================
   ONGLETS (page Rapports)
   ============================================= */
.onglets {
  display: flex;
  gap: 0;
  border-bottom: 2px solid #2563eb;
  margin-bottom: 1rem;
}
.onglet {
  padding: 0.45rem 1.1rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  border: 1px solid #ccc;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  background: #f1f5f9;
  color: #374151;
  margin-right: 3px;
  transition: background 0.15s;
}
.onglet:hover { background: #e2e8f0; }
.onglet.actif { background: #2563eb; color: #fff; border-color: #2563eb; }

/* =============================================
   MODE LECTURE SEULE (licence inactive)
   ============================================= */
.readonly * {
  pointer-events: none;
  opacity: 0.6;
}
body.readonly #code-client,
body.readonly button[onclick="activerLicence()"] {
  pointer-events: auto !important;
  opacity: 1 !important;
}

/* =============================================
   IMPRESSION
   ============================================= */
@media print {
  /* Masquer navigation et boutons */
  header, .nav, .no-print,
  .btn, .btn-primary, .btn-success, .btn-danger, .btn-warning,
  button { display: none !important; }

  body    { background: white; color: black; }
  section { box-shadow: none; border: none; margin: 0; padding: 0; }

  /* Planning : masquer colonnes Abs / Prévu / Écart */
  .col-abs, .col-prevu, .col-ecart,
  th.col-abs, th.col-prevu, th.col-ecart,
  td.cell-abs, td.cell-prevu, td.cell-ecart { display: none !important; }

  /* Éviter coupure d'un bloc journée */
  .jour-block { page-break-inside: avoid; break-inside: avoid; }
}
