/* HABILLAGE VISUEL — RELEVÉS DE FONCTIONNEMENT UI
   Même style "B+D" que le Procès-Verbal / DRV-Utopia (Segoe UI, bandeau
   anthracite + liseré rouge, coins arrondis, ombre douce), appliqué au
   tableau des relevés des unités intérieures (FROID en bleu / CHAUD en saumon,
   comme sur la fiche papier Hitachi). */

:root {
  --font: "Segoe UI", Inter, -apple-system, Arial, sans-serif;
  --rfui-froid: #1f6fb5;
  --rfui-froid-sub: #d6e6f5;
  --rfui-froid-cell: #e8f1fa;
  --rfui-froid-cell-alt: #dde9f6;
  --rfui-chaud: #c8102e;
  --rfui-chaud-sub: #f5d3c6;
  --rfui-chaud-cell: #fbeae3;
  --rfui-chaud-cell-alt: #f6ddd3;
}
body {
  font-family: var(--font);
}

/* ===== EN-TÊTE (titre sur 2 lignes) ===== */
.page-header-title h1 {
  font-size: 24px;
  line-height: 1.18;
  letter-spacing: -0.2px;
}
.page {
  padding-top: 5mm;
}
.page-header {
  margin-bottom: 2px;
  padding-bottom: 2px;
}
.hitachi-logo .logo-text {
  color: var(--red);
}

/* ===== PAGE & BLOCS : coins arrondis + ombre douce ===== */
.page {
  border-radius: 14px;
  box-shadow: 0 4px 20px rgba(20, 20, 30, 0.14);
  overflow: hidden;
}
.block {
  border-radius: 12px;
  border-color: #e2e2e6;
  box-shadow: 0 2px 10px rgba(20, 20, 30, 0.06);
  overflow: hidden;
}

/* ===== BANDEAU DE SECTION : anthracite + liseré rouge ===== */
.section-title {
  background: #20232b !important;
  position: relative;
  padding-left: 18px !important;
  padding-right: 18px !important;
  text-transform: uppercase;
}
.section-title::before,
.section-title::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--red);
}
.section-title::before {
  left: 0;
}
.section-title::after {
  right: 0;
}

/* ===== CHAMPS ===== */
input[type="text"],
input[type="date"],
select {
  background: #d7d9df !important;
  border-radius: 7px;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
input[type="text"]:focus,
input[type="date"]:focus,
select:focus {
  background: #fffde7 !important;
  border-color: var(--red) !important;
  box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.12);
}

/* ===== BOUTONS ===== */
.btn {
  border-radius: 8px;
}
.btn:disabled {
  background: #b9bbc2;
  cursor: not-allowed;
}
.btn-secondary {
  background: #777;
}
.btn-secondary:hover {
  background: #555;
}

/* ===== TABLEAU DES RELEVÉS ===== */
.rfui-table-wrap {
  width: 100%;
}
.rfui-table {
  table-layout: fixed;
  width: 100%;
  font-size: 10px;
}
.rfui-col-ad {
  width: 7mm;
}
.rfui-col-modele {
  width: 27mm;
}
.rfui-col-lieu {
  width: 29mm;
}
.rfui-col-val,
.rfui-col-end {
  width: auto;
}

/* En-têtes : anthracite par défaut (Ad, Modèle, Emplacement, GrT, CH) */
.rfui-table th {
  background: #5a5f6c;
  color: #fff;
  font-size: 10px;
  padding: 3px 2px;
  line-height: 1.15;
}
.rfui-table th.rfui-th-froid {
  background: var(--rfui-froid);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.rfui-table th.rfui-th-chaud {
  background: var(--rfui-chaud);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
/* Codes affichés par la télécommande / l'afficheur 7 segments */
.rfui-table th.rfui-code {
  font-family: var(--font); /* Segoe UI, comme le reste du rapport */
  font-weight: 700;
  font-size: 10px;
  padding: 2px 0;
}
.rfui-table th.rfui-sub-froid {
  background: var(--rfui-froid-sub);
  color: var(--rfui-froid);
}
.rfui-table th.rfui-sub-chaud {
  background: var(--rfui-chaud-sub);
  color: var(--rfui-chaud);
}

/* Cellules */
.rfui-table td {
  padding: 0;
  height: 8.6mm;
}
.rfui-table td.rfui-td-ad {
  font-weight: 700;
  background: #fff;
  padding: 0 2px;
}
.rfui-table td.rfui-td-txt {
  background: #f4f5f7;
}
.rfui-table td.rfui-td-froid {
  background: var(--rfui-froid-cell);
}
.rfui-table td.rfui-td-chaud {
  background: var(--rfui-chaud-cell);
}
.rfui-table td.rfui-td-end {
  background: #f4f5f7;
}
/* Zébrage léger, en conservant la couleur de chaque zone */
.rfui-table tbody tr:nth-child(even) td.rfui-td-ad,
.rfui-table tbody tr:nth-child(even) td.rfui-td-txt,
.rfui-table tbody tr:nth-child(even) td.rfui-td-end {
  background: #e9ebef;
}
.rfui-table tbody tr:nth-child(even) td.rfui-td-froid {
  background: var(--rfui-froid-cell-alt);
}
.rfui-table tbody tr:nth-child(even) td.rfui-td-chaud {
  background: var(--rfui-chaud-cell-alt);
}
/* Séparateurs plus marqués entre les groupes de colonnes */
.rfui-table td:nth-child(3),
.rfui-table td:nth-child(9),
.rfui-table td:nth-child(15) {
  border-right: 2px solid #8a8e99;
}

/* Champs dans les cellules : transparents, ils suivent la couleur de la cellule */
.rfui-table td input[type="text"] {
  background: transparent !important;
  border: none;
  border-radius: 0;
  width: 100%;
  height: 100%;
  min-height: var(--field-h);
  padding: 0 2px;
  text-align: center;
  font-size: 10px;
}
.rfui-table td.rfui-td-txt input[type="text"] {
  text-align: left;
  padding: 0 4px;
}
.rfui-table td input[type="text"]:focus {
  background: #fffde7 !important;
  box-shadow: inset 0 0 0 2px var(--red);
}

/* Barre "+ Ajouter une ligne" sous le tableau */
.rfui-rows-bar {
  align-items: center;
  padding: 6px 8px;
}
.rfui-rows-bar .btn {
  font-size: 10px;
  padding: 5px 12px;
}
.rfui-rows-count {
  font-size: 10px;
  color: #666;
  margin-right: auto;
  order: -1;
}

/* ===== ONGLETS Unité / Froid / Chaud (petits écrans uniquement) ===== */
.rfui-tabs {
  display: none;
}

/* ===== PETITS ÉCRANS : un seul groupe de colonnes à la fois =====
   Sous 860px, les 17 colonnes ne tiennent plus en largeur : on affiche la
   colonne "Ad" + le groupe choisi dans les onglets (Unité = Modèle,
   Emplacement, GrT, CH ; Froid ; Chaud). Le tableau occupe toujours 100 % de
   la largeur, sans défilement horizontal. L'impression n'est pas concernée
   (règles limitées à "screen") et affiche le tableau complet. */
@media screen and (max-width: 860px) {
  .page-header-title h1 {
    font-size: 17px;
  }
  .rfui-tabs {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 8px 6px;
    background: #fff;
  }
  .rfui-tabs button {
    flex: 1 1 0;
    max-width: 130px;
    border: 1px solid #5a5f6c;
    background: #fff;
    color: #5a5f6c;
    border-radius: 14px;
    padding: 6px 10px;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
  }
  .rfui-tabs button.on {
    background: #5a5f6c;
    color: #fff;
  }
  .rfui-tabs button.rfui-tab-froid {
    border-color: var(--rfui-froid);
    color: var(--rfui-froid);
  }
  .rfui-tabs button.rfui-tab-froid.on {
    background: var(--rfui-froid);
    color: #fff;
  }
  .rfui-tabs button.rfui-tab-chaud {
    border-color: var(--rfui-chaud);
    color: var(--rfui-chaud);
  }
  .rfui-tabs button.rfui-tab-chaud.on {
    background: var(--rfui-chaud);
    color: #fff;
  }

  .rfui-table {
    table-layout: auto;
    width: 100%;
  }
  .rfui-table col {
    width: auto;
  }
  .rfui-table th,
  .rfui-table td.rfui-td-ad {
    font-size: 12px;
  }
  .rfui-table td.rfui-td-ad,
  .rfui-table thead th:first-child {
    width: 34px;
  }
  .rfui-table td {
    height: 36px;
  }
  .rfui-table td input[type="text"] {
    font-size: 14px;
    min-width: 0;
  }

  /* Masquage des groupes non choisis */
  .rfui-table[data-mode="id"] .g-froid,
  .rfui-table[data-mode="id"] .g-chaud,
  .rfui-table[data-mode="froid"] .g-id,
  .rfui-table[data-mode="froid"] .g-chaud,
  .rfui-table[data-mode="chaud"] .g-id,
  .rfui-table[data-mode="chaud"] .g-froid {
    display: none;
  }
  /* Onglet Unité : Modèle et Emplacement larges, GrT / CH étroits */
  .rfui-table[data-mode="id"] td.rfui-td-end,
  .rfui-table[data-mode="id"] th.g-id:nth-last-child(-n + 2) {
    width: 16%;
  }
  /* Le séparateur épais après "Emplacement" n'a plus de sens quand les groupes sont séparés */
  .rfui-table td:nth-child(3),
  .rfui-table td:nth-child(9),
  .rfui-table td:nth-child(15) {
    border-right: 1px solid var(--border);
  }
}

/* ===== PAGES D'IMPRESSION GÉNÉRÉES (invisibles à l'écran) ===== */
@media screen {
  #rfui-print-pages {
    display: none;
  }
}
.rfui-print-val {
  display: block;
  padding: 0 2px;
  font-size: 10px;
  line-height: 8.6mm;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rfui-td-txt .rfui-print-val {
  text-align: left;
  padding: 0 4px;
}
.rfui-print-meta {
  white-space: nowrap;
}

/* ===== IMPRESSION ===== */
@media print {
  /* La feuille elle-même reste à angles droits, mais le bloc du tableau garde
     ses coins arrondis comme à l'écran (et comme sur les autres rapports). */
  .page {
    border-radius: 0;
    box-shadow: none;
  }
  .block {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: none;
  }
  .rfui-table thead {
    display: table-header-group; /* en-tête répété si le tableau déborde sur une 2e page */
  }
  .rfui-table tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .rfui-table th,
  .rfui-table td {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  /* Pages générées : chaque page reprend en-tête + tableau + pied de page */
  .rfui-print-page {
    display: flex !important;
    flex-direction: column !important;
  }
  /* Pas de page blanche en fin d'impression quand il n'y a aucune photo */
  #rfui-print-pages:has(+ #rfui-photo-pages:empty) .page:last-child {
    page-break-after: auto !important;
    break-after: auto !important;
  }
  #rfui-photo-pages .page:last-child {
    page-break-after: auto !important;
    break-after: auto !important;
  }
}
