/* ============================================================
   EsHard Peru - main.css
   Sistema de diseno premium - dark theme con acento purpura
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

/* --- Variables globales --- */
:root {
  --bg-base:      #0a0f1e;
  --bg-surface:   #111827;
  --bg-card:      #1a2235;
  --bg-hover:     #1f2d45;
  --border:       #1e3a5f;
  --border-light: #2d4a6e;
  --primary:      #7c3aed;
  --primary-light:#9d6aea;
  --primary-glow: rgba(124,58,237,0.25);
  --accent:       #a855f7;
  --accent-cyan:  #06b6d4;
  --success:      #10b981;
  --warning:      #f59e0b;
  --danger:       #ef4444;
  --text-primary: #f1f5f9;
  --text-secondary:#94a3b8;
  --text-muted:   #64748b;
  --radius-sm:    6px;
  --radius:       10px;
  --radius-lg:    16px;
  --radius-xl:    24px;
  --shadow-card:  0 4px 24px rgba(0,0,0,0.4);
  --shadow-glow:  0 0 30px rgba(124,58,237,0.3);
  --transition:   0.2s ease;
  --font:         'Inter', system-ui, sans-serif;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: var(--font); }
input, select, textarea { font-family: var(--font); }

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-surface); }
::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 99px; }

/* --- HEADER --- */
.header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(10,15,30,0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 64px;
  display: flex; align-items: center; gap: 20px;
}
.header-logo {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none;
}
.header-logo span { color: var(--accent); }
.header-logo img {
  height: 42px;
  width: auto;
  max-width: 180px;
  object-fit: contain;
  display: block;
  transition: transform 0.2s ease;
}
.header-logo:hover img {
  transform: scale(1.03);
}

.header-search {
  flex: 1; max-width: 480px;
  position: relative;
}
.header-search input {
  width: 100%; padding: 10px 16px 10px 44px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 50px;
  color: var(--text-primary);
  font-size: 0.9rem;
  transition: var(--transition);
}
.header-search input::placeholder { color: var(--text-muted); }
.header-search input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.header-search .search-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: 1rem; pointer-events: none;
}
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.btn-cart {
  display: flex; align-items: center; gap: 8px;
  background: var(--primary); color: #fff;
  border: none; border-radius: 50px;
  padding: 10px 20px; font-size: 0.9rem; font-weight: 600;
  transition: var(--transition);
  position: relative;
}
.btn-cart:hover { background: var(--primary-light); transform: translateY(-1px); }
.cart-badge {
  background: var(--accent-cyan); color: #000; font-size: 0.7rem;
  font-weight: 700; border-radius: 50%; width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  position: absolute; top: -6px; right: -6px;
}

/* --- LAYOUT PRINCIPAL --- */
.layout { display: flex; min-height: calc(100vh - 64px); }

/* --- SIDEBAR --- */
.sidebar {
  width: 320px; min-height: 100%;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  padding: 0 0 24px 0;
  position: sticky; top: 64px; height: calc(100vh - 64px);
  overflow-y: auto; flex-shrink: 0;
}
.sidebar-header {
  background: #e30613;
  padding: 13px 20px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-bottom: 8px;
}
.sidebar-header-title {
  color: #ffffff;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}
.sidebar-title {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--text-muted);
  padding: 14px 20px 8px;
}
.cat-group {
  display: flex;
  flex-direction: column;
}
.cat-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 16px 9px 18px;
  cursor: pointer; border-radius: 0;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  color: var(--text-primary);
  font-size: 0.95rem;
  line-height: 1.35;
  border-left: 3px solid transparent;
  user-select: none;
}
.cat-item:hover {
  background: var(--bg-hover);
  color: #ffffff;
}
.cat-item.active {
  color: #ff3344;
  font-weight: 700;
  border-left-color: #e30613;
  background: rgba(227, 6, 19, 0.08);
}
.cat-content {
  display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0;
}
.cat-name {
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.cat-icon { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; opacity: 0.85; }

/* Indicador de colapso/despliegue (+ y −) */
.cat-toggle {
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1;
  color: var(--text-muted);
  transition: color 0.15s ease, background 0.15s ease;
  padding: 2px 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  flex-shrink: 0;
  min-width: 22px;
  text-align: center;
}
.cat-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}
.cat-item.active .cat-toggle,
.cat-toggle.open {
  color: #ff3344;
}

/* Niveles de jerarquía y sangrías */
.cat-item.level-0 {
  font-size: 0.98rem;
  font-weight: 700;
  padding-left: 18px;
}
.cat-item.level-1 {
  font-size: 0.92rem;
  font-weight: 500;
  padding-left: 28px;
  color: var(--text-secondary);
}
.cat-item.level-2 {
  font-size: 0.88rem;
  font-weight: 600;
  padding-left: 38px;
  color: var(--text-secondary);
}
.cat-item.level-3 {
  font-size: 0.86rem;
  font-weight: 400;
  padding-left: 48px;
  color: var(--text-muted);
}
.cat-item.level-4 {
  font-size: 0.84rem;
  font-weight: 400;
  padding-left: 58px;
  color: var(--text-muted);
}

.cat-item.level-1:hover,
.cat-item.level-2:hover,
.cat-item.level-3:hover,
.cat-item.level-4:hover {
  color: #ffffff;
}

.cat-sublist {
  display: none;
  flex-direction: column;
  position: relative;
}
.cat-sublist.open {
  display: flex;
}

/* Horizontal pill bar in main area */
.subcategories-bar {
  display: none;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.subcategories-bar.visible {
  display: flex;
}
.subcat-pill {
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 500;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 50px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.subcat-pill:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--primary);
  transform: translateY(-1px);
}
.subcat-pill.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-weight: 600;
  box-shadow: 0 0 12px var(--primary-glow);
}

/* Filtros de precio */
.filter-section { padding: 20px; border-top: 1px solid var(--border); margin-top: 8px; }
.filter-label { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); margin-bottom: 10px; display: block; }
.price-inputs { display: flex; gap: 8px; }
.price-inputs input {
  width: 100%; padding: 8px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-primary); font-size: 0.82rem;
}
.price-inputs input:focus { outline: none; border-color: var(--primary); }
.btn-filtrar {
  width: 100%; margin-top: 12px; padding: 10px;
  background: var(--primary); border: none; border-radius: var(--radius-sm);
  color: #fff; font-weight: 600; font-size: 0.85rem;
  transition: var(--transition);
}
.btn-filtrar:hover { background: var(--primary-light); }

/* Stock toggle */
.toggle-wrap { display: flex; align-items: center; gap: 10px; margin-top: 16px; }
.toggle { position: relative; width: 40px; height: 22px; }
.toggle input { display: none; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--border-light); border-radius: 999px;
  cursor: pointer; transition: var(--transition);
}
.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle-slider::before {
  content: ''; position: absolute;
  width: 16px; height: 16px; background: #fff;
  border-radius: 50%; left: 3px; top: 3px;
  transition: var(--transition);
}
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }
.toggle-text { font-size: 0.82rem; color: var(--text-secondary); }

/* --- MAIN CONTENT --- */
.main-content { flex: 1; padding: 24px; overflow-x: hidden; }

/* Hero banner */
.hero {
  background: linear-gradient(135deg, #1a0533 0%, #0f172a 40%, #0a1628 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px 48px;
  margin-bottom: 28px;
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 40px;
}
.hero::before {
  content: ''; position: absolute; right: -60px; top: -60px;
  width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(124,58,237,0.3) 0%, transparent 70%);
  border-radius: 50%;
}
.hero-text h1 { font-size: 2.2rem; font-weight: 800; line-height: 1.2; margin-bottom: 12px; }
.hero-text h1 span { color: var(--accent); }
.hero-text p { color: var(--text-secondary); font-size: 1rem; max-width: 400px; }
.hero-badges { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.badge {
  display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 6px 14px; border-radius: 50px;
  font-size: 0.8rem; color: var(--text-secondary);
}
.badge.primary { background: var(--primary-glow); border-color: var(--primary); color: var(--accent); }

/* Toolbar de productos */
.products-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; flex-wrap: wrap; gap: 12px;
}
.results-count { color: var(--text-muted); font-size: 0.88rem; }
.results-count span { color: var(--text-primary); font-weight: 600; }

/* Selector de ordenamiento */
.sort-select {
  padding: 8px 14px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-primary); font-size: 0.85rem;
}

/* --- GRID DE PRODUCTOS --- */
.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}

.product-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  cursor: pointer;
  position: relative;
}
.product-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-card);
  border-color: var(--primary);
}

.product-img-wrap {
  aspect-ratio: 1;
  background: linear-gradient(135deg, #0f172a, #1a2235);
  display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
}
.product-img-wrap img {
  width: 100%; height: 100%; object-fit: contain;
  padding: 16px; transition: transform 0.4s ease;
}
.product-card:hover .product-img-wrap img { transform: scale(1.06); }
.product-img-wrap .no-img {
  font-size: 3rem; color: var(--text-muted);
}

.stock-badge {
  position: absolute; top: 10px; right: 10px;
  padding: 3px 10px; border-radius: 50px; font-size: 0.7rem; font-weight: 600;
}
.stock-badge.disponible { background: rgba(16,185,129,0.2); color: #10b981; border: 1px solid rgba(16,185,129,0.3); }
.stock-badge.bajo       { background: rgba(245,158,11,0.2);  color: #f59e0b; border: 1px solid rgba(245,158,11,0.3); }
.stock-badge.agotado    { background: rgba(239,68,68,0.2);   color: #ef4444; border: 1px solid rgba(239,68,68,0.3); }
.destaque-badge {
  position: absolute; top: 10px; left: 10px;
  background: linear-gradient(135deg,var(--primary),var(--accent));
  color: #fff; font-size: 0.65rem; font-weight: 700;
  padding: 3px 8px; border-radius: 50px;
}

.product-info { padding: 14px; }
.product-brand { font-size: 0.72rem; color: var(--accent); font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase; margin-bottom: 4px; }
.product-name  { font-size: 0.88rem; color: var(--text-primary); font-weight: 500; line-height: 1.4; margin-bottom: 8px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.product-category { font-size: 0.72rem; color: var(--text-muted); margin-bottom: 10px; }
.product-price {
  font-size: 1.3rem; font-weight: 800; color: var(--text-primary);
  display: flex; align-items: baseline; gap: 4px;
}
.product-price .currency { font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); }
.product-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; }
.product-garantia { font-size: 0.72rem; color: var(--text-muted); }

.btn-add-cart {
  display: flex; align-items: center; gap: 6px;
  background: var(--primary); border: none;
  color: #fff; border-radius: 50px;
  padding: 8px 16px; font-size: 0.82rem; font-weight: 600;
  transition: var(--transition);
}
.btn-add-cart:hover { background: var(--primary-light); transform: scale(1.03); }
.btn-add-cart:disabled { background: var(--border-light); cursor: not-allowed; }

/* --- PAGINACION --- */
.pagination { display: flex; justify-content: center; gap: 8px; margin-top: 32px; }
.page-btn {
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-secondary); font-size: 0.9rem;
  transition: var(--transition); cursor: pointer;
}
.page-btn:hover, .page-btn.active {
  background: var(--primary); border-color: var(--primary); color: #fff;
}

/* --- LOADING SKELETON --- */
.skeleton { background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-hover) 50%, var(--bg-card) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: var(--radius); }
@keyframes shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

/* --- TOAST --- */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 18px;
  box-shadow: var(--shadow-card); font-size: 0.88rem;
  min-width: 240px; animation: slideInToast 0.3s ease;
  display: flex; align-items: center; gap: 10px;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--primary); }
@keyframes slideInToast { from { transform: translateX(100%); opacity:0; } to { transform: translateX(0); opacity:1; } }

/* --- MODAL --- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-xl); max-width: 640px; width: 100%;
  max-height: 90vh; overflow-y: auto;
  padding: 32px; position: relative;
  animation: modalIn 0.3s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes modalIn { from { transform: scale(0.92); opacity:0; } to { transform: scale(1); opacity:1; } }
.modal-close {
  position: absolute; top: 16px; right: 16px;
  background: var(--bg-hover); border: none; border-radius: 50%;
  width: 36px; height: 36px; color: var(--text-secondary);
  font-size: 1.1rem; display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
.modal-close:hover { background: var(--danger); color: #fff; }

/* --- FOOTER --- */
.footer {
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  padding: 40px 24px 20px;
  margin-top: 60px;
}
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 32px; margin-bottom: 32px; }
.footer-brand h3 { font-size: 1.3rem; font-weight: 800; margin-bottom: 8px; }
.footer-brand h3 span { color: var(--accent); }
.footer-brand p { color: var(--text-muted); font-size: 0.85rem; line-height: 1.6; }
.footer-section h4 { font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); margin-bottom: 12px; }
.footer-section a { display: block; color: var(--text-secondary); font-size: 0.85rem; margin-bottom: 8px; transition: color var(--transition); }
.footer-section a:hover { color: var(--accent); }
.footer-bottom { border-top: 1px solid var(--border); padding-top: 20px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.footer-bottom p { color: var(--text-muted); font-size: 0.8rem; }

/* --- BOTONES GENERALES --- */
.btn { display: inline-flex; align-items: center; gap: 8px; border: none; border-radius: var(--radius-sm); padding: 12px 24px; font-size: 0.9rem; font-weight: 600; transition: var(--transition); cursor: pointer; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); transform: translateY(-1px); box-shadow: var(--shadow-glow); }
.btn-primary:disabled { background: var(--border-light); cursor: not-allowed; transform: none; box-shadow: none; color: var(--text-muted); }
.btn-outline { background: transparent; color: var(--text-primary); border: 1px solid var(--border); }
.btn-outline:hover { border-color: var(--primary); color: var(--accent); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }

/* --- FORMULARIOS --- */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.form-label .req { color: var(--danger); }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 12px 16px;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary); font-size: 0.9rem;
  transition: var(--transition);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.form-input.error { border-color: var(--danger); }
.form-error { font-size: 0.78rem; color: var(--danger); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

/* --- RESPONSIVE --- */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .hero { flex-direction: column; padding: 24px; }
  .hero-text h1 { font-size: 1.6rem; }
  .products-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
}
@media (max-width: 600px) {
  .header { padding: 0 16px; }
  .header-search { display: none; }
  .main-content { padding: 16px; }
  .products-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
}
