/* =================================
   NAVBAR DROPDOWN - INTEGRACIÓN CON TEMA EXISTENTE + SCROLL LIMITADO
   ================================= */

/* Contenedor principal del navbar */
.navbar-container {
    background: rgba(30, 41, 59, 0.95) !important;
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    position: relative;
    z-index: 40;
}

/* Contenedor del dropdown */
.dropdown-container {
    position: relative;
    display: inline-block;
}

/* Botón trigger del dropdown */
.dropdown-trigger {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8) !important;
    color: white !important;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
    display: flex;
    align-items: center;
    gap: 8px;
}

.dropdown-trigger:hover {
    background: linear-gradient(135deg, #6366f1, #4338ca) !important;
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
    transform: translateY(-1px);
}

.dropdown-trigger:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3),
                0 6px 20px rgba(59, 130, 246, 0.4);
}

/* Icono de flecha */
.dropdown-arrow {
    transition: transform 0.3s ease;
    font-size: 0.8rem;
}

.dropdown-container.open .dropdown-arrow {
    transform: rotate(180deg);
}

/* 🎯 DROPDOWN MENU BASE - SIN SCROLL AÚN */
.dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: auto;
    min-width: 280px;
    max-width: 320px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2),
                0 10px 10px -5px rgba(0, 0, 0, 0.08);
    z-index: 50;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    overflow: hidden; /* 🔧 IMPORTANTE: Evitar scroll en el contenedor principal */
}

.dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* 🆕 DROPDOWN DE LOTERÍAS CON SCROLL LIMITADO A 5 ELEMENTOS */
.group:nth-child(2) .dropdown-menu {
    /* Aplicar solo al segundo dropdown (Loterías) */
    max-height: 400px; /* Altura máxima para 5 elementos + header */
}

.group:nth-child(2) .dropdown-menu .py-2 {
    /* Contenedor de items con scroll */
    max-height: 300px; /* ~5 elementos * 60px cada uno */
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f8fafc;
    
    /* 🎯 INDICADORES VISUALES DE SCROLL */
    background: linear-gradient(white 30%, rgba(255,255,255,0)),
                linear-gradient(rgba(255,255,255,0), white 70%) 0 100%,
                radial-gradient(50% 0, farthest-side, rgba(0,0,0,.2), rgba(0,0,0,0)),
                radial-gradient(50% 100%, farthest-side, rgba(0,0,0,.2), rgba(0,0,0,0)) 0 100%;
    background-repeat: no-repeat;
    background-color: white;
    background-size: 100% 40px, 100% 40px, 100% 14px, 100% 14px;
    background-attachment: local, local, scroll, scroll;
}

/* 🎨 SCROLLBAR PERSONALIZADO PARA DROPDOWN DE LOTERÍAS */
.group:nth-child(2) .dropdown-menu .py-2::-webkit-scrollbar {
    width: 8px;
    background: transparent;
}

.group:nth-child(2) .dropdown-menu .py-2::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
    margin: 4px 0;
}

.group:nth-child(2) .dropdown-menu .py-2::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #cbd5e1, #94a3b8);
    border-radius: 4px;
    border: 1px solid #e2e8f0;
    transition: all 0.3s ease;
}

.group:nth-child(2) .dropdown-menu .py-2::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #94a3b8, #64748b);
    border-color: #cbd5e1;
    transform: scaleY(1.1);
}

.group:nth-child(2) .dropdown-menu .py-2::-webkit-scrollbar-thumb:active {
    background: linear-gradient(135deg, #64748b, #475569);
}

/* 🎯 SCROLLBAR CORNER - ESQUINA DEL SCROLLBAR */
.group:nth-child(2) .dropdown-menu .py-2::-webkit-scrollbar-corner {
    background: #f8fafc;
}

/* 🆕 INDICADOR DE MÁS CONTENIDO - GRADIENTE SUTIL */
.group:nth-child(2) .dropdown-menu .py-2::after {
    content: '';
    position: sticky;
    bottom: 0;
    left: 0;
    right: 8px; /* Espacio para scrollbar */
    height: 20px;
    background: linear-gradient(transparent, rgba(248, 250, 252, 0.95));
    pointer-events: none;
    border-radius: 0 0 12px 0;
}

/* 🔧 DROPDOWN DE PATRONES SIN SCROLL (mantener normal) */
.group:nth-child(3) .dropdown-menu {
    /* El dropdown de Patrones mantiene comportamiento normal */
    max-height: 400px;
    overflow-y: auto;
}

.group:nth-child(3) .dropdown-menu::-webkit-scrollbar {
    width: 6px;
}

.group:nth-child(3) .dropdown-menu::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #cbd5e1, #94a3b8);
    border-radius: 3px;
}

.group:nth-child(3) .dropdown-menu::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #94a3b8, #64748b);
}

.group:nth-child(3) .dropdown-menu::-webkit-scrollbar-track {
    background: #f8fafc;
    border-radius: 3px;
}

/* Header del dropdown */
.dropdown-header {
    padding: 16px 20px 12px;
    border-bottom: 1px solid #f1f5f9;
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    border-radius: 12px 12px 0 0; /* 🔧 Solo border-radius arriba */
    position: sticky;
    top: 0;
    z-index: 2;
}

.dropdown-header h3 {
    color: #1f2937 !important;
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
    text-shadow: none;
}

.dropdown-header p {
    color: #6b7280 !important;
    font-size: 0.875rem;
    margin: 4px 0 0 0;
}

/* Items del dropdown */
.dropdown-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: #374151;
    text-decoration: none;
    border-bottom: 1px solid #f9fafb;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:first-of-type {
    border-radius: 0;
}

.dropdown-item:hover {
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    color: #1d4ed8;
    transform: translateX(4px);
    box-shadow: inset 4px 0 0 #3b82f6;
}

.dropdown-item:focus {
    outline: none;
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    color: #1d4ed8;
    box-shadow: inset 4px 0 0 #3b82f6;
}

/* 🎯 VARIABLES CSS PERSONALIZABLES - AJUSTA ESTOS VALORES */
:root {
    --dropdown-icon-size: 40px; /* 🎛️ CAMBIAR ESTE VALOR: 32px, 40px, 48px, etc. */
    --dropdown-icon-padding: 3px; /* 🎛️ ESPACIO INTERNO: 2px, 3px, 4px, etc. */
    --dropdown-icon-border: 2px; /* 🎛️ GROSOR DEL BORDE: 1px, 2px, 3px, etc. */
}

/* Icono de la lotería en el dropdown */
.dropdown-item-icon {
    width: var(--dropdown-icon-size);
    height: var(--dropdown-icon-size);
    background: white;
    border: var(--dropdown-icon-border) solid #e5e7eb;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.875rem;
    font-weight: bold;
    margin-right: 12px;
    transition: all 0.3s ease;
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
    padding: var(--dropdown-icon-padding);
}

/* 🆕 IMAGEN REAL DE LA LOTERÍA - AJUSTADA */
.dropdown-item-image {
    width: calc(100% - calc(var(--dropdown-icon-padding) * 2));
    height: calc(100% - calc(var(--dropdown-icon-padding) * 2));
    object-fit: contain;
    border-radius: 50%;
    background: white;
}

/* 🆕 FALLBACK CON INICIALES - FONDO AZUL */
.dropdown-item-icon-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(var(--dropdown-icon-size) * 0.25); /* 🎛️ TAMAÑO DE TEXTO PROPORCIONAL */
    font-weight: bold;
    color: white;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    border-radius: 50%;
}

.dropdown-item:hover .dropdown-item-icon {
    border-color: #3b82f6;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

/* 🆕 HOVER para el fallback con iniciales */
.dropdown-item:hover .dropdown-item-icon-fallback {
    background: linear-gradient(135deg, #6366f1, #4338ca);
}

/* Contenido del item */
.dropdown-item-content {
    flex: 1;
    min-width: 0;
}

.dropdown-item-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin: 0 0 2px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dropdown-item-subtitle {
    font-size: 0.8rem;
    color: #6b7280;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dropdown-item:hover .dropdown-item-subtitle {
    color: #4338ca;
}

/* Indicador de enlace externo */
.dropdown-item-arrow {
    color: #9ca3af;
    font-size: 0.75rem;
    transition: all 0.2s ease;
    margin-left: 8px;
}

.dropdown-item:hover .dropdown-item-arrow {
    color: #3b82f6;
    transform: translateX(2px);
}

/* Estilos para items destacados (featured) */
.dropdown-item.featured {
    background: linear-gradient(135deg, #fefce8, #fef3c7);
    border-left: 4px solid #f59e0b;
}

.dropdown-item.featured:hover {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border-left-color: #d97706;
}

.dropdown-item.featured .dropdown-item-icon-fallback {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

/* Estados especiales */
.dropdown-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Overlay para cerrar el dropdown en mobile */
.dropdown-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.1);
    z-index: 30;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.dropdown-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* =================================
   RESPONSIVE DESIGN
   ================================= */

/* Mobile: Dropdown más ancho y overlay */
@media (max-width: 768px) {
    .dropdown-menu {
        min-width: 280px;
        max-width: calc(100vw - 32px);
        left: 50%;
        transform: translateX(-50%) translateY(-10px) scale(0.95);
    }
    
    .dropdown-menu.show {
        transform: translateX(-50%) translateY(0) scale(1);
    }
    
    .dropdown-trigger {
        padding: 8px 16px;
        font-size: 0.85rem;
    }
    
    .dropdown-item {
        padding: 14px 16px;
    }
    
    .dropdown-item-icon {
        width: 32px;
        height: 32px;
        font-size: 0.8rem;
    }

    /* 🔧 MOBILE: Aumentar altura máxima del scroll */
    .group:nth-child(2) .dropdown-menu {
        max-height: 50vh;
    }
    
    .group:nth-child(2) .dropdown-menu .py-2 {
        max-height: calc(50vh - 100px);
    }
}

/* Tablet */
@media (max-width: 1024px) {
    .dropdown-menu {
        min-width: 260px;
    }

    .group:nth-child(2) .dropdown-menu .py-2 {
        max-height: 320px; /* Un poco más de espacio en tablet */
    }
}

/* =================================
   ANIMACIONES ESPECIALES
   ================================= */

/* Animación de entrada escalonada para los items */
.dropdown-menu.show .dropdown-item {
    animation: slideInStagger 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    opacity: 0;
    transform: translateX(-20px);
}

.dropdown-menu.show .dropdown-item:nth-child(1) { animation-delay: 0.05s; }
.dropdown-menu.show .dropdown-item:nth-child(2) { animation-delay: 0.1s; }
.dropdown-menu.show .dropdown-item:nth-child(3) { animation-delay: 0.15s; }
.dropdown-menu.show .dropdown-item:nth-child(4) { animation-delay: 0.2s; }
.dropdown-menu.show .dropdown-item:nth-child(5) { animation-delay: 0.25s; }
.dropdown-menu.show .dropdown-item:nth-child(6) { animation-delay: 0.3s; }
.dropdown-menu.show .dropdown-item:nth-child(7) { animation-delay: 0.35s; }
.dropdown-menu.show .dropdown-item:nth-child(8) { animation-delay: 0.4s; }
.dropdown-menu.show .dropdown-item:nth-child(n+9) { animation-delay: 0.45s; }

@keyframes slideInStagger {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Efecto hover suave */
.dropdown-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(59, 130, 246, 0.1), transparent);
    transition: left 0.5s ease;
}

.dropdown-item:hover::before {
    left: 100%;
}

/* =================================
   ACCESIBILIDAD
   ================================= */

/* Focus visible para navegación con teclado */
.dropdown-trigger:focus-visible,
.dropdown-item:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Reducir animaciones si el usuario prefiere menos movimiento */
@media (prefers-reduced-motion: reduce) {
    .dropdown-menu,
    .dropdown-trigger,
    .dropdown-item,
    .dropdown-arrow {
        transition: none;
    }
    
    .dropdown-menu.show .dropdown-item {
        animation: none;
        opacity: 1;
        transform: none;
    }
}

/* =================================
   INTEGRACIÓN CON TEMA EXISTENTE
   ================================= */

/* Asegurar que el dropdown mantenga los estilos de cards blancas */
.dropdown-menu {
    background: white !important;
    color: #1f2937 !important;
}

.dropdown-header {
    background: linear-gradient(135deg, #f8fafc, #f1f5f9) !important;
}

/* Mantener consistencia con botones existentes */
.dropdown-trigger {
    font-family: inherit;
    letter-spacing: inherit;
}

/* 🆕 SMOOTH SCROLL BEHAVIOR */
.group:nth-child(2) .dropdown-menu .py-2 {
    scroll-behavior: smooth;
}

/* 🎯 ESTILO PARA CUANDO HAY POCO CONTENIDO (menos de 5 items) */
.group:nth-child(2) .dropdown-menu.small-content .py-2 {
    max-height: none;
    overflow: visible;
}

.group:nth-child(2) .dropdown-menu.small-content .py-2::after {
    display: none;
}

/* 🎯 SCROLL DEFINITIVO PARA DROPDOWN DE LOTERÍAS - FONDO CORRECTO */
#dynamicLotteryMenu {
    max-height: 300px !important; /* ~5 elementos * 60px cada uno */
    overflow-y: auto !important;
    overflow-x: hidden !important;
    /* Sin forzar background - mantiene el tema oscuro */
}

/* 🎨 SCROLLBAR PERSONALIZADO PARA TEMA OSCURO */
#dynamicLotteryMenu::-webkit-scrollbar {
    width: 8px;
}

#dynamicLotteryMenu::-webkit-scrollbar-track {
    background: #475569; /* Color del tema oscuro */
    border-radius: 4px;
}

#dynamicLotteryMenu::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #64748b, #475569);
    border-radius: 4px;
    transition: all 0.3s ease;
    border: 1px solid #334155;
}

#dynamicLotteryMenu::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #94a3b8, #64748b);
    border-color: #475569;
}