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

:root {
    --primary: #3483FA;
    --primary-hover: #2968C8;
    --bg: #f5f5f5;
    --surface: #ffffff;
    --text: #333333;
    --text-light: #666666;
    --border: #e0e0e0;
    --success: #00a650;
    --danger: #e74c3c;
    --warning: #f39c12;
    --radius: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Navbar ===== */
.navbar {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.nav-brand { font-weight: 700; font-size: 1.1rem; color: var(--primary); }
.nav-links { display: flex; gap: 1rem; }
.nav-auth { margin-left: auto; display: flex; align-items: center; gap: 0.75rem; }
.user-badge {
    background: var(--primary);
    color: #fff;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* ===== Container ===== */
.container { max-width: 1100px; margin: 0 auto; padding: 2rem 1.5rem; flex: 1; }

/* ===== Buttons ===== */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    text-decoration: none;
}
.btn:hover { text-decoration: none; opacity: 0.9; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: #6c757d; color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }
.btn-lg { padding: 0.7rem 1.5rem; font-size: 1.1rem; }

/* ===== Alerts ===== */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}
.alert-error { background: #fdecea; color: var(--danger); border: 1px solid #f5c6cb; }
.alert-success { background: #d4edda; color: var(--success); border: 1px solid #c3e6cb; }

/* ===== Hero ===== */
.hero { text-align: center; padding: 2rem 0 1rem; }
.hero h1 { font-size: 1.8rem; margin-bottom: 0.5rem; }
.hero p { color: var(--text-light); }
.hero-cta { text-align: center; padding: 3rem 0; }

/* ===== Cards ===== */
.card-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 1.5rem; margin-top: 1rem; }
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}
.card h3 { margin-bottom: 1rem; font-size: 1rem; }
.actions-card .action-list { list-style: none; }
.actions-card .action-list li { margin-bottom: 0.75rem; }

/* ===== Data Table ===== */
.data-table { width: 100%; border-collapse: collapse; }
.data-table td { padding: 0.4rem 0; border-bottom: 1px solid #f0f0f0; font-size: 0.9rem; }
.data-table td:first-child { width: 40%; color: var(--text-light); }
.data-table.full-width { margin-top: 0.5rem; }
.data-table th { text-align: left; padding: 0.5rem; background: #fafafa; border-bottom: 2px solid var(--border); font-size: 0.85rem; }

/* ===== Badge ===== */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}
.badge-active { background: #d4edda; color: #155724; }
.badge-inactive { background: #f8d7da; color: #721c24; }
.badge-paused { background: #fff3cd; color: #856404; }
.badge-closed { background: #f8d7da; color: #721c24; }
.badge-free-shipping { background: #d4edda; color: var(--success); }
.badge-featured { background: #fff3cd; color: #8a6d00; }

/* ===== Forms (field) ===== */
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--text-light); margin-bottom: 0.3rem; }
.field input, .field select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.9rem;
    background: #fff;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--primary); }
.field-hint { font-size: 0.8rem; color: var(--text-light); margin-top: 0.25rem; }

.inline-form { display: inline; }

/* ===== CRUD layout (verticales / marcas / config) ===== */
.crud-layout { display: grid; grid-template-columns: 320px 1fr; gap: 1.5rem; margin-top: 1rem; align-items: start; }
.crud-form, .crud-list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
.crud-list { overflow-x: auto; }
.crud-list h2, .crud-form h2 { font-size: 1rem; margin-bottom: 0.75rem; }
.empty-cell { text-align: center; color: var(--text-light); padding: 1rem !important; }
@media (max-width: 768px) { .crud-layout { grid-template-columns: 1fr; } }

/* ===== Storefront metadata (admin) ===== */
.store-metadata-section { margin-top: 1.5rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
.store-metadata-section h2 { font-size: 1.1rem; margin-bottom: 0.75rem; }
.store-metadata-form { margin-bottom: 1rem; }
.store-meta-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.store-meta-row { margin-bottom: 0.75rem; }
.store-toggle { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.9rem; font-weight: 600; cursor: pointer; }
.store-toggle input { width: auto; accent-color: var(--primary); }
.item-store-actions { display: flex; flex-direction: column; gap: 0.4rem; justify-content: center; align-items: flex-start; }
.store-publish-form { margin: 0; }

/* ===== Items Grid ===== */
.items-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; margin-top: 1rem; }
.item-card {
    display: flex;
    gap: 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
    transition: box-shadow 0.2s;
}
.item-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.item-img { width: 80px; height: 80px; flex-shrink: 0; border-radius: 4px; overflow: hidden; background: #f9f9f9; }
.item-img img { width: 100%; height: 100%; object-fit: cover; }
.item-info h3 { font-size: 0.9rem; margin-bottom: 0.25rem; }
.item-info h3 a { color: var(--text); }
.item-price { color: var(--primary); font-weight: 700; font-size: 1rem; }
.item-stock { color: var(--text-light); font-size: 0.8rem; }

/* ===== Search ===== */
.search-form-container { margin-bottom: 1.5rem; }
.search-form { display: flex; gap: 0.5rem; }
.search-input { flex: 1; padding: 0.6rem 1rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: 1rem; }
.search-input:focus { outline: none; border-color: var(--primary); }
.search-select { padding: 0.6rem; border: 1px solid var(--border); border-radius: var(--radius); }
.results-count { color: var(--text-light); margin-bottom: 1rem; }
.results-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; }
.result-card {
    display: flex;
    gap: 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
}
.result-img { width: 90px; height: 90px; flex-shrink: 0; border-radius: 4px; overflow: hidden; background: #f9f9f9; }
.result-img img { width: 100%; height: 100%; object-fit: cover; }
.result-info h3 { font-size: 0.9rem; margin-bottom: 0.25rem; }
.result-price { color: var(--primary); font-weight: 700; }
.result-condition { color: var(--text-light); font-size: 0.8rem; }

/* ===== Item Detail ===== */
.item-detail-header { margin-bottom: 1.5rem; }
.item-detail-header h1 { font-size: 1.5rem; margin: 0.5rem 0; }
.back-link { font-size: 0.85rem; }
.item-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; margin-bottom: 2rem; }
.item-gallery { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.gallery-img { width: 140px; height: 140px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--border); }
.item-info-panel .price { font-size: 1.3rem; font-weight: 700; color: var(--primary); }
.item-description { margin-top: 2rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; }
.description-content { white-space: pre-wrap; line-height: 1.8; }
.item-variations { margin-top: 2rem; }

/* ===== Pagination ===== */
.pagination { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1.5rem; }
.page-info { color: var(--text-light); font-size: 0.9rem; }

/* ===== Empty State ===== */
.empty-state { text-align: center; padding: 3rem; color: var(--text-light); }

/* ===== Filter Bar ===== */
.filter-bar { margin-bottom: 1rem; }
.filter-form { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.filter-form label { font-weight: 600; font-size: 0.9rem; }
.filter-form select { padding: 0.4rem; border: 1px solid var(--border); border-radius: var(--radius); }
.filter-search {
    flex: 1 1 220px;
    max-width: 320px;
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
}
.filter-search:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(52, 131, 250, 0.15); }

/* ===== Footer ===== */
.footer { text-align: center; padding: 1.5rem; color: var(--text-light); font-size: 0.8rem; border-top: 1px solid var(--border); }

/* ===== No image placeholder ===== */
.no-image { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; color: #bbb; font-size: 0.7rem; }
.no-image.large { height: 200px; font-size: 1rem; }

/* ===== Carousel (progressive enhancement) =====
   Sin JS: .carousel-track muestra todas las imágenes (galería plana).
   Con JS: .carousel.js-carousel activa la vista principal + controles. */
.carousel { position: relative; }

/* Fallback sin JS: todas las imágenes visibles */
.carousel-track { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* Modo carrusel (JS activo) */
.carousel.js-carousel .carousel-track { display: block; position: relative; }
.carousel.js-carousel .carousel-img { display: none; width: 100%; height: 320px; object-fit: contain; }
.carousel.js-carousel .carousel-img.is-active { display: block; }

/* Controles prev/next — ocultos sin JS */
.carousel-control {
    display: none;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface);
    color: var(--text);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    z-index: 2;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}
.carousel.js-carousel .carousel-control { display: flex; align-items: center; justify-content: center; }
.carousel-prev { left: 0.5rem; }
.carousel-next { right: 0.5rem; }
.carousel-control:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Miniaturas — ocultas sin JS */
.carousel-thumbs {
    display: none;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}
.carousel.js-carousel .carousel-thumbs { display: flex; }
.carousel-thumb {
    padding: 0;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    background: var(--surface);
    overflow: hidden;
    width: 56px;
    height: 56px;
}
.carousel-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.carousel-thumb.is-active { border-color: var(--primary); }

/* Contador — oculto sin JS */
.carousel-counter {
    display: none;
    position: absolute;
    bottom: 0.75rem;
    right: 0.75rem;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
}
.carousel.js-carousel .carousel-counter { display: inline-block; }

/* ===== Auth (login / register) ===== */
.auth-section {
    max-width: 420px;
    margin: 2rem auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
}
.auth-section h2 { margin-bottom: 1rem; font-size: 1.25rem; }
.auth-section p { margin-bottom: 1rem; color: var(--text-light); }
.auth-form { display: flex; flex-direction: column; gap: 0.75rem; }
.auth-form label { font-weight: 600; font-size: 0.9rem; }
.auth-form input[type="text"],
.auth-form input[type="password"] {
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
}
.auth-form input:focus { outline: 2px solid var(--primary); border-color: var(--primary); }
.auth-links { margin-top: 1rem; font-size: 0.9rem; text-align: center; }
.auth-links a { color: var(--primary); }

/* ===== Admin Toast (publish/feature sin recarga) ===== */
.admin-toast {
    position: fixed;
    bottom: 1.25rem;
    left: 50%;
    transform: translateX(-50%) translateY(0.75rem);
    background: var(--success);
    color: #fff;
    padding: 0.65rem 1.1rem;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease, transform 0.22s ease;
    z-index: 1000;
}
.admin-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.admin-toast.toast-error { background: var(--danger); }

/* ===== Animaciones de toggles admin ===== */
/* Checkbox toggle: feedback de escala al cambiar */
.store-toggle { transition: transform 0.14s ease; }
.store-toggle.toggling { transform: scale(1.08); }

/* Form destacado: slide vertical suave */
.feature-form-wrap {
    overflow: hidden;
    max-height: 120px;
    opacity: 1;
    transition: max-height 0.25s ease, opacity 0.25s ease, margin 0.25s ease;
}
.feature-form-wrap.is-collapsed {
    max-height: 0;
    opacity: 0;
    margin: 0;
}

/* Badge destacado: pop-in al aparecer */
.badge-featured { transition: transform 0.2s ease, opacity 0.2s ease; }
.badge-featured.is-new { animation: badgePop 0.35s ease; }
.badge-featured.is-leaving { opacity: 0; transform: scale(0.8); }
.featured-badge-wrap { display: inline-block; }

@keyframes badgePop {
    0%   { transform: scale(0.6); opacity: 0; }
    60%  { transform: scale(1.15); }
    100% { transform: scale(1); opacity: 1; }
}

/* Respetar preferencias de movimiento reducido */
@media (prefers-reduced-motion: reduce) {
    .store-toggle,
    .store-toggle.toggling,
    .feature-form-wrap,
    .badge-featured,
    .admin-toast {
        transition: none;
        animation: none;
    }
}

/* ==================================================================
 * Listado informativo de items (estilo mayorista: fila imagen·producto·precio)
 * ================================================================== */
.admin-item-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1rem;
}
.admin-item-row {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    background: #fff;
    border: 1px solid #e6e6e6;
    border-radius: 4px;
    padding: 0.6rem 0.9rem;
}
.admin-item-thumb {
    width: 60px;
    height: 60px;
    flex-shrink: 0;
    border-radius: 4px;
    overflow: hidden;
    background: #f5f5f5;
}
.admin-item-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.admin-item-thumb .no-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: #999;
    background: #f5f5f5;
}
.admin-item-info { flex: 1; min-width: 0; }
.admin-item-info .wholesale-title {
    display: block;
    font-size: 0.92rem;
    font-weight: 500;
    color: #333;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.admin-item-info .wholesale-title:hover { color: #3483FA; text-decoration: none; }
.admin-item-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-top: 0.3rem;
}
.admin-item-prices {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.2rem;
    white-space: nowrap;
}
.admin-item-price { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.4rem; justify-content: flex-end; }
.admin-item-price .price-final { font-size: 1.05rem; font-weight: 700; color: #333; }
.admin-item-price .price-compare { font-size: 0.75rem; color: #999; text-decoration: line-through; }
.admin-item-wholesale .wholesale-price { font-size: 0.95rem; font-weight: 700; color: #2968C8; }

/* ---------------------------------------------------------------------------
 * Header dedicado del canal Mayorista (sin búsqueda/categorías/carrito del store)
 * ------------------------------------------------------------------------- */
.m-header {
    background: #23262b;
    color: #fff;
    border-bottom: 3px solid #36a854;
}
.m-header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.m-brand {
    font-family: "Kanit", sans-serif;
    font-weight: 700;
    font-size: 1.05rem;
    color: #fff;
    text-decoration: none;
    letter-spacing: .3px;
}
.m-nav {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}
.m-nav-link {
    color: #d7dbe0;
    text-decoration: none;
    font-weight: 500;
}
.m-nav-link:hover { color: #fff; }
.m-user {
    color: #9aa1a9;
    font-size: .9rem;
}
.mayorista-body { background: #f5f6f7; }
