/* Disposition Aircooling sur grand écran.
   - PC (≥ 1200 px) : menu latéral, tableaux, formulaires en deux colonnes.
   - Planning (≥ 768 px, PC et tablette) : vue calendrier à bandes continues.
   Sous 1200 px, aucun autre écran ne change ; sous 768 px, le Planning ne change pas.
   Chargé après les autres feuilles ; les couleurs existantes sont réutilisées. */

.side-nav { display:none; }
.visually-hidden { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; }
.planning-today-button { display:none; }

/* Sous 1200 px : affichage d'origine des listes (outils de recherche masqués). */
.list-toolbar { display:contents; }
.list-search,#saved-view .list-toolbar { display:none; }

/* ======================== PC (≥ 1200 px) ======================== */
@media (min-width:1200px) {
  /* ---------- Socle : menu latéral et largeur utile ---------- */
  body[data-role]:not([data-role=""]) .side-nav { display:flex; flex-direction:column; gap:4px; position:fixed; z-index:5; top:80px; bottom:0; left:0; width:248px; padding:24px 14px; overflow-y:auto; border-right:1px solid var(--line); background:#fff; }
  body[data-role]:not([data-role=""]) .app-shell { max-width:1320px; margin:0 auto 0 248px; padding:36px 40px 72px; }
  body[data-role]:not([data-role=""]) .privacy-footer { max-width:1320px; margin:0 auto 0 248px; }
  body[data-role]:not([data-role=""]) .topbar { padding:0 32px; }
  body[data-role]:not([data-role=""]) .hero h1,body[data-role]:not([data-role=""]) .form-header h1 { font-size:2.5rem; }
  .side-nav-item { display:flex; align-items:center; gap:12px; width:100%; min-height:46px; padding:10px 12px; border:0; border-radius:10px; color:var(--ink); background:transparent; font-weight:700; text-align:left; }
  .side-nav-item svg { flex:0 0 22px; width:22px; height:22px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; color:var(--blue); }
  .side-nav-item span { min-width:0; overflow-wrap:anywhere; }
  .side-nav-item:hover { background:var(--ice); }
  .side-nav-item.is-active { color:var(--blue); background:var(--ice); box-shadow:inset 3px 0 0 var(--blue); }

  /* ---------- Listes métier en tableau ---------- */
  .list-toolbar { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:12px; margin-top:22px; }
  #saved-view .list-toolbar { display:flex; }
  .list-toolbar .record-filter { margin-top:0; }
  .list-search { display:block; flex:1 1 280px; max-width:440px; }
  .list-search input { min-height:46px; padding-left:14px; background:#fff; }
  .record-page.saved-section { margin-top:18px; padding-top:0; border-top:0; }
  .sheet-table,.bon-table { gap:0; margin-top:0; overflow:hidden; border:1px solid var(--line); border-radius:12px; background:#fff; box-shadow:0 2px 5px #173d4c08; }
  .sheet-table > .field-help,.bon-table > .field-help { margin:0; padding:16px; }
  .record-head,.record-row { display:grid; grid-template-columns:var(--record-columns); align-items:center; gap:18px; min-width:0; padding:13px 18px; }
  .record-head { color:var(--muted); background:#f3f7fc; font-size:.74rem; font-weight:800; letter-spacing:.05em; text-transform:uppercase; border-bottom:1px solid var(--line); }
  .record-head span:last-child { text-align:right; }
  .record-row + .record-row { border-top:1px solid #edf1f5; }
  .record-row:hover { background:#fafcff; }
  .record-row > * { min-width:0; }
  .record-primary strong { display:block; color:var(--navy); overflow-wrap:anywhere; }
  .record-primary span { display:block; margin-top:3px; color:var(--muted); font-size:.88rem; overflow-wrap:anywhere; }
  .record-cell { color:#41586d; font-size:.88rem; overflow-wrap:anywhere; }
  .record-status { display:flex; flex-wrap:wrap; gap:6px; }
  .record-actions { display:flex; flex-wrap:wrap; justify-content:flex-end; gap:8px; }
  .sheet-table { --record-columns:minmax(0,1.5fr) minmax(0,1.6fr) 130px 190px; }
  .bon-table { --record-columns:minmax(0,1.3fr) 105px minmax(0,.8fr) 90px minmax(470px,2.6fr); }

  /* ---------- Détail d'une fiche d'intervention ---------- */
  #intervention-sheet-form { display:grid; grid-template-columns:minmax(0,1.1fr) minmax(0,1fr); gap:20px; align-items:start; }
  #intervention-sheet-form > .form-section:first-child { grid-row:span 2; }
  #intervention-sheet-form > .form-error { margin:0; }
  #intervention-sheet-form > .form-error,#intervention-sheet-form > .form-actions { grid-column:1 / -1; }
  #intervention-sheet-form .four-choice-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }

  /* ---------- Formulaire du bon d'intervention ---------- */
  #intervention-form { grid-template-columns:repeat(2,minmax(0,1fr)); gap:20px; align-items:stretch; }
  #intervention-form > .signatures-section,#intervention-form > .privacy-notice,#intervention-form > .form-error,#intervention-form > .form-actions { grid-column:1 / -1; }
}

/* ============ Planning calendrier (≥ 768 px, PC et tablette) ============ */
@media (min-width:768px) {
  #planning-view { overflow-x:visible; }
  .planning-today-button { display:inline-flex; align-items:center; min-height:44px; }
  .planning-navigation strong { min-width:170px; }
  .planning-grid.tt-calendar { display:block; min-width:0; margin-bottom:0; overflow:hidden; border:1px solid var(--line); border-radius:12px; background:#fff; }
  .tt-weekdays { display:grid; grid-template-columns:repeat(7,minmax(0,1fr)); border-bottom:1px solid var(--line); background:#f6f9fd; }
  .tt-weekdays span { padding:8px 6px; color:var(--muted); font-size:.74rem; font-weight:800; text-align:center; text-transform:uppercase; letter-spacing:.04em; }
  .tt-weekdays span:last-child { color:var(--danger); }
  /* Une semaine = fond des 7 cases (couche du dessous) + lignes empilées : numéros, rangées de bandes, « +N ». */
  .tt-week { --tt-lane:24px; --tt-more:6px; position:relative; display:flex; flex-direction:column; gap:3px; padding-bottom:4px; }
  .tt-week + .tt-week { border-top:1px solid var(--line); }
  .tt-cells { position:absolute; inset:0; display:grid; grid-template-columns:repeat(7,minmax(0,1fr)); }
  .tt-line { position:relative; display:grid; grid-template-columns:repeat(7,minmax(0,1fr)); }
  .tt-line > * { grid-row:1; } /* une seule rangée par ligne, quel que soit l'ordre des bandes */
  .tt-lane { height:var(--tt-lane); }
  .tt-more-line { flex:1 0 auto; min-height:var(--tt-more); }
  .tt-cell { border-left:1px solid #edf1f5; background:#fff; }
  .tt-cell:first-child { border-left:0; }
  .tt-cell.is-outside-month { background:#f4f6f9; }
  .tt-day { z-index:1; display:flex; align-items:flex-start; gap:4px; min-width:0; padding:5px 5px 2px; }
  .tt-day-number { display:inline-grid; place-items:center; flex:0 0 auto; min-width:30px; height:30px; padding:0 6px; border:0; border-radius:99px; color:var(--navy); background:transparent; font-weight:800; font-size:.86rem; }
  .tt-day-number:hover { background:var(--ice); }
  .tt-day.is-outside-month .tt-day-number { color:#9aa8b8; }
  .tt-day.is-red .tt-day-number { color:var(--danger); }
  .tt-day.is-outside-month.is-red .tt-day-number { color:#e3a3a0; }
  .tt-day.is-today .tt-day-number { color:#fff; background:var(--navy); }
  .tt-holiday { min-width:0; overflow:hidden; padding-top:7px; color:var(--danger); font-size:.68rem; font-weight:800; line-height:1.2; text-overflow:ellipsis; white-space:nowrap; }
  .tt-band { z-index:2; display:block; min-width:0; height:24px; margin:0 3px; padding:0 7px; overflow:hidden; border-width:1px; border-style:solid; border-radius:5px; color:var(--navy); font-size:.76rem; line-height:22px; text-align:left; text-overflow:ellipsis; white-space:nowrap; }
  .tt-band strong { font-weight:800; }
  .tt-band small { margin-left:5px; color:#48627f; font-size:.7rem; }
  .tt-band:hover { filter:brightness(.97); }
  .tt-band.continues-before { margin-left:0; border-left-width:0; border-top-left-radius:0; border-bottom-left-radius:0; }
  .tt-band.continues-after { margin-right:0; border-right-width:0; border-top-right-radius:0; border-bottom-right-radius:0; }
  .tt-more { z-index:2; justify-self:start; min-height:24px; margin:0 4px; padding:0 6px; border:0; border-radius:5px; color:var(--blue); background:transparent; font-size:.76rem; font-weight:800; text-align:left; }
  .tt-more:hover { background:var(--ice); }
  .planning-week.tt-calendar .tt-week { min-height:260px; }
}
@media (min-width:768px) and (max-width:1199px) {
  .tt-week { --tt-lane:28px; }
  .tt-day-number { min-width:34px; height:34px; }
  .tt-band { height:28px; line-height:26px; }
  .tt-more { min-height:28px; }
}

/* ======================== Téléphone (< 768 px) ========================
   Finition du téléphone uniquement : la tablette (≥ 768 px) et le PC ne sont pas concernés.
   Mêmes couleurs, icônes et typographie ; cartes compactes, cibles tactiles de 44 px minimum. */
@media (max-width:767px) {
  /* ---------- En-tête : logo entier, boutons sur une ligne ---------- */
  .topbar { height:64px; padding:0 12px; gap:8px; }
  .brand { flex:0 0 auto; width:76px; height:46px; }
  .brand-logo { width:76px; height:76px; transform:translateY(-13px); }
  .sync-status { display:none; }
  .topbar-actions { gap:6px; }
  .logout-button { min-height:40px; padding:8px 8px; font-size:.78rem; white-space:nowrap; }

  /* ---------- Page : marges régulières, titres lisibles ---------- */
  .app-shell { padding:18px 16px 40px; }
  .hero { margin-bottom:16px; }
  .hero h1,.form-header h1 { font-size:1.75rem; }
  .form-header { gap:4px; margin-bottom:18px; }
  .back-button { min-height:44px; }
  .privacy-footer { padding:0 16px 24px; }

  /* ---------- Cartes de navigation : icône, titre et description, flèche ---------- */
  .workspace-grid,.home-dashboard { gap:10px; grid-auto-rows:auto; }
  .workspace-card,.home-dashboard .workspace-card,.administration-actions .workspace-card { height:auto; min-height:72px; gap:14px; padding:14px 16px; border-radius:14px; }
  .workspace-card strong { font-size:1.05rem; }
  .workspace-card small { margin-top:2px; font-size:.85rem; }

  /* ---------- Espace Technicien : compteur lisible ---------- */
  #technician-view .document-category { margin-bottom:22px; }
  #saved-count-technician { margin-left:8px; padding:1px 8px; border-radius:99px; color:var(--blue); background:#fff; font-size:.8rem; }

  /* ---------- Listes « Bons enregistrés » et « Fiches d'intervention » uniquement : texte puis actions ----------
     (Rapports d'entretien, Facturation, Commercial et Gestion des accès ne sont pas concernés.) */
  :is(#saved-view,#intervention-sheets-view) .saved-section-page { margin-top:14px; padding-top:0; border-top:0; }
  :is(#saved-view,#intervention-sheets-view) .saved-list { margin-top:12px; }
  :is(#saved-view,#intervention-sheets-view) .saved-item { flex-direction:column; align-items:stretch; gap:12px; padding:14px; }
  :is(#saved-view,#intervention-sheets-view) .saved-item > div:first-child { min-width:0; }
  :is(#saved-view,#intervention-sheets-view) .saved-item strong { overflow-wrap:anywhere; }
  :is(#saved-view,#intervention-sheets-view) .saved-item .billing-actions { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
  /* Statut en premier ; un bouton seul sur sa ligne prend toute la largeur. */
  :is(#saved-view,#intervention-sheets-view) .saved-item .billing-actions > .pill { grid-column:1 / -1; justify-self:start; }
  :is(#saved-view,#intervention-sheets-view) .saved-item .billing-actions > button:last-child:nth-child(even) { grid-column:1 / -1; }
  :is(#saved-view,#intervention-sheets-view) .billing-action { min-height:44px; }
  #saved-view .pill-locked { color:#0d663d; background:#dcf5e7; } /* « Validé » en vert, comme sur PC */
  #intervention-sheets-view .record-filter { display:grid; grid-template-columns:repeat(auto-fit,minmax(0,1fr)); width:100%; margin-top:16px; }
  #intervention-sheets-view .record-filter button { min-height:44px; white-space:normal; }
  #refresh-intervention-sheets { width:auto; min-height:44px; padding:10px 16px; }

  /* ---------- Planning : une carte par jour, en liste verticale, textes entiers ---------- */
  #planning-view { overflow-x:visible; }
  .planning-calendar-switch { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); }
  .planning-calendar-switch button { min-height:44px; white-space:normal; line-height:1.2; }
  #planning-actions { margin-bottom:12px; }
  .planning-navigation strong { font-size:.9rem; text-transform:none; }
  .planning-navigation strong::first-letter { text-transform:uppercase; }
  .planning-grid,.planning-grid.planning-week,.planning-grid.planning-month { grid-template-columns:minmax(0,1fr); gap:8px; min-width:0; margin-bottom:0; }
  .planning-day { min-height:0; padding:12px 14px; }
  .planning-day.is-today { border-color:var(--blue); box-shadow:inset 3px 0 0 var(--blue); }
  .planning-day h2 { margin-bottom:8px; font-size:.95rem; text-transform:none; }
  .planning-day-title { display:inline-block; min-height:32px; }
  .planning-day-title::first-letter { text-transform:uppercase; }
  .planning-events > p { margin:0; }
  .planning-event { padding:10px 12px; }
  .planning-event strong,.planning-event span,.planning-event small { overflow:visible; white-space:normal; overflow-wrap:anywhere; }
  .planning-event strong { font-size:.92rem; }
  .planning-event span,.planning-event small { font-size:.82rem; }
  /* Jour vide (vue Mois) : ligne compacte, toute la ligne ouvre l'aperçu du jour comme avant. */
  .planning-day.is-empty { padding:0; }
  .planning-day.is-empty h2 { margin:0; font-weight:700; }
  .planning-day.is-empty .planning-day-title { display:block; width:100%; min-height:44px; padding:0 14px; color:var(--muted); font-weight:700; }
  .planning-day.is-empty.is-today .planning-day-title { color:var(--navy); font-weight:800; }

  /* ---------- Formulaires longs : Bon d'intervention, Fiche d'intervention, élément du Planning ----------
     (formulaires des Rapports d'entretien, du module Commercial et du compte non concernés). */
  :is(#form-view,#intervention-sheet-form-view,#planning-entry-form-view) .form-section { padding:16px; border-radius:12px; }
  :is(#form-view,#intervention-sheet-form-view,#planning-entry-form-view) .form-section h2 { margin-bottom:14px; }
  :is(#form-view,#intervention-sheet-form-view,#planning-entry-form-view) .form-grid { gap:14px; }
  #intervention-form { gap:14px; }
  #intervention-sheet-form,#planning-entry-form { display:grid; gap:14px; }
  #intervention-form .form-grid + fieldset { margin-top:18px; }
  /* Champs date et heure : même largeur et même alignement que les autres champs. Les navigateurs mobiles
     (Safari en particulier) leur donnent sinon une largeur propre qui dépasse ou se décale. */
  :is(#form-view,#intervention-sheet-form-view,#planning-entry-form-view) label { min-width:0; }
  :is(#form-view,#intervention-sheet-form-view,#planning-entry-form-view) :is(input[type="date"],input[type="time"]) { display:block; width:100%; min-width:0; max-width:100%; min-height:46px; margin:0; -webkit-appearance:none; appearance:none; background:#fff; text-align:left; }
  :is(#form-view,#intervention-sheet-form-view,#planning-entry-form-view) :is(input[type="date"],input[type="time"])::-webkit-date-and-time-value { margin:0; text-align:left; }
  #intervention-form .signature-heading h3 { font-size:.9rem; }
  :is(#form-view,#intervention-sheet-form-view,#planning-entry-form-view) .form-actions { gap:10px; }
  :is(#form-view,#intervention-sheet-form-view,#planning-entry-form-view) .form-actions .button { min-height:50px; }
  :is(#form-view,#intervention-sheet-form-view,#planning-entry-form-view) .form-actions .button-primary { min-height:54px; font-size:1.05rem; }
}
