/* =============================================
   CUSTOM SELECT - Componente Compartilhado
   /shared/custom-select.css

   Dropdown customizado com estilo glassmorphism
   Usado em: financas, marketplace, estoque, servicos
   deve ser usado esse modelo sempre que for implementar um select customizado
   ============================================= */

/* ===== BASE ===== */
.custom-select {
    position: relative;
    width: 100%;
}

/* ===== TRIGGER (Botao que abre o dropdown) ===== */
.custom-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    background: linear-gradient(135deg, rgba(26, 26, 46, 0.95) 0%, rgba(16, 24, 39, 0.95) 100%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 0.95rem;
    font-weight: 500;
    user-select: none;
}

.custom-select-trigger:hover {
    border-color: rgba(0, 212, 255, 0.6);
    box-shadow:
        0 0 20px rgba(0, 212, 255, 0.2),
        0 4px 15px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}

/* ===== ESTADOS DE FOCO ===== */
.custom-select:focus {
    outline: none;
}

.custom-select:focus .custom-select-trigger {
    border-color: var(--neon-blue, #00D4FF);
    box-shadow:
        0 0 20px rgba(0, 212, 255, 0.3),
        0 4px 15px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

/* ===== ESTADO ABERTO ===== */
.custom-select.open .custom-select-trigger {
    border-color: var(--neon-blue, #00D4FF);
    box-shadow:
        0 0 25px rgba(0, 212, 255, 0.4),
        0 0 50px rgba(0, 212, 255, 0.15),
        0 4px 20px rgba(0, 0, 0, 0.5),
        inset 0 2px 0 rgba(255, 255, 255, 0.2);
    background: linear-gradient(135deg, rgba(26, 26, 46, 1) 0%, rgba(16, 24, 39, 1) 100%);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

/* ===== VALOR SELECIONADO ===== */
.custom-select-value {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 8px;
}

.custom-select-value.placeholder {
    color: var(--text-secondary, #9ca3af);
    opacity: 0.7;
}

.custom-select-value .option-icon {
    color: var(--neon-blue, #00D4FF);
    font-size: 0.875rem;
}

/* ===== SETA DO DROPDOWN ===== */
.custom-select-arrow {
    width: 12px;
    height: 12px;
    margin-left: 0.5rem;
    color: var(--neon-blue, #00D4FF);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), color 0.3s;
    flex-shrink: 0;
}

.custom-select.open .custom-select-arrow {
    transform: rotate(180deg);
    color: #00ff88;
}

/* ===== DROPDOWN (Lista de opcoes) ===== */
.custom-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 0;
    background: linear-gradient(180deg, rgba(26, 26, 46, 0.98) 0%, rgba(16, 24, 39, 0.98) 100%);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(0, 212, 255, 0.3);
    border-top: none;
    border-radius: 0 0 12px 12px;
    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.6),
        0 0 30px rgba(0, 212, 255, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    overflow: hidden;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: var(--z-dropdown, 1000);
}

.custom-select.open .custom-select-dropdown {
    max-height: 300px;
    overflow-y: auto;
    opacity: 1;
    transform: translateY(0);
    z-index: var(--z-tooltip, 1070);  /* Acima de modals quando aberto */
}

/* ===== DROPDOWN ABRINDO PARA CIMA ===== */
.custom-select.open-up .custom-select-trigger {
    border-radius: 0 0 12px 12px;
}

.custom-select.open-up .custom-select-dropdown {
    border-radius: 12px 12px 0 0;
    box-shadow:
        0 -8px 32px rgba(0, 0, 0, 0.8),
        0 0 0 1px rgba(0, 212, 255, 0.3),
        inset 0 -1px 0 rgba(255, 255, 255, 0.1);
}

/* ===== SCROLLBAR CUSTOMIZADA ===== */
.custom-select-dropdown::-webkit-scrollbar {
    width: 8px;
}

.custom-select-dropdown::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 0 0 8px 0;
}

.custom-select-dropdown::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--neon-blue, #00D4FF), var(--neon-purple, #8B5CF6));
    border-radius: 10px;
    border: 2px solid rgba(0, 0, 0, 0.3);
}

.custom-select-dropdown::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #00ff88, var(--neon-blue, #00D4FF));
}

/* ===== OPCOES INDIVIDUAIS ===== */
.custom-select-option {
    padding: 0.75rem 1rem;
    color: #e0e0e0;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border-left: 3px solid transparent;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    position: relative;
    overflow: hidden;
}

.custom-select-option::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0;
    background: linear-gradient(90deg, rgba(0, 212, 255, 0.2), transparent);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.custom-select-option:hover::before {
    width: 100%;
}

.custom-select-option:hover {
    background: rgba(0, 212, 255, 0.1);
    color: var(--neon-blue, #00D4FF);
    border-left-color: var(--neon-blue, #00D4FF);
    padding-left: 1.25rem;
}

/* ===== OPCAO SELECIONADA ===== */
.custom-select-option.selected {
    background: linear-gradient(90deg, rgba(0, 212, 255, 0.25), rgba(42, 110, 167, 0.15));
    color: #ffffff;
    font-weight: 600;
    border-left-color: #00ff88;
    box-shadow: inset 0 0 20px rgba(0, 212, 255, 0.2);
}

.custom-select-option.selected::after {
    content: '\2713';
    margin-left: auto;
    color: #00ff88;
    font-weight: bold;
    font-size: 1.1em;
    animation: checkmark-appear 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes checkmark-appear {
    0% {
        opacity: 0;
        transform: scale(0) rotate(-180deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(0);
    }
}

/* ===== OPCAO DESABILITADA ===== */
.custom-select-option.disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
    font-style: italic;
}

/* ===== ICONES NAS OPCOES ===== */
.custom-select-option .option-icon {
    width: 18px;
    height: 18px;
    margin-right: 10px;
    color: var(--neon-blue, #00D4FF);
    font-size: 0.875rem;
    flex-shrink: 0;
    opacity: 0.8;
    transition: all 0.2s ease;
}

.custom-select-option:hover .option-icon,
.custom-select-option.selected .option-icon {
    opacity: 1;
    transform: scale(1.1);
}

.custom-select-option .option-text {
    flex: 1;
}

/* ===== ESTADO HIGHLIGHTED (Navegacao por teclado) ===== */
.custom-select-option.highlighted {
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.15) 0%, rgba(139, 92, 246, 0.15) 100%);
    border-left-color: rgba(0, 212, 255, 0.4);
}

.custom-select-option.highlighted .option-icon {
    color: #00D4FF;
    opacity: 1;
}

/* ===== ANIMACAO DE ENTRADA DAS OPCOES ===== */
.custom-select.open .custom-select-option {
    animation: option-slide-in 0.3s cubic-bezier(0.4, 0, 0.2, 1) backwards;
}

.custom-select.open .custom-select-option:nth-child(1) { animation-delay: 0.03s; }
.custom-select.open .custom-select-option:nth-child(2) { animation-delay: 0.06s; }
.custom-select.open .custom-select-option:nth-child(3) { animation-delay: 0.09s; }
.custom-select.open .custom-select-option:nth-child(4) { animation-delay: 0.12s; }
.custom-select.open .custom-select-option:nth-child(5) { animation-delay: 0.15s; }

@keyframes option-slide-in {
    0% {
        opacity: 0;
        transform: translateX(-10px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ===== TOUCH/MOBILE MELHORIAS ===== */
.custom-select-trigger,
.custom-select-option {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

/* ===== RESPONSIVO MOBILE ===== */
@media (max-width: 768px) {
    .custom-select {
        z-index: var(--z-dropdown, 1000);
    }

    .custom-select-trigger {
        min-height: 48px;
        padding: 0.85rem 1rem;
        font-size: 0.95rem;
    }

    .custom-select-dropdown {
        max-height: 250px;
        -webkit-overflow-scrolling: touch;
        z-index: var(--z-tooltip, 1070);
    }

    .custom-select.open .custom-select-dropdown {
        max-height: 280px;
    }

    .custom-select-option {
        min-height: 48px;
        padding: 0.9rem 1rem;
        font-size: 0.95rem;
        transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .custom-select-option:hover {
        padding-left: 1rem;
    }

    .custom-select-option.selected::after {
        font-size: 1.3em;
    }

    .custom-select-dropdown::-webkit-scrollbar {
        width: 12px;
    }

    /* Desabilita animacao no mobile para performance */
    .custom-select.open .custom-select-option {
        animation: none;
    }
}
