/* CSS Global - El Rincón del Tec */
:root {
    --color-primary: #ebd7b2;
    --color-secondary: #bc0c57;
    --color-accent: #750238;
    --color-text: #284531;
    --color-white: #ffffff;
    --color-gray-light: #f8f9fa;
    --color-success: #28a745;
    --color-warning: #ffc107;
    --color-danger: #dc3545;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 20px rgba(0,0,0,0.15);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.2);
    --border-radius: 8px;
    --border-radius-lg: 12px;
    --touch-target-size: 44px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Mejoras táctiles globales */
html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: rgba(117, 2, 56, 0.2);
    touch-action: manipulation;
    /* Prevenir pull-to-refresh y overscroll */
    overscroll-behavior: none;
    overscroll-behavior-y: none;
    -webkit-overscroll-behavior: none;
    -webkit-overscroll-behavior-y: none;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--color-primary);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    /* Prevenir pull-to-refresh y overscroll */
    overscroll-behavior: none;
    overscroll-behavior-y: none;
    -webkit-overscroll-behavior: none;
    -webkit-overscroll-behavior-y: none;
}



/* Elementos interactivos táctiles */
button, 
input[type="button"], 
input[type="submit"], 
input[type="reset"],
.btn,
.quantity-change,
.cart-btn,
.help-btn {
    min-height: var(--touch-target-size);
    min-width: var(--touch-target-size);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

#main-content {
    flex: 1;
}

/* Header Principal */
.main-header {
    background: var(--color-white);
    box-shadow: var(--shadow-sm);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo img {
    height: 50px;
    width: auto;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
}

.status-indicator.abierta {
    background: rgba(40, 167, 69, 0.1);
    color: var(--color-success);
}

.status-indicator.cerrada {
    background: rgba(220, 53, 69, 0.1);
    color: var(--color-danger);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-indicator.abierta .status-dot {
    background: var(--color-success);
}

.status-indicator.cerrada .status-dot {
    background: var(--color-danger);
}

.help-btn, .cart-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.75rem;
    border-radius: 50%;
    transition: all 0.3s ease;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.help-btn:hover, .cart-btn:hover {
    background: rgba(117, 2, 56, 0.1);
    transform: scale(1.05);
}

.help-btn:active, .cart-btn:active {
    transform: scale(0.95);
    background: rgba(117, 2, 56, 0.2);
}

.cart-btn {
    position: relative;
}

.cart-count {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--color-secondary);
    color: var(--color-white);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

/* Búsqueda */
.search-container {
    padding: 1.5rem 2rem;
    background: var(--color-white);
    border-bottom: 1px solid rgba(117, 2, 56, 0.1);
}

.search-box {
    position: relative;
    max-width: 500px;
    margin: 0 auto;
}

.search-input {
    width: 100%;
    padding: 1rem 1.5rem;
    border: 2px solid rgba(117, 2, 56, 0.2);
    border-radius: 25px;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
    min-height: var(--touch-target-size);
    touch-action: manipulation;
}

.search-input:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(117, 2, 56, 0.1);
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--color-white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    max-height: 300px;
    overflow-y: auto;
    z-index: 10;
    display: none;
    -webkit-overflow-scrolling: touch;
}

.search-result-item {
    padding: 1rem;
    border-bottom: 1px solid rgba(117, 2, 56, 0.1);
    cursor: pointer;
    transition: background-color 0.3s ease;
    min-height: var(--touch-target-size);
    display: flex;
    align-items: center;
}

.search-result-item:hover,
.search-result-item:active {
    background: rgba(117, 2, 56, 0.05);
}

/* Grid de Productos */
.products-section {
    padding: 2rem;
}

.section-title {
    color: var(--color-accent);
    margin-bottom: 2rem;
    text-align: center;
    font-size: 2rem;
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
}

/* Footer */
.main-footer {
    background: var(--color-accent);
    color: var(--color-white);
    padding: 2rem 0;
    text-align: center;
    width: 100%;
    margin-top: auto;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.footer-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.institutional-link {
    color: var(--color-white);
    opacity: 0.8;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius);
    min-height: var(--touch-target-size);
    touch-action: manipulation;
}

.institutional-link:hover,
.institutional-link:active {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

@media (max-width: 768px) {
    .footer-links {
        flex-direction: column;
        gap: 1rem;
    }
    
    .institutional-link {
        width: 100%;
        justify-content: center;
        padding: 1rem;
    }
}

.watermark {
    position: fixed;
    bottom: 10px;
    right: 10px;
    font-size: 0.7rem;
    color: rgba(117, 2, 56, 0.3);
    pointer-events: none;
    z-index: 100;
}

/* Utilidades */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.text-center {
    text-align: center;
}

.hidden {
    display: none !important;
}

/* Modal de Ayuda */
.help-option {
    margin-bottom: 1rem;
}

.help-option a,
.help-option button {
    text-decoration: none;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    min-height: var(--touch-target-size);
    padding: 1rem;
    border-radius: var(--border-radius);
    touch-action: manipulation;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.help-option a:hover,
.help-option button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.help-option a:active,
.help-option button:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

/* Mejoras específicas para elementos deslizables */
.swipe-container {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    overscroll-behavior: contain;
}

/* Mejoras avanzadas para scroll y deslizamiento táctil */

/* Contenedores con scroll personalizado */
.scroll-container {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--color-accent) rgba(117, 2, 56, 0.1);
}

/* Barras de scroll mejoradas para diferentes navegadores */
.scroll-container::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

.scroll-container::-webkit-scrollbar-track {
    background: rgba(117, 2, 56, 0.05);
    border-radius: 6px;
    margin: 2px;
}

.scroll-container::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--color-accent), var(--color-secondary));
    border-radius: 6px;
    border: 2px solid rgba(117, 2, 56, 0.05);
    min-height: 40px;
    transition: all 0.3s ease;
}

.scroll-container::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, var(--color-secondary), var(--color-accent));
    border-color: rgba(117, 2, 56, 0.1);
}

.scroll-container::-webkit-scrollbar-thumb:active {
    background: var(--color-accent);
    border-color: rgba(117, 2, 56, 0.2);
}

.scroll-container::-webkit-scrollbar-corner {
    background: rgba(117, 2, 56, 0.05);
}

/* Indicadores de scroll para móviles */
.scroll-indicator {
    position: relative;
}

.scroll-indicator::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(to bottom, 
        transparent 0%, 
        rgba(117, 2, 56, 0.1) 10%, 
        rgba(117, 2, 56, 0.2) 50%, 
        rgba(117, 2, 56, 0.1) 90%, 
        transparent 100%);
    border-radius: 2px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.scroll-indicator:hover::before,
.scroll-indicator.scrolling::before {
    opacity: 1;
}

/* Mejoras para elementos deslizables horizontalmente */
.horizontal-scroll {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
    gap: 1rem;
    padding: 1rem 0;
}

.horizontal-scroll::-webkit-scrollbar {
    display: none;
}

.horizontal-scroll-item {
    flex: 0 0 auto;
    touch-action: pan-x;
    user-select: none;
    -webkit-user-select: none;
}

/* Indicadores de scroll horizontal */
.horizontal-scroll-container {
    position: relative;
}

.horizontal-scroll-container::before,
.horizontal-scroll-container::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 20px;
    pointer-events: none;
    z-index: 2;
    transition: opacity 0.3s ease;
}

.horizontal-scroll-container::before {
    left: 0;
    background: linear-gradient(to right, 
        rgba(235, 215, 178, 1) 0%, 
        rgba(235, 215, 178, 0.8) 50%, 
        transparent 100%);
}

.horizontal-scroll-container::after {
    right: 0;
    background: linear-gradient(to left, 
        rgba(235, 215, 178, 1) 0%, 
        rgba(235, 215, 178, 0.8) 50%, 
        transparent 100%);
}

/* Mejoras para elementos con momentum scrolling */
.momentum-scroll {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    overscroll-behavior: auto;
}

/* Pull-to-refresh deshabilitado por solicitud del usuario */
.pull-to-refresh {
    overscroll-behavior-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    pointer-events: none !important;
    position: relative;
}

.pull-to-refresh-indicator {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    /* Código original comentado
    position: absolute;
    top: -80px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--color-accent);
    color: var(--color-white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 1000;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(117, 2, 56, 0.3);
    */
}

/* Animaciones de pull-to-refresh deshabilitadas */
.pull-to-refresh.pulling .pull-to-refresh-indicator {
    display: none !important;
    opacity: 0 !important;
}

.pull-to-refresh.refreshing .pull-to-refresh-indicator {
    display: none !important;
    opacity: 0 !important;
    animation: none !important;
}

@keyframes refreshSpin {
    from { transform: translateX(-50%) translateY(20px) rotate(0deg); }
    to { transform: translateX(-50%) translateY(20px) rotate(360deg); }
}

/* Mejoras para elementos con swipe gestures */
.swipe-item {
    touch-action: pan-y;
    user-select: none;
    -webkit-user-select: none;
    position: relative;
    overflow: hidden;
}

.swipe-actions {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    display: flex;
    align-items: center;
    background: var(--color-danger);
    color: var(--color-white);
    padding: 0 1rem;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.swipe-item.swiped .swipe-actions {
    transform: translateX(0);
}

/* Barras de scroll personalizadas para móviles */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(117, 2, 56, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--color-accent);
    border-radius: 4px;
    min-height: 40px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-secondary);
}

/* Responsive */
@media (max-width: 768px) {
    :root {
        --touch-target-size: 48px;
    }
    
    .main-header {
        padding: 1rem;
    }
    
    .header-actions {
        gap: 0.5rem;
    }
    
    .status-indicator .status-text {
        display: none;
    }
    
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 1rem;
    }
    
    .products-section {
        padding: 1rem;
    }
    
    .watermark {
        display: none;
    }
    
    .help-option a,
    .help-option button {
        padding: 1rem !important;
        font-size: 1rem;
        min-height: 48px;
    }
    
    .search-input {
        font-size: 16px; /* Previene zoom en iOS */
        min-height: 48px;
    }
    
    /* Mejoras táctiles específicas para móviles */
    button, 
    .btn,
    .quantity-change,
    .cart-btn,
    .help-btn {
        min-height: 48px;
        min-width: 48px;
    }
    
    /* Espaciado adicional para elementos táctiles */
    .help-btn, .cart-btn {
        padding: 1rem;
        margin: 0.25rem;
    }
    
    /* Mejoras específicas para móviles */
    .scroll-container::-webkit-scrollbar {
        width: 8px;
        height: 8px;
    }
    
    .scroll-container::-webkit-scrollbar-thumb {
        min-height: 30px;
        border-width: 1px;
    }
    
    .horizontal-scroll {
        padding: 0.5rem 0;
        gap: 0.75rem;
    }
    
    .horizontal-scroll-container::before,
    .horizontal-scroll-container::after {
        width: 15px;
    }
    
    .pull-to-refresh-indicator {
        width: 36px;
        height: 36px;
        font-size: 1.1rem;
        top: -50px;
    }
}

/* Mejoras para dispositivos táctiles */
@media (hover: none) and (pointer: coarse) {
    .help-btn:hover, 
    .cart-btn:hover,
    .institutional-link:hover,
    .help-option a:hover,
    .help-option button:hover,
    .search-result-item:hover {
        transform: none;
        box-shadow: none;
    }
    
    .help-btn:active, 
    .cart-btn:active,
    .institutional-link:active,
    .help-option a:active,
    .help-option button:active,
    .search-result-item:active {
        transform: scale(0.95);
        background: rgba(117, 2, 56, 0.15);
    }
    
    .scroll-container::-webkit-scrollbar-thumb:hover {
        background: linear-gradient(135deg, var(--color-accent), var(--color-secondary));
    }
    
    .scroll-indicator::before {
        opacity: 0.3;
    }
    
    .scroll-indicator.scrolling::before {
        opacity: 0.6;
    }
    
    /* Aumentar área táctil para elementos de scroll */
    .scroll-container::-webkit-scrollbar {
        width: 14px;
        height: 14px;
    }
    
    .scroll-container::-webkit-scrollbar-thumb {
        border-width: 1px;
        min-height: 44px;
    }
}

/* Mejoras para accesibilidad */
@media (prefers-reduced-motion: reduce) {
    .scroll-container,
    .horizontal-scroll,
    .momentum-scroll {
        scroll-behavior: auto;
    }
    
    .pull-to-refresh-indicator,
    .swipe-actions {
        transition: none;
    }
    
    .refreshSpin {
        animation: none;
    }
}

/* Mejoras para pantallas de alta densidad */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .scroll-container::-webkit-scrollbar {
        width: 10px;
        height: 10px;
    }
    
    .scroll-container::-webkit-scrollbar-thumb {
        border-width: 1px;
    }
    
    .scroll-indicator::before {
        width: 3px;
    }
}