/* =============================================================================
   ALMACÉN Y CATÁLOGO — Premium Design System
   iEnTop ERP · Module: almacen_catalogo.css
   ============================================================================= */

/* ─── CSS Variables — Mapped to iEnTop ERP palette (--color-*) ─── */
:root {
  /* Accent — Inherited from ERP active theme */
  --alc-accent: var(--color-accent, #6366f1);
  --alc-accent-light: var(--color-accent-hover, #818cf8);
  --alc-accent-dim: var(--color-accent-subtle, rgba(99, 102, 241, 0.15));
  --alc-accent-glow: var(--color-accent-subtle, rgba(99, 102, 241, 0.2));

  /* Semantic — ERP shared */
  --alc-success: var(--color-success, #22c55e);
  --alc-success-dim: rgba(34, 197, 94, 0.15);
  --alc-warning: var(--color-warning, #f59e0b);
  --alc-warning-dim: rgba(245, 158, 11, 0.15);
  --alc-danger: var(--color-danger, #ef4444);
  --alc-danger-dim: rgba(239, 68, 68, 0.15);
  --alc-info: #3b82f6;
  --alc-info-dim: rgba(59, 130, 246, 0.15);

  /* Backgrounds — ERP palette */
  --alc-bg: var(--color-bg-primary, #0f172a);
  --alc-bg-card: var(--color-bg-card, #1e293b);
  --alc-bg-elevated: var(--color-bg-input, #334155);
  --alc-bg-tertiary: var(--color-bg-input, rgba(255, 255, 255, 0.04));
  --alc-bg-hover: var(--color-bg-hover, rgba(255, 255, 255, 0.06));
  --alc-bg-glass: var(--color-bg-secondary, rgba(30, 41, 59, 0.85));

  /* Text — ERP palette */
  --alc-text: var(--color-text-primary, #f1f5f9);
  --alc-text-muted: var(--color-text-secondary, #94a3b8);
  --alc-text-dim: var(--color-text-muted, #64748b);

  /* Borders — ERP palette */
  --alc-border: var(--color-border, #334155);
  --alc-border-light: var(--color-border, rgba(255, 255, 255, 0.04));
  --alc-border-accent: var(--color-border-focus, rgba(99, 102, 241, 0.3));

  /* Radius — module-specific, kept independent */
  --alc-radius: var(--radius, 0.5rem);
  --alc-radius-sm: 8px;
  --alc-radius-lg: 16px;
  --alc-radius-pill: 999px;

  /* Shadows — ERP shared */
  --alc-shadow: var(--shadow-card, 0 1px 3px rgba(0, 0, 0, 0.4));
  --alc-shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);
  --alc-shadow-glow: 0 0 20px var(--color-accent-subtle, rgba(99, 102, 241, 0.15));

  /* Transitions — ERP shared */
  --alc-transition: var(--transition, all 0.2s ease);
  --alc-transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Layout Shell ─── */
.alc-shell {
  display: flex;
  height: 100vh;
  width: 100%;
  background: var(--alc-bg);
  color: var(--alc-text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  overflow: hidden;
}

/* ─── Sidebar ─── */
.alc-sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--alc-bg-card);
  border-right: 1px solid var(--alc-border);
  display: flex;
  flex-direction: column;
  z-index: 10;
  transition: transform var(--alc-transition);
}

.alc-sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--alc-border);
}

.alc-sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}

.alc-sidebar-logo-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--alc-radius);
  background: var(--alc-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: white;
  box-shadow: var(--alc-shadow-glow);
}

.alc-sidebar-logo-text {
  font-size: 16px;
  font-weight: 700;
  color: var(--alc-text);
  letter-spacing: -0.3px;
}

.alc-sidebar-logo-sub {
  font-size: 11px;
  color: var(--alc-text-dim);
  font-weight: 400;
}

/* Nav Items */
.alc-sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
}

.alc-nav-section {
  margin-bottom: 8px;
}

.alc-nav-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--alc-text-dim);
  padding: 8px 12px 6px;
}

.alc-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--alc-radius-sm);
  cursor: pointer;
  color: var(--alc-text-muted);
  font-weight: 500;
  font-size: 13px;
  transition: all var(--alc-transition);
  position: relative;
  user-select: none;
}

.alc-nav-item:hover {
  background: var(--alc-bg-hover);
  color: var(--alc-text);
}

.alc-nav-item.alc-active {
  background: var(--alc-accent-dim);
  color: var(--alc-accent-light);
  font-weight: 600;
}

.alc-nav-item.alc-active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  border-radius: 0 4px 4px 0;
  background: var(--alc-accent);
}

.alc-nav-item i {
  width: 20px;
  text-align: center;
  font-size: 14px;
}

.alc-nav-badge {
  margin-left: auto;
  background: var(--alc-danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--alc-radius-pill);
  min-width: 18px;
  text-align: center;
}

.alc-nav-badge.alc-badge-warn {
  background: var(--alc-warning);
}

/* Sidebar footer */
.alc-sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--alc-border);
  font-size: 11px;
  color: var(--alc-text-dim);
  text-align: center;
}

/* ─── Main Content ─── */
.alc-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* Top Bar */
.alc-topbar {
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--alc-border);
  background: var(--alc-bg-card);
  min-height: 60px;
  backdrop-filter: blur(12px);
}

.alc-topbar-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--alc-text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.alc-topbar-title i {
  color: var(--alc-accent-light);
}

.alc-topbar-search {
  flex: 1;
  max-width: 400px;
  margin-left: auto;
}

.alc-search-input {
  width: 100%;
  padding: 9px 14px 9px 38px;
  border: 1px solid var(--alc-border);
  border-radius: var(--alc-radius-sm);
  background: var(--alc-bg-tertiary);
  color: var(--alc-text);
  font-size: 13px;
  font-family: inherit;
  transition: all var(--alc-transition);
  outline: none;
}

.alc-search-input::placeholder {
  color: var(--alc-text-dim);
}

.alc-search-input:focus {
  border-color: var(--alc-accent);
  box-shadow: 0 0 0 3px var(--alc-accent-dim);
}

.alc-search-wrap {
  position: relative;
}

.alc-search-wrap i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--alc-text-dim);
  font-size: 13px;
}

.alc-topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─── Buttons ─── */
.alc-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border: none;
  border-radius: var(--alc-radius-sm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--alc-transition);
  outline: none;
  white-space: nowrap;
}

.alc-btn-primary {
  background: var(--alc-accent);
  color: white;
  box-shadow: 0 2px 8px var(--alc-accent-dim);
}

.alc-btn-primary:hover {
  background: var(--alc-accent-light);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--alc-accent-glow);
}

.alc-btn-secondary {
  background: var(--alc-bg-elevated);
  color: var(--alc-text);
  border: 1px solid var(--alc-border);
}

.alc-btn-secondary:hover {
  background: var(--alc-bg-hover);
  border-color: var(--alc-text-dim);
}

.alc-btn-ghost {
  background: transparent;
  color: var(--alc-text-muted);
  padding: 8px 12px;
}

.alc-btn-ghost:hover {
  background: var(--alc-bg-hover);
  color: var(--alc-text);
}

.alc-btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--alc-radius-sm);
  background: var(--alc-bg-tertiary);
  border: 1px solid var(--alc-border);
  color: var(--alc-text-muted);
  cursor: pointer;
  transition: all var(--alc-transition);
}

.alc-btn-icon:hover {
  background: var(--alc-bg-hover);
  color: var(--alc-text);
  border-color: var(--alc-text-dim);
}

/* ─── Content Area ─── */
.alc-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  scroll-behavior: smooth;
}

/* ─── Views ─── */
.alc-view {
  display: none;
  animation: alcFadeIn 0.3s ease;
}

.alc-view.alc-active {
  display: block;
}

@keyframes alcFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Cards ─── */
.alc-card {
  background: var(--alc-bg-card);
  border: 1px solid var(--alc-border);
  border-radius: var(--alc-radius);
  padding: 20px;
  transition: all var(--alc-transition);
}

.alc-card:hover {
  border-color: var(--alc-border-accent);
  box-shadow: var(--alc-shadow-glow);
}

.alc-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.alc-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--alc-text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.alc-card-title i {
  color: var(--alc-accent-light);
  font-size: 14px;
}

/* ─── KPI Cards ─── */
.alc-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.alc-kpi {
  background: var(--alc-bg-card);
  border: 1px solid var(--alc-border);
  border-radius: var(--alc-radius);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  transition: all var(--alc-transition);
  cursor: default;
}

.alc-kpi:hover {
  border-color: var(--alc-border-accent);
  transform: translateY(-2px);
  box-shadow: var(--alc-shadow-glow);
}

.alc-kpi-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--alc-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.alc-kpi-data {
  flex: 1;
  min-width: 0;
}

.alc-kpi-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--alc-text);
  line-height: 1.1;
  letter-spacing: -0.5px;
}

.alc-kpi-label {
  font-size: 12px;
  color: var(--alc-text-dim);
  margin-top: 4px;
  font-weight: 500;
}

.alc-kpi-trend {
  font-size: 11px;
  font-weight: 600;
  margin-top: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--alc-radius-pill);
}

.alc-kpi-trend.up {
  background: var(--alc-success-dim);
  color: #6ee7b7;
}

.alc-kpi-trend.down {
  background: var(--alc-danger-dim);
  color: #fca5a5;
}

/* ─── Grid / Table Layout ─── */
.alc-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.alc-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

/* ─── Data Table ─── */
.alc-table-wrap {
  overflow-x: auto;
  border-radius: var(--alc-radius);
  border: 1px solid var(--alc-border);
}

.alc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.alc-table thead th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--alc-text-dim);
  border-bottom: 1px solid var(--alc-border);
  background: var(--alc-bg-card);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

.alc-table tbody tr {
  border-bottom: 1px solid var(--alc-border-light);
  transition: background var(--alc-transition);
}

.alc-table tbody tr:hover {
  background: var(--alc-bg-hover);
}

.alc-table tbody td {
  padding: 12px 16px;
  color: var(--alc-text);
  white-space: nowrap;
}

.alc-table tbody tr:last-child {
  border-bottom: none;
}

/* ─── Tags / Badges ─── */
.alc-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--alc-radius-pill);
  font-size: 11px;
  font-weight: 600;
}

.alc-tag-cyan   { background: var(--alc-accent-dim);  color: var(--alc-accent-light); }
.alc-tag-green  { background: var(--alc-success-dim); color: #6ee7b7; }
.alc-tag-yellow { background: var(--alc-warning-dim); color: #fcd34d; }
.alc-tag-red    { background: var(--alc-danger-dim);  color: #fca5a5; }
.alc-tag-blue   { background: var(--alc-info-dim);    color: #93c5fd; }
.alc-tag-gray   { background: rgba(100,116,139,0.15); color: #94a3b8; }
.alc-tag-purple { background: rgba(167,139,250,0.15); color: #a78bfa; }
.alc-tag-indigo { background: rgba(129,140,248,0.15); color: #818cf8; }
.alc-tag-orange { background: rgba(249,115,22,0.15);  color: #f97316; }

/* ─── Product Card (Grid view) ─── */
.alc-product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.alc-product-card {
  background: var(--alc-bg-card);
  border: 1px solid var(--alc-border);
  border-radius: var(--alc-radius);
  overflow: hidden;
  transition: all var(--alc-transition);
  cursor: pointer;
  /* Altura mínima para que las cards no se aplasten en pantallas bajas
     cuando el contenedor #cat-grid tenga altura limitada. La imagen es
     160px y el body necesita ~140px para mostrar ref/nombre/cat/precio
     sin perder lineas. */
  min-height: 300px;
  display: flex;
  flex-direction: column;
}

.alc-product-card .alc-product-img { flex-shrink: 0; }
.alc-product-card .alc-product-body { flex: 1; }

.alc-product-card:hover {
  border-color: var(--alc-border-accent);
  transform: translateY(-3px);
  box-shadow: var(--alc-shadow-glow);
}

.alc-product-img {
  width: 100%;
  height: 160px;
  background: var(--alc-bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  color: var(--alc-text-dim);
  position: relative;
}

.alc-product-img .alc-product-type-badge {
  position: absolute;
  top: 10px;
  right: 10px;
}

.alc-product-body {
  padding: 16px;
}

.alc-product-ref {
  font-size: 11px;
  color: var(--alc-accent-light);
  font-weight: 600;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.alc-product-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--alc-text);
  margin-bottom: 6px;
  line-height: 1.3;
}

.alc-product-category {
  font-size: 11px;
  color: var(--alc-text-dim);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.alc-product-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid var(--alc-border-light);
}

.alc-product-price {
  font-size: 18px;
  font-weight: 800;
  color: var(--alc-text);
}

.alc-product-price-cost {
  font-size: 11px;
  color: var(--alc-text-dim);
  font-weight: 400;
}

.alc-product-stock {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
}

.alc-stock-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

/* ─── Overlay Backdrop ─── */
.alc-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--alc-transition-slow), visibility var(--alc-transition-slow);
  backdrop-filter: blur(4px);
}

.alc-overlay.visible {
  opacity: 1;
  visibility: visible;
}

/* ─── Detail Panel (Slide-in) ─── */
.alc-detail-panel {
  position: fixed;
  top: 0;
  right: -520px;
  width: 520px;
  max-width: 90vw;
  height: 100vh;
  background: var(--alc-bg-card);
  border-left: 1px solid var(--alc-border);
  box-shadow: var(--alc-shadow-lg);
  z-index: 1000;
  transition: right var(--alc-transition-slow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.alc-detail-panel.open {
  right: 0;
}

.alc-detail-panel-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--alc-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.alc-detail-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.alc-detail-panel-close {
  cursor: pointer;
  color: var(--alc-text-dim);
  font-size: 16px;
  transition: color var(--alc-transition);
}

.alc-detail-panel-close:hover {
  color: var(--alc-text);
}

/* ─── Tabs ─── */
.alc-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--alc-border);
  margin-bottom: 20px;
  overflow-x: auto;
}

.alc-tab {
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--alc-text-dim);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--alc-transition);
  white-space: nowrap;
}

.alc-tab:hover {
  color: var(--alc-text);
}

.alc-tab.active {
  color: var(--alc-accent-light);
  border-bottom-color: var(--alc-accent);
  font-weight: 600;
}

/* ─── Filter Bar ─── */
.alc-filters {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 0;
  flex-wrap: wrap;
}

/* Standalone filters (outside toolbar) keep their spacing */
.alc-content > .alc-filters {
  margin-bottom: 20px;
}

.alc-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--alc-radius-pill);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--alc-border);
  background: var(--alc-bg-card);
  color: var(--alc-text-muted);
  transition: all var(--alc-transition);
}

.alc-filter-chip:hover,
.alc-filter-chip.active {
  background: var(--alc-accent-dim);
  border-color: var(--alc-accent);
  color: var(--alc-accent-light);
}

/* ─── Warehouse Map Visual ─── */
.alc-wh-map {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.alc-wh-slot {
  background: var(--alc-bg-card);
  border: 1px solid var(--alc-border);
  border-radius: var(--alc-radius-sm);
  padding: 14px;
  text-align: center;
  transition: all var(--alc-transition);
  cursor: pointer;
}

.alc-wh-slot:hover {
  border-color: var(--alc-accent);
  box-shadow: var(--alc-shadow-glow);
}

.alc-wh-slot-code {
  font-size: 12px;
  font-weight: 700;
  color: var(--alc-accent-light);
  margin-bottom: 4px;
}

.alc-wh-slot-items {
  font-size: 20px;
  font-weight: 800;
  color: var(--alc-text);
}

.alc-wh-slot-label {
  font-size: 10px;
  color: var(--alc-text-dim);
  margin-top: 2px;
}

.alc-wh-slot-bar {
  height: 4px;
  border-radius: 2px;
  background: var(--alc-bg-elevated);
  margin-top: 8px;
  overflow: hidden;
}

.alc-wh-slot-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width var(--alc-transition-slow);
}

/* ─── Status / Pipeline Kanban ─── */
.alc-kanban {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.alc-kanban-col {
  min-width: 280px;
  flex: 1;
  background: var(--alc-bg-tertiary);
  border-radius: var(--alc-radius);
  padding: 12px;
}

.alc-kanban-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 0 4px;
}

.alc-kanban-col-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--alc-text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.alc-kanban-col-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.alc-kanban-col-count {
  font-size: 11px;
  font-weight: 700;
  background: var(--alc-bg-elevated);
  color: var(--alc-text-muted);
  padding: 2px 8px;
  border-radius: var(--alc-radius-pill);
}

.alc-kanban-card {
  background: var(--alc-bg-card);
  border: 1px solid var(--alc-border);
  border-radius: var(--alc-radius-sm);
  padding: 14px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all var(--alc-transition);
}

.alc-kanban-card:hover {
  border-color: var(--alc-border-accent);
  transform: translateY(-1px);
  box-shadow: var(--alc-shadow);
}

.alc-kanban-card-title {
  font-weight: 600;
  color: var(--alc-text);
  margin-bottom: 6px;
  font-size: 13px;
}

.alc-kanban-card-sub {
  font-size: 11px;
  color: var(--alc-text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.alc-kanban-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 8px;
  border-top: 1px solid var(--alc-border-light);
}

.alc-kanban-card-amount {
  font-weight: 700;
  color: var(--alc-text);
  font-size: 14px;
}

.alc-kanban-card-date {
  font-size: 11px;
  color: var(--alc-text-dim);
}

/* ─── Form Inputs ─── */
.alc-form-group {
  margin-bottom: 16px;
}

.alc-form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--alc-text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.alc-form-input,
.alc-form-select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--alc-border);
  border-radius: var(--alc-radius-sm);
  background: var(--alc-bg-tertiary);
  color: var(--alc-text);
  font-size: 13px;
  font-family: inherit;
  transition: all var(--alc-transition);
  outline: none;
  box-sizing: border-box;
}

.alc-form-input:focus,
.alc-form-select:focus {
  border-color: var(--alc-accent);
  box-shadow: 0 0 0 3px var(--alc-accent-dim);
}

.alc-form-select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* ─── Charts (Simple Bar/Mini) ─── */
.alc-chart-bar {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 120px;
  padding-top: 8px;
}

.alc-chart-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.alc-chart-bar-fill {
  width: 100%;
  max-width: 32px;
  border-radius: 4px 4px 0 0;
  transition: height var(--alc-transition-slow);
}

.alc-chart-bar-label {
  font-size: 10px;
  color: var(--alc-text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* ─── Empty State ─── */
.alc-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--alc-text-dim);
}

.alc-empty i {
  font-size: 48px;
  margin-bottom: 16px;
  color: var(--alc-text-dim);
  opacity: 0.4;
}

.alc-empty-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--alc-text-muted);
  margin-bottom: 8px;
}

.alc-empty-desc {
  font-size: 13px;
  color: var(--alc-text-dim);
}

/* ─── Overlay / Backdrop ─── */
.alc-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--alc-transition);
}

.alc-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

/* ─── Progress / Loading ─── */
.alc-progress {
  height: 6px;
  border-radius: 3px;
  background: var(--alc-bg-elevated);
  overflow: hidden;
}

.alc-progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width var(--alc-transition-slow);
}

/* ─── Stock Status Colors ─── */
.alc-stock-ok   { color: var(--alc-success); }
.alc-stock-low  { color: var(--alc-warning); }
.alc-stock-out  { color: var(--alc-danger); }
.alc-stock-over { color: var(--alc-info); }

/* ─── View Toggle ─── */
.alc-view-toggle {
  display: flex;
  gap: 2px;
  background: var(--alc-bg-elevated);
  border-radius: var(--alc-radius-sm);
  padding: 3px;
}

.alc-view-toggle-btn {
  padding: 6px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--alc-text-dim);
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  transition: all var(--alc-transition);
}

.alc-view-toggle-btn.active {
  background: var(--alc-bg-card);
  color: var(--alc-text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

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

.alc-toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.alc-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─── Scrollbar ─── */
.alc-content::-webkit-scrollbar,
.alc-sidebar-nav::-webkit-scrollbar,
.alc-detail-panel-body::-webkit-scrollbar {
  width: 6px;
}

.alc-content::-webkit-scrollbar-track,
.alc-sidebar-nav::-webkit-scrollbar-track,
.alc-detail-panel-body::-webkit-scrollbar-track {
  background: transparent;
}

.alc-content::-webkit-scrollbar-thumb,
.alc-sidebar-nav::-webkit-scrollbar-thumb,
.alc-detail-panel-body::-webkit-scrollbar-thumb {
  background: var(--alc-bg-elevated);
  border-radius: 3px;
}

/* ─── Responsive ─── */
@media (max-width: 1024px) {
  .alc-sidebar { width: 220px; min-width: 220px; }
  .alc-kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .alc-grid-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  .alc-sidebar { display: none; }
  .alc-kpi-grid { grid-template-columns: 1fr; }
  .alc-grid-2, .alc-grid-3 { grid-template-columns: 1fr; }
  .alc-detail-panel { width: 100%; right: -100%; }
  .alc-content { padding: 16px; }
}

/* ─── Toast & Offer Animations ─── */
@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}
.alc-tag-red {
  background: rgba(239, 68, 68, 0.15);
  color: var(--alc-danger);
  font-weight: 600;
}

/* =================================================================
   TELÉFONO (≤ 760 px) — Almacén y catálogo + Tienda Online, 10-11-2026
   Un solo desplazamiento por vista (el motor encaja cada lista en la
   ventana con alturas en línea), KPIs de dos en dos, barras que bajan de
   fila, pestañas y chips deslizables y el catálogo como lista de fichas.
   ================================================================= */
@media (max-width: 760px) {
  .alc-content { padding: 12px; }

  /* Un solo scroll: el motor fija max-height/height en línea a la zona de
     filas de cada vista (_alcAltoHasta / _alcAutoFit / autoFit*Rows). En el
     teléfono manda el desplazamiento de .alc-content; se vencen con
     !important porque son estilos en línea del motor. */
  #cat-grid, #cat-list,
  .alc-content [id^="stock-"][id$="-rows"],
  .alc-content [id^="stock-tab-"],
  .alc-content [id^="ped-tab-"],
  .alc-content [id^="fab-tab-"] {
    max-height: none !important;
    height: auto !important;
    overflow-y: visible !important;
  }

  /* ── Barra de herramientas: izquierda (pestañas/chips) y derecha
        (acciones) en filas propias; nada se sale por la derecha ── */
  .alc-toolbar { flex-direction: column; align-items: stretch; gap: 10px; margin-bottom: 14px; }
  .alc-toolbar-left { min-width: 0; max-width: 100%; }
  .alc-toolbar-right { flex-wrap: wrap; min-width: 0; max-width: 100%; gap: 8px; }
  .alc-toolbar-right > * { margin-right: 0 !important; }   /* margin-right en línea del motor */
  /* Buscadores del motor (anchos fijos en línea): a lo ancho y los primeros */
  .alc-toolbar-right > div:has(> input[id$="-search"]) { order: -1; flex: 1 1 100%; }
  .alc-content input[id$="-search"] { width: 100% !important; }
  .alc-toolbar-right > select { flex: 1 1 100%; width: 100% !important; }

  /* Pestañas y chips: una fila deslizable */
  .alc-tabs {
    flex-wrap: nowrap; overflow-x: auto; max-width: 100%;
    scrollbar-width: none; -webkit-overflow-scrolling: touch; margin-bottom: 0;
  }
  .alc-tabs::-webkit-scrollbar { display: none; }
  .alc-tab { flex: 0 0 auto; padding: 10px 14px; }
  .alc-toolbar-left > .alc-tabs { width: 100%; }
  .alc-filters {
    flex-wrap: nowrap; overflow-x: auto; min-width: 0; flex: 1 1 auto;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .alc-filters::-webkit-scrollbar { display: none; }
  .alc-filter-chip { flex: 0 0 auto; white-space: nowrap; min-height: 36px; }

  /* Filas en línea del motor (cabeceras de pestaña, pies con botones):
     bajan de línea en vez de cortarse contra el borde */
  /* (las columnas no: en un flex multilínea cada línea se estira al ancho
     de su hijo más ancho y la columna entera se saldría de la pantalla) */
  .alc-content [style*="display:flex"]:not(.alc-tabs):not(.alc-filters):not([style*="flex-direction:column"]):not([style*="flex-direction: column"]),
  .alc-content [style*="display: flex"]:not(.alc-tabs):not(.alc-filters):not([style*="flex-direction:column"]):not([style*="flex-direction: column"]) { flex-wrap: wrap; }
  /* Rejillas de formulario con campos «span 2»: una columna */
  .alc-content [style*="grid-column:span 2"],
  .alc-content [style*="grid-column: span 2"] { grid-column: 1 / -1 !important; }

  /* ── Tarjetas y KPIs ── */
  .alc-card { padding: 14px; }
  .alc-card:hover, .alc-kpi:hover, .alc-product-card:hover { transform: none; }
  .alc-card-header { flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
  .alc-card-title { flex: 1 1 auto; min-width: 0; }
  .alc-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
  .alc-kpi { flex-direction: column; gap: 8px; padding: 12px; }
  .alc-kpi-icon { width: 34px; height: 34px; font-size: 15px; }
  .alc-kpi-value {
    font-size: clamp(1.05rem, 5.2vw, 1.35rem);
    font-variant-numeric: tabular-nums; white-space: nowrap;
  }
  .alc-kpi-label { font-size: 11.5px; }
  .alc-grid-2, .alc-grid-3 { gap: 12px; }
  .alc-grid-2 > *, .alc-grid-3 > * { min-width: 0; }

  /* Tablas: siguen deslizándose de lado (capa común), con celdas compactas */
  .alc-table { font-size: 12.5px; }
  .alc-table thead th, .alc-table tbody td { padding: 9px 10px; }

  /* ── Catálogo en vista de fichas: una ficha por fila, imagen a la izquierda ── */
  .alc-product-grid { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .alc-product-card { flex-direction: row; min-height: 0; }
  .alc-product-card .alc-product-img {
    flex: 0 0 88px; width: 88px; height: auto; min-height: 100px;
    font-size: 26px; flex-direction: column; justify-content: center; gap: 6px;
  }
  /* El tipo (Producto/Servicio) baja bajo el icono, dentro de la imagen */
  .alc-product-img .alc-product-type-badge {
    position: static; display: flex; flex-wrap: wrap; justify-content: center; gap: 3px;
  }
  .alc-product-img .alc-product-type-badge .alc-tag { font-size: 9.5px; padding: 1px 6px; }
  /* Distintivos en línea del motor: FABRICABLE queda en su icono (lleva
     title) y la oferta pasa arriba a la derecha para no pisar el tipo */
  .alc-product-img > div[title="Producto fabricable"] { font-size: 0 !important; padding: 3px 5px !important; top: 4px !important; left: 4px !important; }
  .alc-product-img > div[title="Producto fabricable"] i { font-size: 10px; margin: 0 !important; }
  .alc-product-img > div[style*="bottom:6px;left:6px"] { top: 4px !important; right: 4px !important; bottom: auto !important; left: auto !important; font-size: 10px !important; padding: 2px 5px !important; }
  .alc-product-card .alc-product-body { padding: 10px 12px; min-width: 0; display: flex; flex-direction: column; }
  .alc-product-name {
    font-size: 14px; margin-bottom: 2px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  }
  .alc-product-category { margin-bottom: 8px; }
  .alc-product-footer { margin-top: auto; padding-top: 8px; gap: 8px; }
  .alc-product-price { font-size: 15px; font-variant-numeric: tabular-nums; }

  /* Panel de detalle (cuelga de <html>, fuera de #formarea: la capa común no
     le llega). Pantalla completa lo pone el motor; aquí, campos a 16 px (el
     iPhone amplía la página con menos; el motor los pone a 11 px en línea),
     la barra Guardar / Borrar / Cancelar que quepa y las filas de alta de
     ofertas en dos columnas */
  #alc-detail-panel input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="file"]),
  #alc-detail-panel select, #alc-detail-panel textarea { font-size: 16px !important; }
  #detail-body > div[style*="position:sticky"] { gap: 8px !important; }
  #detail-body > div[style*="position:sticky"] > .alc-btn { padding: 10px 10px !important; font-size: 12.5px; min-width: 0; justify-content: center; }
  #detail-body [style*="grid-template-columns:1fr 70px 1fr 1fr auto"] { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important; }
  #detail-body [style*="grid-template-columns"] > * { min-width: 0; }

  /* ── Tienda Online (view-tienda): el motor la monta como «solo scrollea
        la tabla» con alturas al 100 % en línea; en el teléfono la vista entera
        se desplaza y el maestro-detalle de artículos se apila ── */
  #view-tienda, #view-tienda > div { height: auto !important; overflow: visible !important; }
  #view-tienda .alc-card { margin-left: 0 !important; margin-right: 0 !important; }
  #view-tienda > div > div[style*="margin:0 18px 10px"] { margin-left: 0 !important; margin-right: 0 !important; }
  #view-tienda > div > div[style*="margin:0 18px 10px"] > .alc-btn { flex: 1 1 0; justify-content: center; }
  #view-tienda .alc-card > div[style*="min-width:220px"] { min-width: 0 !important; flex-basis: calc(100% - 60px) !important; }
  #hub-pane-config { overflow: visible !important; }
  #hub-pane-items {
    flex-direction: column; flex-wrap: nowrap; overflow: visible !important;
    margin-left: 0 !important; margin-right: 0 !important;
  }
  #hub-pane-items > .alc-card { overflow: visible !important; min-height: 0 !important; }
  #hub-filter { width: 100% !important; }
  #hub-pane-items div:has(> #hub-filter) { flex: 1 1 100%; }
  #hub-detalle { flex: none !important; width: auto !important; max-height: none; overflow: visible !important; }
  #hub-detalle > div[style*="overflow-y:auto"] { overflow: visible !important; }
  [id^="hub-img-"] { max-width: 100%; }
}
