@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;500;600;700&family=Nunito:wght@400;600;700&display=swap');

:root {
  --caracol-amber: #f59e0b;
  --caracol-cream: #fef3c7;
  --caracol-brown: #78350f;
  --caracol-green: #15803d;
  --caracol-mint: #a7f3d0;
  --caracol-coral: #fb7185;
  --caracol-sky: #38bdf8;
  --shadow: 0 4px 20px rgba(120, 53, 15, 0.12);
  --radius: 20px;
  --radius-sm: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Nunito', sans-serif;
  min-height: 100vh;
  color: var(--caracol-brown);
  background: #f8fafc;
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(253, 230, 138, 0.4), transparent),
    radial-gradient(ellipse 60% 40% at 100% 50%, rgba(254, 243, 199, 0.35), transparent),
    radial-gradient(ellipse 50% 30% at 0% 80%, rgba(254, 249, 195, 0.3), transparent),
    linear-gradient(180deg, #fffbeb 0%, #fefce8 25%, #f8fafc 100%);
  background-attachment: fixed;
}

.tienda-top {
  background: linear-gradient(90deg, #1e293b 0%, #334155 100%);
  color: white;
  padding: 0.85rem 2rem;
  margin-top: 0.5rem;
  font-size: 1.9rem;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.tienda-header {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: white;
  padding: 1.5rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  box-shadow: 0 4px 24px rgba(245, 158, 11, 0.25);
}

.tienda-header h1 { font-family: 'Fredoka', sans-serif; font-size: 1.75rem; font-weight: 700; }
.tienda-header a { color: white; text-decoration: none; font-weight: 600; padding: 0.5rem 1rem; background: rgba(255,255,255,0.2); border-radius: var(--radius-sm); }
.tienda-header a:hover { background: rgba(255,255,255,0.35); }

.tienda-main { max-width: 1200px; margin: 0 auto; padding: 2rem; }

.buscador-wrap { margin-bottom: 1.75rem; }
.buscador-input {
  width: 100%; max-width: 560px; margin: 0 auto; display: block;
  padding: 0.9rem 1.25rem 0.9rem 3rem; font-size: 1rem; font-family: inherit; color: var(--caracol-brown);
  background: #fff; border: 1px solid #e2e8f0; border-radius: 14px; box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 1rem center; background-size: 1.25rem;
}
.buscador-input::placeholder { color: #94a3b8; }
.buscador-input:focus { outline: none; border-color: var(--caracol-amber); box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15); }

.tabs-wrap { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.tab { padding: 0.6rem 1.25rem; font-size: 1rem; font-family: inherit; font-weight: 600; color: #64748b; background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; cursor: pointer; }
.tab:hover { color: var(--caracol-brown); border-color: #cbd5e1; background: #f8fafc; }
.tab.active { color: #fff; background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); border-color: transparent; box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3); }

.tienda-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(272px, 1fr)); gap: 1.5rem; }

.producto-card {
  background: #fff; border-radius: 16px; overflow: hidden; border: 1px solid rgba(0,0,0,0.06);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04), 0 8px 24px rgba(0,0,0,0.06);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.2s;
}
.producto-card:hover { transform: translateY(-6px); box-shadow: 0 12px 32px rgba(0,0,0,0.08), 0 20px 48px rgba(245, 158, 11, 0.12); border-color: rgba(245, 158, 11, 0.2); }

.producto-img-wrap { aspect-ratio: 1; background: linear-gradient(145deg, #fefce8 0%, #fef9c3 100%); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.producto-img-wrap img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.35s ease; }
.producto-card:hover .producto-img-wrap img { transform: scale(1.04); }

.producto-body { padding: 1.25rem; }
.producto-num { font-size: 0.75rem; color: #94a3b8; font-weight: 600; margin-bottom: 0.25rem; }
.producto-nombre { font-family: 'Fredoka', sans-serif; font-size: 1.15rem; margin-bottom: 0.5rem; color: #1e293b; }
.producto-desc { font-size: 0.9rem; color: #64748b; line-height: 1.45; margin-bottom: 0.75rem; }
.producto-meta { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.5rem; }
.producto-precio { font-family: 'Fredoka', sans-serif; font-size: 1.35rem; color: var(--caracol-green); font-weight: 600; }
.producto-cant { font-size: 0.85rem; color: #94a3b8; }
.producto-wa-wrap { flex: 0 0 auto; }
.producto-whatsapp { font-size: 0.9rem; color: #0ea5e9; text-decoration: none; font-weight: 600; }
.producto-whatsapp:hover { text-decoration: underline; }
.btn-ver-producto {
  display: inline-block; margin-top: 0.75rem; padding: 0.6rem 1.25rem; font-size: 0.95rem; font-weight: 600;
  color: white; background: linear-gradient(135deg, var(--caracol-amber), #d97706); border-radius: var(--radius-sm);
  text-decoration: none; transition: transform 0.2s, box-shadow 0.2s;
}
.btn-ver-producto:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35); }

/* Página detalle producto */
.producto-main { max-width: 1100px; margin: 0 auto; padding: 2rem; }
.producto-loading, .producto-error { text-align: center; padding: 4rem 2rem; color: #64748b; font-size: 1.1rem; }
.producto-error a { color: var(--caracol-amber); }
.producto-detail {
  display: grid; grid-template-columns: 1fr 1fr; gap: 2.5rem; align-items: start;
  background: #fff; border-radius: 20px; padding: 2rem; box-shadow: 0 4px 20px rgba(0,0,0,0.06), 0 12px 40px rgba(0,0,0,0.06);
  border: 1px solid rgba(0,0,0,0.06);
}
.producto-gallery { position: sticky; top: 1rem; }
.producto-gallery-main {
  aspect-ratio: 1; border-radius: 16px; overflow: hidden; background: linear-gradient(145deg, #fefce8 0%, #fef9c3 100%);
  margin-bottom: 0.75rem; display: flex; align-items: center; justify-content: center;
}
.producto-gallery-main img { width: 100%; height: 100%; object-fit: cover; object-position: center; }
.producto-gallery-thumbs { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.gallery-thumb {
  width: 72px; height: 72px; padding: 0; border: 2px solid transparent; border-radius: 10px; overflow: hidden;
  cursor: pointer; background: #f5f5f4; transition: border-color 0.2s, box-shadow 0.2s; flex-shrink: 0;
}
.gallery-thumb:hover { border-color: #e2e8f0; }
.gallery-thumb.active { border-color: var(--caracol-amber); box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2); }
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: center; display: block; }
.producto-info { min-width: 0; }
.producto-codigo { font-size: 0.85rem; color: #94a3b8; font-weight: 600; margin-bottom: 0.35rem; }
.producto-titulo { font-family: 'Fredoka', sans-serif; font-size: 1.75rem; color: #1e293b; margin-bottom: 1rem; line-height: 1.3; }
.producto-descripcion { font-size: 1rem; color: #64748b; line-height: 1.6; margin-bottom: 1.5rem; }
.producto-specs { display: grid; grid-template-columns: auto 1fr; gap: 0.35rem 1.5rem; margin-bottom: 1.5rem; }
.producto-specs dt { color: #78716c; font-weight: 600; font-size: 0.9rem; }
.producto-specs dd { margin: 0; color: var(--caracol-brown); }
.producto-precio-big { font-family: 'Fredoka', sans-serif; font-size: 1.75rem; color: var(--caracol-green); font-weight: 700; }
.producto-specs a { color: #0ea5e9; text-decoration: none; font-weight: 600; }
.producto-specs a:hover { text-decoration: underline; }
.producto-cta { margin-top: 1rem; }
.btn-whatsapp {
  display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.85rem 1.5rem; font-size: 1.05rem; font-weight: 600;
  color: white; background: #25d366; border-radius: var(--radius-sm); text-decoration: none;
  transition: transform 0.2s, box-shadow 0.2s; border: none; cursor: pointer; font-family: inherit;
}
.btn-whatsapp:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(37, 211, 102, 0.4); }

@media (max-width: 768px) {
  .producto-detail { grid-template-columns: 1fr; }
  .producto-gallery { position: static; }
  .producto-titulo { font-size: 1.4rem; }
}

.sin-productos, .sin-resultados { text-align: center; padding: 4rem 2rem; color: #64748b; font-size: 1.1rem; }

.admin-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem; }
.admin-login-box { background: #fff; border-radius: 16px; border: 1px solid rgba(0,0,0,0.06); box-shadow: 0 4px 16px rgba(0,0,0,0.06), 0 12px 40px rgba(0,0,0,0.08); padding: 2.5rem; max-width: 380px; width: 100%; }
.admin-login-box h1 { font-family: 'Fredoka', sans-serif; color: var(--caracol-brown); margin-bottom: 0.5rem; font-size: 1.5rem; }
.admin-login-box .sub { color: #78716c; font-size: 0.95rem; margin-bottom: 1.5rem; }
.admin-form .field { margin-bottom: 1rem; }
.admin-form label { display: block; font-weight: 600; margin-bottom: 0.35rem; color: var(--caracol-brown); }
.admin-form input, .admin-form select { width: 100%; padding: 0.65rem 1rem; border: 2px solid #e7e5e4; border-radius: var(--radius-sm); font-family: inherit; font-size: 1rem; }
.admin-form input:focus, .admin-form select:focus { outline: none; border-color: var(--caracol-amber); }
.admin-form button[type="submit"] { width: 100%; padding: 0.85rem; background: linear-gradient(135deg, var(--caracol-amber), #d97706); color: white; border: none; border-radius: var(--radius-sm); font-family: 'Fredoka', sans-serif; font-size: 1.1rem; font-weight: 600; cursor: pointer; margin-top: 0.5rem; }
.admin-form .error-msg { color: #dc2626; font-size: 0.9rem; margin-top: 0.5rem; }

.admin-panel { display: none; width: 100%; max-width: 1000px; }
.admin-panel.activo { display: block; }
.admin-panel h1 { font-family: 'Fredoka', sans-serif; color: var(--caracol-brown); margin-bottom: 0.5rem; }
.admin-panel .bar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.5rem; }
.admin-panel .bar a, .admin-panel .bar button { padding: 0.5rem 1rem; border-radius: var(--radius-sm); font-weight: 600; text-decoration: none; cursor: pointer; border: none; font-family: inherit; font-size: 0.95rem; }
.btn-store { background: var(--caracol-amber); color: white; }
.btn-logout { background: #e7e5e4; color: var(--caracol-brown); }
.btn-add { background: var(--caracol-green); color: white; }

.admin-table-wrap { background: #fff; border-radius: 16px; border: 1px solid rgba(0,0,0,0.06); box-shadow: 0 2px 8px rgba(0,0,0,0.04), 0 8px 24px rgba(0,0,0,0.06); overflow: hidden; }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td { padding: 0.85rem 1rem; text-align: left; border-bottom: 1px solid #f5f5f4; }
.admin-table th { background: var(--caracol-cream); font-weight: 700; color: var(--caracol-brown); }
.admin-table tr:hover td { background: #fffbeb; }
.admin-table .img-cell { width: 56px; }
.admin-table .img-cell img { width: 48px; height: 48px; object-fit: cover; border-radius: 8px; }
.admin-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.admin-actions button { padding: 0.4rem 0.75rem; border: none; border-radius: 8px; font-size: 0.85rem; font-weight: 600; cursor: pointer; font-family: inherit; }
.btn-edit { background: var(--caracol-sky); color: white; }
.btn-del { background: var(--caracol-coral); color: white; }

.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 1rem; opacity: 0; visibility: hidden; transition: opacity 0.2s, visibility 0.2s; }
.modal-overlay.activo { opacity: 1; visibility: visible; }
.modal { background: #fff; border-radius: 16px; border: 1px solid rgba(0,0,0,0.06); box-shadow: 0 12px 40px rgba(0,0,0,0.12), 0 24px 80px rgba(0,0,0,0.1); max-width: 480px; width: 100%; max-height: 90vh; overflow-y: auto; }
.modal-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid #f5f5f4; display: flex; align-items: center; justify-content: space-between; }
.modal-header h2 { font-family: 'Fredoka', sans-serif; color: var(--caracol-brown); font-size: 1.25rem; }
.modal-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: #78716c; }
.modal-body { padding: 1.5rem; }
.modal-body .field { margin-bottom: 1rem; }
.modal-body label { display: block; font-weight: 600; margin-bottom: 0.35rem; color: var(--caracol-brown); }
.modal-body input, .modal-body textarea, .modal-body select { width: 100%; padding: 0.65rem 1rem; border: 2px solid #e7e5e4; border-radius: var(--radius-sm); font-family: inherit; font-size: 1rem; }
.modal-body textarea { min-height: 80px; resize: vertical; }
.modal-body input:focus, .modal-body textarea:focus, .modal-body select:focus { outline: none; border-color: var(--caracol-amber); }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid #f5f5f4; display: flex; gap: 0.75rem; justify-content: flex-end; }
.modal-footer button { padding: 0.6rem 1.25rem; border-radius: var(--radius-sm); font-weight: 600; cursor: pointer; border: none; font-family: inherit; }
.modal-footer .btn-cancel { background: #e7e5e4; color: var(--caracol-brown); }
.modal-footer .btn-save { background: var(--caracol-green); color: white; }

.upload-wrap { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.upload-wrap input[type="file"] { flex: 1; min-width: 0; }
.upload-wrap img.preview { width: 80px; height: 80px; object-fit: cover; object-position: center; border-radius: 8px; flex-shrink: 0; }

@media (max-width: 640px) {
  .admin-table th:nth-child(n+5), .admin-table td:nth-child(n+5) { display: none; }
  .tienda-header h1 { font-size: 1.35rem; }
  .buscador-input { padding-left: 2.75rem; background-size: 1.1rem; }
}
