/* ==========================================================================
   🎨 DigitalShop - style.css
   Diseño moderno, responsive y accesible con Buscador Integrado
   ========================================================================== */

/* ==========================================================================
   🎨 VARIABLES CSS (con soporte dinámico desde PHP)
   ========================================================================== */
:root {
    /* Colores principales - pueden ser sobrescritos desde PHP */
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #8b5cf6;
    
    /* Estados */
    --success: #16a34a;
    --success-light: #dcfce7;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    
    /* Neutros */
    --dark: #1e293b;
    --dark-light: #334155;
    --gray: #64748b;
    --gray-light: #94a3b8;
    --light: #f8fafc;
    --white: #ffffff;
    --border: #e2e8f0;
    
    /* Efectos */
    --shadow: 0 4px 20px rgba(0,0,0,0.08);
    --shadow-hover: 0 8px 30px rgba(0,0,0,0.12);
    --shadow-soft: 0 2px 10px rgba(0,0,0,0.05);
    --radius: 12px;
    --radius-lg: 20px;
    --radius-full: 9999px;
    --transition: all 0.3s ease;
    --transition-fast: all 0.15s ease;
    
    /* Tipografía */
    --font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    --font-size-base: 16px;
    --line-height: 1.6;
}

/* ==========================================================================
   🔄 RESET Y BASE
   ========================================================================== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-size: var(--font-size-base);
}

body {
    font-family: var(--font-family);
    background: var(--light);
    color: var(--dark);
    line-height: var(--line-height);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Accesibilidad: foco visible */
:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

/* Enlaces */
a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition-fast);
}
a:hover { color: var(--primary-dark); }

/* Imágenes */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Contenedor principal */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
}

/* ==========================================================================
   📊 UTILIDADES
   ========================================================================== */
.text-center { text-align: center; }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-gray { color: var(--gray); }

.hidden { display: none !important; }
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Estado vacío */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray);
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    margin: 20px 0;
}
.empty-state p { font-size: 1.1rem; }
.empty-state i { font-size: 3rem; margin-bottom: 15px; opacity: 0.5; }

/* Badge de estado */
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.status-badge.active {
    background: var(--success-light);
    color: var(--success);
}
.status-badge.inactive {
    background: var(--danger-light);
    color: var(--danger);
}

/* Botones pequeños */
.btn-sm {
    padding: 6px 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
}
.btn-sm:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

/* ==========================================================================
   🏠 HEADER
   ========================================================================== */
.header {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: var(--white);
    padding: 30px 0;
    text-align: center;
    position: relative;
    overflow: hidden;
}

/* Efecto decorativo de fondo */
.header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    animation: pulse 8s ease-in-out infinite;
    pointer-events: none;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

.header-content {
    max-width: 800px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 15px;
}

.logo-icon {
    font-size: 2rem;
    animation: bounce 2s ease infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.logo h1 {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.header-subtitle {
    font-size: 1.1rem;
    opacity: 0.95;
    margin-bottom: 20px;
}

.highlight-message {
    background: rgba(255,255,255,0.15);
    padding: 15px 20px;
    border-radius: var(--radius);
    font-weight: 500;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.2);
}

.highlight-message br { display: none; }
@media (min-width: 600px) {
    .highlight-message br { display: block; }
}

/* ==========================================================================
   🧭 NAVEGACIÓN + BUSCADOR
   ========================================================================== */
.category-nav {
    background: var(--white);
    box-shadow: var(--shadow-soft);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-wrapper {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 10px 0;
}

/* 🔍 Contenedor del Buscador */
.search-container {
    position: relative;
    max-width: 500px;
    margin: 0 auto;
    width: 100%;
}

.search-input {
    width: 100%;
    padding: 12px 45px 12px 40px;
    border: 2px solid var(--border);
    border-radius: var(--radius-full);
    font-size: 0.95rem;
    background: var(--white);
    transition: var(--transition);
    outline: none;
    font-family: var(--font-family);
}

.search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
}

.search-input::placeholder {
    color: var(--gray-light);
}

.search-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray);
    font-size: 1rem;
    pointer-events: none;
    z-index: 1;
}

.search-clear {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--gray-light);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.7rem;
    transition: var(--transition-fast);
    opacity: 0;
    visibility: hidden;
    z-index: 1;
    padding: 0;
}

.search-clear.visible {
    opacity: 1;
    visibility: visible;
}

.search-clear:hover {
    background: var(--danger);
    transform: translateY(-50%) scale(1.1);
}

.search-count {
    position: absolute;
    right: 45px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75rem;
    color: var(--gray);
    background: var(--light);
    padding: 2px 8px;
    border-radius: 10px;
    display: none;
    font-weight: 500;
}

.search-count.visible {
    display: block;
}

/* Mensaje de resultados de búsqueda */
.search-message {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--warning-light);
    color: var(--dark);
    padding: 10px 16px;
    border-radius: var(--radius);
    margin: 15px auto;
    max-width: 600px;
    font-size: 0.9rem;
    border-left: 4px solid var(--warning);
}

.search-message.hidden {
    display: none;
}

.search-message i {
    font-size: 1.1rem;
    color: var(--warning);
}

#search-reset {
    margin-left: auto;
    background: var(--warning);
    color: white;
    border: none;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
}

#search-reset:hover {
    background: var(--primary);
    transform: scale(1.05);
}

/* Scroll de categorías */
.category-scroll {
    display: flex;
    gap: 8px;
    padding: 0 0 12px 0;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-behavior: smooth;
    justify-content: flex-start;
}

.category-scroll::-webkit-scrollbar {
    display: none;
}

.cat-btn {
    padding: 10px 18px;
    background: var(--light);
    border: 2px solid transparent;
    border-radius: var(--radius-full);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: var(--transition);
    text-decoration: none;
    color: var(--dark);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.cat-btn:hover {
    background: var(--primary-light);
    color: var(--white);
    transform: translateY(-2px);
}

.cat-btn.active {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* ==========================================================================
   📦 CATÁLOGO Y PRODUCTOS
   ========================================================================== */
.catalog {
    padding: 40px 0;
}

.category-section {
    margin-bottom: 50px;
    opacity: 0;
    animation: fadeInUp 0.5s ease forwards;
}

.category-section:nth-child(1) { animation-delay: 0.1s; }
.category-section:nth-child(2) { animation-delay: 0.2s; }
.category-section:nth-child(3) { animation-delay: 0.3s; }

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.category-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 3px solid var(--border);
    color: var(--dark);
}

.cat-icon {
    font-size: 1.8rem;
}

/* Grid de productos */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
}

/* Tarjeta de producto */
.product-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    position: relative;
    border: 1px solid var(--border);
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
    border-color: var(--primary-light);
}

/* Efecto de resaltado para resultados de búsqueda */
.product-card.highlight {
    animation: highlight-pulse 0.4s ease;
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.3) !important;
}

@keyframes highlight-pulse {
    0% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(99, 102, 241, 0); }
    100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); }
}

/* Producto oculto por filtro de búsqueda */
.product-card.no-match {
    display: none !important;
}

/* Imagen del producto */
.product-image {
    height: 180px;
    background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.product-card:hover .product-image img {
    transform: scale(1.05);
}

.no-img {
    font-size: 4rem;
    opacity: 0.7;
    transition: transform 0.3s ease;
}

.product-card:hover .no-img {
    transform: scale(1.1);
}

/* Badge de destacado */
.badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: var(--warning);
    color: var(--white);
    padding: 5px 12px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    z-index: 2;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.badge.featured {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

/* Información del producto */
.product-info {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.product-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--dark);
    line-height: 1.4;
    margin: 0;
}

.product-desc {
    font-size: 0.95rem;
    color: var(--gray);
    margin: 0;
    flex: 1;
}

/* Precios */
.product-price {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 8px 0;
}

.price-original {
    text-decoration: line-through;
    color: var(--gray-light);
    font-size: 0.9rem;
    font-weight: 400;
}

.price-current {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
}

/* Información de entrega */
.delivery-info {
    font-size: 0.85rem;
    color: var(--success);
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 8px 0;
    font-weight: 500;
}

.delivery-info i {
    font-size: 1rem;
}

/* Botón WhatsApp */
.btn-whatsapp {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #25D366;
    color: var(--white);
    padding: 12px 20px;
    border-radius: var(--radius-full);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition);
    margin-top: auto;
    border: 2px solid transparent;
}

.btn-whatsapp:hover {
    background: #128C7E;
    transform: scale(1.02);
    border-color: #0d7a6e;
    box-shadow: 0 4px 15px rgba(37, 211, 102, 0.4);
}

.btn-whatsapp:active {
    transform: scale(0.98);
}

.btn-whatsapp i {
    font-size: 1.1rem;
}

/* Estado: Sin resultados de búsqueda */
.no-results {
    text-align: center;
    padding: 60px 20px;
    grid-column: 1 / -1;
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    margin: 10px 0;
}

.no-results i {
    font-size: 4rem;
    color: var(--gray-light);
    margin-bottom: 20px;
    display: block;
    animation: bounce 2s ease infinite;
}

.no-results h3 {
    font-size: 1.3rem;
    color: var(--dark);
    margin-bottom: 10px;
}

.no-results p {
    color: var(--gray);
    margin-bottom: 20px;
}

.no-results ul {
    list-style: none;
    padding: 0;
    text-align: left;
    max-width: 300px;
    margin: 0 auto 20px;
    color: var(--gray);
}

.no-results li {
    padding: 4px 0;
}

/* ==========================================================================
   🦶 FOOTER
   ========================================================================== */
.footer {
    background: var(--dark);
    color: var(--white);
    text-align: center;
    padding: 30px 20px;
    margin-top: 40px;
}

.footer p {
    margin: 0;
    opacity: 0.9;
    font-size: 0.95rem;
}

/* Botón flotante de WhatsApp */
.whatsapp-float {
    position: fixed;
    bottom: 25px;
    right: 25px;
    z-index: 1000;
}

.whatsapp-float a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    background: #25D366;
    color: var(--white);
    border-radius: 50%;
    font-size: 1.8rem;
    box-shadow: 0 4px 20px rgba(37, 211, 102, 0.4);
    transition: var(--transition);
    text-decoration: none;
    animation: pulse-whatsapp 2s ease-in-out infinite;
}

@keyframes pulse-whatsapp {
    0%, 100% { box-shadow: 0 4px 20px rgba(37, 211, 102, 0.4); }
    50% { box-shadow: 0 4px 30px rgba(37, 211, 102, 0.7); }
}

.whatsapp-float a:hover {
    transform: scale(1.1) rotate(5deg);
    background: #128C7E;
}

/* ==========================================================================
   📱 RESPONSIVE DESIGN
   ========================================================================== */

/* Tablets */
@media (max-width: 1024px) {
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
    
    .logo h1 {
        font-size: 1.6rem;
    }
}

/* Móviles grandes */
@media (max-width: 768px) {
    :root {
        --font-size-base: 15px;
    }
    
    .header {
        padding: 25px 0;
    }
    
    .logo h1 {
        font-size: 1.4rem;
    }
    
    .logo-icon {
        font-size: 1.6rem;
    }
    
    .header-subtitle {
        font-size: 1rem;
    }
    
    .highlight-message {
        padding: 12px 16px;
        font-size: 0.95rem;
    }
    
    /* Buscador responsive */
    .nav-wrapper {
        gap: 10px;
    }
    
    .search-input {
        padding: 10px 40px 10px 35px;
        font-size: 0.9rem;
    }
    
    .search-icon {
        left: 12px;
        font-size: 0.9rem;
    }
    
    .search-clear {
        width: 22px;
        height: 22px;
        right: 10px;
        font-size: 0.65rem;
    }
    
    .search-count {
        right: 40px;
        font-size: 0.7rem;
    }
    
    .search-message {
        flex-wrap: wrap;
        text-align: center;
        justify-content: center;
        padding: 12px 14px;
    }
    
    #search-reset {
        margin-left: 0;
        margin-top: 10px;
        width: 100%;
    }
    
    .category-scroll {
        padding: 0 0 10px 0;
    }
    
    .cat-btn {
        padding: 8px 14px;
        font-size: 0.85rem;
        gap: 4px;
    }
    
    .category-title {
        font-size: 1.3rem;
        gap: 10px;
    }
    
    .cat-icon {
        font-size: 1.5rem;
    }
    
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 20px;
    }
    
    .product-image {
        height: 160px;
    }
    
    .product-info {
        padding: 16px;
    }
    
    .product-name {
        font-size: 1rem;
    }
    
    .price-current {
        font-size: 1.3rem;
    }
    
    .btn-whatsapp {
        padding: 10px 16px;
        font-size: 0.9rem;
    }
    
    .whatsapp-float {
        bottom: 20px;
        right: 20px;
    }
    
    .whatsapp-float a {
        width: 55px;
        height: 55px;
        font-size: 1.6rem;
    }
}

/* Móviles pequeños */
@media (max-width: 480px) {
    .container {
        padding: 0 15px;
    }
    
    .products-grid {
        grid-template-columns: 1fr;
    }
    
    .product-card {
        max-width: 400px;
        margin: 0 auto;
    }
    
    .product-image {
        height: 200px;
    }
    
    .no-img {
        font-size: 3.5rem;
    }
    
    .category-title {
        font-size: 1.2rem;
    }
    
    .header h1 {
        font-size: 1.3rem;
    }
    
    .cat-btn {
        padding: 7px 12px;
        font-size: 0.8rem;
    }
    
    /* Buscador en móviles muy pequeños */
    .search-container {
        max-width: 100%;
    }
    
    .search-input {
        padding: 10px 35px 10px 32px;
        font-size: 0.85rem;
    }
    
    .search-icon {
        left: 10px;
        font-size: 0.85rem;
    }
    
    .search-clear {
        width: 20px;
        height: 20px;
        right: 8px;
        font-size: 0.6rem;
    }
}

/* Modo horizontal en móviles muy pequeños */
@media (max-width: 360px) {
    .product-price {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .price-current {
        font-size: 1.2rem;
    }
    
    .search-input {
        padding: 9px 32px 9px 30px;
        font-size: 0.8rem;
    }
}

/* ==========================================================================
   🖨️ PRINT STYLES
   ========================================================================== */
@media print {
    .category-nav,
    .whatsapp-float,
    .btn-whatsapp,
    .search-container,
    .search-message {
        display: none !important;
    }
    
    .product-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
        page-break-inside: avoid;
    }
    
    body {
        background: white;
        color: black;
        font-size: 12pt;
    }
    
    .header {
        background: white !important;
        color: black !important;
        padding: 10px 0;
    }
    
    .price-current {
        color: black !important;
    }
    
    .no-img, .badge {
        display: none;
    }
}

/* ==========================================================================
   ♿ ACCESIBILIDAD Y PREFERENCIAS DE USUARIO
   ========================================================================== */

/* Reducir animaciones para usuarios con preferencia */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .product-card:hover {
        transform: none;
    }
    
    .whatsapp-float a {
        animation: none;
    }
    
    .search-input:focus {
        box-shadow: none;
        border-width: 3px;
    }
}

/* Alto contraste para mejor accesibilidad */
@media (prefers-contrast: high) {
    .search-input {
        border-width: 3px;
    }
    
    .search-input:focus {
        outline: 3px solid var(--primary);
        outline-offset: 2px;
    }
    
    .cat-btn.active {
        border-width: 3px;
    }
    
    .btn-whatsapp {
        border-width: 3px;
    }
}

/* Modo oscuro (opcional - futuro) */
@media (prefers-color-scheme: dark) {
    /* Descomentar si se desea implementar modo oscuro automático */
    /*
    body {
        background: #0f172a;
        color: #f1f5f9;
    }
    
    .product-card,
    .category-nav,
    .footer,
    .search-input,
    .search-container {
        background: #1e293b;
        border-color: #334155;
    }
    
    .cat-btn {
        background: #334155;
        color: #f1f5f9;
    }
    
    .product-desc {
        color: #94a3b8;
    }
    
    .search-input {
        color: #f1f5f9;
    }
    
    .search-input::placeholder {
        color: #64748b;
    }
    
    .search-message {
        background: #334155;
        color: #f1f5f9;
    }
    */
}

/* ==========================================================================
   🎯 ANIMACIONES
   ========================================================================== */

/* Fade in para tarjetas */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.product-card {
    animation: fadeIn 0.4s ease forwards;
    animation-delay: calc(var(--i, 0) * 0.05s);
}

/* Efecto de carga skeleton (opcional) */
.skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: var(--radius);
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ==========================================================================
   🐛 DEBUG (eliminar en producción)
   ========================================================================== */
/* 
.debug-border * {
    outline: 1px solid rgba(255, 0, 0, 0.1) !important;
}
*/