/* ============================================================
   Catálogo Oddone — frontend sin build
   ============================================================ */

:root {
  --brand: #009fe3;
  --brand-dark: #007bb5;
  --brand-tint: #e6f7fd;
  --navy: #0f172a;
  --text: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --bg: #f1f5f9;
  --card: #ffffff;
  --ok: #15803d;
  --ok-bg: #dcfce7;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --error: #b91c1c;
  --error-bg: #fee2e2;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgb(15 23 42 / 5%), 0 12px 32px rgb(15 23 42 / 7%);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  z-index: 100;
  padding: 10px 16px;
  color: #fff;
  background: var(--navy);
  border-radius: 0 0 8px 0;
  text-decoration: none;
}
.skip-link:focus { left: 0; top: 0; }

/* ============================================================
   Topbar
   ============================================================ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px clamp(16px, 4vw, 40px);
  background: rgb(255 255 255 / 92%);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  color: #fff;
  font-size: 1.15rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--brand), #0b6fa4);
  border-radius: 11px;
  box-shadow: 0 6px 16px rgb(0 159 227 / 30%);
}

.brand__text { min-width: 0; }

.brand__eyebrow {
  margin: 0 0 1px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.brand__title {
  margin: 0;
  font-size: clamp(1rem, 1.4vw, 1.2rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--navy);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.pill--muted { color: var(--muted); background: #f1f5f9; border-color: var(--line); }
.pill--ok { color: var(--ok); background: var(--ok-bg); }
.pill--busy { color: var(--brand-dark); background: var(--brand-tint); }
.pill--error { color: var(--error); background: var(--error-bg); }

/* ============================================================
   Botones
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 8px 14px;
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}
.btn svg { width: 15px; height: 15px; }
.btn:hover { background: #f8fafc; border-color: #b6c2d2; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn--primary {
  color: #fff;
  background: var(--brand);
  border-color: var(--brand);
  box-shadow: 0 6px 14px rgb(0 159 227 / 22%);
}
.btn--primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn--ghost { background: #fff; }
.btn--danger { color: #fff; background: var(--error); border-color: var(--error); }
.btn--danger:hover { background: #991b1b; border-color: #991b1b; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 1.35rem;
  line-height: 1;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 8px;
}
.icon-btn:hover { color: var(--navy); background: #f1f5f9; }

/* ============================================================
   Layout
   ============================================================ */

.shell {
  width: min(1220px, 100%);
  margin: 0 auto;
  padding: clamp(20px, 4vw, 38px) clamp(16px, 4vw, 40px) 48px;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--brand-dark);
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 24px;
}

.hero__copy { max-width: 660px; }
.hero h2 {
  margin: 0;
  font-size: clamp(1.6rem, 3.2vw, 2.5rem);
  line-height: 1.08;
  letter-spacing: -0.035em;
  color: var(--navy);
}
.muted {
  margin: 10px 0 0;
  max-width: 62ch;
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.93rem;
}

.stats {
  display: flex;
  gap: 10px;
  flex: 0 0 auto;
}
.stat {
  min-width: 92px;
  padding: 12px 15px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: 0 1px 2px rgb(15 23 42 / 4%);
}
.stat__value {
  display: block;
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}
.stat__value--ok { color: var(--ok); }
.stat__value--error { color: var(--error); }
.stat__label {
  display: block;
  margin-top: 3px;
  font-size: 0.7rem;
  color: var(--muted);
  white-space: nowrap;
}

/* ============================================================
   Toolbar / búsqueda
   ============================================================ */

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}

.search {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}
.search__icon {
  position: absolute;
  left: 13px;
  top: 50%;
  width: 16px;
  height: 16px;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}
.search__input {
  width: 100%;
  height: 42px;
  padding: 0 14px 0 38px;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  outline: none;
}
.search__input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgb(0 159 227 / 14%); }

.select {
  height: 42px;
  padding: 0 34px 0 12px;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  outline: none;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 18px, calc(100% - 12px) 18px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgb(0 159 227 / 14%); }

/* ============================================================
   Avisos / sync
   ============================================================ */

.notice {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin: 0 0 14px;
  padding: 11px 14px;
  font-size: 0.86rem;
  line-height: 1.45;
  color: var(--warn);
  background: var(--warn-bg);
  border: 1px solid #fde68a;
  border-radius: 10px;
}
.notice--error { color: var(--error); background: var(--error-bg); border-color: #fecaca; }
.notice--ok { color: var(--ok); background: var(--ok-bg); border-color: #bbf7d0; }
.notice__close {
  flex: 0 0 auto;
  padding: 0 2px;
  color: inherit;
  background: transparent;
  border: 0;
  font-size: 1.1rem;
  line-height: 1;
}

.sync-panel {
  margin: 0 0 14px;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 1px 2px rgb(15 23 42 / 4%);
}
.sync-panel__row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}
.sync-panel__count { color: var(--muted); font-variant-numeric: tabular-nums; }
.progress {
  height: 6px;
  overflow: hidden;
  background: #e2e8f0;
  border-radius: 999px;
}
.progress__bar {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--brand), #38bdf8);
  border-radius: inherit;
  transition: width 220ms ease;
}

/* ============================================================
   Tabla
   ============================================================ */

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

.table-wrap { overflow-x: auto; }
.table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td {
  padding: 12px 16px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background 100ms ease; }
.table tbody tr:hover { background: #f8fbfd; }
.actions-col { width: 1%; white-space: nowrap; }

.product {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 220px;
}
.thumb {
  position: relative;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  overflow: hidden;
  background: var(--brand-tint);
  border: 1px solid #d7eef8;
  border-radius: 10px;
}
.thumb__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.thumb__fallback {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--brand-dark);
  text-transform: uppercase;
}
.product__name {
  margin: 0;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.3;
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.product__sku {
  display: inline-block;
  margin-top: 2px;
  font-size: 0.7rem;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.price {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-weight: 600;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 999px;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}
.badge--ok { color: var(--ok); background: var(--ok-bg); }
.badge--error { color: var(--error); background: var(--error-bg); }
.badge--pending { color: var(--warn); background: var(--warn-bg); }
.badge--neutral { color: var(--muted); background: #f1f5f9; border-color: var(--line); }

.date { color: var(--muted); white-space: nowrap; font-size: 0.8rem; }

.actions {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: flex-end;
}
.action {
  padding: 5px 8px;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  white-space: nowrap;
}
.action:hover { color: var(--brand-dark); background: var(--brand-tint); }
.action--danger:hover { color: var(--error); background: var(--error-bg); }

/* ============================================================
   Empty / loading
   ============================================================ */

.empty {
  padding: 46px 22px;
  text-align: center;
}
.empty h3 {
  margin: 0 0 6px;
  font-size: 1.05rem;
  color: var(--navy);
}
.empty p {
  margin: 0 auto 16px;
  max-width: 46ch;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 42px 20px;
  color: var(--muted);
  font-size: 0.88rem;
}
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #dbeafe;
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 4px 0;
  font-size: 0.76rem;
  color: var(--muted);
}
.footer a { color: var(--muted); }
.footer a:hover { color: var(--brand-dark); }

/* ============================================================
   Diálogos
   ============================================================ */

.dialog {
  width: min(760px, calc(100% - 24px));
  max-height: calc(100vh - 32px);
  padding: 0;
  color: var(--text);
  background: var(--card);
  border: 0;
  border-radius: 16px;
  box-shadow: 0 24px 80px rgb(15 23 42 / 30%);
  overflow: auto;
}
.dialog--sm { width: min(460px, calc(100% - 24px)); }
.dialog::backdrop { background: rgb(15 23 42 / 45%); backdrop-filter: blur(2px); }
.dialog__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 20px 22px 0;
}
.dialog__head h2 {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  color: var(--navy);
}
.dialog__foot {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  padding: 16px 22px 20px;
  border-top: 1px solid var(--line);
}
.confirm-message {
  margin: 14px 22px 4px;
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.9rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 18px 22px 0;
}
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field--full { grid-column: 1 / -1; }
.field > span { font-size: 0.76rem; font-weight: 700; color: var(--text); }
.field small { font-size: 0.7rem; color: var(--muted); line-height: 1.35; }
.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  outline: none;
}
.field textarea { resize: vertical; min-height: 76px; }
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgb(0 159 227 / 13%);
}
.field input[readonly] { background: #f8fafc; color: var(--muted); }

.preview {
  margin: 18px 22px 0;
  overflow: hidden;
  background: var(--navy);
  border-radius: 11px;
}
.preview__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 13px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #cbd5e1;
  border-bottom: 1px solid rgb(255 255 255 / 10%);
}
.preview__head .badge {
  color: #bae6fd;
  background: rgb(0 159 227 / 18%);
  border-color: rgb(56 189 248 / 25%);
}
.preview pre {
  min-height: 84px;
  margin: 0;
  padding: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.55;
  color: #e2e8f0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.form-error {
  margin: 14px 22px 0;
  padding: 9px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--error);
  background: var(--error-bg);
  border: 1px solid #fecaca;
  border-radius: 8px;
}

/* ============================================================
   Toasts
   ============================================================ */

.toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(360px, calc(100% - 36px));
  pointer-events: none;
}
.toast {
  padding: 11px 14px;
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.4;
  color: #fff;
  background: var(--navy);
  border-radius: 10px;
  box-shadow: 0 12px 28px rgb(15 23 42 / 22%);
  animation: toast-in 160ms ease-out;
  pointer-events: auto;
}
.toast--error { background: var(--error); }
.toast--warn { background: #92400e; }
.toast--ok { background: #166534; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 900px) {
  .hero { flex-direction: column; align-items: stretch; gap: 18px; }
  .stats { justify-content: flex-start; }
  .stat { flex: 1 1 0; min-width: 0; }
}

@media (max-width: 640px) {
  .topbar { align-items: flex-start; flex-direction: column; gap: 12px; }
  .topbar__actions { width: 100%; justify-content: space-between; }
  .topbar__actions .btn { flex: 1 1 auto; }
  .pill { display: none; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .select { width: 100%; }
  .hide-sm { display: none; }
  .form-grid { grid-template-columns: 1fr; padding-inline: 16px; }
  .dialog__head, .dialog__foot { padding-inline: 16px; }
  .preview, .form-error { margin-inline: 16px; }
  .footer { flex-direction: column; gap: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
