/* ================================================================
   Soft Retail — App Design System
   Tokens alineados con Softia Intranet (azul navy + acento cian/azul).
   El branding por tenant (CompanyConfig: --brand-primary/--brand-accent,
   inyectado en base.html) sigue sobreescribiendo el tinte de fondo y
   el theme-color sin tocar estos tokens base.
   Compartido por: panel admin (back-office) y storefront público.
   Coherente con auth.css (login).
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  /* Brand — azul Softia Intranet (#0077e6 / #1a8cff) */
  --brand: #0077e6;
  --brand-light: #4da6ff;
  --brand-dark: #05306b;
  --accent: #1a8cff;            /* acento cian-azul Softia */
  --accent-light: #80c0ff;

  /* Navy Softia — superficies oscuras (topbar/sidebar opcional) */
  --nav-bg: #0b1220;            /* ~hsl(220 70% 6%) */
  --nav-bg-2: #101a30;
  --nav-fg: #f1f5f9;
  --nav-line: rgba(255, 255, 255, 0.08);

  /* Backgrounds — limpios, white-first */
  --bg-cream: #FAFAFA;
  --bg-cream-2: #FFFFFF;
  --bg-paper: #FFFFFF;
  --bg-soft: #F5F5F5;

  /* Text */
  --text: #0f172a;
  --text-soft: rgba(15, 23, 42, 0.7);
  --text-muted: rgba(15, 23, 42, 0.55);

  /* Lines */
  --line: rgba(0, 0, 0, 0.10);
  --line-soft: rgba(0, 0, 0, 0.06);

  /* States — paleta Softia Intranet */
  --ok: #10b981;
  --ok-bg: rgba(52, 211, 153, 0.14);
  --warn: #f59e0b;
  --warn-bg: rgba(251, 191, 36, 0.16);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.10);
  --info: #38bdf8;
  --info-bg: rgba(56, 189, 248, 0.12);

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(11, 18, 32, 0.06);
  --shadow-md: 0 4px 12px -2px rgba(11, 18, 32, 0.12),
               0 2px 4px -2px rgba(11, 18, 32, 0.07);
  --shadow-lg: 0 16px 40px -12px rgba(11, 18, 32, 0.22),
               0 4px 12px -4px rgba(0, 119, 230, 0.12);

  /* Radius */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;

  /* Spacing scale */
  --gap-xs: 6px;
  --gap-sm: 10px;
  --gap-md: 16px;
  --gap-lg: 24px;
  --gap-xl: 36px;

  /* Glass */
  --glass-bg: rgba(255, 255, 255, 0.62);
  --glass-bg-strong: rgba(255, 255, 255, 0.78);
  --glass-border: rgba(255, 255, 255, 0.7);
}

/* ================================================================
   RESET / BASE
   ================================================================ */
.app-body { background: var(--bg-cream); margin: 0; }
.app-body main { max-width: none; padding: 0; margin: 0; }

/* Hide global topbar/footer when using admin shell */
.app-body .topbar,
.app-body .site-topbar,
.app-body .foot,
.app-body .site-foot { display: none !important; }

.app-page {
  min-height: 100vh;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text);
  position: relative;
  background:
    radial-gradient(ellipse 90% 60% at 0% 0%, color-mix(in srgb, var(--brand-primary) 10%, white) 0%, transparent 55%),
    radial-gradient(ellipse 80% 60% at 100% 100%, color-mix(in srgb, var(--brand-primary) 15%, white) 0%, transparent 50%),
    linear-gradient(180deg, var(--bg-cream-2) 0%, var(--bg-cream) 100%);
}

/* Subtle grid pattern in the background */
.app-page::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(color-mix(in srgb, var(--brand-primary) 3%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--brand-primary) 3%, transparent) 1px, transparent 1px);
  background-size: 56px 56px;
  pointer-events: none;
  z-index: 0;
}

* { box-sizing: border-box; }
.app-page * { font-family: inherit; }
a { color: var(--brand); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--brand-dark); }

/* ================================================================
   TOPBAR (admin nav)
   ================================================================ */
.app-topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: var(--gap-lg);
  padding: 12px 28px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border-bottom: 1px solid var(--line);
}
.app-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none !important;
  color: var(--text);
  flex-shrink: 0;
}
.app-brand-mark {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}
.app-brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.app-brand:hover .app-brand-mark { transform: rotate(-3deg) scale(1.05); }
.app-brand-text {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
  display: inline-flex;
}
.app-brand-text .brand-amo     { color: var(--brand); }
.app-brand-text .brand-blarthe { color: var(--accent); }

.app-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  /* Fade hint en el borde derecho cuando hay overflow — indica que se puede scrollear */
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent 100%);
  mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent 100%);
}
.app-nav::-webkit-scrollbar { height: 4px; }
.app-nav::-webkit-scrollbar-thumb { background: rgba(0,0,0,.18); border-radius: 4px; }
.app-nav a { white-space: nowrap; flex-shrink: 0; }
.app-nav a {
  padding: 8px 14px;
  border-radius: 9px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-soft);
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 7px;
}
.app-nav a:hover {
  background: rgba(0, 119, 230, 0.08);
  color: var(--brand-dark);
}
.app-nav a.is-active {
  background: rgba(0, 119, 230, 0.12);
  color: var(--brand-dark);
  font-weight: 600;
}
.app-nav a svg { width: 16px; height: 16px; opacity: 0.85; }

.app-user {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.app-user-name {
  font-size: 0.88rem;
  color: var(--text-soft);
  font-weight: 500;
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.app-user-name strong { color: var(--text); font-weight: 600; font-size: 0.88rem; }
.app-user-role {
  display: inline-block;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--brand);
  margin-top: 1px;
}
.app-user-divider {
  width: 1px;
  height: 24px;
  background: var(--line);
  margin: 0 4px;
}

/* Volver al catálogo - destacado en la barra superior */
.app-back-catalog {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border-radius: 9px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-soft);
  text-decoration: none !important;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}
.app-back-catalog:hover {
  background: rgba(0, 119, 230, 0.08);
  color: var(--brand-dark);
  transform: translateX(-2px);
}
.app-back-catalog svg { width: 15px; height: 15px; flex-shrink: 0; transition: transform 0.15s; }
.app-back-catalog:hover svg { transform: translateX(-2px); }
.app-user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-light), var(--brand));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  box-shadow: var(--shadow-sm);
}
.app-logout {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 11px;
  cursor: pointer;
  color: var(--text-soft);
  font: inherit;
  font-size: 0.85rem;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.app-logout:hover { background: rgba(0, 119, 230, 0.08); color: var(--danger); border-color: rgba(0, 119, 230, 0.3); }
.app-logout svg { width: 14px; height: 14px; }

/* ================================================================
   CONTENT WRAPPER
   ================================================================ */
.app-content {
  position: relative;
  z-index: 1;
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 28px 80px;
  animation: page-in 0.35s ease-out;
}
@keyframes page-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Entrada suave para cards (estilo Softia Intranet) + loader spin reutilizable */
.card { animation: card-in 0.28s ease-out both; }
@keyframes card-in {
  from { opacity: 0; transform: translateY(8px) scale(0.99); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(0, 119, 230, 0.25);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ================================================================
   PAGE HEADER (title + actions + breadcrumb)
   ================================================================ */
.page-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
  margin-bottom: 8px;
  font-size: 0.88rem;
  color: var(--text-soft);
  font-weight: 500;
  transition: all 0.15s;
}
.page-back:hover { color: var(--brand-dark); transform: translateX(-2px); }
.page-back svg { width: 16px; height: 16px; }

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--gap-lg);
  margin-bottom: var(--gap-lg);
  flex-wrap: wrap;
}
.page-title {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}
.page-title-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}
.page-count {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0;
}
.page-subtitle {
  margin: 4px 0 0;
  color: var(--text-soft);
  font-size: 0.95rem;
}
.page-actions {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  flex-wrap: wrap;
}

/* ================================================================
   CARD
   ================================================================ */
.card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-lg);
  padding: var(--gap-lg);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  box-shadow: var(--shadow-md);
  position: relative;
}
.card-solid {
  background: var(--bg-paper);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.card-pad-lg { padding: var(--gap-xl); }
.card-pad-sm { padding: var(--gap-md); }
.card-section + .card-section { margin-top: var(--gap-lg); }
.card h3, .card-title {
  margin: 0 0 var(--gap-md);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* ================================================================
   BUTTONS
   ================================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-paper);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
}
.btn:hover {
  border-color: rgba(0, 119, 230, 0.3);
  background: rgba(255, 255, 255, 0.95);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
  color: var(--text);
}
.btn:active { transform: translateY(0); }
.btn svg { width: 15px; height: 15px; }

.btn-primary {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 12px -3px rgba(0, 119, 230, 0.5),
              inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.btn-primary:hover {
  color: #fff;
  box-shadow: 0 6px 16px -3px rgba(0, 119, 230, 0.55),
              inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-soft);
}
.btn-ghost:hover { background: rgba(0, 119, 230, 0.08); color: var(--brand-dark); border-color: transparent; }

.btn-danger { color: var(--danger); border-color: rgba(220, 38, 38, 0.25); }
.btn-danger:hover {
  background: rgba(220, 38, 38, 0.08);
  border-color: rgba(220, 38, 38, 0.4);
  color: var(--danger);
}

.btn-sm { padding: 6px 11px; font-size: 0.82rem; border-radius: 8px; }
.btn-lg { padding: 12px 22px; font-size: 0.95rem; border-radius: 12px; }
.btn-icon { padding: 9px; }
.btn-icon svg { width: 16px; height: 16px; }

/* ================================================================
   FORM (inputs, selects, textareas, labels)
   ================================================================ */
.form { display: flex; flex-direction: column; gap: var(--gap-md); }
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--gap-md);
}
.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.88rem;
}
.form-field > label,
.form-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.01em;
}
.form-field small,
.form-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.input,
.select,
.textarea {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-paper);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font: inherit;
  font-size: 0.92rem;
  color: var(--text);
  outline: none;
  transition: all 0.15s ease;
}
.input::placeholder, .textarea::placeholder { color: rgba(23, 23, 23, 0.4); }
.input:hover, .select:hover, .textarea:hover { border-color: rgba(0, 119, 230, 0.3); }
.input:focus, .select:focus, .textarea:focus {
  border-color: rgba(0, 119, 230, 0.7);
  box-shadow: 0 0 0 4px rgba(0, 119, 230, 0.1);
}
.textarea { min-height: 90px; resize: vertical; line-height: 1.5; }
.input-sm { padding: 7px 10px; font-size: 0.85rem; border-radius: 8px; }

/* Checkbox */
.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  font-size: 0.9rem;
  user-select: none;
}
.checkbox input { accent-color: var(--brand); width: 16px; height: 16px; cursor: pointer; }

/* Form actions */
.form-actions {
  display: flex;
  gap: var(--gap-sm);
  margin-top: var(--gap-md);
  padding-top: var(--gap-md);
  border-top: 1px solid var(--line-soft);
  flex-wrap: wrap;
}

/* ================================================================
   TABLE
   ================================================================ */
.table-wrap {
  background: var(--bg-paper);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.table thead th {
  background: rgba(0, 119, 230, 0.04);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-soft);
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background 0.12s; }
.table tbody tr:hover { background: rgba(0, 119, 230, 0.03); }
.table .row-thumb {
  width: 44px; height: 44px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}
.table .row-thumb-empty {
  width: 44px; height: 44px;
  border-radius: 8px;
  background: var(--line-soft);
  color: var(--text-muted);
  font-size: 0.75rem;
  display: flex; align-items: center; justify-content: center;
}
.table-empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--text-muted);
}
.row-warn { background: rgba(217, 119, 6, 0.06) !important; }
.row-danger { background: rgba(220, 38, 38, 0.06) !important; }

/* Inline form within a table cell (e.g. "Adjust min stock") */
.inline-form {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* ================================================================
   BADGE
   ================================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--line-soft);
  color: var(--text-soft);
  white-space: nowrap;
}
.badge-ok      { background: var(--ok-bg);     color: var(--ok); }
.badge-warn    { background: var(--warn-bg);   color: var(--warn); }
.badge-danger  { background: var(--danger-bg); color: var(--danger); }
.badge-info    { background: var(--info-bg);   color: var(--info); }
.badge-neutral { background: var(--line-soft); color: var(--text-soft); }
.badge-dot::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* ================================================================
   KPI CARDS
   ================================================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--gap-md);
  margin-bottom: var(--gap-lg);
}
.kpi {
  background: var(--bg-paper);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}
.kpi-label {
  font-size: 0.78rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.kpi-value {
  font-size: 2.1rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.kpi-sub {
  font-size: 0.82rem;
  color: var(--text-soft);
  margin-top: 4px;
}
.kpi.kpi-warn .kpi-value   { color: var(--warn); }
.kpi.kpi-danger .kpi-value { color: var(--danger); }
.kpi.kpi-ok .kpi-value     { color: var(--ok); }
.kpi-icon {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 28px; height: 28px;
  color: var(--text-muted);
  opacity: 0.5;
}

/* ================================================================
   TABS / FILTER PILLS
   ================================================================ */
.tabs {
  display: inline-flex;
  background: var(--bg-paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
  margin-bottom: var(--gap-md);
}
.tabs a, .tabs button {
  padding: 7px 14px;
  border-radius: 7px;
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--text-soft);
  background: transparent;
  border: 0;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}
.tabs a:hover, .tabs button:hover { background: rgba(0, 119, 230, 0.08); color: var(--text); }
.tabs a.is-active, .tabs button.is-active {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: #fff;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* ================================================================
   FLASH (notifications)
   ================================================================ */
.flash {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  margin-bottom: var(--gap-md);
  border-radius: var(--r-md);
  font-size: 0.9rem;
  font-weight: 500;
  background: var(--info-bg);
  color: var(--info);
  border: 1px solid rgba(14, 165, 233, 0.2);
  animation: rise-in 0.3s ease-out;
}
.flash svg { width: 18px; height: 18px; flex-shrink: 0; }
.flash-ok     { background: var(--ok-bg);     color: var(--ok);     border-color: rgba(22, 163, 74, 0.2); }
.flash-warn   { background: var(--warn-bg);   color: var(--warn);   border-color: rgba(217, 119, 6, 0.2); }
.flash-danger { background: var(--danger-bg); color: var(--danger); border-color: rgba(220, 38, 38, 0.2); }
.flash.hide   { animation: rise-out 0.4s forwards; }
@keyframes rise-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes rise-out {
  to { opacity: 0; transform: translateY(-6px); height: 0; padding: 0; margin: 0; }
}

/* ================================================================
   STOCK BAR (inventory)
   ================================================================ */
.stock-bar-wrap {
  width: 100%;
  max-width: 110px;
  height: 6px;
  background: var(--line-soft);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 4px;
}
.stock-bar {
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s;
}

/* Low stock alert widget (used in products list) */
.alert-widget {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 18px;
  background: linear-gradient(135deg, rgba(217, 119, 6, 0.08), rgba(0, 119, 230, 0.06));
  border: 1px solid rgba(217, 119, 6, 0.22);
  border-radius: var(--r-md);
  margin-bottom: var(--gap-lg);
}
.alert-widget-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.alert-widget-icon {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--warn-bg);
  color: var(--warn);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.alert-widget-icon svg { width: 16px; height: 16px; }
.alert-widget-title {
  font-weight: 600;
  color: var(--warn);
  font-size: 0.95rem;
  flex: 1;
}
.alert-widget-link {
  font-size: 0.85rem;
  color: var(--warn);
  font-weight: 600;
}
.alert-widget-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.alert-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  background: rgba(255,255,255,0.65);
  border-radius: 999px;
  font-size: 0.82rem;
  border: 1px solid rgba(217, 119, 6, 0.18);
}
.alert-pill.is-critico { border-color: rgba(220, 38, 38, 0.3); color: var(--danger); }
.alert-pill b { font-weight: 700; }

/* ================================================================
   IMAGE GRID (admin existing images, e.g. product form)
   ================================================================ */
.img-tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
}
.img-tile {
  background: var(--bg-paper);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  transition: transform 0.15s, box-shadow 0.15s;
}
.img-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.img-tile.is-primary { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(0, 119, 230, 0.2); }
.img-tile img { width: 100%; height: 130px; object-fit: cover; display: block; background: var(--line-soft); }
.img-tile-actions {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.img-tile-actions form { display: flex; }
.img-tile-actions .btn { width: 100%; font-size: 0.78rem; padding: 6px 10px; }
.img-tile-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--brand);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 5px 8px;
  background: rgba(0, 119, 230, 0.1);
  border-radius: 6px;
}

/* ================================================================
   PUBLIC STOREFRONT (catalog + product detail)
   ================================================================ */
.store-hero {
  text-align: left;
  padding: 28px 0 16px;
}
.store-hero h1 {
  margin: 0 0 6px;
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--accent);
}
.store-hero h1 em {
  font-style: normal;
  color: var(--brand);
}
.store-hero p { margin: 0; color: var(--text-soft); font-size: 1.05rem; }

.store-filters {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr auto;
  gap: 10px;
  margin: 18px 0 24px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-md);
  backdrop-filter: blur(22px) saturate(170%);
  -webkit-backdrop-filter: blur(22px) saturate(170%);
  /* Sticky bajo el topbar (~76px de alto) — se mantiene visible al scrollear */
  position: sticky;
  top: 76px;
  z-index: 40;
  box-shadow: 0 4px 20px -8px rgba(0, 0, 0, 0.18);
  transition: padding 0.18s ease, box-shadow 0.18s ease;
}
/* Pequeña sombra extra cuando deja de estar pegado al borde superior natural */
.store-filters.is-pinned {
  padding: 10px 12px;
  box-shadow: 0 8px 24px -10px rgba(0, 0, 0, 0.28);
}
.store-filters input,
.store-filters select { padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff; }

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
}
.product-card {
  background: var(--bg-paper);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  transition: transform 0.18s, box-shadow 0.18s;
  display: block;
  color: inherit;
  text-decoration: none !important;
  position: relative;
}
.product-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: rgba(0, 119, 230, 0.25);
}
.product-card-img {
  width: 100%;
  aspect-ratio: 1080 / 1440;   /* proporción 3:4 estilo Instagram (vertical) */
  object-fit: cover;            /* las fotos 1080×1440 llenan perfecto sin recorte */
  object-position: center;
  display: block;
  background: #FAFAFA;
}
.product-card-noimg {
  width: 100%;
  aspect-ratio: 1080 / 1440;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  background: var(--line-soft);
  font-size: 0.85rem;
}
.product-card-body { padding: 14px 16px; }
.product-card-cat {
  font-size: 0.72rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.07em;
  font-weight: 500;
}
.product-card-name { margin: 4px 0 8px; font-size: 1rem; font-weight: 600; line-height: 1.3; }
.product-card-price { font-size: 1.05rem; font-weight: 700; color: var(--brand-dark); }

.color-dots { display: flex; gap: 5px; margin-top: 10px; }
.color-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.1);
  display: inline-block;
  background: #ddd;
}
.color-dot.lg { width: 26px; height: 26px; border-width: 2px; cursor: pointer; transition: transform 0.15s; }
.color-dot.lg:hover { transform: scale(1.1); }

/* ---------- Product detail (the page with the buggy thumbnails) ---------- */
.detail-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 36px;
  align-items: start;
}
@media (max-width: 880px) {
  .detail-grid { grid-template-columns: 1fr; gap: 24px; }
}

.detail-gallery { display: flex; flex-direction: column; gap: 12px; }
.detail-main-img {
  width: 100%;
  height: 460px;
  object-fit: cover;
  border-radius: var(--r-md);
  background: var(--line-soft);
  box-shadow: var(--shadow-md);
  display: block;
}
.detail-noimg-big {
  width: 100%; height: 460px;
  border-radius: var(--r-md);
  background: var(--line-soft);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
}

/* THUMBS — fix del bug: grid de cuadritos, NO flex con stretch */
.detail-thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 80px));
  gap: 10px;
}
/* High specificity to override `.detail-gallery img { width: 100% }` */
.detail-thumbs .detail-thumb {
  width: 80px;
  height: 80px;
  max-width: 80px;
  object-fit: cover;
  border-radius: 10px;
  cursor: pointer;
  opacity: 0.75;
  transition: all 0.15s;
  border: 2px solid transparent;
  box-sizing: border-box;
  background: var(--line-soft);
  display: block;
}
.detail-thumbs .detail-thumb:hover { opacity: 1; transform: translateY(-1px); }
.detail-thumbs .detail-thumb.is-active { opacity: 1; border-color: var(--brand); }

.detail-info-cat {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 6px;
}
.detail-info h1 {
  margin: 0 0 12px;
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.detail-price {
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--brand-dark);
  margin-bottom: 18px;
}
.detail-desc { color: var(--text); white-space: pre-wrap; line-height: 1.65; }

.detail-block { margin-top: 22px; }
.detail-block h4 {
  margin: 0 0 8px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--brand-dark);
  font-weight: 700;
}
.detail-kv { padding: 0; margin: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.detail-kv li { font-size: 0.92rem; color: var(--text); }
.detail-kv b { color: var(--text); font-weight: 600; }
.detail-kv em { color: var(--text-muted); font-style: normal; font-size: 0.85rem; }

.complement-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.complement-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-paper);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  text-align: center;
  text-decoration: none !important;
  color: inherit;
  transition: all 0.15s;
}
.complement-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: rgba(0, 119, 230, 0.25); }
.complement-card img { width: 100%; height: 110px; object-fit: cover; display: block; background: var(--line-soft); }
.complement-card-body { padding: 10px; font-size: 0.85rem; }
.complement-card-body strong { display: block; margin-bottom: 2px; }
.complement-card-body div { color: var(--text-muted); font-size: 0.8rem; }

/* ================================================================
   EMPTY STATE
   ================================================================ */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}
.empty-state-icon {
  display: flex; align-items: center; justify-content: center;
  width: 56px; height: 56px;
  margin: 0 auto 14px;
  border-radius: 14px;
  background: var(--line-soft);
  color: var(--text-muted);
}
.empty-state-icon svg { width: 28px; height: 28px; }
.empty-state h3 { margin: 0 0 6px; color: var(--text); font-size: 1.05rem; font-weight: 600; }
.empty-state p { margin: 0 0 16px; font-size: 0.9rem; }

/* ================================================================
   PAGINATION
   ================================================================ */
.pager {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: var(--gap-lg);
}
.pager .btn { min-width: 38px; padding: 7px 11px; font-size: 0.85rem; }

/* ================================================================
   UTILS
   ================================================================ */
.row { display: flex; gap: var(--gap-md); align-items: center; flex-wrap: wrap; }
.row-end { display: flex; gap: var(--gap-md); align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--text-muted); }
.text-soft { color: var(--text-soft); }
.text-danger { color: var(--danger); }
.text-ok { color: var(--ok); }
.mb-0 { margin-bottom: 0; }
.mb-md { margin-bottom: var(--gap-md); }
.mb-lg { margin-bottom: var(--gap-lg); }
.mt-md { margin-top: var(--gap-md); }
.mt-lg { margin-top: var(--gap-lg); }

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 1100px) {
  .app-back-catalog span { display: none; }
  .app-back-catalog { padding: 7px 9px; }
  .app-user-name { display: none; }
}

/* ── Tablet (821–920px): topbar no-wrap, nav scrollable ── */
@media (min-width: 821px) and (max-width: 920px) {
  .app-topbar { flex-wrap: nowrap; padding: 0 16px; }
  .app-nav { overflow-x: auto; flex: 1; min-width: 0; }
  .app-nav::-webkit-scrollbar { display: none; }
  .app-content { padding: 18px 16px 60px; }
  .page-title { font-size: 1.35rem; }
  .store-filters { grid-template-columns: 1fr 1fr; }
  .form-actions { flex-direction: column; }
  .form-actions .btn { width: 100%; }
}

/* ── Mobile (≤820px): handled by hamburger in base.html ── */
@media (max-width: 820px) {
  .app-content { padding: 14px 12px 64px; }
  .app-brand-text { font-size: 1rem; }
  .app-brand-mark { width: 34px; height: 34px; }
  .page-title { font-size: 1.2rem; }
  .store-filters { grid-template-columns: 1fr; }
  .form-actions { flex-direction: column; }
  .form-actions .btn { width: 100%; }

  /* Page header: stack title + actions vertically */
  .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .page-header .page-actions { width: 100%; display: flex; flex-wrap: wrap; gap: 8px; }
  .page-header .page-actions .btn { flex: 1; min-width: 120px; justify-content: center; }

  /* Stat grids → 2 columns */
  .stats-grid, .kpi-row { grid-template-columns: 1fr 1fr !important; }

  /* Cards grid → 1 column */
  .cards-grid, .product-grid { grid-template-columns: 1fr !important; }
  .product-card { max-width: 100%; }

  /* Detail 2-col → 1 col */
  .detail-grid { grid-template-columns: 1fr !important; gap: 16px; }

  /* Form grids → 1 col */
  .form-grid-2 { grid-template-columns: 1fr !important; }
  .form-grid-3 { grid-template-columns: 1fr !important; }

  /* Modals → full width */
  .modal-content { width: 96vw !important; max-width: 96vw !important; margin: 0 auto; border-radius: 12px 12px 0 0; }

  /* Tabs → scrollable */
  .tab-bar { overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
  .tab-bar::-webkit-scrollbar { display: none; }
}

/* ── Small mobile (≤540px): tables → card-stack ── */
@media (max-width: 540px) {
  /* Generic .table stacked cards */
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tbody tr {
    border: 1px solid #e5e7eb; border-radius: 10px;
    padding: 10px 14px; margin-bottom: 8px;
    background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.05);
  }
  .table tbody td { padding: 4px 0; border-bottom: none; font-size: 13.5px; }
  .table tbody td[data-label]::before { content: attr(data-label) ' '; font-weight: 600; color: #6b7280; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; display: block; margin-bottom: 1px; }
  .table tbody td:empty { display: none; }

  /* Hide less critical columns with .col-hide-xs */
  .col-hide-xs { display: none !important; }

  /* CRM / conversation list adjustments */
  .conv-row { flex-direction: column; gap: 6px; }
  .conv-meta { font-size: 11px; }

  /* Products list stacked */
  .product-list-row { flex-direction: column; align-items: flex-start; gap: 10px; }
  .product-list-img { width: 60px; height: 60px; }

  /* Order summary → full width items */
  .order-line { flex-direction: column; gap: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  .app-content { animation: none; }
  .product-card, .img-tile, .complement-card { transition: none; }
  .product-card:hover, .img-tile:hover, .complement-card:hover { transform: none; }
}
