/* -----------------------------
   Variables & Reset
   ----------------------------- */
:root {
    --primary-color: #0F4C81;    /* Azul profundo (Principal) */
    --primary-hover: #0a3d6a;
    --secondary-color: #3182ce;  /* Azul Formal (Acentos e Iconos) */
    --secondary-hover: #2b6cb0;
    
    --bg-color: #f4f7fa;
    --white: #ffffff;
    --text-main: #2d3748;
    --text-muted: #718096;
    --border-color: #e2e8f0;
    --success-color: #38b2ac;
    --danger-color: #ff4d4d;
    
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-md: 0 10px 25px rgba(0,0,0,0.08);
    --shadow-lg: 0 20px 40px rgba(0,0,0,0.12);
    
    --radius-sm: 8px;
    --radius-md: 15px;
    --radius-lg: 25px;
    
    --header-height: 80px;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
}

a { text-decoration: none; color: inherit; transition: all 0.3s ease; cursor: pointer; }
ul { list-style: none; }
img { max-width: 100%; display: block; }
.container { max-width: 1250px; margin: 0 auto; padding: 0 1.5rem; }

/* -----------------------------
   Header & Unified Search Bar
   ----------------------------- */
.main-header {
    background-color: var(--white);
    min-height: var(--header-height);
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow-sm);
    transition: top 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* El panel administrativo era color blanco */
.admin-header {
    background-color: var(--white) !important;
}

.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    width: 100%;
}

.logo-img {
    height: 90px;
    width: auto;
}

.search-wrapper {
    flex: 1;
    max-width: 700px;
}

.unified-search-form {
    display: flex;
    align-items: center;
    background: #f8fafc;
    border-radius: var(--radius-md); /* Menos redondeado, mÃ¡s limpio */
    padding: 2px;
    border: 1px solid #e2e8f0;
    transition: all 0.3s ease;
    width: 100%;
}

.unified-search-form:focus-within {
    background: #fff;
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.search-part {
    display: flex;
    align-items: center;
    padding: 0 0.8rem;
    height: 38px;
}

.search-part:not(:last-child) {
    border-right: 1px solid #e2e8f0;
}

/* -----------------------------
   Premium Dropdowns (Custom Selects)
   ----------------------------- */
.custom-select-wrapper { position: relative; cursor: pointer; user-select: none; }
.select-trigger {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-main);
    white-space: nowrap;
}

.select-trigger i {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.custom-options {
    position: absolute;
    top: calc(100% + 15px);
    left: 0;
    min-width: 220px;
    background: var(--white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    padding: 8px;
    display: none;
    z-index: 1100;
    animation: dropIn 0.2s ease-out;
}

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

.custom-select-wrapper.open .custom-options { display: block; }
.custom-options li {
    padding: 10px 15px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
}
.custom-options li:hover { background: #f1f5f9; color: var(--primary-color); }
.custom-options li.selected { background: var(--primary-color); color: var(--white); }

.location-part { min-width: 140px; }
.location-part i:first-child { color: var(--primary-color); }

.input-part { flex: 1; }
.input-part input {
    width: 100%; border: none; background: transparent;
    padding: 0 10px; font-size: 0.95rem; outline: none;
}

.search-btn {
    background: var(--primary-color);
    border: none; color: var(--white);
    width: 42px; height: 42px; border-radius: 50%;
    cursor: pointer; transition: all 0.3s;
    display: flex; justify-content: center; align-items: center;
    font-size: 1rem;
}
.search-btn:hover { background: var(--primary-hover); transform: scale(1.1); }

/* -----------------------------
   Buttons & Navigation
   ----------------------------- */
.header-nav { display: flex; align-items: center; gap: 1.5rem; }
.nav-link { font-weight: 600; font-size: 0.95rem; color: var(--text-main); }
.nav-link:hover { color: var(--primary-color); }

.auth-buttons {
    display: flex; align-items: center; gap: 1.2rem;
    padding-left: 1.5rem; border-left: 1px solid var(--border-color);
}

.btn {
    padding: 0.6rem 1.2rem; border-radius: var(--radius-sm);
    font-weight: 700; font-size: 0.8rem;
    cursor: pointer; transition: all 0.2s ease;
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
    border: 2px solid transparent;
    white-space: nowrap;
}

/* La mayorÃ­a de los botones son AZULES */
.btn-primary {
    background: var(--primary-color);
    color: var(--white);
    box-shadow: 0 4px 10px rgba(15, 76, 129, 0.15);
}
.btn-primary:hover { 
    background: var(--primary-hover); 
    transform: translateY(-1px);
    box-shadow: 0 6px 15px rgba(15, 76, 129, 0.25);
}

.btn-secondary { background: #2d3748; color: var(--white); }
.btn-secondary:hover { background: #000; }

.btn-outline { border-color: var(--border-color); color: var(--text-main); }
.btn-outline:hover { border-color: var(--primary-color); color: var(--primary-color); }

.menu-toggle { display: none; font-size: 1.5rem; cursor: pointer; color: var(--text-main); }

/* -----------------------------
   Pops (Toast Notifications)
   ----------------------------- */
.toast-container {
    position: fixed; top: 25px; right: 25px;
    z-index: 3000; display: flex; flex-direction: column; gap: 12px;
}
.toast-popup {
    background: var(--white); padding: 15px 25px;
    border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
    display: flex; align-items: center; gap: 15px;
    min-width: 320px; border-left: 6px solid var(--primary-color);
    animation: toastIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}
.toast-popup.error { border-left-color: var(--danger-color); }
.toast-popup.success { border-left-color: var(--success-color); }
.toast-popup i {
    font-size: 1.3rem;
}
.toast-popup.success i { color: var(--success-color); }
.toast-popup.error i { color: var(--danger-color); }

@keyframes toastIn { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.toast-popup.hide { animation: toastOut 0.5s ease forwards; }
@keyframes toastOut { to { transform: translateX(120%); opacity: 0; } }

/* Modals */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
    display: none; justify-content: center; align-items: center; z-index: 2000;
}
.modal-content {
    background: var(--white); padding: 2rem;
    border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
    max-width: 450px; width: 90%; text-align: center;
    animation: modalPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes modalPop { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Intro Preloader */
#intro-preloader {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: var(--white);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}

#intro-logo {
    max-width: 350px;
    animation: logoIntro 2.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes logoIntro {
    0% { transform: scale(0.8); opacity: 0; filter: blur(10px); }
    50% { transform: scale(1.1); opacity: 1; filter: blur(0); }
    100% { transform: scale(1); opacity: 1; }
}

.fade-out {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.6s ease-in-out;
}

/* -----------------------------
   Auth Forms & Eye Icon
   ----------------------------- */
.auth-card {
    background: var(--white); padding: 2.5rem;
    border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
    width: 100%; max-width: 450px; margin: auto;
}
.form-group { margin-bottom: 1.5rem; }
.form-group label { display: block; margin-bottom: 0.6rem; font-weight: 700; font-size: 0.9rem; }

.input-icon { position: relative; display: flex; align-items: center; }
.input-icon i:first-child { position: absolute; left: 1.2rem; color: var(--text-muted); font-size: 1.1rem; }

.form-control {
    width: 100%; padding: 0.8rem 1.2rem;
    border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    background: #f8fafc; transition: 0.3s; outline: none; font-size: 1rem;
}
.input-icon .form-control { padding-left: 3.2rem; }
.form-control:focus { border-color: var(--primary-color); background: #fff; box-shadow: 0 0 0 4px rgba(15, 76, 129, 0.1); }

.toggle-password { position: absolute; right: 1.2rem; color: var(--text-muted); cursor: pointer; z-index: 10; font-size: 1.1rem; }
.toggle-password:hover { color: var(--primary-color); }

/* -----------------------------
   Dashboards & Sidebar
   ----------------------------- */
.sidebar {
    width: 230px; /* MÃ¡s angosto como antes */
    background: var(--white); padding: 1rem;
    border-radius: var(--radius-md); border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm); height: fit-content;
}
.sidebar h3 { font-size: 0.95rem; margin-bottom: 1.2rem; display: flex; align-items: center; gap: 0.5rem; color: var(--text-muted); }
.sidebar-nav a {
    display: flex; align-items: center; gap: 0.8rem; padding: 0.6rem 0.9rem;
    border-radius: var(--radius-sm); font-weight: 600; color: var(--text-main);
    font-size: 0.85rem;
}
.sidebar-nav a:hover { background: #f1f5f9; color: var(--primary-color); }
.sidebar-nav a.active { 
    background: var(--primary-color); 
    color: var(--white); 
    box-shadow: none; /* Quitamos la sombra para que no 'se mueva' */
}

/* Switches en Admin */
.switch input:checked + .slider { background-color: var(--primary-color) !important; }
.slider:before {
    position: absolute; content: ""; height: 16px; width: 16px; left: 4px; bottom: 4px;
    background-color: white; transition: .4s; border-radius: 50%;
}
.switch input:checked + .slider:before { transform: translateX(26px); }

/* -----------------------------
   Product Cards
   ----------------------------- */
.product-grid { 
    display: grid; 
    grid-template-columns: repeat(5, 1fr); 
    gap: 1.2rem; 
}
.product-card {
    background: var(--white); border-radius: var(--radius-md);
    border: 1px solid var(--border-color); overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); display: flex; flex-direction: column; position: relative;
}
.product-card:hover { transform: translateY(-5px); border-color: var(--primary-color); box-shadow: var(--shadow-md); }

.product-image { aspect-ratio: 1/1; overflow: hidden; background: #f7fafc; }
.product-image img { width: 100%; height: 100%; object-fit: cover; transition: 0.6s; }
.product-card:hover .product-image img { transform: scale(1.1); }

.product-info { padding: 0.8rem; flex: 1; display: flex; flex-direction: column; }
.product-price { font-size: 1.1rem; font-weight: 900; color: #1a202c; margin-bottom: 0.2rem; }
.product-title { font-size: 0.85rem; color: var(--text-muted); font-weight: 500; height: 2.2rem; overflow: hidden; margin-bottom: 0.6rem; line-height: 1.1; }

.product-card.highlighted {
    border: 2px solid #6366f1 !important;
    box-shadow: 0 10px 25px rgba(99, 102, 241, 0.15) !important;
}

.product-footer {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: auto;
    padding-top: 0.6rem;
    border-top: 1px solid #f1f5f9;
}

.product-category, .product-seller {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.product-seller {
    font-weight: 700;
    color: var(--text-main);
}

.product-seller i.fa-check-circle {
    color: var(--primary-color);
}

.featured-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.9);
    color: #fbbf24; /* Dorado/Amarillo Premium */
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    box-shadow: var(--shadow-sm);
    z-index: 10;
    border: 1px solid #fde68a;
}

/* Honeypot field */
.hp-field { display: none !important; visibility: hidden !important; position: absolute; left: -9999px; }

/* -----------------------------
   Responsive
   ----------------------------- */
@media (max-width: 1100px) {
    .header-container { flex-direction: column; padding: 1.5rem 0; gap: 1.5rem; }
    .search-wrapper { width: 100%; }
    .auth-buttons { border-left: none; padding-left: 0; }
}

@media (max-width: 768px) {
    .menu-toggle { display: block; position: absolute; right: 1.5rem; top: 1.5rem; z-index: 1002; }
    .unified-search-form { flex-direction: column; padding: 12px; height: auto; border-radius: var(--radius-md); }
    .search-part { width: 100%; border-right: none !important; border-bottom: 1px solid #edf2f7; padding: 1rem 0; height: auto; }
    .search-btn { width: 100%; margin-top: 10px; height: 50px; border-radius: var(--radius-sm); }
    
    .header-nav {
        position: fixed; top: 0; right: -100%; width: 100%; height: 100vh;
        background: var(--white); flex-direction: column; padding: 5rem 2rem;
        transition: 0.4s; z-index: 1001;
    }
    .header-nav.active { right: 0; }

    /* En móvil el header se va con el scroll, no estorba */
    .main-header {
        position: relative;
        top: 0 !important; /* Anular el JS que mueve el top */
    }
}

/* Evitar que los productos se apachurren usando auto-fill y minmax. 
   En pantallas grandes cabrán 5 (ej: 1250px / 200px = ~5-6), en medianas 3-4, en móviles 2. */
.product-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); 
    gap: 1.2rem; 
}

@media (max-width: 600px) {
    /* Forzar 2 columnas exactas en celulares pequeños si auto-fill falla */
    .product-grid { grid-template-columns: repeat(2, 1fr); gap: 0.8rem; }
    .product-price { font-size: 1.1rem; }
    .product-title { font-size: 0.8rem; height: 2.2rem; }
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
}

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

/* -----------------------------
   Global Loading Screens (Minimalist Premium)
   ----------------------------- */
.global-loading-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.global-loading-overlay.inline {
    position: absolute;
    border-radius: inherit;
    z-index: 100;
}

.minimal-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(49, 130, 206, 0.2);
    border-top: 3px solid var(--secondary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 1.5rem;
}

.loading-text {
    font-weight: 600;
    color: var(--text-main);
    font-size: 1rem;
    letter-spacing: 0.5px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* -----------------------------
   Paginación Premium
   ----------------------------- */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin: 4rem 0 2rem;
}

.page-link {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 0.8rem;
    border-radius: 50px;
    background: var(--white);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
}

.page-link:hover {
    border-color: var(--secondary-color);
    color: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.page-link.active {
    background: var(--secondary-color);
    border-color: var(--secondary-color);
    color: var(--white);
    box-shadow: 0 4px 12px rgba(49, 130, 206, 0.3);
}

.page-link.disabled {
    opacity: 0.5;
    pointer-events: none;
    background: #f7fafc;
}

@media (max-width: 480px) {
    .pagination { gap: 0.3rem; }
    .page-link { min-width: 35px; height: 35px; font-size: 0.8rem; padding: 0 0.5rem; }
}