/* ── Facture (invoice generator) page styles ── */

.facture-page {
  min-height: 100vh;
  padding: 2rem 1.25rem 4rem;
}
.facture-page__inner {
  max-width: 1100px;
  margin: 0 auto;
}
.calc-breadcrumb {
  font-size: 0.8rem;
  color: var(--fg-muted);
  margin-bottom: 1.5rem;
}
.calc-breadcrumb a {
  color: var(--fg-muted);
  text-decoration: none;
}
.calc-breadcrumb a:hover { color: var(--fg); }

.facture-header { margin-bottom: 2.5rem; }
.facture-header h1 {
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: clamp(1.8rem, 3.5vw, 2.6rem);
  line-height: 1.15;
  color: var(--fg);
  margin-bottom: 0.6rem;
}
.facture-header__sub {
  color: var(--accent-dark);
}
.facture-header p {
  color: var(--fg-muted);
  font-size: 1rem;
  max-width: 480px;
}

.facture-layout {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 2rem;
  align-items: start;
}

/* ── Form panel ── */
.facture-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.facture-section {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  padding: 1.25rem;
}
.facture-section__title {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-bottom: 1rem;
}
.facture-section .form-field { margin-bottom: 0.9rem; }
.facture-section .form-field:last-child { margin-bottom: 0; }

.form-field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--fg-muted);
  margin-bottom: 0.35rem;
}
.form-field input[type="text"],
.form-field input[type="email"],
.form-field input[type="number"],
.form-field input[type="date"],
.form-field select,
.form-field textarea {
  width: 100%;
  padding: 0.6rem 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-family: 'Outfit', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--fg);
  background: var(--bg);
  appearance: none;
  transition: border-color 0.15s;
  resize: vertical;
}
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.form-field input::placeholder,
.form-field textarea::placeholder { color: #B5AEA0; font-weight: 400; }
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

/* Lignes table */
.lignes-header {
  display: grid;
  grid-template-columns: 1fr 50px 90px 70px 28px;
  gap: 0.5rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0 0 0.5rem;
}
#lignes-container { display: flex; flex-direction: column; gap: 0.5rem; }

.ligne-row {
  display: grid;
  grid-template-columns: 1fr 50px 90px 70px 28px;
  gap: 0.5rem;
  align-items: center;
}
.ligne-row input,
.ligne-row select {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: 'Outfit', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--fg);
  background: var(--bg);
  appearance: none;
  transition: border-color 0.15s;
}
.ligne-row input:focus,
.ligne-row select:focus {
  outline: none;
  border-color: var(--accent);
}
.ligne-row input[type="number"] { text-align: right; }

.ligne-del {
  width: 28px;
  height: 28px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--fg-muted);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}
.ligne-del:hover:not(:disabled) {
  background: #FEF2F2;
  border-color: #EF4444;
  color: #EF4444;
}
.ligne-del:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

.btn-add-ligne {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.75rem;
  padding: 0.55rem 1rem;
  border: 1.5px dashed var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--fg-muted);
  font-family: 'Outfit', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-add-ligne:hover {
  border-color: var(--accent);
  color: var(--fg);
  background: var(--accent-light);
}

/* ── Preview panel ── */
.facture-preview {
  position: sticky;
  top: 80px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.preview-label {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-muted);
}
.pdf-preview {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  aspect-ratio: 595 / 842; /* A4 landscape-ish but portrait for invoice */
  position: relative;
  box-shadow: 0 4px 24px rgba(0,0,0,0.06);
}
.preview-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  color: var(--fg-muted);
  font-size: 0.85rem;
}
.preview-loading__spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* The PDF preview is rendered as an iframe-like canvas */
#pdf-preview iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* Action buttons */
.preview-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.4rem;
  border-radius: 12px;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  flex: 1;
  justify-content: center;
}
.btn--primary {
  background: var(--fg);
  color: white;
}
.btn--primary:hover { background: #333; }
.btn--secondary {
  background: var(--surface);
  color: var(--fg);
  border: 1.5px solid var(--border);
}
.btn--secondary:hover { border-color: var(--accent); color: var(--accent-dark); }

.copy-feedback {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--green);
  font-weight: 600;
}
.copy-feedback[hidden] { display: none; }

/* Required field asterisk */
.req { color: var(--accent-dark); font-weight: 700; }

/* Save hint under preview */
.preview-save-hint {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--fg-muted);
  margin: 0;
}
.preview-save-hint svg { flex-shrink: 0; }
.preview-save-hint[hidden] { display: none; }

/* FAQ Section */
.faq-section {
  margin-top: 4rem;
  padding-top: 2.5rem;
  border-top: 1.5px solid var(--border);
  max-width: 720px;
}
.faq-section h2 {
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: clamp(1.3rem, 2.5vw, 1.7rem);
  color: var(--fg);
  margin-bottom: 1.5rem;
}
.faq-item {
  margin-bottom: 1.5rem;
}
.faq-item h3 {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--fg);
  margin-bottom: 0.5rem;
}
.faq-item p {
  font-size: 0.9rem;
  color: var(--fg-muted);
  line-height: 1.65;
}
.faq-item em {
  color: var(--fg);
  font-style: italic;
}
.faq-item strong {
  color: var(--fg);
  font-weight: 700;
}

/* Mobile responsive */
@media (max-width: 860px) {
  .facture-layout { grid-template-columns: 1fr; }
  .facture-preview { position: static; top: auto; }
  .pdf-preview { aspect-ratio: auto; height: 400px; }
}
@media (max-width: 480px) {
  .facture-page { padding: 1.25rem 1rem 3rem; }
  .form-row { grid-template-columns: 1fr; }
  .lignes-header { grid-template-columns: 1fr 45px 80px 60px 26px; }
  .ligne-row { grid-template-columns: 1fr 45px 80px 60px 26px; }
  .preview-actions { flex-direction: column; }
}