/* ── Reset & Base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #e91e63;
    --primary-dark: #c2185b;
    --bg: #f5f5f5;
    --card-bg: #fff;
    --text: #212121;
    --text-light: #757575;
    --shadow: 0 2px 8px rgba(0,0,0,.08);
    --shadow-lg: 0 4px 20px rgba(0,0,0,.12);
    --radius: 12px;
}

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

/* ── Header ──────────────────────────────────────────── */
.header {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    padding: 1.2rem 1rem;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-lg);
}
.header h1 { font-size: 1.4rem; font-weight: 700; }
.header p { font-size: .85rem; opacity: .9; margin-top: .2rem; }
.search-bar { margin-top: .8rem; }
.search-bar input {
    width: 100%;
    max-width: 400px;
    padding: .6rem 1rem;
    border: none;
    border-radius: 50px;
    font-size: .9rem;
    font-family: inherit;
    outline: none;
}
.search-bar input::placeholder { color: #999; }
.ask-price { font-size: .85rem !important; color: var(--text-light) !important; font-weight: 500 !important; }

/* ── Category Slider ──────────────────────────────────── */
.cat-slider-wrapper {
    position: relative;
}
.cat-slider-arrow {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: var(--primary);
    background: linear-gradient(to right, transparent, var(--bg) 60%);
    pointer-events: none;
    animation: pulseArrow 1.5s ease-in-out infinite;
    z-index: 2;
}
@keyframes pulseArrow {
    0%, 100% { opacity: 1; transform: translateX(0); }
    50% { opacity: .5; transform: translateX(4px); }
}
.cat-slider {
    display: flex;
    gap: .75rem;
    padding: 1rem;
    padding-right: 2.5rem;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}
.cat-slider::-webkit-scrollbar { display: none; }
.cat-slide {
    flex-shrink: 0;
    width: 90px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .4rem;
    cursor: pointer;
    scroll-snap-align: center;
    transition: transform .2s;
}
.cat-slide:active { transform: scale(.95); }
.cat-slide-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--card-bg);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    border: 3px solid transparent;
    transition: border-color .2s, box-shadow .2s;
}
.cat-slide.active .cat-slide-icon {
    border-color: var(--primary);
    box-shadow: var(--shadow-lg);
}
.cat-slide span {
    font-size: .72rem;
    font-weight: 600;
    color: var(--text-light);
    text-align: center;
    line-height: 1.2;
    transition: color .2s;
}
.cat-slide.active span { color: var(--primary); }

/* ── Product Grid ────────────────────────────────────── */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
    padding: 0 1rem 2rem;
}

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform .2s, box-shadow .2s;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
}
.card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}
.card-img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    background: #eee;
}
.card-body {
    padding: .75rem;
}
.card-body h3 {
    font-size: .9rem;
    font-weight: 600;
    margin-bottom: .25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.card-body .price {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
}
.card-body .category-tag {
    font-size: .7rem;
    color: var(--text-light);
    margin-top: .25rem;
}

/* ── Detalle ─────────────────────────────────────────── */
.detalle-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 1rem;
}
.detalle-gallery {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    background: #eee;
}
.detalle-gallery img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: none;
}
.detalle-gallery img.active { display: block; }
.gallery-dots {
    text-align: center;
    padding: .5rem 0;
}
.gallery-dots span {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #ccc;
    margin: 0 3px;
    cursor: pointer;
}
.gallery-dots span.active { background: var(--primary); }
.detalle-info { padding: 1rem 0; }
.detalle-info h2 { font-size: 1.3rem; margin-bottom: .5rem; }
.detalle-info .price { font-size: 1.5rem; color: var(--primary); font-weight: 700; }
.detalle-info .desc { margin-top: 1rem; color: var(--text-light); line-height: 1.7; }
.back-btn {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    font-size: .9rem;
    margin-bottom: 1rem;
}

/* ── WhatsApp Button ─────────────────────────────────── */
.wa-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    width: 100%;
    padding: .9rem;
    margin-top: 1rem;
    background: #25d366;
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}
.wa-btn:hover { background: #1da851; }

/* ── Login ───────────────────────────────────────────── */
.login-container {
    max-width: 360px;
    margin: 3rem auto;
    padding: 2rem;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}
.login-container h2 { text-align: center; margin-bottom: 1.5rem; }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .3rem; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: .7rem;
    border: 1.5px solid #ddd;
    border-radius: 8px;
    font-size: .95rem;
    font-family: inherit;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .7rem 1.5rem;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s;
}
.btn:hover { background: var(--primary-dark); }
.btn-block { width: 100%; }
.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
}
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-danger { background: #f44336; }
.btn-danger:hover { background: #d32f2f; }
.btn-sm { padding: .4rem .8rem; font-size: .8rem; }
.error-msg { color: #f44336; text-align: center; margin-bottom: 1rem; font-size: .85rem; }

/* ── Admin ───────────────────────────────────────────── */
.admin-header {
    background: linear-gradient(135deg, #333, #555);
    color: #fff;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}
.admin-header h1 { font-size: 1.1rem; }
.admin-content { padding: 1rem; max-width: 800px; margin: 0 auto; }

.admin-tabs {
    display: flex;
    gap: .5rem;
    margin-bottom: 1rem;
}
.admin-tab {
    flex: 1;
    padding: .6rem;
    border: 2px solid var(--primary);
    border-radius: 8px;
    background: transparent;
    color: var(--primary);
    font-weight: 600;
    font-size: .85rem;
    cursor: pointer;
}
.admin-tab.active { background: var(--primary); color: #fff; }

.product-item {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: .75rem;
    box-shadow: var(--shadow);
    display: flex;
    gap: .75rem;
    align-items: center;
}
.product-item img {
    width: 60px; height: 60px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}
.product-item .info { flex: 1; min-width: 0; }
.product-item .info h4 {
    font-size: .9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.product-item .info .price { color: var(--primary); font-weight: 600; }
.product-item .actions { display: flex; gap: .4rem; flex-shrink: 0; }

.img-preview-grid {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    margin-top: .5rem;
}
.img-preview-item {
    position: relative;
    width: 70px; height: 70px;
}
.img-preview-item img {
    width: 100%; height: 100%;
    object-fit: cover;
    border-radius: 6px;
}
.img-preview-item .remove-img {
    position: absolute;
    top: -6px; right: -6px;
    width: 20px; height: 20px;
    background: #f44336;
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: .7rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cat-item {
    background: var(--card-bg);
    border-radius: 8px;
    padding: .75rem 1rem;
    margin-bottom: .5rem;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.fab {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 56px; height: 56px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 1.5rem;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    z-index: 50;
}

/* ── Modal ───────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 200;
    align-items: flex-end;
    justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal {
    background: var(--card-bg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    border-radius: var(--radius) var(--radius) 0 0;
    overflow-y: auto;
    padding: 1.5rem;
    animation: slideUp .3s ease;
}
@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}
.modal h3 { margin-bottom: 1rem; }

.no-img-placeholder {
    width: 100%;
    aspect-ratio: 1;
    background: #eee;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #aaa;
    font-size: 3rem;
}

/* ── Empty state ─────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-light);
}
.empty-state .icon { font-size: 3rem; margin-bottom: .5rem; }

/* ── Toggle Switch ───────────────────────────────────── */
.toggle-label {
    display: flex;
    align-items: center;
    gap: .75rem;
    cursor: pointer;
    padding: .6rem .8rem;
    background: #f0f0f0;
    border-radius: 8px;
    border: 1.5px solid #ddd;
    font-size: .85rem;
    font-weight: 500;
}
.toggle-input { display: none; }
.toggle-slider {
    width: 48px;
    min-width: 48px;
    height: 28px;
    background: #bbb;
    border-radius: 14px;
    position: relative;
    transition: background .2s;
    flex-shrink: 0;
}
.toggle-slider::after {
    content: '';
    position: absolute;
    top: 3px; left: 3px;
    width: 22px; height: 22px;
    background: #fff;
    border-radius: 50%;
    transition: transform .2s;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle-input:checked + .toggle-slider { background: var(--primary); }
.toggle-input:checked + .toggle-slider::after { transform: translateX(20px); }

/* ── Checkbox Row ─────────────────────────────────────── */
.checkbox-row {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .6rem .8rem;
    background: #f0f0f0;
    border-radius: 8px;
    border: 1.5px solid #ddd;
}
.checkbox-row input[type="checkbox"] {
    width: 22px;
    height: 22px;
    accent-color: var(--primary);
    cursor: pointer;
    flex-shrink: 0;
}
.checkbox-row label {
    font-size: .9rem;
    font-weight: 500;
    cursor: pointer;
    margin: 0;
}

/* ── Footer ──────────────────────────────────────────── */
.site-footer {
    text-align: center;
    padding: 1.5rem 1rem;
    margin-top: 2rem;
    font-size: .75rem;
    color: var(--text-light);
    border-top: 1px solid #e0e0e0;
}

@media (min-width: 768px) {
    .grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
    .modal { border-radius: var(--radius); margin-bottom: 2rem; }
    .modal-overlay { align-items: center; }
}
