/* ═══════════════════════════════════════════
   RESET & BASE
═══════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 14px;
  background: #F5F5F5;
  color: #111827;
}

/* ═══════════════════════════════════════════
   LOGO
═══════════════════════════════════════════ */
.logo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: #D85A30;
  border-radius: 10px;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.logo-icon--sm {
  width: 30px;
  height: 30px;
  font-size: 16px;
  border-radius: 7px;
}
.logo-text {
  font-size: 20px;
  font-weight: 700;
  color: #111827;
  margin-left: 10px;
}

/* ═══════════════════════════════════════════
   BOTONES
═══════════════════════════════════════════ */
.btn-primary {
  background: #D85A30;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary:hover { background: #C04E28; }
.btn-full { width: 100%; }

.btn-ghost {
  background: transparent;
  border: 1px solid #D1D5DB;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  color: #374151;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-ghost:hover { background: #F3F4F6; }
.btn-ghost--danger { color: #DC2626; border-color: #FCA5A5; }
.btn-ghost--danger:hover { background: #FEF2F2; }

/* ═══════════════════════════════════════════
   LOGIN
═══════════════════════════════════════════ */
#login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.login-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 360px;
}
.logo-row {
  display: flex;
  align-items: center;
}
.login-subtitle {
  margin: 0 0 16px;
  color: #6B7280;
  font-size: 13px;
}
.login-card {
  width: 100%;
  background: #fff;
  border: 1px solid #E5E7EB;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,.07);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.field-label {
  font-size: 12px;
  color: #6B7280;
  font-weight: 500;
  letter-spacing: .02em;
}
.token-input {
  font-family: ui-monospace, 'Cascadia Code', monospace;
  font-size: 15px;
  padding: 9px 12px;
  border: 1px solid #D1D5DB;
  border-radius: 8px;
  outline: none;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.token-input:focus {
  border-color: #D85A30;
  box-shadow: 0 0 0 3px rgba(216,90,48,.15);
}
.login-error {
  background: #FEF2F2;
  border: 1px solid #FCA5A5;
  border-radius: 8px;
  color: #DC2626;
  font-size: 12px;
  padding: 10px 14px;
  line-height: 1.5;
}
.hidden { display: none !important; }

/* ═══════════════════════════════════════════
   HEADER
═══════════════════════════════════════════ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #fff;
  border-bottom: 1px solid #E5E7EB;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  gap: 16px;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.header-brand {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}
.header-cliente {
  color: #6B7280;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.countdown-text {
  color: #9CA3AF;
  font-size: 12px;
  white-space: nowrap;
}

/* ═══════════════════════════════════════════
   BARRA DE FILTROS
═══════════════════════════════════════════ */
.filter-bar {
  background: #fff;
  border-bottom: 1px solid #E5E7EB;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.search-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}
.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  pointer-events: none;
}
.search-input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border: 1px solid #D1D5DB;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-input:focus {
  border-color: #D85A30;
  box-shadow: 0 0 0 3px rgba(216,90,48,.15);
}
.filter-select {
  padding: 8px 10px;
  border: 1px solid #D1D5DB;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  outline: none;
  cursor: pointer;
  color: #374151;
}
.filter-select:focus { border-color: #D85A30; }

@media (max-width: 639px) {
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-select { width: 100%; }
}

/* ═══════════════════════════════════════════
   TABLA
═══════════════════════════════════════════ */
.table-container {
  padding: 16px 20px;
}
.table-meta {
  margin-bottom: 8px;
}
.product-count {
  font-size: 13px;
  color: #6B7280;
}
.table-scroll {
  overflow-x: auto;
  border: 1px solid #E5E7EB;
  border-radius: 8px;
  background: #fff;
}

table {
  min-width: 1040px;
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

/* Grupos de cabecera */
.thead-groups th {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  border-bottom: 1px solid #E5E7EB;
}
.th-group--stock {
  background: #F9FAFB;
  color: #6B7280;
}
.th-group--entradas {
  background: #EFF6FF;
  color: #185FA5;
  border-left: 2px solid #BFDBFE;
}
.th-group--pronostico {
  background: #F5F3FF;
  color: #3C3489;
  border-left: 2px solid #C4B5FD;
}

/* Cabecera columnas */
.thead-cols th {
  padding: 7px 12px;
  font-size: 11px;
  font-weight: 600;
  color: #6B7280;
  text-transform: uppercase;
  letter-spacing: .05em;
  background: #F9FAFB;
  border-bottom: 1px solid #E5E7EB;
  white-space: nowrap;
  text-align: left;
}
.col-border-blue  { border-left: 2px solid #BFDBFE !important; }
.col-border-purple { border-left: 2px solid #C4B5FD !important; }

/* Ordenación */
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { background: #F3F4F6; }
th.sort-asc::after  { content: " ↑"; color: #D85A30; }
th.sort-desc::after { content: " ↓"; color: #D85A30; }

/* Filas de datos */
tbody tr {
  border-bottom: 1px solid #F3F4F6;
  transition: background 0.1s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #F9FAFB; }

tbody td {
  padding: 9px 12px;
  vertical-align: middle;
  text-align: left;
}

/* Columnas mono */
.col-ref, .col-ean {
  font-family: ui-monospace, 'Cascadia Code', monospace;
  color: #6B7280;
  font-size: 12px;
}

/* Columna Uds. */
.col-qty {
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  min-width: 70px;
}
.qty-zero { color: #DC2626; background: #FEF2F2; }
.qty-low  { color: #D97706; background: #FFFBEB; }
.qty-ok   { color: #166534; background: #F0FDF4; }

/* Badges de estado */
.badge {
  display: inline-block;
  border-radius: 9999px;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.badge--agotado    { background: #FEF2F2; color: #991B1B; }
.badge--bajo       { background: #FFFBEB; color: #92400E; }
.badge--disponible { background: #F0FDF4; color: #166534; }

/* Columnas entradas */
.col-border-blue-td   { border-left: 2px solid #BFDBFE; }
.col-border-purple-td { border-left: 2px solid #C4B5FD; text-align: center; }

.entrada-uds {
  color: #185FA5;
  font-weight: 600;
  font-family: ui-monospace, 'Cascadia Code', monospace;
}
.badge--fecha {
  display: inline-block;
  background: #EFF6FF;
  color: #185FA5;
  border-radius: 9999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.entrada-line {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}
.entrada-line:last-child { margin-bottom: 0; }
.no-data { color: #D1D5DB; }

/* Columna pronosticado */
.pronostico-num {
  font-size: 15px;
  font-weight: 700;
  color: #3C3489;
  line-height: 1.2;
}
.pronostico-sub {
  font-size: 10px;
  color: #9CA3AF;
  margin-top: 2px;
  line-height: 1.3;
}

/* Fila vacía */
.row-empty td {
  text-align: center;
  color: #9CA3AF;
  padding: 32px;
}

/* ═══════════════════════════════════════════
   FAQ Y CONTACTO
═══════════════════════════════════════════ */
.faq-container {
  padding: 0 20px 16px;
}
.faq-card {
  background: #fff;
  border: 1px solid #E5E7EB;
  border-radius: 8px;
  padding: 1.5rem;
}
.faq-title {
  font-size: 14px;
  font-weight: 600;
  color: #374151;
  margin: 0 0 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #E5E7EB;
}
.faq-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}
.faq-item {
  margin-bottom: 2px;
}
.faq-item summary {
  cursor: pointer;
  list-style: none;
  font-weight: 600;
  font-size: 13px;
  padding: 8px 0;
  color: #374151;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary:hover { color: #D85A30; }
.faq-item p {
  font-size: 13px;
  color: #6B7280;
  padding: 4px 0 8px 0;
  margin: 0;
  line-height: 1.5;
}
.contact-col {
  border-left: 1px solid #F3F4F6;
  padding-left: 2rem;
}
.contact-title {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  margin: 0 0 12px;
}
.contact-list {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  color: #374151;
}
.contact-list a {
  color: #D85A30;
  text-decoration: none;
}
.contact-list a:hover { text-decoration: underline; }
.contact-note {
  font-size: 12px;
  color: #9CA3AF;
  margin: 0;
  line-height: 1.5;
}

@media (max-width: 639px) {
  .faq-grid { grid-template-columns: 1fr; }
  .contact-col {
    border-left: none;
    border-top: 1px solid #F3F4F6;
    padding-left: 0;
    padding-top: 1.5rem;
    margin-top: 0.5rem;
  }
}

/* ═══════════════════════════════════════════
   SPINNER DE CARGA
═══════════════════════════════════════════ */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #F3F4F6;
  border-top-color: #D85A30;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════════
   PRIMERA COLUMNA FIJA (sticky scroll horizontal)
═══════════════════════════════════════════ */
#stockBody td:first-child,
.thead-cols th:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: #fff;
}
.thead-cols th:first-child {
  background: #F9FAFB;
}
#stockBody tr:hover td:first-child {
  background: #F9FAFB;
}

/* ═══════════════════════════════════════════
   DESTELLO DE ACTUALIZACIÓN
═══════════════════════════════════════════ */
@keyframes flashUpdate {
  0%   { opacity: 0.4; }
  100% { opacity: 1;   }
}
.table-refreshed {
  animation: flashUpdate 0.4s ease-out;
}

/* ═══════════════════════════════════════════
   SELECTOR DE IDIOMA
═══════════════════════════════════════════ */
.lang-switcher {
  display: flex;
  align-items: center;
  gap: 4px;
}
.lang-btn {
  background: none;
  border: 2px solid transparent;
  border-radius: 4px;
  padding: 2px 3px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 24px;
  opacity: 0.45;
  transition: opacity 0.15s, border-color 0.15s;
}
.lang-btn:hover { opacity: 0.8; }
.lang-btn.lang-active { opacity: 1; border-color: #D85A30; }
.lang-btn svg {
  width: 24px;
  height: 16px;
  display: block;
  border-radius: 2px;
}

/* ═══════════════════════════════════════════
   PAGINACIÓN
═══════════════════════════════════════════ */
.page-btn {
  min-width: 32px;
  height: 32px;
  border: 1px solid #E5E7EB;
  border-radius: 6px;
  background: white;
  color: #374151;
  font-size: 13px;
  cursor: pointer;
  padding: 0 8px;
  white-space: nowrap;
}
.page-btn:hover:not(:disabled) { border-color: #D85A30; color: #D85A30; }
.page-btn.active { background: #D85A30; color: white; border-color: #D85A30; }
.page-btn:disabled { opacity: 0.4; cursor: default; }
.page-ellipsis { padding: 0 4px; color: #9CA3AF; font-size: 13px; }

/* ═══════════════════════════════════════════
   PANTALLA DE SELECCIÓN DE MARCA
═══════════════════════════════════════════ */
.brand-selector-body {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}
.brand-selector-body h2 {
  font-size: 18px;
  font-weight: 600;
  color: #111827;
  margin: 0 0 4px;
}
.brand-selector-body p {
  font-size: 13px;
  color: #6B7280;
  margin: 0 0 1.5rem;
}
#brandGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.brand-card {
  background: white;
  border: 1px solid #E5E7EB;
  border-radius: 10px;
  padding: 1.25rem 1rem;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
  text-align: center;
}
.brand-card:hover {
  border-color: #D85A30;
  box-shadow: 0 2px 8px rgba(216,90,48,0.12);
  transform: translateY(-1px);
}
.brand-card-name {
  font-size: 13px;
  font-weight: 600;
  color: #111827;
  margin-bottom: 4px;
  word-break: break-word;
}
.brand-card-count {
  font-size: 11px;
  color: #9CA3AF;
}

/* ═══════════════════════════════════════════
   FOOTER
═══════════════════════════════════════════ */
.site-footer {
  text-align: center;
  padding: 16px 20px 24px;
  color: #9CA3AF;
  font-size: 12px;
}
