/* VARIABLES (MODO CLARO POR DEFECTO) */
:root {
  --bg-main: #f8f9fa;
  --header-bg: #ffffff;
  --nav-bg: #f1f3f5;
  --card-bg: #ffffff;
  --text-main: #1a1a1a;
  --text-muted: #666666;
  --accent-gold: #ff9d00;
  --ws-color: #23d366;
  --input-bg: #f1f3f5;
  --input-border: #e0e0e0;
  --border-color: #e5e7eb;
  --card-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  --thumb-bg: #e9ecef;
  --modal-bg: #ffffff;
  --footer-bg: #111111;
  --footer-text: #ffffff;
}

/* MODIFICADORES PARA MODO OSCURO */
body.dark-mode {
  --bg-main: #0a0a0a;
  --header-bg: #000000;
  --nav-bg: #111111;
  --card-bg: #1e1e1e;
  --text-main: #ffffff;
  --text-muted: #aaaaaa;
  --accent-gold: #ff9d00;
  --ws-color: #23d366;
  --input-bg: #1c1c1c;
  --input-border: #2a2a2a;
  --border-color: #222222;
  --card-shadow: none;
  --thumb-bg: #282828;
  --modal-bg: #181818;
  --footer-bg: #050505;
  --footer-text: #dddddd;
}

* { box-sizing: border-box; margin: 0; padding: 0; transition: background-color 0.2s, color 0.2s; }

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* HEADER Y NAVEGACIÓN */
.main-header {
  background-color: var(--header-bg);
  width: 100%;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  gap: 16px;
  flex-wrap: nowrap;
}

.brand-container {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.header-logo { height: 40px; width: auto; object-fit: contain; }

.brand-title {
  color: var(--text-main);
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  line-height: 1.1;
  display: inline-block;
  white-space: normal;
}

.header-center { flex: 1; display: flex; justify-content: center; min-width: 0; }
.search-box { width: 100%; max-width: 550px; }
.search-box input {
  width: 100%;
  background-color: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--text-main);
  padding: 9px 18px;
  border-radius: 25px;
  outline: none;
  font-size: 0.9rem;
}

.header-actions { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.btn-theme-mini {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--text-main);
  border-radius: 50%;
  width: 36px; height: 36px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
}

.cart-header-btn {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: 20px;
  cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  font-weight: bold; font-size: 0.85rem;
}

.cart-badge {
  background: var(--accent-gold);
  color: #000;
  border-radius: 50%;
  width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem;
}

/* CATEGORÍAS */
.categories-nav {
  background-color: var(--nav-bg);
  display: flex; gap: 4px; padding: 0 12px;
  overflow-x: auto; white-space: nowrap;
  border-top: 1px solid var(--border-color);
  -webkit-overflow-scrolling: touch;
}
.categories-nav::-webkit-scrollbar, .subcategories-nav::-webkit-scrollbar { display: none; }

.nav-tab {
  background: transparent; border: none;
  color: var(--text-muted); padding: 10px 14px;
  font-weight: 600; font-size: 0.85rem; cursor: pointer;
  position: relative; flex-shrink: 0;
}
.nav-tab.active { color: var(--text-main); }
.nav-tab.active::after {
  content: ''; position: absolute; bottom: 0; left: 0;
  width: 100%; height: 3px; background-color: var(--accent-gold);
}

.subcategories-nav {
  background-color: var(--header-bg);
  display: flex; gap: 8px; padding: 8px 12px;
  border-top: 1px solid var(--border-color);
  overflow-x: auto; white-space: nowrap;
}
.subtab {
  background: var(--input-bg); border: 1px solid var(--input-border);
  color: var(--text-muted); padding: 4px 10px; border-radius: 4px;
  font-size: 0.75rem; cursor: pointer; flex-shrink: 0;
}
.subtab.active { background: var(--accent-gold); color: #000; font-weight: bold; border-color: var(--accent-gold); }

/* CONTENIDO Y CARRUSEL / SLIDER DE FLYERS */
.main-container { padding: 16px; max-width: 1400px; margin: 0 auto; flex: 1; width: 100%; }

.slider-wrapper {
  position: relative;
  width: 100%;
  margin-bottom: 24px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  display: none; /* Se activa cuando existen flyers */
}

.slider-container {
  display: flex;
  transition: transform 0.4s ease-in-out;
  touch-action: pan-y;
}

.slide {
  min-width: 100%;
  user-select: none;
}

.slide img {
  width: 100%;
  max-height: 380px;
  object-fit: cover;
  display: block;
}

.slider-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.5);
  color: white;
  border: none;
  padding: 10px 14px;
  cursor: pointer;
  border-radius: 50%;
  font-size: 1.2rem;
  z-index: 10;
}
.slider-btn:hover { background: rgba(0, 0, 0, 0.8); }
.prev-btn { left: 10px; }
.next-btn { right: 10px; }

.slider-dots {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
}
.dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  cursor: pointer;
}
.dot.active { background: var(--accent-gold); width: 22px; border-radius: 10px; }

/* CATÁLOGO DE PRODUCTOS */
.loading-text { grid-column: 1/-1; text-align: center; padding: 40px 0; }
.catalog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

.card {
  background: var(--card-bg);
  border-radius: 12px; padding: 14px;
  display: flex; flex-direction: column; justify-content: space-between;
  border: 1px solid var(--border-color);
  box-shadow: var(--card-shadow);
}

.product-img-container {
  text-align: center; height: 190px;
  display: flex; align-items: center; justify-content: center;
  background: var(--thumb-bg); border-radius: 8px; padding: 8px;
}
.product-img { max-height: 100%; max-width: 100%; object-fit: contain; }

.badge {
  background: var(--input-bg); color: var(--accent-gold);
  font-size: 0.7rem; font-weight: bold; padding: 3px 6px;
  border-radius: 4px; align-self: flex-start; margin-top: 8px;
  border: 1px solid var(--border-color); text-transform: uppercase;
}

.product-title { font-size: 1rem; font-weight: bold; margin: 6px 0 4px; }

.details-list {
  font-size: 0.8rem; padding-left: 16px; margin: 6px 0;
  color: var(--text-muted); line-height: 1.35;
}

.kit-includes {
  font-size: 0.75rem; background: rgba(255, 157, 0, 0.1);
  border: 1px dashed var(--accent-gold); padding: 6px;
  border-radius: 4px; margin-top: 6px; color: var(--text-main);
}

.stock-info { font-size: 0.8rem; margin: 6px 0; display: flex; align-items: center; gap: 4px; }
.stock-info.available { color: #23d366; }
.stock-info.empty { color: #ff4d4d; font-weight: bold; }

.pricing-section {
  display: flex; justify-content: space-between; align-items: center;
  margin: 10px 0 8px; padding-top: 8px; border-top: 1px dashed var(--border-color);
}

.quantity-selector { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; }
.quantity-selector input {
  width: 44px; padding: 4px; background: var(--input-bg);
  border: 1px solid var(--border-color); color: var(--text-main);
  border-radius: 4px; text-align: center;
}

.price { font-size: 1.15rem; font-weight: bold; color: var(--accent-gold); }

.btn-add-cart {
  background: var(--text-main); color: var(--bg-main);
  border: 1px solid var(--text-main); padding: 9px;
  border-radius: 8px; font-weight: bold; cursor: pointer; width: 100%; font-size: 0.85rem;
}
.btn-add-cart.disabled {
  background: #888888 !important; color: #ffffff !important;
  border-color: #888888 !important; cursor: not-allowed; opacity: 0.6;
}

/* MODAL CARRITO */
.modal-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.6); display: none; justify-content: flex-end; z-index: 200;
}
.modal-overlay.active { display: flex; }
.cart-drawer {
  background: var(--modal-bg); width: 100%; max-width: 420px; height: 100%; padding: 16px;
  display: flex; flex-direction: column; justify-content: space-between;
}
.cart-drawer-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-color); padding-bottom: 10px; }
.close-btn { background: none; border: none; font-size: 1.5rem; color: var(--text-main); cursor: pointer; }
.cart-items-list { flex: 1; overflow-y: auto; margin: 12px 0; display: flex; flex-direction: column; gap: 10px; }
.cart-item { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border-color); font-size: 0.85rem; }
.cart-item-controls { display: flex; align-items: center; gap: 8px; }
.btn-remove { background: #ff4d4d; color: #fff; border: none; padding: 2px 6px; border-radius: 4px; cursor: pointer; font-size: 0.75rem; }
.cart-total-row { display: flex; justify-content: space-between; font-weight: bold; margin-bottom: 12px; }
.price-text { color: var(--accent-gold); }
.btn-checkout-ws { background: var(--ws-color); color: #000; border: none; padding: 12px; border-radius: 8px; font-weight: bold; width: 100%; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; }

/* FOOTER */
.main-footer {
  background-color: var(--footer-bg);
  color: var(--footer-text);
  margin-top: auto;
  border-top: 1px solid var(--border-color);
}
.footer-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 30px 24px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px;
}
.footer-brand h4 { color: var(--accent-gold); margin-bottom: 8px; }
.footer-brand p { font-size: 0.85rem; max-width: 400px; opacity: 0.8; }
.footer-social h5 { margin-bottom: 10px; font-size: 0.95rem; }
.social-links { display: flex; gap: 10px; flex-wrap: wrap; }
.social-btn {
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: bold;
  color: #ffffff;
  background: #333333;
}
.social-btn.facebook { background: #1877f2; }
.social-btn.instagram { background: #e4405f; }
.social-btn.tiktok { background: #000000; border: 1px solid #333; }
.social-btn.whatsapp { background: #23d366; color: #000; }

.footer-bottom {
  text-align: center;
  padding: 14px;
  background: rgba(0, 0, 0, 0.2);
  font-size: 0.75rem;
  opacity: 0.7;
}

/* RESPONSIVE CELULARES */
@media (max-width: 600px) {
  .header-top { flex-wrap: wrap; padding: 10px 12px; }
  .brand-container { max-width: 175px; gap: 6px; }
  .header-logo { height: 34px; }
  .brand-title { font-size: 0.82rem; }
  .header-center { order: 3; width: 100%; min-width: 100%; margin-top: 6px; }
  .main-container { padding: 12px 8px; }
  .catalog-grid { grid-template-columns: 1fr; }
  .footer-content { flex-direction: column; text-align: center; }
  .footer-brand p { margin: 0 auto; }
  .social-links { justify-content: center; }
}