/* ========================================================
   ESTILOS COMPACTOS V2: CONSULTA COMERCIAL EN 1 SOLA PANTALLA
   Prioridad Celular (Mobile-First) y PC Visual (Cero Scroll Lateral)
   ======================================================== */

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --bg-main: #f1f5f9;
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08);
}

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

html {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

body.compact-mode {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.4;
  min-height: 100vh;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.app-compact-container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-sizing: border-box;
  overflow-x: hidden;
}

/* Header Compacto */
.compact-header {
  background: #0f172a;
  color: white;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  width: 100%;
  box-shadow: var(--shadow-md);
  box-sizing: border-box;
}

.compact-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.brand-bolt {
  font-size: 18px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

.brand-title-compact {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.01em;
}

.version-badge {
  background: rgba(59, 130, 246, 0.25);
  color: #60a5fa;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
}

.compact-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-empresa-status {
  font-size: 11px;
  font-weight: 600;
  color: #34d399;
  background: rgba(16, 185, 129, 0.15);
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid rgba(52, 211, 153, 0.3);
  white-space: nowrap;
}

/* ========================================================
   SELECTOR DE EMPRESAS TÁCTIL (Móvil Prioritario)
   ======================================================== */
.company-selector-wrapper {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.company-selector-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding-left: 2px;
}

.company-selector-pills {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
  max-width: 100%;
  padding-bottom: 2px;
}

.btn-empresa-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  border: 1.5px solid var(--border);
  color: var(--text-main);
  padding: 7px 12px;
  border-radius: 9999px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  user-select: none;
  min-height: 36px;
  flex-shrink: 0;
}

.btn-empresa-pill:hover {
  border-color: #94a3b8;
  background: #f8fafc;
}

.btn-empresa-pill.active {
  background: #0f172a;
  color: #ffffff;
  border-color: #0f172a;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.2);
}

.btn-empresa-pill[data-empresa="audiomarcas"].active {
  background: #1e40af;
  border-color: #1e40af;
}

.btn-empresa-pill[data-empresa="impotodo"].active {
  background: #065f46;
  border-color: #065f46;
}

.btn-empresa-pill[data-empresa="fornitura"].active {
  background: #92400e;
  border-color: #92400e;
}

.dot-color {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.dot-blue { background-color: #2563eb; }
.dot-green { background-color: #10b981; }
.dot-orange { background-color: #f59e0b; }

/* Barra de Búsqueda Móvil First */
.compact-search-bar {
  width: 100%;
}

.search-form-mobile {
  display: flex;
  gap: 6px;
  width: 100%;
  align-items: stretch;
}

.search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
}

.search-icon-inside {
  position: absolute;
  left: 12px;
  font-size: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

.input-search-compact {
  width: 100%;
  min-width: 0;
  padding: 10px 34px 10px 36px;
  font-size: 16px; /* 16px evita auto-zoom en iOS Safari */
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1.5px solid #cbd5e1;
  background: #ffffff;
  color: #0f172a;
  outline: none;
  transition: all 0.15s;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.input-search-compact:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
}

.btn-clear-input {
  position: absolute;
  right: 10px;
  background: #e2e8f0;
  border: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 12px;
  color: #475569;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-search-compact {
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 700;
  border-radius: var(--radius-md);
  flex-shrink: 0;
  min-height: 42px;
}

/* Chips Rápidos Horizontales */
.chips-container-compact {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  overflow: hidden;
}

.chips-label {
  font-size: 10.5px;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
}

.chips-scrollable {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  min-width: 0;
  width: 100%;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.chips-scrollable::-webkit-scrollbar { display: none; }

.chip-item {
  background: #ffffff;
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 11.5px;
  font-weight: 600;
  font-family: monospace;
  color: #334155;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  user-select: none;
  flex-shrink: 0;
}

.chip-item:active, .chip-item:hover {
  background: #e2e8f0;
  color: #0f172a;
}

/* Aviso de Sincronización */
.notice-sync {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  line-height: 1.4;
  width: 100%;
}

/* Tarjeta Principal Unificada (Cero Scroll Lateral) */
.compact-main-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  box-sizing: border-box;
}

/* Barra de Multi-Coincidencia si el SKU está en varias empresas */
.multi-match-bar {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: #1e40af;
  flex-wrap: wrap;
  width: 100%;
}

.multi-match-btn {
  background: white;
  border: 1px solid #93c5fd;
  color: #1d4ed8;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.multi-match-btn.active {
  background: #1d4ed8;
  color: white;
  border-color: #1d4ed8;
}

/* Barra de Identificación de Producto */
.compact-product-bar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  width: 100%;
}

.product-bar-title-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  width: 100%;
}

.product-bar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  width: 100%;
}

.badge-company-lg {
  background: #2563eb;
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 5px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge-code-lg {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  font-family: monospace;
  font-size: 13px;
  font-weight: 800;
  padding: 3px 7px;
  border-radius: 5px;
  color: #0f172a;
  white-space: nowrap;
}

.compact-product-name {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.25;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.badge-stock-pill {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
  font-size: 12px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 9999px;
  white-space: nowrap;
}

.link-zauru-btn {
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 10px;
  white-space: nowrap;
}

/* ================= LOS 3 DATOS ESENCIALES (MÓVIL FIRST) ================= */
.trio-metrics-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  width: 100%;
}

.trio-metric-card {
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.border-costo {
  border-left: 5px solid #dc2626;
  background: linear-gradient(to right, #fef2f2, #f8fafc 40%);
}
.border-precio {
  border-left: 5px solid #2563eb;
  background: linear-gradient(to right, #eff6ff, #f8fafc 40%);
}
.border-fecha {
  border-left: 5px solid #059669;
  background: linear-gradient(to right, #ecfdf5, #f8fafc 40%);
}

.trio-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.trio-badge-sub {
  font-size: 10px;
  font-weight: 700;
  color: #1d4ed8;
  background: #dbeafe;
  padding: 2px 6px;
  border-radius: 4px;
}

.trio-value {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.15;
  margin: 3px 0;
  letter-spacing: -0.02em;
  word-break: break-word;
}

.text-costo { color: #b91c1c; }
.text-precio { color: #1d4ed8; }
.text-fecha { color: #047857; }

.trio-sub {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.35;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* ================= DETALLE EN TABS PARA CELULAR ================= */
.mobile-detail-tabs-bar {
  display: flex;
  gap: 4px;
  background: #e2e8f0;
  padding: 3px;
  border-radius: var(--radius-md);
  width: 100%;
}

.tab-mob-btn {
  flex: 1;
  padding: 7px 4px;
  border: none;
  background: transparent;
  color: #475569;
  font-size: 11.5px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
  min-height: 36px;
  white-space: nowrap;
}

.tab-mob-btn.active {
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.compact-detail-columns {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.mini-card {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.mini-card-head {
  padding: 8px 12px;
  background: #f1f5f9;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  font-weight: 700;
  color: #1e293b;
  width: 100%;
  box-sizing: border-box;
}

.desktop-subtab-title {
  cursor: pointer;
  color: var(--text-muted);
  font-weight: 600;
  padding: 2px 4px;
}

.desktop-subtab-title.active {
  color: var(--primary);
  font-weight: 700;
}

.mini-table-scroll {
  width: 100%;
  max-width: 100%;
  max-height: 160px;
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
}

.compact-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
}

.compact-data-table th {
  padding: 6px 8px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 10.5px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: nowrap;
}

.compact-data-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.compact-data-table td:first-child {
  white-space: normal;
  word-break: break-word;
}

.compact-data-table tr:hover td {
  background: #f1f5f9;
}

/* Estado Vacío */
.compact-empty-state {
  text-align: center;
  padding: 35px 16px;
  background: white;
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  box-sizing: border-box;
}

/* Botones Comunes */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: all 0.15s;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary { background: white; border-color: var(--border); color: #1e293b; }
.btn-secondary:hover { background: #f8fafc; }

.btn-sm { padding: 4px 8px; font-size: 11px; }

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(37, 99, 235, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast-container {
  position: fixed;
  bottom: 16px;
  left: 16px;
  right: 16px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}
.toast {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: #1e293b;
  color: white;
  font-size: 12px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  pointer-events: auto;
  text-align: center;
}
.toast-success { background: #059669; }
.toast-warning { background: #d97706; }
.toast-error { background: #dc2626; }

/* ========================================================
   MEDIA QUERIES: RESPONSIVO CELULAR (Prioritario) Y PC VISUAL
   ======================================================== */


/* PC Visual (Desktop >= 850px) */
@media (min-width: 850px) {
  .app-compact-container {
    padding: 16px 20px;
    gap: 12px;
  }

  .compact-header {
    padding: 10px 18px;
  }

  .company-selector-wrapper {
    flex-direction: row;
    align-items: center;
    gap: 12px;
  }

  .compact-product-bar {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  .product-bar-actions {
    width: auto;
  }

  .trio-metrics-grid {
    grid-template-columns: 1.05fr 1.25fr 0.95fr;
    gap: 12px;
  }

  .trio-metric-card {
    padding: 12px 14px;
  }

  .trio-value {
    font-size: 25px;
  }

  /* En PC ocultamos el selector de tabs de móvil */
  .mobile-detail-tabs-bar {
    display: none !important;
  }

  /* En PC las 2 columnas se muestran lado a lado */
  .compact-detail-columns {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  #cardPanelListasPrecios,
  #cardPanelVentasRecientes {
    display: block !important;
  }

  .toast-container {
    left: auto;
    right: 16px;
    width: auto;
  }
}
.brand-logo{height:32px;width:auto;display:block;flex-shrink:0}
