/* Visual language shared with Product Check (layout, header, palette) and Scripi (cards, drop zone, progress, badges). */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-muted: #f1f5f9;
  --border: #e2e4e9;
  --text: #1c1e21;
  --text-dim: #334155;
  --text-muted: #6b7280;
  --accent: #2d6cdf;
  --accent-dark: #1f4fb0;
  --accent-bg: #eaf1fd;
  --brand-navy: #1b3a57;
  --brand-teal: #22a37f;
  --green: #059669;
  --green-bg: #d1fae5;
  --green-border: #a7f3d0;
  --red: #d92d20;
  --red-bg: #fee2e2;
  --yellow: #b45309;
  --yellow-bg: #fef3c7;
  --yellow-border: #fde68a;
  --radius: 8px;
  --radius-card: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 16px rgba(0, 0, 0, 0.03);
  --font-sans:
    'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial,
    sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p {
  margin: 0;
}

code {
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.88em;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 4px;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Top bar ─────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid #e5e7eb;
}

.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.brand-mark {
  display: block;
}

.brand-name {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--brand-navy);
}

.brand-name-accent {
  color: var(--brand-teal);
}

.icon-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid #e5e7eb;
  border-radius: var(--radius);
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    color 0.15s ease;
}

.icon-button:hover {
  background: rgba(17, 24, 39, 0.06);
  color: var(--accent);
}

.topbar-actions,
.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* Initial of the signed-in user; the full email shows on hover. */
.user-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: default;
  user-select: none;
}

/* ── Page ───────────────────────────────────────────────────────────────── */
.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 64px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.page-header {
  text-align: center;
}

.page-header h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.page-header p {
  color: var(--text-muted);
}

/* ── Card ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.card-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.card-heading .card-title {
  margin-bottom: 0;
}

.empty-state {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  padding: 12px;
}

/* ── Upload ─────────────────────────────────────────────────────────────── */
.drop-zone {
  display: block;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  color: var(--text-muted);
  background: var(--surface-muted);
  transition: all 0.2s;
}

.drop-zone:hover,
.drop-zone.drag-over,
#file-input:focus-visible + .drop-zone {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--accent);
}

.drop-zone svg {
  margin-bottom: 8px;
}

.drop-zone p {
  font-size: 14px;
  color: var(--text-dim);
}

.drop-zone small {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.file-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--green-bg);
  border: 1px solid var(--green-border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--green);
}

.file-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  color: var(--text);
}

.file-size {
  color: var(--text-muted);
  font-size: 12px;
}

.file-remove {
  display: flex;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
}

.file-remove:hover {
  color: var(--red);
  background: rgba(217, 45, 32, 0.08);
}

.form-row {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 220px;
}

.field label {
  font-size: 14px;
  font-weight: 600;
}

select,
input[type='search'] {
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

select:focus,
input[type='search']:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-dark);
}

.btn-ghost {
  background: transparent;
  color: var(--accent);
  border-color: var(--accent);
}

.btn-ghost:hover:not(:disabled) {
  background: rgba(45, 108, 223, 0.1);
}

.btn-danger {
  background: var(--red-bg);
  color: var(--red);
  border-color: #fca5a5;
}

.btn-danger:hover:not(:disabled) {
  background: #fecaca;
}

.btn-export {
  background: linear-gradient(135deg, #10b981, var(--green));
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(5, 150, 105, 0.3);
}

.btn-export:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(5, 150, 105, 0.35);
}

.btn-small {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 5px;
}

/* ── Alerts & notices ───────────────────────────────────────────────────── */
.alert {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 14px;
}

.alert-error {
  background: #fef2f2;
  color: #b91c1c;
}

/* ── Badges ─────────────────────────────────────────────────────────────── */
.badge {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.badge-pending {
  background: var(--surface-muted);
  color: var(--text-muted);
}

.badge-processing {
  background: var(--accent-bg);
  color: var(--accent);
}

.badge-completed {
  background: var(--green-bg);
  color: var(--green);
}

.badge-cancelled {
  background: var(--yellow-bg);
  color: var(--yellow);
}

.badge-failed,
.badge-unavailable {
  background: var(--red-bg);
  color: var(--red);
}

/* ── Progress ───────────────────────────────────────────────────────────── */
.analysis-label {
  font-size: 14px;
  color: var(--text-dim);
  font-weight: 500;
}

.progress-track {
  height: 8px;
  margin: 16px 0 10px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 100px;
  overflow: hidden;
}

.progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--brand-teal));
  border-radius: 100px;
  transition: width 0.4s ease;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--text-muted);
}

.progress-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

/* ── Results ────────────────────────────────────────────────────────────── */
.results-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.results-count {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
}

.results-count strong {
  color: var(--text);
}

.results-filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.results-filters input[type='search'] {
  width: 300px;
  max-width: 100%;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 20px;
}

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

.product-card.is-failed {
  border-color: #fecaca;
}

.product-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.product-card-title {
  min-width: 0;
}

.product-row {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.4px;
}

.product-name {
  font-size: 15px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.product-card-body {
  padding: 12px 16px 16px;
}

.product-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.product-status.is-error {
  color: #b91c1c;
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.keyword-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.keyword-item {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 10px;
}

.keyword-rank {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-align: right;
}

.keyword-text {
  font-size: 14px;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.keyword-searches {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.keyword-bar {
  grid-column: 2 / 4;
  height: 4px;
  background: var(--surface-muted);
  border-radius: 100px;
  overflow: hidden;
}

.keyword-bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--brand-teal), #5cc9a7);
  border-radius: 100px;
}

.product-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.copy-button {
  background: var(--accent-bg);
  color: var(--accent);
  border-color: #c9dbfa;
}

.copy-button:hover {
  background: #d7e5fb;
}

/* ── History ────────────────────────────────────────────────────────────── */
.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 4px;
  border-top: 1px solid var(--border);
}

.history-item:first-child {
  border-top: none;
}

.history-main {
  flex: 1;
  min-width: 0;
}

.history-file {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.history-item.is-current {
  background: var(--accent-bg);
  border-radius: var(--radius);
}

/* ── Dialog ─────────────────────────────────────────────────────────────── */
.dialog {
  width: min(560px, calc(100vw - 32px));
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px 24px;
  color: var(--text);
  font-family: inherit;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.2);
}

.dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(3px);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.dialog-header h2 {
  font-size: 1.15rem;
}

.help-steps {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 14px;
  color: var(--text-dim);
}

.help-note {
  margin-top: 14px;
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Legal pages and footer ─────────────────────────────────────────────── */
.legal {
  max-width: 860px;
}

.legal-languages {
  display: flex;
  justify-content: flex-end;
  gap: 16px;
  font-size: 13px;
  font-weight: 600;
}

.legal-document h1 {
  font-size: 1.75rem;
  font-weight: 700;
}

.legal-document h2 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 24px 0 8px;
}

.legal-document p,
.legal-document ul {
  color: var(--text-dim);
}

.legal-document p + p,
.legal-document ul + p,
.legal-document p + ul {
  margin-top: 10px;
}

.legal-document ul {
  margin-bottom: 0;
  padding-left: 22px;
}

.legal-document li + li {
  margin-top: 6px;
}

.legal-updated {
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-muted);
}

.legal a:not(.btn),
.site-footer a {
  color: var(--accent);
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 24px;
  padding: 0 16px 32px;
  font-size: 13px;
}

.site-footer a {
  text-decoration: none;
}

.site-footer a:hover,
.site-footer a[aria-current='page'] {
  text-decoration: underline;
}

.landing-lead {
  margin-top: 10px;
  font-size: 16px;
}

.landing-steps {
  margin: 0;
  padding-left: 22px;
  color: var(--text-dim);
}

.landing-steps li + li {
  margin-top: 8px;
}

.landing-actions {
  margin-top: 20px;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 760px) {
  .results-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  .topbar-inner {
    padding: 10px 16px;
    gap: 12px;
  }

  .topbar-actions,
  .user-menu {
    gap: 8px;
  }

  .brand-name {
    font-size: 1.05rem;
    white-space: nowrap;
  }

  .page {
    padding: 24px 16px 48px;
    gap: 18px;
  }

  .page-header h1 {
    font-size: 1.5rem;
  }

  .card {
    padding: 16px;
  }

  .field,
  .form-row .btn,
  .progress-actions .btn,
  .results-filters,
  .results-filters input[type='search'],
  .results-filters select {
    width: 100%;
  }
}

/* The user menu adds two controls to the header: on phones, make room for them and let the brand
   name shorten with an ellipsis rather than push the buttons off-screen. */
@media (max-width: 480px) {
  .brand {
    min-width: 0;
    gap: 8px;
  }

  .brand-mark {
    flex-shrink: 0;
  }

  .brand-name {
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .topbar-actions,
  .user-menu {
    gap: 6px;
  }

  .icon-button,
  .user-avatar {
    width: 30px;
    height: 30px;
  }
}
