/* ==============================================
   ESTILOS RESPONSIVE PARA BONDCOMMERCE DASHBOARD
   ============================================== */

/* === VARIABLES GLOBALES === */
:root {
  /* Colores bond */
  --bond1: #6f42c1;
  --bond2: #4c6ef5;
  --bond3: #1fb6ff;
  --bond-grad: linear-gradient(135deg, var(--bond1), var(--bond2), var(--bond3));

  /* Espaciados responsive */
  --gap-xs: clamp(0.5rem, 2vw, 0.75rem);
  --gap-sm: clamp(0.75rem, 2.5vw, 1rem);
  --gap-md: clamp(1rem, 3vw, 1.5rem);
  --gap-lg: clamp(1.5rem, 4vw, 2rem);

  /* Tipografía responsive */
  --fs-kpi: clamp(1.8rem, 4vw, 2.5rem);
  --fs-h5: clamp(1rem, 2.5vw, 1.25rem);
  --fs-small: clamp(0.75rem, 2vw, 0.875rem);
  --fs-tiny: clamp(0.7rem, 1.8vw, 0.8rem);

  /* Alturas y dimensiones */
  --card-min-height: clamp(200px, 25vh, 300px);
  --bar-max-height: clamp(60px, 8vh, 80px);
}

/* === LAYOUT PRINCIPAL === */
#app {
  min-height: 100vh;
}

.main-content {
  transition: margin-left 0.3s ease;
}

/* === MENÚ HORIZONTAL === */
.navbar {
  background: rgba(255,255,255,0.95) !important;
  backdrop-filter: blur(10px);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  border-bottom: 1px solid rgba(0,0,0,0.05) !important;
}

.navbar-brand {
  color: var(--bond1) !important;
  font-weight: 600;
  font-size: 1.1rem;
}

.navbar-nav .nav-link {
  color: #6b7280 !important;
  font-weight: 500;
  font-size: 0.9rem;
  padding: 0.5rem 0.75rem !important;
  border-radius: 6px;
  transition: all 0.2s ease;
  margin: 0 0.1rem;
}

.navbar-nav .nav-link:hover {
  color: var(--bond1) !important;
  background: rgba(111, 66, 193, 0.1);
}

.navbar-nav .nav-link.active {
  color: var(--bond1) !important;
  background: rgba(111, 66, 193, 0.15);
}

.navbar-nav .nav-link i {
  font-size: 0.85rem;
  opacity: 0.8;
}

.dropdown-item-form {
  margin: 0;
  padding: 0;
}

.dropdown-item-form .dropdown-item {
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  padding: 0.375rem 1rem;
  color: #212529;
  transition: all 0.2s ease;
}

.dropdown-item-form .dropdown-item:hover {
  background-color: #f8f9fa;
}

.btn-group .btn {
  border-color: rgba(111, 66, 193, 0.2);
  color: var(--bond1);
}

.btn-group .btn:hover {
  background: rgba(111, 66, 193, 0.1);
  border-color: var(--bond1);
}

/* Modo oscuro para navbar */
.dark .navbar {
  background: rgba(26, 32, 44, 0.95) !important;
  border-bottom-color: #4a5568 !important;
}

.dark .navbar-brand {
  color: #e2e8f0 !important;
}

.dark .navbar-nav .nav-link {
  color: #a0aec0 !important;
}

.dark .navbar-nav .nav-link:hover {
  color: #e2e8f0 !important;
  background: rgba(111, 66, 193, 0.2);
}

.dark .navbar-nav .nav-link.active {
  color: #e2e8f0 !important;
  background: rgba(111, 66, 193, 0.3);
}

.dark .btn-group .btn {
  background: #2d3748;
  border-color: #4a5568;
  color: #e2e8f0;
}

.dark .dropdown-menu {
  background: #2d3748;
  border-color: #4a5568;
}

.dark .dropdown-item {
  color: #e2e8f0;
}

.dark .dropdown-item:hover {
  background: #4a5568;
  color: #f7fafc;
}

/* Responsive navbar */
@media (max-width: 991.98px) {
  .navbar-collapse {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(0,0,0,0.1);
  }

  .dark .navbar-collapse {
    border-top-color: #4a5568;
  }

  .navbar-nav {
    gap: 0.25rem;
  }

  .navbar-nav .nav-link {
    padding: 0.6rem 0.75rem !important;
    margin: 0;
    border-radius: 8px;
  }
}

/* Botón hamburguesa móvil */
#mobile-menu-toggle {
  background: var(--bond-grad) !important;
  border: none !important;
  box-shadow: 0 4px 12px rgba(111, 66, 193, 0.3) !important;
  transition: all 0.2s ease;
}

#mobile-menu-toggle:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(111, 66, 193, 0.4) !important;
}

#mobile-menu-toggle:active {
  transform: scale(0.95);
}

/* Ocultar en desktop */
@media (min-width: 768px) {
  #mobile-menu-toggle {
    display: none !important;
  }
}

/* Ajustar contenido en móvil cuando hay botón hamburguesa */
@media (max-width: 767.98px) {
  .main-content {
    padding-top: 0 !important; /* El navbar ya da el espaciado necesario */
  }

  /* Ajustar el botón hamburguesa para que no interfiera con navbar */
  #mobile-menu-toggle {
    top: 0.5rem !important;
    left: 0.5rem !important;
    z-index: 1070 !important;
  }

  /* Asegurar que el navbar no se superponga */
  .navbar {
    padding-left: 4rem !important; /* Espacio para el botón hamburguesa */
  }
}

/* === CONTENEDOR PRINCIPAL === */
.bd {
  padding: var(--gap-sm) !important;
}

/* === MEJORAS PARA CARDS === */
.bd-card {
  border: none !important;
  border-radius: 12px !important;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08) !important;
  transition: all 0.2s ease;
  min-height: var(--card-min-height);
}

.bd-card:hover {
  box-shadow: 0 4px 20px rgba(0,0,0,0.12) !important;
  transform: translateY(-1px);
}

.bd-card .card-body {
  padding: var(--gap-md) !important;
  display: flex;
  flex-direction: column;
  gap: var(--gap-sm);
}

.bd-card .card-title {
  font-size: var(--fs-h5) !important;
  font-weight: 600 !important;
  margin: 0 !important;
}

/* === KPI MEJORADOS === */
.bd-kpi {
  font-size: var(--fs-kpi) !important;
  font-weight: 700 !important;
  background: var(--bond-grad);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.2;
}

/* === PILLS/BADGES RESPONSIVE === */
.bd-pill {
  background: rgba(111, 66, 193, 0.1) !important;
  color: var(--bond1) !important;
  padding: 0.25rem 0.75rem !important;
  border-radius: 20px !important;
  font-size: var(--fs-tiny) !important;
  font-weight: 500 !important;
  border: 1px solid rgba(111, 66, 193, 0.2);
}

/* === GRÁFICOS DE BARRAS MEJORADOS === */
.bd-bars {
  display: flex;
  align-items: flex-end;
  gap: var(--gap-xs);
  height: var(--bar-max-height);
  padding: var(--gap-xs) 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.bd-bars::-webkit-scrollbar {
  height: 4px;
}

.bd-bars::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.05);
  border-radius: 2px;
}

.bd-bars::-webkit-scrollbar-thumb {
  background: var(--bond1);
  border-radius: 2px;
}

.bd-bars__col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  min-width: clamp(40px, 8vw, 60px);
  flex-shrink: 0;
}

.bd-bars__bar {
  width: 100%;
  min-height: 4px;
  height: var(--h, 20px);
  max-height: calc(var(--bar-max-height) - 20px);
  background: var(--bond-grad);
  border-radius: 4px 4px 2px 2px;
  transition: all 0.3s ease;
  cursor: pointer;
}

.bd-bars__bar:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(111, 66, 193, 0.3);
}

.bd-bars__bar--brand {
  background: linear-gradient(135deg, var(--bond2), var(--bond3)) !important;
}

.bd-bars__col small {
  font-size: var(--fs-tiny) !important;
  color: #6c757d;
  text-align: center;
  white-space: nowrap;
}

/* === LISTAS MEJORADAS === */
.bd-scroll {
  max-height: none !important;
  overflow-y: visible !important;
  scrollbar-width: none;
}

.bd-scroll::-webkit-scrollbar {
  display: none;
}

.bd-item {
  background: transparent !important;
  border: none !important;
  border-bottom: 1px solid rgba(0,0,0,0.05) !important;
  padding: var(--gap-sm) !important;
  transition: background-color 0.2s ease;
}

.bd-item:hover {
  background: rgba(111, 66, 193, 0.03) !important;
}

.bd-rank {
  display: flex;
  align-items: center;
  justify-content: center;
  width: clamp(24px, 5vw, 32px);
  height: clamp(24px, 5vw, 32px);
  background: var(--bond-grad);
  color: white;
  font-size: var(--fs-tiny);
  font-weight: 600;
  border-radius: 50%;
  flex-shrink: 0;
}

/* === PROGRESO Y BARRAS HORIZONTALES === */
.bd-progress {
  height: 4px;
  background: rgba(0,0,0,0.1);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

.bd-progress::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: var(--pct, 0%);
  background: var(--bond-grad);
  transition: width 0.5s ease;
  border-radius: 2px;
}

.bd-hbar {
  height: 6px;
  background: rgba(0,0,0,0.1);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.bd-hbar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: var(--pct, 0%);
  background: var(--c, var(--bond1));
  transition: width 0.5s ease;
  border-radius: 3px;
}

/* === BADGES Y MÉTRICAS === */
.bd-badge {
  background: rgba(0,0,0,0.05) !important;
  color: #495057 !important;
  padding: 0.2rem 0.5rem !important;
  border-radius: 6px !important;
  font-size: var(--fs-tiny) !important;
  font-weight: 500 !important;
  white-space: nowrap;
}

.bd-badge--ok {
  background: rgba(25, 135, 84, 0.1) !important;
  color: #198754 !important;
}

.bd-metrics {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  align-items: flex-end;
}

.bd-muted {
  color: #6c757d !important;
  font-size: var(--fs-tiny) !important;
}

/* === TIMELINE === */
.bd-timeline {
  max-height: none;
  overflow-y: visible;
  scrollbar-width: none;
  list-style: none;
  padding: 0;
  margin: 0;
}

.bd-timeline li {
  padding: var(--gap-xs) 0;
  border-bottom: 1px solid rgba(0,0,0,0.05);
  font-size: var(--fs-small);
}

.bd-timeline li:last-child {
  border-bottom: none;
}

/* === TOP VENDIDOS - PRO STYLE === */
.bd-top-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bd-top-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  transition: background 0.2s ease;
  border-left: 3px solid transparent;
}

.bd-top-item:hover {
  background: rgba(111, 66, 193, 0.04);
  border-left-color: var(--bond1);
}

.bd-top-rank {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}

.bd-top-info {
  flex: 1;
  min-width: 0;
}

.bd-top-name {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 3px;
}

.bd-top-nombre {
  font-size: 0.78rem;
  font-weight: 500;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bd-top-code {
  font-size: 0.62rem;
  color: #94a3b8;
  white-space: nowrap;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.bd-top-bar {
  height: 3px;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 2px;
  overflow: hidden;
}

.bd-top-bar-fill {
  height: 100%;
  background: var(--bond-grad);
  border-radius: 2px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.bd-top-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.bd-top-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 42px;
}

.bd-top-stat-val {
  font-size: 0.72rem;
  font-weight: 600;
  color: #334155;
  line-height: 1.1;
}

.bd-top-stat-lbl {
  font-size: 0.55rem;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.bd-top-stat--money .bd-top-stat-val {
  color: #16a34a;
  font-weight: 700;
  font-size: 0.74rem;
}

/* === STOCK / ALERTAS - PRO STYLE === */
.bd-stock-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.bd-stock-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-radius: 6px;
  border-left: 3px solid #94a3b8;
  transition: all 0.2s ease;
}

.bd-stock-item:hover {
  background: rgba(0, 0, 0, 0.02);
}

.bd-stock-item.bd-stock-low {
  border-left-color: #f59e0b;
}

.bd-stock-item.bd-stock-critical {
  border-left-color: #f97316;
  background: rgba(249, 115, 22, 0.03);
}

.bd-stock-item.bd-stock-zero {
  border-left-color: #ef4444;
  background: rgba(239, 68, 68, 0.03);
}

.bd-stock-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex: 1;
}

.bd-stock-name {
  font-size: 0.72rem;
  font-weight: 500;
  color: #334155;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bd-stock-code {
  font-size: 0.6rem;
  color: #94a3b8;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.bd-stock-qty {
  display: flex;
  align-items: baseline;
  gap: 2px;
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.04);
}

.bd-stock-num {
  font-size: 0.72rem;
  font-weight: 700;
  color: #f59e0b;
}

.bd-stock-num--danger {
  color: #ef4444;
}

.bd-stock-zero .bd-stock-num {
  color: #ef4444;
}

.bd-stock-critical .bd-stock-num {
  color: #f97316;
}

.bd-stock-unit {
  font-size: 0.55rem;
  color: #94a3b8;
  text-transform: uppercase;
}

/* Dark mode overrides for new widgets */
.dark .bd-top-nombre {
  color: #e2e8f0;
}

.dark .bd-top-code {
  color: #64748b;
}

.dark .bd-top-stat-val {
  color: #cbd5e1;
}

.dark .bd-top-stat-lbl {
  color: #64748b;
}

.dark .bd-top-stat--money .bd-top-stat-val {
  color: #4ade80;
}

.dark .bd-top-item:hover {
  background: rgba(139, 92, 246, 0.08);
}

.dark .bd-top-bar {
  background: rgba(255, 255, 255, 0.08);
}

.dark .bd-stock-name {
  color: #e2e8f0;
}

.dark .bd-stock-code {
  color: #64748b;
}

.dark .bd-stock-qty {
  background: rgba(255, 255, 255, 0.06);
}

.dark .bd-stock-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

/* === RESPONSIVE BREAKPOINTS === */

/* Tablets (768px - 1199px) */
@media (max-width: 1199.98px) and (min-width: 768px) {
  .bd-row-top .col-lg-4 {
    margin-bottom: var(--gap-sm);
  }

  .bd-bars__col {
    min-width: clamp(35px, 7vw, 50px);
  }

  .bd-metrics {
    flex-direction: row;
    gap: 0.5rem;
    flex-wrap: wrap;
  }
}

/* Móviles (< 768px) */
@media (max-width: 767.98px) {
  :root {
    --gap-xs: 0.5rem;
    --gap-sm: 0.75rem;
    --gap-md: 1rem;
    --gap-lg: 1.25rem;
    --card-min-height: 180px;
    --bar-max-height: 60px;
  }

  .bd {
    padding: var(--gap-xs) !important;
  }

  /* Cards en móvil */
  .bd-card .card-body {
    padding: var(--gap-sm) !important;
  }

  /* Gráficos más compactos */
  .bd-bars {
    gap: 0.25rem;
    padding: 0.5rem 0;
  }

  .bd-bars__col {
    min-width: 32px;
  }

  .bd-bars__col small {
    font-size: 0.65rem !important;
    transform: rotate(-45deg);
    transform-origin: center;
    margin-top: 0.5rem;
  }

  /* Métricas apiladas en móvil */
  .bd-metrics {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }

  /* Listas más compactas */
  .bd-item {
    padding: var(--gap-xs) !important;
  }

  .bd-rank {
    width: 24px;
    height: 24px;
    font-size: 0.7rem;
  }

  /* KPI más pequeño en móvil */
  .bd-kpi {
    font-size: clamp(1.5rem, 6vw, 2rem) !important;
  }

  /* Timeline más compacta */
  .bd-timeline {
    max-height: 180px;
  }

  /* Ajustar grid en móvil */
  .bd-row-top .col-12 {
    margin-bottom: var(--gap-sm);
  }

  /* Ocultar elementos menos importantes en móvil muy pequeño */
  @media (max-width: 479.98px) {
    .bd-pill {
      display: none;
    }

    .bd-badge {
      font-size: 0.65rem !important;
      padding: 0.15rem 0.4rem !important;
    }

    .bd-bars__col small {
      display: none;
    }
  }
}

/* === MODO OSCURO === */
.dark .bd-card {
  background: #1a1a1a !important;
  border: 1px solid #333 !important;
}

.dark .bd-item {
  border-bottom-color: #333 !important;
}

.dark .bd-item:hover {
  background: rgba(111, 66, 193, 0.1) !important;
}

.dark .bd-badge {
  background: rgba(255,255,255,0.1) !important;
  color: #e0e0e0 !important;
}

.dark .bd-muted {
  color: #9ca3af !important;
}

.dark .bd-progress,
.dark .bd-hbar {
  background: rgba(255,255,255,0.1);
}

/* === ANIMACIONES Y TRANSICIONES === */
@media (prefers-reduced-motion: reduce) {
  .bd-card,
  .bd-bars__bar,
  .bd-progress::before,
  .bd-hbar::before {
    transition: none !important;
  }
}

/* === MEJORAS DE ACCESIBILIDAD === */
.bd-bars__bar:focus,
.bd-item:focus {
  outline: 2px solid var(--bond2);
  outline-offset: 2px;
}

/* === UTILIDADES ADICIONALES === */
.bd-surface {
  background: rgba(255,255,255,0.8);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.2);
}

.dark .bd-surface {
  background: rgba(0,0,0,0.6);
  border: 1px solid rgba(255,255,255,0.1);
}
