/* ========================================
   Technofox Reports v3 — Styles
   ======================================== */

:root {
  --orange: #E87722;
  --orange-dark: #D06A1E;
  --gray-900: #1F2937;
  --gray-700: #374151;
  --gray-500: #6B7280;
  --gray-300: #D1D5DB;
  --gray-100: #F3F4F6;
  --white: #FFFFFF;
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
  --radius: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--gray-100);
  color: var(--gray-900);
  line-height: 1.45;
}

/* ========================================
   FORMULAIRE
   ======================================== */

.form-page .container {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 20px;
}

.form-header {
  text-align: center;
  margin-bottom: 40px;
}

.form-header .logo {
  margin-bottom: 16px;
}

.form-header .logo img {
  max-height: 48px;
  width: auto;
}

.form-header h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 8px;
}

.form-header p {
  color: var(--gray-500);
  font-size: 16px;
}

.report-form {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
}

.form-section {
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--gray-100);
}

.form-section:last-of-type { border-bottom: none; }

.form-section h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 16px;
}

.section-desc {
  color: var(--gray-500);
  font-size: 14px;
  margin-bottom: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-700);
}

.form-group input,
.form-group select {
  padding: 10px 14px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 15px;
  font-family: inherit;
  transition: border-color .2s, box-shadow .2s;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(232,119,34,0.12);
}

.form-group small {
  font-size: 12px;
  color: var(--gray-500);
}

.machine-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.machine-row input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 15px;
}

.btn-icon {
  width: 40px; height: 40px;
  border: none;
  background: var(--gray-100);
  border-radius: var(--radius);
  color: var(--gray-500);
  font-size: 22px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s, color .2s;
}

.btn-icon:hover { background: #FEE2E2; color: #DC2626; }

.btn-secondary {
  margin-top: 8px;
  padding: 8px 16px;
  border: 1px dashed var(--gray-300);
  background: transparent;
  border-radius: var(--radius);
  color: var(--gray-700);
  font-size: 14px;
  cursor: pointer;
  transition: border-color .2s, color .2s;
}

.btn-secondary:hover { border-color: var(--orange); color: var(--orange); }

.radio-group {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}

.radio-group:hover {
  border-color: var(--orange);
  background: rgba(232,119,34,0.03);
}

.radio-group input[type="radio"] {
  margin-top: 3px;
  accent-color: var(--orange);
}

.radio-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.radio-label strong {
  font-size: 14px;
  color: var(--gray-900);
}

.radio-label span {
  font-size: 13px;
  color: var(--gray-500);
}

.form-actions {
  display: flex;
  justify-content: center;
  margin-top: 8px;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 32px;
  background: var(--orange);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, transform .1s;
}

.btn-primary:hover { background: var(--orange-dark); }

.btn-primary:active { transform: scale(0.98); }

@media (max-width: 600px) {
  .form-grid { grid-template-columns: 1fr; }
  .report-form { padding: 20px; }
}

/* ========================================
   ALERTES
   ======================================== */

.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 12px;
}

.alert-warning {
  background: #FEF3C7;
  border: 1px solid #F59E0B;
  color: #92400E;
}

.alert-warning ul { margin: 4px 0 0 16px; }

/* ========================================
   PAGE RAPPORT A4
   ======================================== */

body.report-page {
  background: #E5E7EB;
  padding: 12px;
}

body.report-page.pdf-export {
  background: #FFFFFF;
  padding: 0;
}

body.report-page.pdf-export .a4-sheet {
  box-shadow: none;
  margin: 0;
}

.a4-sheet {
  width: 210mm;
  height: 297mm;
  max-width: 210mm;
  max-height: 297mm;
  margin: 0 auto 16px;
  background: var(--white);
  box-shadow: 0 0 20px rgba(0,0,0,0.15);
  padding: 14mm 16mm 12mm 16mm;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Background machine + overlay blanc */
.bg-machine {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(255,255,255,0.88), rgba(255,255,255,0.88)),
    url('../img/TF_Machine_IOT_ACU_sans_ombres.png') center bottom / 85% auto no-repeat;
  z-index: 0;
  pointer-events: none;
}

/* Header — logo à droite */
.report-header {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--gray-100);
}

.report-header-text {
  flex: 1;
  min-width: 0;
}

.report-header .label {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  color: var(--orange);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 4px;
}

.report-header h1 {
  font-size: 26px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 4px;
  line-height: 1.15;
}

.report-header .subtitle {
  font-size: 13px;
  color: var(--gray-700);
  margin-bottom: 2px;
}

.report-header .subtitle.city {
  font-weight: 600;
  color: var(--gray-900);
}

.report-header .machines {
  font-size: 14px;
  color: var(--gray-500);
  margin-top: 6px;
}

.report-header .machines strong {
  color: var(--gray-700);
}

.report-header-logo {
  flex-shrink: 0;
}

.report-header-logo img {
  max-height: 44px;
  width: auto;
  display: block;
}

/* Graphique linéaire */
.chart-section {
  position: relative;
  z-index: 1;
  margin-bottom: 16px;
}

.chart-section h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 3px;
  text-align: center;
}

.chart-meta {
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-500);
  margin-bottom: 6px;
}

.chart-container {
  width: 100%;
  height: 170px;
  position: relative;
}

/* Deux colonnes */
.two-col {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 12px;
  flex: 1;
  min-height: 0;
}

.left-col, .right-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.left-col {
  gap: 24px;
}

.right-col {
  gap: 50px;
}

.text-block h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 4px;
}

.text-block p {
  font-size: 13px;
  color: var(--gray-700);
  line-height: 1.5;
  margin-bottom: 4px;
}

.text-block ul {
  list-style: disc;
  padding-left: 14px;
  margin: 0;
}

.text-block li {
  font-size: 13px;
  color: var(--gray-700);
  line-height: 1.4;
  margin-bottom: 1px;
}

/* Highlight box Impact global */
.highlight-box {
  background: rgba(243,244,246,0.92);
  border-left: 4px solid var(--orange);
  padding: 10px 12px;
  border-radius: 0 6px 6px 0;
}

.highlight-box h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--orange);
  margin-bottom: 3px;
}

.highlight-box p {
  font-size: 13px;
  color: var(--gray-700);
  line-height: 1.45;
  margin: 0;
}

/* Bar chart comparaison */
.bar-chart-section {
  text-align: center;
}

.bar-chart-section h3 {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--gray-900);
}

.bar-chart-wrap {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 28px;
  height: 150px;
  padding: 0 10px 4px;
  border-bottom: 2px solid var(--gray-300);
  margin-bottom: 6px;
}

.bar-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.bar {
  width: 40px;
  border-radius: 4px 4px 0 0;
  min-height: 4px;
}

.bar.trad { background: var(--gray-300); }
.bar.tech { background: var(--orange); }

.bar-label {
  font-size: 9px;
  font-weight: 600;
  color: var(--gray-700);
  text-align: center;
  max-width: 70px;
  line-height: 1.2;
}

.bar-value {
  font-size: 11px;
  font-weight: 700;
  color: var(--gray-900);
}

.legend {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 4px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  color: var(--gray-700);
}

.legend-dot {
  width: 10px; height: 10px;
  border-radius: 2px;
}

.legend-dot.trad { background: var(--gray-300); }
.legend-dot.tech { background: var(--orange); }

/* CO2 box sous Impact Global */
.co2-box {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  background: #ECFDF5;
  border: 1px solid #A7F3D0;
  padding: 14px 20px;
  border-radius: 50px;
  align-self: center;
  margin-top: 8px;
}

.co2-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.co2-icon {
  font-size: 28px;
}

.co2-label {
  font-size: 14px;
  font-weight: 600;
  color: #065F46;
}

.co2-value {
  font-size: 22px;
  font-weight: 700;
  color: #047857;
}

/* Footer entreprise */
.company-footer {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--gray-100);
  padding-top: 6px;
  margin-top: auto;
}

.company-footer-inner {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 10px;
  font-size: 10px;
  color: var(--gray-500);
  text-align: center;
}

.co2-note {
  font-size: 10px;
  line-height: 1.35;
  color: #065F46;
  margin: 0;
  text-align: center;
}

.company-footer-inner .sep {
  color: var(--gray-300);
}

/* Boutons action */
.action-bar {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 16px auto;
  max-width: 210mm;
}

.action-bar a,
.action-bar button {
  padding: 10px 22px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  transition: background .2s;
}

.btn-print { background: var(--orange); color: white; }
.btn-print:hover { background: var(--orange-dark); }

.btn-print-secondary {
  background: white;
  color: var(--gray-700);
  border: 1px solid var(--gray-300) !important;
}

.btn-print-secondary:hover { background: var(--gray-100); }

.btn-back {
  background: white;
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}
.btn-back:hover { background: var(--gray-100); }

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
  @page {
    size: A4 portrait;
    margin: 0;
  }

  body.report-page {
    background: white;
    padding: 0;
  }

  .a4-sheet {
    box-shadow: none;
    margin: 0;
    width: 210mm;
    height: 297mm;
    max-height: 297mm;
    padding: 14mm 16mm 12mm 16mm;
    page-break-after: avoid;
    break-inside: avoid;
  }

  .action-bar { display: none; }
  .bar { animation: none; }
}
