/* Estilos base y responsivos */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: #f9fafb;
    overflow-x: hidden;
}

#funner-wrapper {
    font-family: 'Inter', sans-serif;
    max-width: 1400px;
    margin: 0 auto;
    background-color: #f9fafb;
    min-height: 100vh;
    position: relative;
}

/* Scrollbar personalizada para escritorio */
@media (min-width: 768px) {
    ::-webkit-scrollbar {
        width: 8px;
        height: 8px;
    }
    
    ::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 10px;
    }
    
    ::-webkit-scrollbar-thumb {
        background: #c7d2fe;
        border-radius: 10px;
    }
    
    ::-webkit-scrollbar-thumb:hover {
        background: #818cf8;
    }
}

/* Utilidades */
.hide-scrollbar::-webkit-scrollbar {
    display: none;
}

.hide-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Animaciones */
@keyframes loading-bar {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

.animate-loading-bar {
    animation: loading-bar 1.5s infinite linear;
}

@keyframes fade-out {
    0% {
        opacity: 1;
    }
    80% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        pointer-events: none;
    }
}

.animate-fade-out {
    animation: fade-out 2.5s ease-in-out forwards;
}

@keyframes fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in {
    animation: fade-in 0.3s ease-out;
}

/* Safe area para dispositivos móviles */
.pb-safe {
    padding-bottom: env(safe-area-inset-bottom, 20px);
}

/* Header y navegación desktop */
.header-container {
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.desktop-nav {
    background: rgba(249, 250, 251, 0.8);
    backdrop-filter: blur(4px);
}

.nav-desktop-btn {
    color: #6b7280;
    transition: all 0.2s ease;
}

.nav-desktop-btn:hover {
    background-color: #e0e7ff;
    color: #4f46e5;
}

.nav-desktop-btn.active {
    background-color: #4f46e5;
    color: white;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.2);
}

/* Mejoras para escritorio */
@media (min-width: 768px) {
    #funner-wrapper {
        box-shadow: 0 0 30px rgba(0, 0, 0, 0.05);
    }
    
    .page-content {
        padding-left: 2rem;
        padding-right: 2rem;
    }
    
    #catalog-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        gap: 1.5rem;
    }
    
    #home-sections .flex.overflow-x-auto {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(260px, auto));
        gap: 1.5rem;
        overflow-x: visible;
        scroll-snap-type: none;
    }
    
    #home-sections .flex.overflow-x-auto > div {
        width: auto !important;
    }
    
    #game-modal .bg-white {
        max-width: 540px;
    }

    #game-modal .bg-white {
        max-height: 90vh;
        overflow-y: auto;
    }
    
    header {
        padding-left: 0;
        padding-right: 0;
    }
    
    .header-container {
        padding-left: 2rem;
        padding-right: 2rem;
    }
    
    main {
        padding-bottom: 2rem;
    }
}

/* Ajustes para tablets */
@media (min-width: 768px) and (max-width: 1024px) {
    #catalog-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Mejoras en las tarjetas para escritorio */
@media (min-width: 1024px) {
    .home-card {
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }
    
    .home-card:hover {
        transform: translateY(-4px);
        box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    }
    
    #catalog-grid > div {
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }
    
    #catalog-grid > div:hover {
        transform: translateY(-4px);
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
    }
}

/* Mejoras de accesibilidad */
@media (hover: hover) {
    button:hover {
        cursor: pointer;
    }
    
    .nav-btn:hover svg {
        transform: scale(1.05);
        transition: transform 0.2s ease;
    }
}

html {
    scroll-behavior: smooth;
}

@media (min-width: 1600px) {
    #funner-wrapper {
        max-width: 1600px;
    }
    
    #catalog-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

@media print {
    .mobile-nav, .desktop-nav, header, #splash-screen, #toast, .modal {
        display: none;
    }
}

/* ======================================== */
/* PLACEHOLDERS Y SKELETON LOADING */
/* ======================================== */

/* 1. Placeholder para imágenes (efecto shimmer) */
.image-placeholder {
    background: linear-gradient(135deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%);
    background-size: 400% 400%;
    animation: shimmer 1.8s ease-in-out infinite;
    min-height: 120px;
    position: relative;
}

body.dark-mode .image-placeholder {
    background: linear-gradient(135deg, #1f2937 25%, #374151 50%, #1f2937 75%);
    background-size: 400% 400%;
}

@keyframes shimmer {
    0% {
        background-position: 0% 0%;
    }
    100% {
        background-position: 100% 100%;
    }
}

/* 2. Skeleton loading para texto */
.skeleton-text {
    background: linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: 4px;
    min-height: 14px;
}

body.dark-mode .skeleton-text {
    background: linear-gradient(90deg, #1f2937 25%, #374151 50%, #1f2937 75%);
    background-size: 200% 100%;
}

/* Variantes de skeleton */
.skeleton-text-sm {
    min-height: 10px;
    width: 60%;
}

.skeleton-text-md {
    min-height: 16px;
    width: 80%;
}

.skeleton-text-lg {
    min-height: 24px;
    width: 70%;
}

.skeleton-text-full {
    min-height: 14px;
    width: 100%;
}

.skeleton-circle {
    background: linear-gradient(135deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%);
    background-size: 400% 400%;
    animation: shimmer 1.8s ease-in-out infinite;
    border-radius: 50%;
    min-height: 80px;
    min-width: 80px;
}

body.dark-mode .skeleton-circle {
    background: linear-gradient(135deg, #1f2937 25%, #374151 50%, #1f2937 75%);
    background-size: 400% 400%;
}

/* 3. Imagen con fade-in al cargar - CORREGIDO */
img {
    transition: opacity 0.4s ease-in;
}

img.loaded {
    opacity: 1 !important;
}

/* Imágenes que no deben tener fade (banner, avatar) */
img.no-fade {
    opacity: 1 !important;
}

/* 4. Grid skeleton para catálogo */
.skeleton-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    padding: 0.5rem;
}

.skeleton-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #f3f4f6;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

body.dark-mode .skeleton-card {
    background: #1f2937;
    border-color: #374151;
}

.skeleton-card-image {
    height: 160px;
    background: linear-gradient(135deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%);
    background-size: 400% 400%;
    animation: shimmer 1.8s ease-in-out infinite;
}

body.dark-mode .skeleton-card-image {
    background: linear-gradient(135deg, #1f2937 25%, #374151 50%, #1f2937 75%);
    background-size: 400% 400%;
}

.skeleton-card-content {
    padding: 0.75rem;
}

.skeleton-card-content > div {
    margin-bottom: 0.5rem;
}

/* 5. Skeleton para lista de reservas */
.skeleton-reservation {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background: white;
    border-radius: 12px;
    border: 1px solid #f3f4f6;
    margin-bottom: 0.75rem;
}

body.dark-mode .skeleton-reservation {
    background: #1f2937;
    border-color: #374151;
}

.skeleton-reservation .image {
    width: 80px;
    height: 80px;
    border-radius: 12px;
    flex-shrink: 0;
    background: linear-gradient(135deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%);
    background-size: 400% 400%;
    animation: shimmer 1.8s ease-in-out infinite;
}

body.dark-mode .skeleton-reservation .image {
    background: linear-gradient(135deg, #1f2937 25%, #374151 50%, #1f2937 75%);
    background-size: 400% 400%;
}

.skeleton-reservation .content {
    flex: 1;
}

.skeleton-reservation .content > div {
    margin-bottom: 0.5rem;
}

/* 6. Animación de carga suave para contenedores */
.content-loading {
    opacity: 0.6;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.content-loaded {
    opacity: 1;
    pointer-events: auto;
    transition: opacity 0.3s ease;
}

/* 7. Spinner de carga personalizado */
.loading-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid #e5e7eb;
    border-top: 4px solid #4f46e5;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

body.dark-mode .loading-spinner {
    border-color: #374151;
    border-top-color: #818cf8;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 8. Placeholder para imágenes con overlay de texto */
.image-placeholder .placeholder-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: rgba(0,0,0,0.02);
}

body.dark-mode .image-placeholder .placeholder-text {
    color: #6b7280;
    background: rgba(255,255,255,0.02);
}

/* 9. Transición suave para el contenido de páginas */
.page-content {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.page-content.loading {
    opacity: 0.5;
    transform: scale(0.98);
    pointer-events: none;
}

.page-content.loaded {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

/* 10. Skeleton para el detalle del modal */
.skeleton-modal-image {
    height: 200px;
    border-radius: 12px;
    background: linear-gradient(135deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%);
    background-size: 400% 400%;
    animation: shimmer 1.8s ease-in-out infinite;
}

body.dark-mode .skeleton-modal-image {
    background: linear-gradient(135deg, #1f2937 25%, #374151 50%, #1f2937 75%);
    background-size: 400% 400%;
}

/* 11. Efecto de carga en botones */
.btn-loading {
    position: relative;
    color: transparent !important;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: 3px solid rgba(255,255,255,0.3);
    border-top: 3px solid white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* 12. Mejora para el splash screen */
#splash-screen {
    position: fixed;
    inset: 0;
    z-index: 100;
}

/* ======================================== */
/* MODO OSCURO - Estilos globales */
/* ======================================== */
body.dark-mode {
    background-color: #111827;
}

body.dark-mode #funner-wrapper {
    background-color: #111827;
}

body.dark-mode .bg-white {
    background-color: #1f2937 !important;
}

body.dark-mode .bg-gray-50 {
    background-color: #111827 !important;
}

body.dark-mode .bg-gray-100 {
    background-color: #1f2937 !important;
}

body.dark-mode .text-gray-800,
body.dark-mode .text-gray-900,
body.dark-mode .text-gray-700 {
    color: #f3f4f6 !important;
}

body.dark-mode .text-indigo-950 {
    color: white !important;
}

body.dark-mode .text-gray-600,
body.dark-mode .text-gray-500 {
    color: #9ca3af !important;
}

body.dark-mode .text-gray-400 {
    color: #6b7280 !important;
}

body.dark-mode .border-gray-100,
body.dark-mode .border-gray-200 {
    border-color: #374151 !important;
}

body.dark-mode header {
    background-color: #1f2937cc !important;
    border-bottom-color: #374151 !important;
}

body.dark-mode .bg-white\/90 {
    background-color: #1f2937e6 !important;
}

body.dark-mode .mobile-nav {
    background-color: #1f2937f2 !important;
    border-top-color: #374151 !important;
}

body.dark-mode .desktop-nav {
    background-color: #37415180 !important;
}

body.dark-mode .filter-btn.bg-white {
    background-color: #1f2937 !important;
    color: #e5e7eb !important;
    border-color: #374151 !important;
}

body.dark-mode .filter-btn.bg-white:hover {
    background-color: #374151 !important;
}

body.dark-mode .bg-black\/70 {
    background-color: #000000cc !important;
}

body.dark-mode #game-modal .bg-white,
body.dark-mode #notif-modal .bg-white,
body.dark-mode #event-modal > div {
    background-color: #1f2937 !important;
}

body.dark-mode #game-modal .text-gray-800 {
    color: #1a1a1a !important;
}

body.dark-mode button.bg-indigo-100 {
    background-color: #374151 !important;
    color: #818cf8 !important;
}

body.dark-mode button.bg-red-50 {
    background-color: #374151 !important;
}

body.dark-mode button.bg-red-50:hover {
    background-color: #4c0519 !important;
}

body.dark-mode input,
body.dark-mode textarea {
    background-color: #111827 !important;
    border-color: #374151 !important;
    color: #f3f4f6 !important;
}

body.dark-mode input:focus,
body.dark-mode textarea:focus {
    border-color: #4f46e5 !important;
    outline-color: #4f46e5 !important;
}

body.dark-mode .shadow-sm,
body.dark-mode .shadow-md,
body.dark-mode .shadow-lg,
body.dark-mode .shadow-xl {
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.3) !important;
}

body.dark-mode ::-webkit-scrollbar-track {
    background: #1f2937;
}

body.dark-mode ::-webkit-scrollbar-thumb {
    background: #4b5563;
}

body.dark-mode ::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}

/* ======================================== */
/* MODO OSCURO - Extensiones para placeholders */
/* ======================================== */

body.dark-mode .skeleton-text {
    background: linear-gradient(90deg, #1f2937 25%, #374151 50%, #1f2937 75%);
    background-size: 200% 100%;
}

body.dark-mode .skeleton-card {
    background: #1f2937;
    border-color: #374151;
}

body.dark-mode .skeleton-card-image {
    background: linear-gradient(135deg, #1f2937 25%, #374151 50%, #1f2937 75%);
    background-size: 400% 400%;
}

body.dark-mode .skeleton-reservation {
    background: #1f2937;
    border-color: #374151;
}

body.dark-mode .skeleton-reservation .image {
    background: linear-gradient(135deg, #1f2937 25%, #374151 50%, #1f2937 75%);
    background-size: 400% 400%;
}

body.dark-mode .skeleton-modal-image {
    background: linear-gradient(135deg, #1f2937 25%, #374151 50%, #1f2937 75%);
    background-size: 400% 400%;
}

body.dark-mode .image-placeholder {
    background: linear-gradient(135deg, #1f2937 25%, #374151 50%, #1f2937 75%);
    background-size: 400% 400%;
}

body.dark-mode .skeleton-circle {
    background: linear-gradient(135deg, #1f2937 25%, #374151 50%, #1f2937 75%);
    background-size: 400% 400%;
}

body.dark-mode .loading-spinner {
    border-color: #374151;
    border-top-color: #818cf8;
}

/* ======================================== */
/* RESPONSIVE - Placeholders */
/* ======================================== */

@media (max-width: 640px) {
    .skeleton-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    
    .skeleton-card-image {
        height: 120px;
    }
    
    .skeleton-reservation .image {
        width: 60px;
        height: 60px;
    }
    
    .skeleton-modal-image {
        height: 160px;
    }
}

@media (min-width: 768px) and (max-width: 1024px) {
    .skeleton-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ======================================== */
/* FIX PARA BARRA INFERIOR EN MÓVIL */
/* ======================================== */

.mobile-nav {
    height: 56px !important;
    min-height: 56px !important;
    max-height: 56px !important;
    flex-shrink: 0 !important;
    overflow: hidden !important;
}

.mobile-nav .nav-btn {
    flex: 1 !important;
    min-width: 0 !important;
}

.mobile-nav .nav-btn svg {
    width: 24px !important;
    height: 24px !important;
    min-width: 24px !important;
    min-height: 24px !important;
    flex-shrink: 0 !important;
}

.mobile-nav .nav-btn span {
    font-size: 10px !important;
    flex-shrink: 0 !important;
}

main {
    padding-bottom: calc(56px + env(safe-area-inset-bottom, 20px)) !important;
}

@supports (-webkit-touch-callout: none) {
    .mobile-nav {
        height: 56px !important;
        min-height: 56px !important;
        max-height: 56px !important;
    }
}