/* =========================================
   Styles personnalisés — ElectroFact
   ========================================= */

/* Labels et champs */
.label {
  @apply block text-xs font-semibold text-slate-600 uppercase tracking-wide mb-1.5;
}

/* Champs : font-size 16px sur mobile pour éviter le zoom automatique iOS,
   padding plus généreux pour faciliter la frappe sur petit écran. */
.input {
  @apply w-full px-3.5 py-3 sm:py-2.5 rounded-lg border border-slate-300 bg-white text-slate-800 text-base sm:text-sm
         placeholder:text-slate-400
         focus:outline-none focus:ring-2 focus:ring-brand-500/30 focus:border-brand-500
         transition;
}

/* Boutons — touch-target 48px minimum sur mobile, 40px sur desktop */
.btn-primary {
  @apply inline-flex items-center justify-center gap-2 px-5 py-3 sm:py-2.5 rounded-lg
         bg-brand-600 text-white font-semibold text-base sm:text-sm shadow-sm
         hover:bg-brand-700 active:bg-brand-800
         focus:outline-none focus:ring-2 focus:ring-brand-500/40
         transition disabled:opacity-50 disabled:cursor-not-allowed;
}

.btn-secondary {
  @apply inline-flex items-center justify-center gap-2 px-4 py-2.5 sm:py-2 rounded-lg
         bg-brand-50 text-brand-700 font-semibold text-sm border border-brand-200
         hover:bg-brand-100 transition;
}

.btn-ghost {
  @apply inline-flex items-center justify-center gap-2 px-5 py-3 sm:py-2.5 rounded-lg
         bg-slate-100 text-slate-700 font-semibold text-base sm:text-sm
         hover:bg-slate-200 transition;
}

.btn-danger {
  @apply inline-flex items-center justify-center gap-1.5 px-3 py-1.5 rounded-md
         bg-red-50 text-red-600 font-medium text-xs
         hover:bg-red-100 transition;
}

.btn-icon {
  @apply inline-flex items-center justify-center w-8 h-8 rounded-md
         text-slate-500 hover:bg-slate-100 hover:text-slate-800 transition;
}

/* Navigation */
.nav-btn {
  @apply text-slate-600 hover:text-brand-600 hover:bg-brand-50;
}
.nav-btn.active-nav {
  @apply bg-brand-500 text-white shadow-sm hover:bg-brand-600 hover:text-white;
}

/* Boutons type de client (Particulier / Revendeur) */
.client-type-btn {
  @apply px-3 py-2 rounded-lg text-sm font-semibold border transition
         border-slate-200 bg-white text-slate-600 hover:bg-slate-50;
}
.client-type-btn.active {
  @apply bg-brand-500 text-white border-brand-500 shadow-sm;
}

/* Carte revendeur */
.reseller-card {
  @apply bg-white rounded-2xl shadow-sm border border-slate-200 p-4
         hover:shadow-md hover:border-brand-200 transition;
}

/* Ligne article */
.item-row {
  @apply grid grid-cols-12 gap-2 items-start p-3 bg-slate-50 rounded-xl border border-slate-200;
}

/* Toast visible */
#toast.show {
  @apply opacity-100;
  transform: translate(-50%, -4px);
}

/* =========================================
   Modale d'aperçu — coque & boutons d'action
   La coque utilise 100dvh sur mobile pour tenir compte de la barre d'URL
   dynamique d'iOS. flex-shrink-0 sur l'en-tête + barre d'actions garantit
   que la zone d'aperçu rétrécit en premier — les boutons restent visibles.
   ========================================= */
.preview-shell {
  height: 100dvh;
  max-height: 100dvh;
}
@media (min-width: 640px) {
  .preview-shell {
    height: auto;
    max-height: 95vh;
  }
}

.preview-actions {
  padding-bottom: max(env(safe-area-inset-bottom), 12px);
}

/* Boutons d'action colorés vifs — Télécharger (rouge CCSS) / Partager (vert WhatsApp) */
.action-btn {
  flex: 1 1 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  padding: 14px 18px;
  border-radius: 12px;
  border: 0;
  color: #fff;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
  letter-spacing: 0.2px;
  white-space: nowrap;
}
@media (min-width: 640px) {
  .action-btn {
    flex: 0 0 auto;
    font-size: 14px;
    padding: 11px 20px;
  }
}
.action-btn:active { transform: translateY(1px); }
.action-btn:disabled { opacity: 0.65; cursor: not-allowed; }

.action-download {
  background: linear-gradient(135deg, #e40607 0%, #910606 100%);
  box-shadow: 0 4px 14px rgba(228, 6, 7, 0.40);
}
.action-download:hover { filter: brightness(1.08); }

.action-share {
  background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
  box-shadow: 0 4px 14px rgba(37, 211, 102, 0.40);
}
.action-share:hover { filter: brightness(1.08); }

/* =========================================
   Mise en page PDF (A4)
   ========================================= */
.invoice-a4 {
  width: 210mm;
  min-height: 297mm;
  padding: 18mm 16mm;
  box-sizing: border-box;
  background: #fff;
  color: #1e293b;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 11pt;
  line-height: 1.45;
}
.invoice-a4 .brand-bar {
  /* Bande informations entreprise — dégradé rouge CCSS */
  background: linear-gradient(135deg, #e40607 0%, #910606 100%);
  color: #fff;
  padding: 14mm 14mm 11mm 14mm;
  margin: -18mm -16mm 10mm -16mm;
  border-radius: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10mm;
  position: relative;
}
.invoice-a4 .brand-bar .brand-block {
  display: flex;
  gap: 6mm;
  align-items: center;
}
.invoice-a4 .brand-bar .logo-box {
  height: 24mm;
  background: #fff;
  border-radius: 2.5mm;
  padding: 2.5mm 4mm;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2mm 6mm rgba(0,0,0,0.18);
  flex-shrink: 0;
}
.invoice-a4 .brand-bar .logo-box img,
.invoice-a4 .brand-bar .logo-box svg {
  height: 100%;
  width: auto;
  max-width: 58mm;
  object-fit: contain;
  display: block;
}
.invoice-a4 .brand-bar .brand-info {
  padding-top: 1mm;
}
.invoice-a4 .brand-bar .tag {
  font-size: 8.5pt;
  color: rgba(255,255,255,0.92);
  line-height: 1.55;
}

/* Bande des marques partenaires (bas de facture) */
.invoice-a4 .brands-strip {
  margin-top: 8mm;
  padding: 5mm 4mm;
  border-top: 1px dashed #cbd5e1;
  border-bottom: 1px dashed #cbd5e1;
  text-align: center;
}
.invoice-a4 .brands-strip-title {
  font-size: 7.5pt;
  text-transform: uppercase;
  letter-spacing: 1.8px;
  color: #64748b;
  margin-bottom: 4mm;
  font-weight: 600;
}
.invoice-a4 .brands-row {
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 5mm;
  flex-wrap: nowrap;
}
.invoice-a4 .brands-row .brand-item {
  height: 11mm;
  max-width: 28mm;
  flex: 0 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}
.invoice-a4 .brands-row .brand-item svg,
.invoice-a4 .brands-row .brand-item img {
  height: 100%;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  display: block;
}
.invoice-a4 .meta-box {
  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(4px);
  padding: 6mm 7mm;
  border-radius: 3mm;
  text-align: right;
  min-width: 55mm;
}
.invoice-a4 .meta-box .num {
  font-size: 13pt;
  font-weight: 700;
  color: #fff;
}
.invoice-a4 .meta-box .date {
  font-size: 9pt;
  color: rgba(255,255,255,0.85);
  margin-top: 1mm;
}
.invoice-a4 .section-title {
  font-size: 8pt;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #64748b;
  font-weight: 700;
  margin-bottom: 2mm;
}
.invoice-a4 .client-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 2mm;
  padding: 5mm 6mm;
  margin: 4mm 0 8mm 0;
}
.invoice-a4 .client-card .biz {
  font-size: 13pt;
  font-weight: 800;
  color: #002F49;
  margin-bottom: 1mm;
}
.invoice-a4 .client-card .name {
  font-size: 11pt;
  font-weight: 600;
  color: #0f172a;
}
.invoice-a4 .badge-reseller {
  display: inline-block;
  background: linear-gradient(135deg, #e40607 0%, #910606 100%);
  color: #fff;
  font-size: 7.5pt;
  letter-spacing: 0.8px;
  padding: 0.8mm 2.5mm;
  border-radius: 1.5mm;
  margin-left: 2mm;
  vertical-align: middle;
  text-transform: uppercase;
  font-weight: 700;
}
.invoice-a4 .client-card .line {
  font-size: 10pt;
  color: #475569;
  margin-top: 1mm;
}
.invoice-a4 table.items {
  width: 100%;
  border-collapse: collapse;
  margin-top: 4mm;
  table-layout: fixed;
}
.invoice-a4 table.items thead th {
  background: #002F49;
  color: #fff;
  padding: 3mm 2.5mm;
  font-size: 8.5pt;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: left;
}
.invoice-a4 table.items thead th:nth-child(1) { width: 18%; }  /* Référence */
.invoice-a4 table.items thead th:nth-child(2) { width: 44%; }  /* Description */
.invoice-a4 table.items thead th:nth-child(3) { width: 8%;  }  /* Qté */
.invoice-a4 table.items thead th:nth-child(4) { width: 15%; }  /* Prix unit. */
.invoice-a4 table.items thead th:nth-child(5) { width: 15%; }  /* Total */
.invoice-a4 table.items thead th.num,
.invoice-a4 table.items tbody td.num {
  text-align: right;
}
.invoice-a4 table.items tbody td {
  padding: 3mm 2.5mm;
  font-size: 9.5pt;
  border-bottom: 1px solid #e2e8f0;
  word-break: break-word;
}
.invoice-a4 table.items tbody tr:nth-child(even) td {
  background: #f8fafc;
}
.invoice-a4 .totals {
  margin-top: 6mm;
  display: flex;
  justify-content: flex-end;
}
.invoice-a4 .totals .box {
  min-width: 80mm;
  border-top: 2px solid #002F49;
  padding: 4mm 0 0 0;
}
.invoice-a4 .totals .row {
  display: flex;
  justify-content: space-between;
  padding: 1.5mm 0;
  font-size: 10pt;
  color: #475569;
}
.invoice-a4 .totals .grand {
  border-top: 1px solid #e2e8f0;
  padding-top: 3mm;
  margin-top: 2mm;
  font-size: 14pt;
  font-weight: 800;
  color: #002F49;
}
.invoice-a4 .totals .grand .amount {
  color: #e40607;
}
.invoice-a4 .footer {
  margin-top: 14mm;
  padding-top: 5mm;
  border-top: 1px solid #e2e8f0;
  text-align: center;
  font-size: 9pt;
  color: #64748b;
  line-height: 1.6;
}
.invoice-a4 .warranty-note {
  margin-top: 6mm;
  padding: 0 4mm;
  font-size: 7.5pt;
  line-height: 1.45;
  color: #64748b;
  text-align: center;
  font-style: italic;
}

.invoice-a4 .thanks {
  margin-top: 6mm;
  padding: 4mm 5mm;
  background: #f1f5f9;
  border-left: 3px solid #e40607;
  border-radius: 0 2mm 2mm 0;
  font-size: 10pt;
  color: #002F49;
  font-style: italic;
}
.invoice-a4 .socials {
  margin-top: 4mm;
  display: flex;
  justify-content: center;
  gap: 5mm;
  font-size: 9pt;
  color: #64748b;
}
.invoice-a4 .socials span {
  display: inline-flex;
  align-items: center;
  gap: 1.5mm;
}
.invoice-a4 .socials strong {
  color: #002F49;
  font-weight: 600;
}

/* =========================================
   Page « Conditions Générales de Vente » (A4 - 2e page)
   Toujours rendue à dimensions fixes 210×297 mm — n'apparaît jamais à
   l'écran (générée uniquement dans le conteneur caché lors du PDF).
   ========================================= */
.conditions-a4 {
  width: 210mm;
  height: 297mm;
  padding: 16mm 18mm;
  box-sizing: border-box;
  background: #fff;
  color: #1e293b;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 9pt;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.conditions-a4 .cgv-header {
  background: linear-gradient(135deg, #002F49 0%, #001F33 100%);
  color: #fff;
  padding: 6mm 8mm;
  margin: -16mm -18mm 6mm -18mm;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.conditions-a4 .cgv-header .brand {
  font-size: 13pt;
  font-weight: 800;
  letter-spacing: 0.5px;
}
.conditions-a4 .cgv-header .tag {
  font-size: 8.5pt;
  color: rgba(255,255,255,0.85);
  margin-top: 1mm;
}
.conditions-a4 .cgv-title {
  font-size: 14pt;
  font-weight: 800;
  color: #002F49;
  text-align: center;
  margin: 4mm 0 5mm 0;
  letter-spacing: 0.5px;
}
.conditions-a4 .cgv-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5mm 7mm;
  align-content: start;
}
.conditions-a4 .cgv-item h4 {
  font-size: 9.5pt;
  font-weight: 700;
  color: #e40607;
  margin: 0 0 1.2mm 0;
}
.conditions-a4 .cgv-item p {
  font-size: 8.3pt;
  line-height: 1.4;
  color: #334155;
  margin: 0;
  text-align: justify;
}
.conditions-a4 .cgv-item p strong {
  color: #002F49;
  font-weight: 700;
}
.conditions-a4 .cgv-footer {
  margin-top: 5mm;
  padding-top: 3mm;
  border-top: 1px solid #e2e8f0;
  text-align: center;
  font-size: 7.5pt;
  color: #64748b;
}
.conditions-a4 .cgv-footer strong { color: #002F49; }

/* Impression / ajustement écran */
@media (max-width: 900px) {
  .invoice-a4 { width: 100%; min-height: 0; padding: 12mm 8mm; font-size: 10pt; }
  .invoice-a4 .brand-bar { margin: -12mm -8mm 8mm -8mm; padding: 10mm 8mm 8mm 8mm; flex-wrap: wrap; }
}

/* Mode "rendu PDF" — force le format A4 même sur mobile pendant la capture
   html2canvas. Surcharge les styles responsives ci-dessus avec !important. */
.invoice-a4.pdf-rendering {
  width: 210mm !important;
  min-height: 297mm !important;
  padding: 18mm 16mm !important;
  font-size: 11pt !important;
  line-height: 1.45 !important;
}
.invoice-a4.pdf-rendering .brand-bar {
  margin: -18mm -16mm 10mm -16mm !important;
  padding: 14mm 14mm 11mm 14mm !important;
  flex-wrap: nowrap !important;
}
.invoice-a4.pdf-rendering .brand-bar .brand-block {
  flex-wrap: nowrap !important;
}
.invoice-a4.pdf-rendering .brands-row {
  flex-wrap: nowrap !important;
}
