:root {
  --bg: #f6f6f5;
  --panel: #ffffff;
  --border: rgba(17, 17, 17, 0.1);
  --text: #131313;
  --muted: #6b6b6b;
  --accent: #4f46e5;
  --accent-dark: #3730a3;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #d97706;
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Manrope', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

header.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
header.topbar .brand { font-family: var(--font-display); font-weight: 600; font-size: 1.15rem; letter-spacing: -0.01em; }
header.topbar nav a { margin-left: 16px; font-size: 0.9rem; color: var(--muted); }

main {
  max-width: 880px;
  margin: 0 auto;
  padding: 36px 20px 64px;
}
main.wide { max-width: 1100px; }

h1 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; font-size: 1.85rem; margin: 0 0 6px; }
h2 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; font-size: 1.2rem; margin: 30px 0 14px; }
p.lead { color: var(--muted); margin-top: 0; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  margin-bottom: 18px;
  box-shadow: 0 1px 2px rgba(17, 17, 17, 0.03);
}

form .field { margin-bottom: 14px; }
label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: var(--font-body);
  background: #fff;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input[type=text]:focus, input[type=email]:focus, input[type=password]:focus,
select:focus, textarea:focus, input[type=number]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.14);
}
small.help { color: var(--muted); display: block; margin-top: 4px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 999px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn:hover { background: var(--accent-dark); text-decoration: none; transform: translateY(-1px); }
.btn.secondary { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn.secondary:hover { background: var(--bg); transform: none; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #b91c1c; }
.btn.small { padding: 6px 14px; font-size: 0.8rem; }

.error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--danger);
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: .03em; }
tbody tr:hover { background: var(--bg); }

.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.pill.activo, .pill.activa { background: #dcfce7; color: var(--ok); }
.pill.pendiente, .pill.pendiente_configuracion, .pill.esperando_dns, .pill.en_verificacion, .pill.verificado, .pill.ssl_pendiente { background: #fef3c7; color: var(--warn); }
.pill.error, .pill.suspendida, .pill.archivada { background: #fee2e2; color: var(--danger); }

.steps { display: flex; gap: 8px; margin-bottom: 24px; }
.steps span {
  flex: 1;
  height: 5px;
  border-radius: 999px;
  background: var(--border);
}
.steps span.done { background: var(--accent); }

.muted { color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

/* ---- Fase 2: panel /admin ---- */

.admin-shell { display: flex; align-items: flex-start; min-height: calc(100vh - 57px); }
.admin-sidebar {
  width: 200px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 18px 0;
  position: sticky;
  top: 57px;
  align-self: flex-start;
}
.admin-sidebar a {
  position: relative;
  display: block;
  padding: 9px 22px;
  font-size: 0.88rem;
  color: var(--text);
}
.admin-sidebar a:hover { background: var(--bg); text-decoration: none; }
.admin-sidebar a.active { color: var(--accent); font-weight: 600; background: var(--bg); }
.admin-sidebar a.active::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
}
.admin-content { flex: 1; padding: 28px 32px 64px; max-width: 1100px; }

.field.inline { display: flex; align-items: center; gap: 8px; }
.field.inline input[type=checkbox] { width: auto; }
.field.inline label { margin-bottom: 0; }
input[type=number], input[type=file] {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
  background: #fff;
  color: var(--text);
}

.grid-productos { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 18px; }
.producto-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.producto-card .miniatura { width: 100%; aspect-ratio: 1/1; object-fit: cover; background: var(--bg); display: block; }
.producto-card .info { padding: 12px 14px; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.producto-card .nombre { font-weight: 600; font-size: 0.95rem; }
.producto-card .nombre a { color: var(--text); }

.producto-card .miniatura-link { position: relative; }
.insignias { position: absolute; top: 8px; left: 8px; display: flex; flex-direction: column; gap: 6px; z-index: 2; }
.insignia { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: #fff; width: fit-content; }
.insignia-nuevo { background: #2563eb; }
.insignia-oferta { background: #dc2626; }
.insignia-destacado { background: #b45309; }

.precio-original { text-decoration: line-through; color: var(--muted); margin-right: 6px; font-size: 0.88rem; }
.precio-actual { font-weight: 700; font-size: 1.05rem; }

.imagen-principal-wrap { position: relative; }
.galeria-flecha {
  position: absolute; top: 50%; transform: translateY(-50%); width: 38px; height: 38px;
  border-radius: 50%; border: none; background: rgba(255,255,255,0.9); color: #111;
  font-size: 1.4rem; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15); z-index: 2;
}
.galeria-flecha:hover { background: #fff; }
.galeria-flecha-prev { left: 10px; }
.galeria-flecha-next { right: 10px; }
.galeria-zoom-btn {
  position: absolute; bottom: 10px; right: 10px; width: 36px; height: 36px; border-radius: 50%;
  border: none; background: rgba(255,255,255,0.9); cursor: pointer; font-size: 1.05rem;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 6px rgba(0,0,0,0.15); z-index: 2;
}
.galeria-zoom-btn:hover { background: #fff; }
.lightbox-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.85); display: none; align-items: center; justify-content: center;
  z-index: 1000; padding: 24px;
}
.lightbox-overlay.activo { display: flex; }
.lightbox-imagen { max-width: 92vw; max-height: 92vh; object-fit: contain; border-radius: 6px; }
.lightbox-cerrar {
  position: absolute; top: 18px; right: 24px; background: none; border: none; color: #fff;
  font-size: 2.2rem; line-height: 1; cursor: pointer;
}

.pill.en-stock { background: #dcfce7; color: var(--ok); }
.pill.stock-bajo { background: #fef3c7; color: var(--warn); }
.pill.sin-stock, .pill.agotado { background: #fee2e2; color: var(--danger); }
.pill.borrador { background: #e5e7eb; color: var(--muted); }

.galeria { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.galeria .miniatura-wrap { position: relative; }
.galeria img { width: 90px; height: 90px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); display: block; }
.galeria .quitar {
  position: absolute; top: -6px; right: -6px; background: var(--danger); color: #fff;
  border: none; border-radius: 50%; width: 20px; height: 20px; font-size: 0.7rem; cursor: pointer; line-height: 1;
}
.galeria-miniatura { cursor: pointer; }
.galeria-miniatura.activa { border-color: var(--accent); border-width: 2px; }

.variantes-selector { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.variantes-selector button {
  padding: 7px 14px; border: 1px solid var(--border); border-radius: 6px;
  background: #fff; cursor: pointer; font-size: 0.88rem;
}
.variantes-selector button.selected { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.variantes-selector button:disabled { opacity: .4; cursor: not-allowed; text-decoration: line-through; }

.filtros-barra { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 20px; }
.filtros-barra .field { margin-bottom: 0; min-width: 140px; }

.paginacion { display: flex; gap: 8px; margin-top: 24px; justify-content: center; }
.paginacion a, .paginacion span {
  padding: 6px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 0.85rem; color: var(--text);
}
.paginacion span.actual { background: var(--accent); color: #fff; border-color: var(--accent); }

.tabla-acciones { display: flex; gap: 10px; }
.tabla-acciones form { display: inline; }

.reporte-errores { max-height: 260px; overflow-y: auto; font-size: 0.85rem; }
.reporte-errores li { padding: 4px 0; border-bottom: 1px solid var(--border); }

/* ---- Theming: selector de paleta y plantilla (panel /admin/configuracion) ---- */

.paleta-selector { display: flex; flex-wrap: wrap; gap: 10px; }
.paleta-opcion {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px;
  cursor: pointer; font-weight: 400; margin-bottom: 0; font-size: 0.88rem;
}
.paleta-opcion:has(input:checked) { border-color: var(--accent); background: var(--bg); }
.paleta-opcion input { width: auto; margin: 0; }
.paleta-opcion .swatch {
  width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--border); flex-shrink: 0;
}
.paleta-nombre { color: var(--text); }

.color-manual-selector { display: flex; gap: 20px; flex-wrap: wrap; margin: 10px 0; }
.color-manual-item { display: flex; flex-direction: column; gap: 4px; }
.color-manual-item label { font-size: 0.82rem; color: var(--muted); margin: 0; }
.color-manual-item input[type="color"] {
  width: 56px; height: 36px; padding: 2px; border: 1px solid var(--border); border-radius: 8px;
  cursor: pointer; background: none;
}

.plantilla-selector { display: flex; gap: 14px; flex-wrap: wrap; }
.plantilla-opcion {
  flex: 1; min-width: 180px; display: flex; flex-direction: column; gap: 6px;
  padding: 14px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer;
  font-weight: 400; margin-bottom: 0;
}
.plantilla-opcion:has(input:checked) { border-color: var(--accent); background: var(--bg); }
.plantilla-opcion input { width: auto; margin: 0 0 4px; }
.plantilla-preview {
  display: flex; gap: 4px; height: 44px; border-radius: 6px; overflow: hidden;
  background: var(--border); padding: 6px;
}
.plantilla-preview span { background: var(--muted); border-radius: 3px; opacity: .5; }
.plantilla-preview-clasica { align-items: stretch; }
.plantilla-preview-clasica span { flex: 1; }
.plantilla-preview-editorial { flex-direction: column; }
.plantilla-preview-editorial span:first-child { height: 60%; }
.plantilla-preview-editorial span:last-child { height: 40%; }
.plantilla-preview-minimalista { align-items: stretch; gap: 8px; background: transparent; padding: 6px 2px; }
.plantilla-preview-minimalista span { flex: 1; border-radius: 0; opacity: .35; border-bottom: 2px solid var(--muted); background: transparent; }
.plantilla-preview-vibrante { align-items: stretch; }
.plantilla-preview-vibrante span { flex: 1; border-radius: 8px; opacity: .7; background: var(--accent); }
.plantilla-preview-boutique { flex-direction: column; background: transparent; padding: 0; gap: 0; }
.plantilla-preview-boutique span:first-child { height: 34%; border-radius: 6px 6px 0 0; opacity: .85; }
.plantilla-preview-boutique span:last-child { height: 66%; border-radius: 0 0 6px 6px; margin-top: 2px; }
.plantilla-preview-calida { align-items: stretch; }
.plantilla-preview-calida span { flex: 1; border-radius: 10px; opacity: .8; background: var(--accent); }
.plantilla-preview-calida span:first-child { flex: 0 0 30%; opacity: .35; background: var(--muted); }

.tipografia-selector { display: flex; flex-wrap: wrap; gap: 10px; }
.tipografia-opcion {
  min-width: 140px; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 14px 10px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer;
  font-weight: 400; margin-bottom: 0; text-align: center;
}
.tipografia-opcion:has(input:checked) { border-color: var(--accent); background: var(--bg); }
.tipografia-opcion input { width: auto; margin: 0; }
.tipografia-muestra { font-size: 1.3rem; line-height: 1.2; color: var(--text); overflow-wrap: anywhere; }
.tipografia-nombre { font-size: 0.8rem; color: var(--muted); }

.logo-posicion-selector, .logo-tamano-selector { display: flex; flex-wrap: wrap; gap: 10px; }
.logo-posicion-opcion, .logo-tamano-opcion {
  min-width: 96px; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 10px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer;
  font-weight: 400; margin-bottom: 0; text-align: center;
}
.logo-posicion-opcion:has(input:checked), .logo-tamano-opcion:has(input:checked) {
  border-color: var(--accent); background: var(--bg);
}
.logo-posicion-opcion input, .logo-tamano-opcion input { width: auto; margin: 0; }
.logo-posicion-preview {
  display: flex; align-items: center; width: 70px; height: 22px;
  padding: 0 4px; border-radius: 4px; background: var(--bg2, var(--bg)); border: 1px solid var(--border);
}
.logo-posicion-punto { width: 12px; height: 12px; border-radius: 3px; background: var(--accent); }
.logo-posicion-nombre, .logo-tamano-nombre { font-size: 0.8rem; color: var(--muted); }
.logo-tamano-preview {
  display: flex; align-items: flex-end; justify-content: center; overflow: hidden;
  width: 70px; height: 60px; border-radius: 4px; background: var(--bg2, var(--bg)); border: 1px solid var(--border);
}
.logo-tamano-preview img { display: block; max-width: 100%; }
.logo-tamano-placeholder { display: block; max-width: 100%; border-radius: 4px; background: var(--accent); opacity: .35; }

.banner-posicion-selector {
  display: grid; grid-template-columns: repeat(3, 34px); grid-template-rows: repeat(3, 34px);
  gap: 4px; width: fit-content; padding: 6px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg2, var(--bg));
}
.banner-posicion-opcion {
  width: 34px; height: 34px; margin: 0; border: 1px solid var(--border); border-radius: 6px;
  background: var(--panel); cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.banner-posicion-opcion input { width: auto; margin: 0; }
.banner-posicion-opcion:has(input:checked) { border-color: var(--accent); background: var(--accent); }

a:focus-visible, .btn:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .btn, input, select, textarea { transition: none; }
}
