/**
 * Estilos Elegantes en Colores Morados para la Tabla de Sucursales Bsale
 * WooCommerce Single Product Page
 * Compatible con WooCommerce 11.0.1
 */

:root {
  --bsale-purple-900: #2e1065;
  --bsale-purple-800: #4c1d95;
  --bsale-purple-700: #6d28d9;
  --bsale-purple-600: #7c3aed;
  --bsale-purple-500: #8b5cf6;
  --bsale-purple-100: #ede9fe;
  --bsale-purple-50: #f5f3ff;
  --bsale-slate-800: #1e293b;
  --bsale-slate-600: #475569;
  --bsale-slate-400: #94a3b8;
  --bsale-slate-200: #e2e8f0;
  --bsale-emerald-600: #059669;
  --bsale-emerald-50: #ecfdf5;
  --bsale-amber-600: #d97706;
  --bsale-amber-50: #fffbeb;
  --bsale-rose-600: #e11d48;
  --bsale-rose-50: #fff1f2;
}

#bsale-branch-stock-container {
  margin: 1.5rem 0 1.25rem 0;
  clear: both;
  width: 100%;
}

.bsale-stock-card {
  background: #ffffff;
  border: 1px solid var(--bsale-purple-100);
  border-radius: 12px;
  box-shadow: 0 4px 20px -2px rgba(109, 40, 217, 0.08), 0 2px 6px -1px rgba(0, 0, 0, 0.04);
  overflow: hidden;
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.bsale-stock-card:hover {
  border-color: rgba(124, 58, 237, 0.35);
  box-shadow: 0 8px 25px -4px rgba(109, 40, 217, 0.12);
}

/* Aviso de Modo de Prueba (Visible solo para administradores) */
.bsale-test-mode-notice {
  background: #fdf4ff;
  border-bottom: 1px solid #f0abfc;
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
}

.bsale-test-mode-badge {
  background: #7c3aed;
  color: #ffffff;
  font-weight: 700;
  font-size: 0.6875rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.bsale-test-mode-text {
  color: #701a75;
  font-weight: 500;
}

/* Header */
.bsale-stock-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1.125rem;
  background: linear-gradient(135deg, var(--bsale-purple-50) 0%, #ffffff 100%);
  border-bottom: 1px solid var(--bsale-purple-100);
}

.bsale-stock-header-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.bsale-stock-header-title h4 {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--bsale-purple-900);
  letter-spacing: -0.01em;
}

.bsale-icon-store {
  width: 18px;
  height: 18px;
  color: var(--bsale-purple-600);
  flex-shrink: 0;
}

.bsale-header-badges {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-wrap: wrap;
}

.bsale-badge-exempt {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--bsale-purple-700);
  background: var(--bsale-purple-100);
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.bsale-badge-wc-status {
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  letter-spacing: 0.025em;
  text-transform: uppercase;
  white-space: nowrap;
}

.bsale-badge-wc-status.bsale-badge-out {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.bsale-product-out-of-stock {
  margin-top: 0.875rem;
  margin-bottom: 1.25rem;
}

/* Table */
.bsale-table-scroll-container {
  width: 100%;
  overflow-x: auto;
}

.bsale-stock-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
  font-size: 0.875rem;
  text-align: left;
}

.bsale-stock-table thead {
  background: #fafafa;
  border-bottom: 1px solid var(--bsale-slate-200);
}

.bsale-stock-table th {
  padding: 0.625rem 1.125rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--bsale-slate-600);
}

.bsale-th-status {
  text-align: right;
}

.bsale-row {
  border-bottom: 1px solid #f1f5f9;
  transition: background-color 0.15s ease;
}

.bsale-row:last-child {
  border-bottom: none;
}

.bsale-row:hover {
  background-color: var(--bsale-purple-50);
}

.bsale-td-branch {
  padding: 0.75rem 1.125rem;
  vertical-align: middle;
}

.bsale-branch-info {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.bsale-branch-name {
  color: var(--bsale-slate-800);
  font-weight: 500;
  line-height: 1.35;
}

/* Status dots */
.bsale-indicator-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.bsale-indicator-dot.is-available {
  background-color: var(--bsale-emerald-600);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}

.bsale-indicator-dot.is-low {
  background-color: var(--bsale-amber-600);
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.15);
}

.bsale-indicator-dot.is-out {
  background-color: var(--bsale-rose-600);
  box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.12);
}

/* Qty Cell & Pills */
.bsale-td-qty {
  padding: 0.75rem 1.125rem;
  text-align: right;
  vertical-align: middle;
  white-space: nowrap;
}

.bsale-stock-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.3125rem 0.6875rem;
  border-radius: 6px;
  font-size: 0.8125rem;
  font-weight: 600;
}

.bsale-stock-pill.in-stock {
  background-color: var(--bsale-purple-50);
  color: var(--bsale-purple-800);
  border: 1px solid rgba(124, 58, 237, 0.2);
}

.bsale-stock-pill.in-stock .bsale-qty-number {
  font-weight: 700;
  color: var(--bsale-purple-700);
}

.bsale-stock-pill.out-of-stock {
  background-color: var(--bsale-rose-50);
  color: var(--bsale-rose-600);
  border: 1px solid rgba(225, 29, 72, 0.15);
}

/* Footer */
.bsale-stock-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.625rem 1.125rem;
  background: #ffffff;
  border-top: 1px solid #f1f5f9;
  font-size: 0.75rem;
  color: var(--bsale-slate-600);
}

.bsale-realtime-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  color: var(--bsale-purple-700);
  font-weight: 500;
}

.bsale-pulse-dot {
  width: 6px;
  height: 6px;
  background-color: var(--bsale-purple-600);
  border-radius: 50%;
  animation: bsale-pulse 2s infinite;
}

.bsale-sku-reference {
  font-family: monospace;
  font-size: 0.71875rem;
  color: var(--bsale-slate-400);
}

@keyframes bsale-pulse {
  0% { transform: scale(0.95); opacity: 0.7; box-shadow: 0 0 0 0 rgba(124, 58, 237, 0.7); }
  70% { transform: scale(1); opacity: 1; box-shadow: 0 0 0 5px rgba(124, 58, 237, 0); }
  100% { transform: scale(0.95); opacity: 0.7; box-shadow: 0 0 0 0 rgba(124, 58, 237, 0); }
}

/* Responsive Styles for Mobile */
@media (max-width: 640px) {
  .bsale-stock-card {
    border-radius: 10px;
  }
  .bsale-stock-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.375rem;
    padding: 0.75rem;
  }
  .bsale-stock-table th, 
  .bsale-stock-table td {
    padding: 0.625rem 0.75rem;
  }
  .bsale-branch-name {
    font-size: 0.8125rem;
  }
  .bsale-stock-pill {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
  }
  .bsale-stock-footer {
    padding: 0.5rem 0.75rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }
}

/* Admin Diagnostic Card (Visible only to administrators) */
.bsale-admin-diagnostic-card {
  margin-top: 1rem;
  border-top: 1px dashed var(--bsale-slate-200);
  padding: 0.875rem 1rem;
  background: #f8fafc;
  border-radius: 0 0 10px 10px;
  font-size: 0.75rem;
}

.bsale-diag-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.bsale-diag-title {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  color: var(--bsale-slate-800);
  font-size: 0.8125rem;
}

.bsale-btn-force-refresh {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.5rem;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--bsale-purple-700);
  background: #fff;
  border: 1px solid var(--bsale-purple-200, #ddd6fe);
  border-radius: 4px;
  text-decoration: none;
  transition: all 0.15s ease;
}

.bsale-btn-force-refresh:hover {
  background: var(--bsale-purple-50);
  color: var(--bsale-purple-900);
}

.bsale-diag-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.5rem;
  background: #fff;
  padding: 0.5rem 0.75rem;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  margin-bottom: 0.5rem;
}

.bsale-diag-grid code {
  font-size: 0.71875rem;
  background: #f1f5f9;
  padding: 1px 4px;
  border-radius: 3px;
  color: #0f172a;
}

.bsale-diag-alert {
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  margin-top: 0.375rem;
}

.bsale-diag-warning {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
}

.bsale-diag-stock-list {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  margin-top: 0.375rem;
}
