/* =============================================================================
 * style.css — Mise en page du simulateur (responsive + impression A4)
 * =============================================================================
 * CHANGELOG
 *   v1.0.0 — 2026-05-29
 *     - Thème, accordéon, grilles de formulaire, tableaux du bulletin,
 *       filigrane "SIMULATION", règles @media (mobile/tablette) et @media print.
 *   POINTS À VÉRIFIER :
 *     - [ ] Rendu d'impression A4 selon navigateur (marges).
 * ========================================================================== */

:root {
  --bg: #f3f4f6;
  --card: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #d1d5db;
  --accent: #1d4ed8;
  --accent-dark: #1e3a8a;
  --total: #eef2ff;
  --grp: #f9fafb;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.4;
  padding: 16px;
}

/* ---------- En-tête application ---------- */
.app-header { text-align: center; margin-bottom: 16px; }
.app-header h1 { font-size: 1.6rem; margin: 0 0 4px; color: var(--accent-dark); }
.app-subtitle { color: var(--muted); margin: 0; }

/* ---------- Accordéon ---------- */
.accordion { background: var(--card); border-radius: var(--radius); box-shadow: 0 1px 3px rgba(0,0,0,.1); margin-bottom: 16px; overflow: hidden; }
.accordion-header {
  width: 100%; text-align: left; border: 0; background: var(--accent); color: #fff;
  font-size: 1.1rem; font-weight: 600; padding: 14px 18px; cursor: pointer;
}
.accordion-body { padding: 16px; display: none; }
.accordion.open .accordion-body { display: block; }

/* ---------- Formulaire ---------- */
fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 14px; padding: 12px 14px; }
legend { font-weight: 600; color: var(--accent-dark); padding: 0 6px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
label { display: flex; flex-direction: column; font-size: .85rem; color: var(--muted); gap: 4px; }
label.full { grid-column: 1 / -1; }
input, select {
  font-size: .95rem; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 6px; color: var(--ink); background: #fff; width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.hint { font-size: .8rem; color: var(--muted); margin: 8px 0 0; }

/* ---------- Autocomplétion d'adresse (liste personnalisée, mobile-friendly) ---------- */
.ac-wrap { position: relative; display: block; }
.ac-list {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 20;
  margin: 2px 0 0; padding: 0; list-style: none;
  background: #fff; border: 1px solid var(--line); border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,.12); max-height: 240px; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.ac-list.hidden { display: none; }
.ac-item {
  padding: 10px 12px; font-size: .9rem; color: var(--ink); cursor: pointer;
  border-bottom: 1px solid var(--grp); touch-action: manipulation;
}
.ac-item:last-child { border-bottom: 0; }
.ac-item:hover, .ac-item:active { background: var(--total); }
.check { flex-direction: row; align-items: center; gap: 8px; margin-top: 10px; }
.check input { width: auto; }

.daytable { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 10px; }
.daytable > span { font-size: .85rem; color: var(--muted); }
.daytable label { flex-direction: row; align-items: center; gap: 6px; }
.daytable input { width: 70px; }
input[readonly] { background: var(--grp); color: var(--muted); cursor: not-allowed; }

/* ---------- Messages d'erreur ---------- */
.errors { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; border-radius: 8px; padding: 10px 16px; margin-bottom: 16px; }
.errors ul { margin: 0; padding-left: 18px; }

/* ---------- Cartes ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: 0 1px 3px rgba(0,0,0,.1); padding: 16px; margin-bottom: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.card h2 { margin: 0 0 12px; color: var(--accent-dark); font-size: 1.25rem; }
.btn { background: var(--accent); color: #fff; border: 0; padding: 10px 16px; border-radius: 8px; font-size: .95rem; cursor: pointer; }
.btn:hover { background: var(--accent-dark); }

/* ---------- Synthèse ---------- */
.synth-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.synth-item { background: var(--total); border-radius: 8px; padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.synth-item span { font-size: .8rem; color: var(--muted); }
.synth-item strong { font-size: 1.15rem; color: var(--accent-dark); }

/* ====================================================================
 * BULLETIN SIMULÉ
 * ================================================================== */
.payslip {
  position: relative; background: #fff; border: 1px solid var(--line);
  border-radius: 8px; padding: 22px; overflow: hidden;
}

/* Filigrane rouge diagonal */
.watermark {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%) rotate(-32deg);
  font-size: clamp(3rem, 12vw, 8rem); font-weight: 800;
  color: rgba(220, 38, 38, .14); letter-spacing: .15em;
  pointer-events: none; user-select: none; white-space: nowrap; z-index: 0;
}
.payslip > *:not(.watermark) { position: relative; z-index: 1; }

.bp-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; border-bottom: 2px solid var(--ink); padding-bottom: 10px; }
.bp-emp { font-size: .85rem; }
.bp-title { text-align: right; }
.bp-title h2 { margin: 0; font-size: 1.3rem; }
.sim-tag { background: #dc2626; color: #fff; font-size: .7rem; padding: 2px 8px; border-radius: 4px; vertical-align: middle; }
.bp-id { border-collapse: collapse; margin-top: 6px; font-size: .8rem; margin-left: auto; }
.bp-id th, .bp-id td { border: 1px solid var(--line); padding: 3px 8px; }

.bp-salarie { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 16px; margin: 12px 0; padding: 10px; background: var(--grp); border-radius: 6px; }

.payslip h3 { font-size: 1rem; color: var(--accent-dark); margin: 18px 0 6px; border-left: 4px solid var(--accent); padding-left: 8px; }

.bp-scroll { overflow-x: auto; } /* scroll horizontal sur mobile */
.bp-table { width: 100%; border-collapse: collapse; font-size: .82rem; min-width: 520px; }
.bp-table th, .bp-table td { border: 1px solid var(--line); padding: 5px 8px; text-align: right; }
.bp-table th:first-child, .bp-table td:first-child { text-align: left; }
.bp-table thead th { background: var(--accent); color: #fff; }
.bp-table tr.total td { background: var(--total); font-weight: 600; }
.bp-table tr.grp td { background: var(--grp); font-weight: 700; text-align: left; color: var(--accent-dark); }
.bp-table tr.reduc td { background: #fef9c3; }

.bp-totaux { min-width: 320px; }
.bp-totaux td:first-child { text-align: left; }
.bp-cout { background: var(--grp); padding: 8px 10px; border-radius: 6px; font-size: .85rem; }

.bp-legal { font-size: .68rem; color: var(--muted); margin-top: 18px; border-top: 1px dashed var(--line); padding-top: 10px; text-align: justify; }

/* ---------- Pied de page ---------- */
.app-footer { text-align: center; color: var(--muted); margin: 20px 0; }
.app-footer code { background: #e5e7eb; padding: 1px 5px; border-radius: 4px; }
.app-footer .credit { margin: 8px 0 0; font-weight: 600; color: var(--ink); }

/* ====================================================================
 * RESPONSIVE
 * ================================================================== */
@media (max-width: 640px) {
  body { padding: 8px; }
  .app-header h1 { font-size: 1.25rem; }
  .bp-title { text-align: left; }
  .bp-id { margin-left: 0; }
  /* Vue simplifiée : masquer les colonnes "patronale" et "imposable" des cotisations */
  .bp-cotis th:nth-child(5), .bp-cotis td:nth-child(5),
  .bp-cotis th:nth-child(6), .bp-cotis td:nth-child(6) { display: none; }
}

/* ====================================================================
 * IMPRESSION A4
 * ================================================================== */
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; padding: 0; color: #000; }
  .app-header, .accordion, .errors, .app-footer, .btn, .card-head .btn { display: none !important; }
  .card { box-shadow: none; border: 0; padding: 0; margin: 0; }
  .card h2 { display: none; }
  /* On imprime uniquement le bulletin */
  #synthese { display: none; }
  .payslip { border: none; padding: 0; }
  .bp-scroll { overflow: visible; }
  .bp-table { min-width: 0; font-size: 8.5pt; }
  .bp-cotis th:nth-child(5), .bp-cotis td:nth-child(5),
  .bp-cotis th:nth-child(6), .bp-cotis td:nth-child(6) { display: table-cell; }
  .watermark { color: rgba(220, 38, 38, .18); -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .bp-table thead th, .sim-tag { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
