/* =============================================
   MARKETMIX - Estilos Principales
   ============================================= */

/* --- Variables de color y tema --- */
:root {
  --primary: #6c5ce7;
  --primary-dark: #5b4bc9;
  --secondary: #fdcb6e;
  --success: #00b894;
  --danger: #e74c3c;
  --cancel: #95a5a6;
  --bg: #f5f6fa;
  --card-bg: #ffffff;
  --text: #2d3436;
  --header-bg: #2d3436;
  --header-text: #ffffff;
  --input-bg: #ffffff;
  --input-border: #cccccc;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  --modal-overlay: rgba(0, 0, 0, 0.45);
  --badge-bg: #f0f0f0;
  --badge-text: #555555;
}

[data-theme="dark"] {
  --bg: #121212;
  --card-bg: #1e1e1e;
  --text: #e0e0e0;
  --header-bg: #0a0a0a;
  --header-text: #f0f0f0;
  --input-bg: #2a2a2a;
  --input-border: #444444;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  --modal-overlay: rgba(0, 0, 0, 0.75);
  --badge-bg: #333333;
  --badge-text: #cccccc;
}

/* --- Reset y base --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', system-ui, sans-serif;
  transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}

body {
  background: var(--bg);
  color: var(--text);
  padding-bottom: 2rem;
  line-height: 1.5;
}

/* --- Header --- */
header {
  background: var(--header-bg);
  color: var(--header-text);
  padding: 0.8rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: var(--shadow);
}

.header-logo a {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.header-logo img {
  height: 45px;
  width: auto;
  border-radius: 8px;
}

.header-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.mode-toggle,
.theme-toggle {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: var(--header-text);
  padding: 0.3rem 0.7rem;
  border-radius: 20px;
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 500;
  transition: 0.2s;
}

.mode-toggle:hover,
.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* --- Layout general --- */
.main-title {
  text-align: center;
  padding: 2rem 1rem;
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .main-title {
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.container {
  max-width: 1200px;
  margin: 1.5rem auto;
  padding: 0 1rem;
}

.section-title {
  margin: 2rem 0 1rem;
  padding-left: 0.6rem;
  border-left: 4px solid var(--primary);
  font-size: 1.3rem;
}

/* --- Grilla de productos --- */
.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

/* --- Tarjeta de producto --- */
.card {
  background: var(--card-bg);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  cursor: pointer;
  border: 1px solid var(--input-border);
  transition: box-shadow 0.2s ease;
}

.card:hover {
  box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}

.card img {
  width: 100%;
  height: 260px;
  object-fit: contain;
  background: #f5f5f5;
  /*padding: 0.8rem;*/
}

.card-body {
  padding: 0.7rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.card h3 {
  margin-bottom: 0.3rem;
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.price {
  font-weight: 700;
  color: var(--primary);
  font-size: 1.2rem;
  margin-top: 0.3rem;
}

.badges {
  display: flex;
  gap: 0.4rem;
  margin: 0.5rem 0;
  flex-wrap: wrap;
}

.badge {
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  background: var(--badge-bg);
  color: var(--badge-text);
  font-weight: 500;
}

.badge.discount {
  background: #fff3cd;
  color: #856404;
  border: 1px solid #ffeeba;
}

.badge.shipping {
  background: #d1ecf1;
  color: #0c5460;
  border: 1px solid #bee5eb;
}

.comment {
  font-size: 0.85rem;
  opacity: 0.8;
  margin-top: 0.5rem;
  flex: 1;
  line-height: 1.4;
}

/* --- Botones --- */
.btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.7rem;
  border-radius: 8px;
  cursor: pointer;
  margin-top: 0.8rem;
  width: 100%;
  font-weight: 500;
  transition: 0.2s;
}

.btn:hover {
  background: var(--primary-dark);
}

.btn:disabled {
  background: #666;
  cursor: not-allowed;
}

.btn-loading::after {
  content: " ⏳";
}

.btn-cancel {
  background: var(--cancel);
}

.btn-cancel:hover {
  opacity: 0.9;
}


.cart-btn:hover {
  opacity: 0.9;
}

/* --- Panel de administración --- */
.admin-panel {
  display: none;
  background: var(--card-bg);
  padding: 1.5rem;
  border-radius: 12px;
  margin-top: 1rem;
  box-shadow: var(--shadow);
}

.admin-panel.active {
  display: block;
}

.login-form {
  max-width: 320px;
  margin: 3rem auto;
  background: var(--card-bg);
  padding: 2rem;
  border-radius: 12px;
  box-shadow: var(--shadow);
  text-align: center;
}

.admin-actions-bar {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.admin-actions-bar .btn {
  width: auto;
  margin: 0;
  font-size: 0.85rem;
  padding: 0.6rem 1rem;
}

.config-panel {
  background: var(--bg);
  padding: 1rem;
  border-radius: 10px;
  margin-bottom: 1.5rem;
  display: none;
  border: 1px solid var(--input-border);
}

.config-panel.active {
  display: block;
}

.cat-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.8rem;
}

.cat-tag {
  background: var(--card-bg);
  border: 1px solid var(--primary);
  padding: 0.3rem 0.7rem;
  border-radius: 20px;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.cat-tag button {
  background: var(--danger);
  color: white;
  border: none;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: 0.7rem;
  cursor: pointer;
}

/* --- Formularios --- */
.input-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

.input-row input {
  flex: 1;
  padding: 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--input-border);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
}

.form-group label {
  margin-bottom: 0.4rem;
  font-size: 0.8rem;
  font-weight: 500;
  opacity: 0.9;
}

.form-group input,
.form-group select,
.form-group textarea,
.login-form input {
  padding: 0.7rem;
  border: 1px solid var(--input-border);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text);
  outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.login-form input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(108, 92, 231, 0.2);
}

.form-group.full {
  grid-column: 1 / -1;
}

.checkbox-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.3rem;
}

.form-actions {
  display: flex;
  gap: 0.8rem;
  margin-top: 1.2rem;
}

/* --- Lista admin --- */
.admin-list {
  margin-top: 1rem;
  background: var(--card-bg);
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--input-border);
}

.admin-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid var(--input-border);
  gap: 1rem;
}

.admin-item:last-child {
  border-bottom: none;
}

.admin-item img {
  width: 50px;
  height: 50px;
  object-fit: cover;
  border-radius: 8px;
  background: #eee;
  flex-shrink: 0;
}

.admin-item-info {
  flex: 1;
  min-width: 0;
}

.admin-item-info strong {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 0.2rem;
}

.admin-item-info span {
  opacity: 0.7;
  font-size: 0.8rem;
}

.admin-actions button {
  margin-left: 0.3rem;
  padding: 0.4rem 0.7rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  color: white;
  font-size: 0.75rem;
  font-weight: 500;
  transition: 0.2s;
}

.btn-edit {
  background: var(--secondary);
  color: #222;
}

.btn-delete {
  background: var(--danger);
}

/* --- Modales --- */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--modal-overlay);
  z-index: 30;
  align-items: center;
  justify-content: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--card-bg);
  width: 90%;
  max-width: 850px;
  max-height: 90vh;
  border-radius: 16px;
  padding: 1.5rem;
  overflow-y: auto;
  position: relative;
  animation: scaleIn 0.2s ease;
}

@keyframes scaleIn {
  from { transform: scale(0.95); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  opacity: 0.6;
  padding: 0.5rem;
}

.modal-close:hover {
  opacity: 1;
}

/* --- Modal detalle de producto --- */
.product-modal-body {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
}

.product-gallery {
  flex: 1;
  min-width: 300px;
  max-width: 450px;
}

.gallery-main {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  background: #eee;
}

.product-gallery {
  position: relative;
}

.gallery-main img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: opacity 0.2s ease;
}

.gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.5);
  color: white;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.4rem;
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: 0.2s;
  backdrop-filter: blur(2px);
}

.gallery-nav:hover {
  background: rgba(0, 0, 0, 0.8);
}

.gallery-nav.prev { left: 8px; }
.gallery-nav.next { right: 8px; }

.gallery-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--input-border);
  cursor: pointer;
  transition: 0.2s;
}

.dot.active {
  background: var(--primary);
  transform: scale(1.3);
}

.product-modal-details {
  flex: 1;
  min-width: 280px;
  display: flex;
  flex-direction: column;
}

.product-modal-details h2 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.product-modal-price {
  font-weight: 700;
  color: var(--primary);
  font-size: 1.6rem;
  margin: 0.5rem 0;
}

.product-modal-comment {
  opacity: 0.8;
  margin: 0.8rem 0;
  line-height: 1.5;
  flex: 1;
  white-space: pre-wrap;
}

.product-modal-stock {
  font-size: 0.85rem;
  margin-top: 0.5rem;
  opacity: 0.7;
}

.qty-selector {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
}

.qty-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--input-border);
  background: var(--bg);
  cursor: pointer;
  font-weight: bold;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: 0.2s;
  color: var(--text);
}

.qty-btn:hover {
  border-color: var(--primary);
  background: rgba(108, 92, 231, 0.1);
}

.qty-display {
  font-size: 1.1rem;
  font-weight: 600;
  min-width: 30px;
  text-align: center;
}

/* --- Carrito y checkout --- */
.cart-item,
.co-item {
  display: flex;
  gap: 1rem;
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--input-border);
  align-items: center;
}

.cart-item img,
.co-item img {
  width: 50px;
  height: 50px;
  object-fit: cover;
  border-radius: 8px;
  background: #eee;
}

.cart-details,
.co-details {
  flex: 1;
}

.cart-details h4,
.co-details h4 {
  font-size: 0.95rem;
  margin-bottom: 0.2rem;
}

.cart-details p,
.co-details p {
  font-size: 0.8rem;
  opacity: 0.7;
  margin: 0;
}

.cart-controls {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.4rem;
}

.cart-modal {
  align-items: flex-end;
}

.cart-modal .modal-content {
  max-width: 600px;
  border-radius: 16px 16px 0 0;
  max-height: 85vh;
}

.qty-btn.remove {
  color: var(--danger);
  border-color: var(--danger);
  font-size: 0.9rem;
}

.total-bar {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 2px solid var(--primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: bold;
  font-size: 1rem;
}

#shipping-info {
  padding: 0.8rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  display: none;
  background: rgba(0, 184, 148, 0.1);
  border: 1px solid rgba(0, 184, 148, 0.3);
}

/* --- Imágenes admin --- */
.img-input-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  align-items: center;
}

.img-input-row input {
  flex: 1;
}

.btn-remove-img {
  background: var(--danger);
  color: white;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: 0.2s;
}

.btn-remove-img:hover {
  opacity: 0.8;
}

/* --- Notificaciones toast --- */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  background: var(--card-bg);
  color: var(--text);
  padding: 1rem 1.2rem;
  border-radius: 10px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--success);
  animation: fadeIn 0.3s, fadeOut 0.3s 2.7s;
  pointer-events: auto;
  max-width: 300px;
  font-size: 0.9rem;
}

.toast.error { border-left-color: var(--danger); }
.toast.info  { border-left-color: var(--primary); }

@keyframes fadeIn  { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }

/* --- Impresión --- */
@media print {
  body { background: white; }
  .no-print { display: none !important; }
  .modal-content { box-shadow: none; border-radius: 0; max-height: none; animation: none; }
}

/* --- Menú de categorías --- */
.cat-nav {
  max-width: 1200px;
  margin: 0 auto 1rem;
  padding: 0 1rem;
}

.cat-nav-desktop {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.cat-nav-btn {
  background: var(--card-bg);
  color: var(--text);
  border: 2px solid var(--input-border);
  padding: 0.5rem 1.2rem;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: 0.2s;
  white-space: nowrap;
}

.cat-nav-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.cat-nav-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Mobile */
.cat-nav-mobile {
  display: none;
  position: relative;
}

.cat-menu-btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.7rem 1.4rem;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  width: 100%;
  text-align: left;
  transition: 0.2s;
}

.cat-menu-btn:hover {
  background: var(--primary-dark);
}

.cat-menu-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  right: 0;
  background: var(--card-bg);
  border: 1px solid var(--input-border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 15;
  overflow: hidden;
}

.cat-menu-dropdown.active {
  display: block;
}

.cat-menu-item {
  padding: 0.8rem 1.2rem;
  cursor: pointer;
  font-size: 0.95rem;
  border-bottom: 1px solid var(--input-border);
  transition: 0.15s;
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border-left: none;
  border-right: none;
  border-top: none;
  color: var(--text);
  font-weight: 500;
}

.cat-menu-item:last-child {
  border-bottom: none;
}

.cat-menu-item:hover,
.cat-menu-item.active {
  background: rgba(108, 92, 231, 0.1);
  color: var(--primary);
}

/* --- Footer --- */
.site-footer {
  background: var(--header-bg);
  color: var(--header-text);
  padding: 2.5rem 1rem 1rem;
  margin-top: 2rem;
  margin-bottom: 80px;
}

.footer-sections {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  justify-content: center;
}

.footer-section {
  flex: 1;
  min-width: 220px;
  max-width: 350px;
}

.footer-section h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.8rem;
  color: var(--secondary);
  border-bottom: 2px solid var(--primary);
  padding-bottom: 0.4rem;
}

.footer-section p {
  font-size: 0.88rem;
  line-height: 1.7;
  opacity: 0.85;
  white-space: pre-wrap;
}

.footer-section img {
  max-width: 100%;
  border-radius: 8px;
  margin-top: 0.5rem;
}

.footer-bottom {
  max-width: 1200px;
  margin: 1.5rem auto 0;
  padding-top: 1rem;
  border-top: 1px solid rgba(255,255,255,0.15);
  text-align: center;
  font-size: 0.8rem;
  opacity: 0.6;
}

/* Footer admin */
.footer-section-admin {
  background: var(--bg);
  border: 1px solid var(--input-border);
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.footer-section-admin .section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.8rem;
}

.footer-section-admin .section-header strong {
  font-size: 0.9rem;
}

/* --- Filtros --- */
.filter-bar {
  max-width: 1200px;
  margin: 0 auto 1rem;
  padding: 0 1rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.filter-bar label {
  font-size: 0.85rem;
  font-weight: 600;
  opacity: 0.7;
}

.filter-select {
  padding: 0.4rem 0.8rem;
  border-radius: 20px;
  border: 1px solid var(--input-border);
  background: var(--card-bg);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  outline: none;
}

.filter-select:focus {
  border-color: var(--primary);
}

.filter-stock {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  cursor: pointer;
}

/* --- Opciones de producto --- */
.option-group-admin {
  background: var(--bg);
  border: 1px solid var(--input-border);
  border-radius: 8px;
  padding: 0.8rem;
  margin-bottom: 0.8rem;
}

.option-group-admin .group-header {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.6rem;
}

.option-group-admin .group-header input {
  flex: 1;
  padding: 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
}

.option-values {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.option-value-tag {
  background: var(--card-bg);
  border: 1px solid var(--primary);
  padding: 0.25rem 0.6rem;
  border-radius: 20px;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.option-value-tag button {
  background: var(--danger);
  color: white;
  border: none;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  font-size: 0.65rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.add-value-row {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.4rem;
}

.add-value-row input {
  flex: 1;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  font-size: 0.85rem;
}

.add-value-row button {
  padding: 0.4rem 0.8rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
}

/* Opciones en el modal de usuario */
.product-options {
  margin-top: 1rem;
}

.product-options .option-group {
  margin-bottom: 0.8rem;
}

.product-options .option-label {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  opacity: 0.8;
}

.option-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.option-btn {
  padding: 0.35rem 0.9rem;
  border: 2px solid var(--input-border);
  border-radius: 20px;
  background: var(--card-bg);
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: 0.15s;
}

.option-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.option-btn.selected {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* --- Subcategorías --- */
.cat-tag-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.5rem;
}

.subcat-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding-left: 1rem;
}

.subcat-tag {
  background: var(--bg);
  border: 1px solid var(--input-border);
  padding: 0.2rem 0.5rem;
  border-radius: 20px;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.subcat-tag button {
  background: var(--danger);
  color: white;
  border: none;
  border-radius: 50%;
  width: 14px;
  height: 14px;
  font-size: 0.6rem;
  cursor: pointer;
}

.add-subcat-inline {
  display: flex;
  gap: 0.3rem;
  align-items: center;
}

.add-subcat-inline input {
  padding: 0.2rem 0.5rem;
  border-radius: 20px;
  border: 1px dashed var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  font-size: 0.75rem;
  width: 120px;
}

.add-subcat-inline button {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 0.8rem;
  cursor: pointer;
}

/* Barra de subcategorías */
.subcat-nav {
  max-width: 1200px;
  margin: 0 auto 0.8rem;
  padding: 0 1rem;
  display: none;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.subcat-nav.active {
  display: flex;
}

.subcat-nav-btn {
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid var(--input-border);
  padding: 0.3rem 0.9rem;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: 0.2s;
}

.subcat-nav-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.subcat-nav-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* --- Botón carrito en header --- */
.cart-header-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: var(--header-text);
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  transition: 0.2s;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.cart-header-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.cart-header-count {
  background: var(--primary);
  color: white;
  border-radius: 20px;
  padding: 0.1rem 0.5rem;
  font-size: 0.85rem;
  min-width: 22px;
  text-align: center;
}

/* --- Buscador --- */
.search-bar-container {
  max-width: 700px;
  margin: 0 auto 1rem;
  padding: 0 1rem;
}

.search-bar {
  display: flex;
  align-items: center;
  background: var(--card-bg);
  border: 2px solid var(--input-border);
  border-radius: 30px;
  padding: 0.5rem 1rem;
  gap: 0.5rem;
  transition: 0.2s;
  box-shadow: var(--shadow);
}

.search-bar:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.15);
}

.search-icon {
  font-size: 1.1rem;
  opacity: 0.6;
  flex-shrink: 0;
}

.search-bar input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 1rem;
  padding: 0;
}

.search-bar input::placeholder {
  opacity: 0.5;
}

.search-clear {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  opacity: 0.5;
  color: var(--text);
  padding: 0.2rem;
  border-radius: 50%;
  transition: 0.2s;
  flex-shrink: 0;
}

.search-clear:hover {
  opacity: 1;
  background: var(--bg);
}

.search-results-info {
  text-align: center;
  font-size: 0.85rem;
  opacity: 0.6;
  margin-bottom: 0.5rem;
}



/* --------------------------------- Responsive móvil ----------------------------------- */
@media (max-width: 768px) {
  header { flex-direction: column; gap: 0.6rem; text-align: center; padding: 0.7rem; }
  .header-logo img { height: 40px; }
  .main-title { font-size: 1.5rem; padding: 1.5rem 1rem; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
  .form-grid { grid-template-columns: 1fr; }
  .product-modal-body { flex-direction: column; gap: 1.5rem; }
  .product-gallery { max-width: 100%; }
  .gallery-nav.prev { left: 5px; }
  .gallery-nav.next { right: 5px; }
  .cart-modal .modal-content { max-height: 90vh; }
  .admin-item { flex-direction: column; align-items: flex-start; }
  .admin-actions { width: 100%; display: flex; justify-content: flex-end; margin-top: 0.5rem; }

  .cat-nav-desktop { display: none; }
  .cat-nav-mobile  { display: block; }


/* Mobile: carrito en esquina superior derecha */
  .cart-header-btn {
    position: fixed;
    top: 0.6rem;
    right: 0.6rem;
    z-index: 25;
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  }

  .footer-sections {
    flex-direction: column;
    align-items: center;
  }
  .footer-section {
    max-width: 100%;
    width: 100%;
  }

  

}

@media (max-width: 1024px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 640px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
}

/* --- Precios mayoristas --- */
.bulk-price-tag {
  font-size: 0.8rem;
  color: var(--success);
  font-weight: 600;
  margin-top: 0.2rem;
}
.product-modal-bulk-price {
  background: rgba(0, 184, 148, 0.1);
  color: var(--success);
  padding: 0.5rem 0.8rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  margin: 0.5rem 0;
  border: 1px solid rgba(0, 184, 148, 0.2);
}





/* =============================================
   TABLAS INFORMATIVAS — Admin editor
   ============================================= */

.table-admin-block {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 1rem;
  background: var(--bg);
}

.table-admin-header {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.table-admin-title-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.table-name-input {
  flex: 1;
  min-width: 160px;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
}

.table-admin-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.table-admin-wrap {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.table-admin-editor {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.table-admin-editor td {
  padding: 2px;
  border: 1px solid var(--border);
  background: var(--card);
  min-width: 100px;
}

.table-admin-editor td.table-row-del-cell {
  width: 28px;
  min-width: 28px;
  text-align: center;
  background: transparent;
  border: none;
  padding: 2px 4px;
}

.table-cell-wrap {
  display: flex;
  align-items: center;
  gap: 2px;
}

.table-cell-wrap input {
  width: 100%;
  padding: 0.35rem 0.5rem;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 0.82rem;
  outline: none;
}

.table-cell-wrap input:focus {
  background: rgba(108, 92, 231, 0.08);
  border-radius: 4px;
}

.table-cell-header {
  font-weight: 700;
  color: var(--primary) !important;
}

.table-cell-del-col,
.table-cell-del-row {
  background: none;
  border: none;
  color: var(--danger, #e74c3c);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 2px 4px;
  border-radius: 4px;
  line-height: 1;
  opacity: 0.6;
  transition: opacity 0.15s;
  flex-shrink: 0;
}

.table-cell-del-col:hover,
.table-cell-del-row:hover { opacity: 1; }

/* =============================================
   TABLAS INFORMATIVAS — Vista usuario
   ============================================= */

.product-tables-section {
  margin-top: 1rem;
}

.product-table-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.product-table-btn {
  padding: 0.45rem 1rem;
  border: 2px solid var(--primary);
  border-radius: 20px;
  background: transparent;
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.1s;
}

.product-table-btn:hover {
  background: var(--primary);
  color: #fff;
}

.product-table-btn.active {
  background: var(--primary);
  color: #fff;
}

.product-table-panel {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin-top: 0.5rem;
  animation: slideDown 0.2s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.product-table-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 1rem;
  background: var(--primary);
  color: #fff;
  font-size: 0.9rem;
}

.product-table-close {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 1rem;
  padding: 0 4px;
  opacity: 0.85;
  transition: opacity 0.15s;
}

.product-table-close:hover { opacity: 1; }

.product-table-scroll {
  overflow-x: auto;
  background: var(--card);
}

.product-info-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.product-info-table td {
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--border);
  color: var(--text);
}

.product-info-table .table-head-row td {
  background: rgba(108, 92, 231, 0.1);
  font-weight: 700;
  color: var(--primary);
  text-align: center;
}

.product-info-table tr:not(.table-head-row):hover td {
  background: rgba(108, 92, 231, 0.05);
}