/* ========================================================================
   FacturX Invoice — Design Tokens & Component Styles
   Used across all pages. Tailwind CDN handles utilities.
   Aligned with the GetUBL design system for consistent look-and-feel.
   ======================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Design Tokens (UBL palette in HSL) ─────────────────────────────────── */
:root {
  --background: 60 20% 99%;
  --foreground: 195 43% 20%;
  --card: 0 0% 100%;
  --card-foreground: 195 43% 20%;
  --popover: 0 0% 100%;
  --popover-foreground: 195 43% 20%;
  --primary: 195 43% 24%;
  --primary-foreground: 60 25% 97%;
  --secondary: 85 18% 92%;
  --secondary-foreground: 195 43% 20%;
  --muted: 60 22% 94%;
  --muted-foreground: 208 11% 45%;
  --accent: 80 19% 65%;
  --accent-foreground: 195 43% 20%;
  --success: 160 60% 35%;
  --success-foreground: 0 0% 100%;
  --warning: 38 92% 50%;
  --warning-foreground: 0 0% 100%;
  --destructive: 12 70% 50%;
  --destructive-foreground: 0 0% 100%;
  --border: 195 7% 88%;
  --input: 195 7% 88%;
  --ring: 195 43% 24%;
  --input-bg: 0 0% 100%;
  --radius: 0.5rem;

  /* Brand colors (use directly, not via hsl()) */
  --brand-teal: #234b58;
  --brand-slate: oklch(0.52 0.025 215);
  --brand-stone: oklch(0.58 0.015 110);
  --brand-sage: oklch(0.74 0.08 115);
  --brand-lime: #d5e43f;

  /* Typography */
  --font-display: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  --shadow-elegant: 0 20px 60px -20px color-mix(in oklab, var(--brand-teal) 35%, transparent);

  /* Full-color aliases (consumed by shared component CSS that runs on both
     this site and GetUBL — UBL stores tokens as full colors, this site
     stores them as HSL components, so we expose a unified set here). */
  --c-background: hsl(var(--background));
  --c-card: hsl(var(--card));
  --c-muted: hsl(var(--muted));
  --c-muted-fg: hsl(var(--muted-foreground));
  --c-fg: hsl(var(--foreground));
  --c-border: hsl(var(--border));
  --c-primary-fg: hsl(var(--primary-foreground));

  /* Radius scale (mirrors UBL) */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.25rem;
  --radius-3xl: 1.5rem;
  --radius-full: 9999px;
}

/* ── Theme Overrides (per-page) ────────────────────────────────────────── */
/* Unified UBL palette across all tool pages — class hooks kept as no-ops
   so existing body classes remain valid and may be re-customized later. */
.theme-convert,
.theme-create,
.theme-extract,
.theme-validate,
.theme-preview {
}

.theme-create input,
.theme-create textarea,
.theme-create [role="combobox"] {
  background-color: hsl(var(--input-bg)) !important;
}

/* ── Base ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; border-color: hsl(var(--border)); }
body {
  margin: 0;
  font-family: var(--font-sans);
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4, h5, h6, .font-display {
  font-family: var(--font-display);
  letter-spacing: -0.02em;
}
.font-mono { font-family: var(--font-mono); }
a { color: inherit; text-decoration: none; }

/* ── Section: Tool page wrapper (mirrors UBL .tool-section) ────────────── */
.tool-section {
  border-bottom: 1px solid color-mix(in oklab, hsl(var(--border)) 60%, transparent);
  background: linear-gradient(to bottom, color-mix(in oklab, hsl(var(--muted)) 50%, transparent), hsl(var(--background)));
}

/* ── Section: Working surface (file list + sidebar after upload) ───────── */
.working-surface {
  min-height: calc(100vh - 4rem);
  background:
    radial-gradient(1200px 600px at 100% 0%, color-mix(in oklab, var(--brand-teal) 10%, transparent), transparent 60%),
    linear-gradient(180deg,
      color-mix(in oklab, var(--brand-teal) 8%, hsl(var(--muted))) 0%,
      hsl(var(--muted)) 100%);
}

/* ── Component: Dropzone (mirrors UBL .dropzone) ───────────────────────── */
.dropzone-idle {
  position: relative;
  border: 2px dashed hsl(var(--border));
  background: hsl(var(--card));
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}
.dropzone-idle:hover {
  border-color: color-mix(in oklab, var(--brand-teal) 60%, transparent);
  background: color-mix(in oklab, var(--brand-teal) 5%, hsl(var(--card)));
}
.dropzone-active {
  border: 2px dashed var(--brand-teal);
  background: color-mix(in oklab, var(--brand-teal) 8%, hsl(var(--card)));
  border-radius: var(--radius);
  transform: scale(1.01);
  box-shadow: var(--shadow-elegant);
  transition: border-color 0.15s, background-color 0.15s, transform 0.2s, box-shadow 0.2s;
}
.dropzone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 5rem 2rem;
  text-align: center;
}
.dropzone-badges {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 2rem;
}
.dropzone-title {
    font-family: var(--font-display);
    font-size: clamp(2rem, 4vw, 2.5rem);
    font-weight: 600;
    letter-spacing: -0.02em;
    max-width: 42rem;
    margin: 0 0 0.75rem;
    color: hsl(var(--foreground));
    line-height: 1.2;
}
.dropzone-subtitle {
  max-width: 42rem;
  margin: 0 0 2rem;
  font-size: 1.125rem;
  line-height: 1.6;
  color: hsl(var(--muted-foreground));
}
.dropzone-hint {
  margin-top: 1rem;
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
}
@media (max-width: 640px) {
  .dropzone-inner { padding: 3.5rem 1.25rem; }
}

/* ── Component: Badge ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 0.5rem;
  padding: 0.25rem 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: hsl(var(--primary) / 0.1);
  color: hsl(var(--primary));
}
.badge-outline {
  background: transparent;
  border: 1px solid hsl(var(--primary) / 0.3);
  color: hsl(var(--primary));
  text-transform: none;
  letter-spacing: normal;
  font-weight: 600;
}

/* ── Component: Card ───────────────────────────────────────────────────── */
.card {
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  box-shadow: 0 1px 2px 0 rgba(0,0,0,0.05);
}

/* ── Component: Button ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.625rem 1.25rem;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.25rem;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  box-shadow: var(--shadow-elegant);
}
.btn-primary:hover { background: hsl(var(--primary) / 0.9); }
.btn-primary:active { transform: scale(0.98); }
.btn-outline {
  background: transparent;
  color: hsl(var(--foreground));
  border: 1px solid hsl(var(--border));
}
.btn-outline:hover { background: hsl(var(--muted)); }
.btn-ghost {
  background: transparent;
  color: hsl(var(--muted-foreground));
}
.btn-ghost:hover { background: hsl(var(--muted)); color: hsl(var(--foreground)); }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; }

/* ── Component: Input ──────────────────────────────────────────────────── */
.input {
  display: flex;
  height: 2.5rem;
  width: 100%;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid hsl(var(--input));
  background: hsl(var(--input-bg));
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: hsl(var(--foreground));
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus {
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 2px hsl(var(--ring) / 0.2);
}
.input::placeholder { color: hsl(var(--muted-foreground)); }
.input-error { border-color: hsl(var(--destructive)); }

select.input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.5rem;
}

/* ── Component: Label ──────────────────────────────────────────────────── */
.label {
  font-size: 0.75rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  display: block;
  margin-bottom: 0.375rem;
}

/* ── Component: Separator ──────────────────────────────────────────────── */
.separator {
  height: 1px;
  background: hsl(var(--border));
  border: none;
  margin: 0.75rem 0;
}

/* ── Component: Accordion ──────────────────────────────────────────────── */
.accordion-item { border-bottom: 1px solid hsl(var(--border)); }
.accordion-trigger {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(var(--foreground));
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
}
.accordion-trigger:hover { text-decoration: underline; }
.accordion-trigger svg { transition: transform 0.2s; flex-shrink: 0; }
.accordion-trigger[aria-expanded="true"] svg { transform: rotate(180deg); }
.accordion-content {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s ease, padding 0.3s ease;
  font-size: 0.875rem;
  line-height: 1.625;
  color: hsl(var(--muted-foreground));
}
.accordion-content.open {
  max-height: 500px;
  padding-bottom: 1rem;
}

/* ── Component: Modal / Dialog ─────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal-content {
  background: hsl(var(--card));
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 100%;
  max-width: 28rem;
  margin: 1rem;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
  transform: translateY(10px) scale(0.98);
  transition: transform 0.2s ease;
}
.modal-overlay.open .modal-content { transform: translateY(0) scale(1); }
.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  cursor: pointer;
  color: hsl(var(--muted-foreground));
  padding: 0.25rem;
  border-radius: 0.25rem;
}
.modal-close:hover { color: hsl(var(--foreground)); background: hsl(var(--muted)); }

/* ── Component: Status Badge ───────────────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  border-radius: 9999px;
  padding: 0.25rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 500;
}
.status-ready { background: hsl(var(--muted)); color: hsl(var(--muted-foreground)); }
.status-processing { background: hsl(var(--primary) / 0.1); color: hsl(var(--primary)); }
.status-done { background: hsl(var(--success) / 0.1); color: hsl(var(--success)); }
.status-error { background: hsl(var(--warning) / 0.1); color: hsl(var(--warning)); }
.status-ratelimit { background: hsl(var(--muted)); color: hsl(var(--muted-foreground)); }
.status-servererror { background: hsl(var(--muted)); color: hsl(var(--muted-foreground)); }

/* ── Component: Navbar logo (mirrors UBL .nav__logo / .nav__title) ─────── */
.nav-logo {
  display: flex;
  height: 2rem;
  width: 2rem;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
  background: var(--brand-teal);
  color: var(--brand-lime);
}
.nav-logo svg path { fill: var(--brand-lime); }

.nav-title {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: hsl(var(--foreground));
}
.nav-title__prefix { color: hsl(var(--muted-foreground)); }

/* ── Component: Step Wizard (mirrors UBL .stepper) ─────────────────────── */
.step-circle {
  display: flex;
  width: 2.75rem;
  height: 2.75rem;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  font-size: 1rem;
  font-weight: 600;
  transition: all 0.2s;
}
.step-circle svg { width: 1.25rem; height: 1.25rem; }
.step-circle.active {
  background: var(--brand-lime);
  color: var(--brand-teal);
  box-shadow: 0 0 0 4px color-mix(in oklab, var(--brand-lime) 30%, transparent);
}
.step-circle.done {
  background: var(--brand-teal);
  color: hsl(var(--primary-foreground));
}
.step-circle.pending {
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
}
.step-connector {
  height: 2px;
  width: 5rem;
  border-radius: 999px;
  transition: background 0.2s;
}

/* ── Utility: Spinner ──────────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.animate-spin { animation: spin 1s linear infinite; }

/* ── Prefill Overlay ───────────────────────────────────────────────────── */
.prefill-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.75rem;
  background: hsl(var(--background) / 0.75);
  backdrop-filter: blur(2px);
  pointer-events: all;
}

/* ── Utility: Premium Badge ────────────────────────────────────────────── */
.premium-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border-radius: 9999px;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  padding: 0.125rem 0.625rem;
  font-size: 0.6875rem;
  font-weight: 600;
}

/* ── Component: File row ───────────────────────────────────────────────── */
.file-icon-box {
  display: flex;
  width: 2.5rem;
  height: 2.5rem;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
  background: hsl(var(--primary) / 0.1);
}

/* ── Component: Radio card ─────────────────────────────────────────────── */
.radio-card {
  display: flex;
  cursor: pointer;
  align-items: center;
  gap: 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid hsl(var(--border));
  padding: 0.875rem;
  transition: border-color 0.15s, background 0.15s;
}
.radio-card input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 1.25rem;
  height: 1.25rem;
  min-width: 1.25rem;
  border: 2px solid hsl(var(--border));
  border-radius: 9999px;
  background: hsl(var(--card));
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.radio-card input[type="radio"]:checked {
  border-color: hsl(var(--primary));
  background: hsl(var(--primary));
  box-shadow: inset 0 0 0 2px hsl(var(--card));
}
.radio-card.selected {
  border-color: hsl(var(--primary));
  background: hsl(var(--primary) / 0.05);
}
.radio-card:not(.selected):hover {
  border-color: hsl(var(--primary) / 0.3);
}

/* ── Right-align date picker icon ──────────────────────────────────────── */
input[type="date"] { position: relative; }
input[type="date"]::-webkit-calendar-picker-indicator {
  position: absolute;
  right: 0.75rem;
  cursor: pointer;
}

/* ── Hide utility (no !important — let Tailwind responsive classes win) */
.is-hidden { display: none; }


/*Additional style wiring ──────────────────────────────────────── */

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.bg-card {
    background: hsl(var(--card));
}

/* ── Component: Premium Limit Sidebar ─────────────────────────────────── */
.premium-sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.premium-sidebar-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}
.premium-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 201;
  width: min(26rem, 100vw);
  background: hsl(var(--card));
  box-shadow: -8px 0 40px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
}
.premium-sidebar.open {
  transform: translateX(0);
}
.premium-sidebar-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  cursor: pointer;
  color: hsl(var(--muted-foreground));
  padding: 0.375rem;
  border-radius: 0.375rem;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}
.premium-sidebar-close:hover {
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
}

/* ── Blog: Article prose ───────────────────────────────────────────────── */
.blog-prose {
  color: hsl(var(--foreground));
  font-size: 1rem;
  line-height: 1.75;
}

.blog-prose h2 {
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: hsl(var(--foreground));
  margin-top: 2.5rem;
  margin-bottom: 0.625rem;
  line-height: 1.3;
}
.blog-prose h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: hsl(var(--foreground));
  margin-top: 2rem;
  margin-bottom: 0.5rem;
  line-height: 1.4;
}
.blog-prose h4 {
  font-size: 1rem;
  font-weight: 600;
  color: hsl(var(--foreground));
  margin-top: 1.5rem;
  margin-bottom: 0.375rem;
}

.blog-prose p {
  margin-top: 0;
  margin-bottom: 1.25rem;
}
.blog-prose p.lead {
  font-size: 1.0625rem;
  color: hsl(var(--muted-foreground));
  border-left: 3px solid hsl(var(--primary));
  padding-left: 1rem;
  margin-bottom: 1.75rem;
}

.blog-prose a {
  color: hsl(var(--primary));
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}
.blog-prose a:hover {
  opacity: 0.75;
}

.blog-prose ul,
.blog-prose ol {
  padding-left: 1.5rem;
  margin-top: 0;
  margin-bottom: 1.25rem;
}
.blog-prose ul { list-style-type: disc; }
.blog-prose ol { list-style-type: decimal; }
.blog-prose li { margin-bottom: 0.375rem; }
.blog-prose li::marker { color: hsl(var(--primary)); font-weight: 600; }

.blog-prose code {
  font-family: var(--font-mono);
  font-size: 0.8125em;
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
  border-radius: 0.25rem;
  padding: 0.15em 0.4em;
}
.blog-prose pre {
  background: hsl(var(--muted));
  border-radius: 0.5rem;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  margin-bottom: 1.25rem;
}
.blog-prose pre code {
  background: none;
  padding: 0;
  font-size: 0.875rem;
}

.blog-prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
  border: 1px solid hsl(var(--border));
  border-radius: 0.5rem;
  overflow: hidden;
}
.blog-prose thead {
  background: hsl(var(--muted));
}
.blog-prose th {
  text-align: left;
  font-weight: 600;
  font-size: 0.8125rem;
  padding: 0.625rem 0.875rem;
  color: hsl(var(--foreground));
  border-bottom: 1px solid hsl(var(--border));
}
.blog-prose td {
  padding: 0.625rem 0.875rem;
  border-bottom: 1px solid hsl(var(--border));
  color: hsl(var(--foreground));
  vertical-align: top;
}
.blog-prose tbody tr:last-child td { border-bottom: none; }
.blog-prose tbody tr:hover { background: hsl(var(--muted) / 0.4); }

.blog-prose hr {
  border: none;
  border-top: 1px solid hsl(var(--border));
  margin: 2rem 0;
}

.blog-prose strong { font-weight: 600; }
.blog-prose em { font-style: italic; }
.blog-prose blockquote {
  border-left: 3px solid hsl(var(--primary));
  margin: 0 0 1.25rem;
  padding: 0.5rem 1rem;
  color: hsl(var(--muted-foreground));
  font-style: italic;
}

/* ── Component: Output Type Picker ─────────────────────────────────────── */
.output-type-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.5rem 1rem;
  border-radius: 0.75rem;
  border: 2px solid hsl(var(--border));
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.output-type-card:hover { background: hsl(var(--muted)/0.3); }
.output-type-card.selected {
  border-color: hsl(var(--primary));
  background: hsl(var(--primary)/0.05);
}
.output-type-radio {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  border-radius: 9999px;
  border: 2px solid hsl(var(--border));
  transition: border-color 0.15s;
}
.output-type-card.selected .output-type-radio {
  border-color: hsl(var(--primary));
}
.output-type-card.selected .output-type-radio::after {
  content: '';
  width: 0.625rem;
  height: 0.625rem;
  border-radius: 9999px;
  background: hsl(var(--primary));
}
/* Hide guest-only marketing elements for authenticated users */
body.is-authenticated .guest-only {
  display: none;
}
/* Hide auth-only elements for guests */
body:not(.is-authenticated) .auth-only {
  display: none;
}

.oauth-btn {
    background: hsl(var(--card));
    border: 1px solid lightgray;
    color: hsl(var(--foreground))
}