/* =============================================================
   FacturaClara · styles.css
   1. Tokens  2. Reset  3. Utilidades  4. Tipografía
   5. Cabecera/pie  6. Componentes  7. Herramienta (factura)
   8. Contenido SEO/FAQ  9. Responsive  10. Reduced-motion
   ============================================================= */

/* ============ 1. Tokens ============ */
:root {
  --bg: #f6f7f6;
  --surface: #ffffff;
  --surface-2: #f0f2f1;
  --ink: #16211d;
  --ink-soft: #4a5a54;
  --ink-faint: #7d8a84;
  --border: #dfe4e1;
  --border-strong: #c8d0cc;
  --accent: #1f6f5c;
  --accent-ink: #165646;
  --accent-soft: #e6f2ee;
  --danger: #b3261e;
  --warn: #9a6a00;
  --shadow: 0 1px 2px rgba(20,33,29,.04), 0 8px 24px rgba(20,33,29,.06);
  --shadow-lg: 0 2px 6px rgba(20,33,29,.06), 0 20px 50px rgba(20,33,29,.12);
  --radius: 14px;
  --radius-sm: 9px;
  --gutter: clamp(16px, 4vw, 28px);
  --maxw: 1080px;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ease: cubic-bezier(.16,1,.3,1);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101613;
    --surface: #17201c;
    --surface-2: #1e2a25;
    --ink: #eaf1ed;
    --ink-soft: #b3c1ba;
    --ink-faint: #7f918a;
    --border: #2a3630;
    --border-strong: #384a42;
    --accent: #48b79b;
    --accent-ink: #6fcdb3;
    --accent-soft: #16302a;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.4);
    --shadow-lg: 0 2px 6px rgba(0,0,0,.35), 0 20px 50px rgba(0,0,0,.5);
  }
}

/* ============ 2. Reset ============ */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; tab-size: 2; scroll-behavior: smooth; }
body {
  font-family: var(--sans); font-size: 16px; line-height: 1.6;
  background: var(--bg); color: var(--ink);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  overflow-x: clip; overscroll-behavior-y: none;
}
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
p { text-wrap: pretty; }
h1, h2, h3, h4 { text-wrap: balance; line-height: 1.12; letter-spacing: -0.02em; }
::selection { background: var(--accent); color: #fff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ============ 3. Utilidades ============ */
.container { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gutter); }
.narrow { max-width: 760px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; top: -100px; left: 1rem; padding: .6rem 1rem; background: var(--accent); color: #fff; z-index: 9999; border-radius: 8px; font-weight: 600; }
.skip-link:focus { top: 1rem; }
.muted { color: var(--ink-soft); }
.center { text-align: center; }

/* ============ 4. Tipografía ============ */
h1, .h1 { font-size: clamp(1.6rem, 4.6vw, 2.5rem); font-weight: 800; }
h2, .h2 { font-size: clamp(1.3rem, 3.2vw, 1.8rem); font-weight: 750; margin-top: 2.2em; }
h3 { font-size: 1.15rem; font-weight: 700; }
.lead { font-size: clamp(1.02rem, 2.4vw, 1.18rem); color: var(--ink-soft); }
.prose p { margin: 0 0 1em; }
.prose h2, .prose h3 { margin-bottom: .5em; }
.prose ul, .prose ol { margin: 0 0 1em 1.2em; }
.prose li { margin: .3em 0; }
.prose strong { color: var(--ink); }
.prose a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.prose table { width: 100%; border-collapse: collapse; margin: 1em 0; font-size: .95rem; }
.prose th, .prose td { border: 1px solid var(--border); padding: .5em .7em; text-align: left; }
.prose th { background: var(--surface-2); }

/* ============ 5. Cabecera / pie ============ */
.site-header {
  position: sticky; top: 0; z-index: 100; background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.site-header__row { display: flex; align-items: center; gap: 16px; height: 62px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 1.12rem; letter-spacing: -.02em; }
.brand__logo { width: 26px; height: 26px; flex: none; }
.brand b { color: var(--accent); }
.nav { margin-left: auto; }
.nav ul { display: flex; gap: 4px; list-style: none; }
.nav a { display: block; padding: 8px 12px; border-radius: 8px; font-size: .93rem; font-weight: 550; color: var(--ink-soft); }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav-toggle { display: none; margin-left: auto; padding: 8px; border-radius: 8px; }
.nav-toggle svg { width: 24px; height: 24px; }

.site-footer { margin-top: 64px; border-top: 1px solid var(--border); background: var(--surface); }
.site-footer .container { padding-top: 40px; padding-bottom: 40px; }
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 28px; }
.site-footer h4 { font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); margin-bottom: 12px; }
.site-footer ul { list-style: none; display: grid; gap: 7px; }
.site-footer a { color: var(--ink-soft); font-size: .93rem; }
.site-footer a:hover { color: var(--accent); }
.footer-legal { margin-top: 30px; padding-top: 20px; border-top: 1px solid var(--border); font-size: .82rem; color: var(--ink-faint); display: flex; flex-wrap: wrap; gap: 6px 18px; justify-content: space-between; }
.footer-disclaimer { margin-top: 14px; font-size: .8rem; color: var(--ink-faint); }

/* ============ 6. Componentes ============ */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 20px; border-radius: 10px; font-weight: 650; background: var(--surface-2); color: var(--ink); transition: background .2s var(--ease), transform .1s var(--ease); border: 1px solid var(--border); }
.btn:hover { background: var(--border); }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--accent); color: #fff; border-color: transparent; }
.btn--primary:hover { background: var(--accent-ink); }
.btn--lg { padding: 15px 26px; font-size: 1.05rem; }
.btn--block { width: 100%; }
.btn svg { width: 20px; height: 20px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; font-size: .82rem; font-weight: 600; background: var(--accent-soft); color: var(--accent-ink); }
.privacy-badge { display: inline-flex; align-items: center; gap: 8px; margin-top: 14px; padding: 10px 14px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-ink); font-size: .9rem; font-weight: 550; }
.privacy-badge svg { width: 18px; height: 18px; flex: none; }

label { font-weight: 600; font-size: .9rem; color: var(--ink-soft); display: block; margin-bottom: 5px; }
.field { margin-bottom: 14px; }
input[type=text], input[type=number], input[type=email], input[type=date], input[type=tel], select, textarea {
  width: 100%; padding: 11px 13px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--ink); transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 70px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }
.hint { font-size: .82rem; color: var(--ink-faint); margin-top: 4px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }

/* Ad slots (vacíos, placeholder) */
.ad-slot { margin: 30px auto; min-height: 100px; display: flex; align-items: center; justify-content: center; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); color: var(--ink-faint); font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; background: var(--surface-2); }
.ad-slot--leaderboard { min-height: 100px; }

/* ============ 7. Hero + herramienta ============ */
.hero { padding: clamp(28px, 5vw, 48px) 0 10px; }
.hero h1 { margin-bottom: 12px; }
.tool-wrap { padding-bottom: 8px; }

.tool-card { padding: clamp(18px, 3vw, 28px); }
.tool-card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.tool-card__head h2 { margin: 0; font-size: 1.15rem; }

/* Layout factura: formulario + preview */
.invoice-layout { display: grid; grid-template-columns: 1fr; gap: 22px; }
@media (min-width: 960px) { .invoice-layout { grid-template-columns: minmax(0,1.15fr) minmax(0,1fr); align-items: start; } }

.section-title { font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; color: var(--accent-ink); font-weight: 700; margin: 22px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.section-title:first-child { margin-top: 0; }

/* Tabla de líneas */
.lines { display: grid; gap: 10px; }
.line-row { display: grid; grid-template-columns: 1fr; gap: 8px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); position: relative; }
.line-row .line-grid { display: grid; grid-template-columns: 2fr 0.8fr 1fr 1.1fr; gap: 8px; align-items: end; }
.line-row label { margin-bottom: 3px; font-size: .78rem; }
.line-row .line-total { font-weight: 700; font-size: .92rem; align-self: center; color: var(--ink); white-space: nowrap; }
.line-remove { position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; border-radius: 7px; color: var(--ink-faint); display: grid; place-items: center; }
.line-remove:hover { background: var(--danger); color: #fff; }
.line-remove svg { width: 16px; height: 16px; }
@media (max-width: 620px) { .line-row .line-grid { grid-template-columns: 1fr 1fr; } .line-row .line-concept { grid-column: 1 / -1; } }

/* Totales en vivo */
.totals { margin-top: 18px; padding: 16px; border-radius: var(--radius-sm); background: var(--accent-soft); }
.totals__row { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; font-size: .94rem; color: var(--ink-soft); }
.totals__row b { color: var(--ink); font-weight: 650; }
.totals__row--sub { font-size: .86rem; color: var(--ink-faint); }
.totals__grand { display: flex; justify-content: space-between; gap: 12px; margin-top: 8px; padding-top: 10px; border-top: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); font-size: 1.3rem; font-weight: 800; color: var(--accent-ink); }

/* Preview PDF */
.preview-panel { position: sticky; top: 78px; }
.preview-frame { width: 100%; aspect-ratio: 210 / 297; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; box-shadow: var(--shadow); }
.preview-note { font-size: .82rem; color: var(--ink-faint); margin-top: 8px; text-align: center; }
.preview-toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }

.template-picker { display: flex; gap: 8px; }
.template-picker label { display: flex; align-items: center; gap: 6px; padding: 8px 12px; border: 1px solid var(--border-strong); border-radius: 8px; cursor: pointer; margin: 0; font-size: .88rem; color: var(--ink); }
.template-picker input { width: auto; }
.template-picker input:checked + span { font-weight: 700; }
.template-picker label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

.inline-check { display: flex; align-items: center; gap: 9px; margin: 8px 0; }
.inline-check input { width: auto; }
.inline-check label { margin: 0; font-weight: 550; color: var(--ink); }

.result-box { margin-top: 16px; padding: 18px; border-radius: var(--radius-sm); background: var(--accent-soft); text-align: center; }
.result-big { font-size: clamp(1.8rem, 6vw, 2.6rem); font-weight: 800; color: var(--accent-ink); letter-spacing: -.02em; line-height: 1.1; }
.result-label { font-size: .85rem; color: var(--ink-soft); margin-top: 4px; }

.noscript-msg { padding: 14px; border-radius: var(--radius-sm); background: #fff3cd; color: #664d03; border: 1px solid #ffe69c; margin-bottom: 16px; }

/* ============ 8. Contenido SEO / FAQ ============ */
.content-section { padding-top: 10px; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin: 22px 0; }
.step { padding: 18px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); }
.step__n { width: 34px; height: 34px; border-radius: 9px; background: var(--accent-soft); color: var(--accent-ink); display: grid; place-items: center; font-weight: 800; margin-bottom: 10px; }
.step h3 { font-size: 1rem; margin-bottom: 5px; }
.step p { font-size: .9rem; color: var(--ink-soft); }

.faq { display: grid; gap: 10px; margin-top: 16px; }
.faq details { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); overflow: hidden; }
.faq summary { padding: 15px 18px; font-weight: 650; cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-size: 1.4rem; color: var(--accent); font-weight: 400; transition: transform .2s var(--ease); }
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details > div { padding: 0 18px 16px; color: var(--ink-soft); }
.faq details > div p { margin: 0 0 .6em; }

.more-tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-top: 18px; }
.tool-link { display: block; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); transition: border-color .15s var(--ease), transform .15s var(--ease), box-shadow .15s var(--ease); }
.tool-link:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.tool-link__t { display: block; font-weight: 700; margin-bottom: 3px; }
.tool-link__d { display: block; font-size: .87rem; color: var(--ink-soft); }

.tool-index { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px,1fr)); gap: 14px; }

/* páginas de confianza / guías */
.page-hero { padding: clamp(30px,5vw,52px) 0 8px; }
.callout { padding: 16px 18px; border-radius: var(--radius-sm); background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); margin: 20px 0; }
.callout strong { color: var(--accent-ink); }
.example-box { padding: 16px 18px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); margin: 18px 0; }
.example-box .example-tag { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--accent-ink); font-weight: 700; margin-bottom: 8px; }

/* ============ 9. Responsive ============ */
@media (max-width: 860px) {
  .nav { position: fixed; inset: 62px 0 auto 0; background: var(--surface); border-bottom: 1px solid var(--border); transform: translateY(-120%); transition: transform .25s var(--ease); box-shadow: var(--shadow-lg); }
  .nav.is-open { transform: translateY(0); }
  .nav ul { flex-direction: column; padding: 12px var(--gutter) 18px; gap: 2px; }
  .nav a { padding: 12px; }
  .nav-toggle { display: grid; place-items: center; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .steps { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .footer-grid { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
}

/* ============ 10. Reduced-motion ============ */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition-duration: .01ms !important; }
}
