/* ===================================
   CUSTOM SELECT / DROPDOWN - PREMIUM
   =================================== */

/* Ocultar select nativo COMPLETAMENTE */
select.form-control[data-custom-select],
select#legal-area {
    display: none !important;
    position: absolute !important;
    opacity: 0 !important;
    pointer-events: none !important;
    height: 0 !important;
    width: 0 !important;
    visibility: hidden !important;
    z-index: -9999 !important;
}

/* Container Principal */
.custom-select-container {
    position: relative;
    width: 100%;
}

/* Display selecionado (botão dropdown) */
.custom-select-selected {
    width: 100%;
    padding: 18px 48px 18px 52px;
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 16px;
    font-size: 1rem;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #1e293b;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.custom-select-selected::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(30, 64, 175, 0.03) 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.custom-select-selected:hover {
    border-color: #cbd5e1;
    box-shadow: 0 4px 12px 0 rgba(30, 64, 175, 0.15);
    transform: translateY(-1px);
}

.custom-select-selected:hover::before {
    opacity: 1;
}

/* Quando está aberto */
.custom-select-container.open .custom-select-selected {
    border-color: #1e40af;
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1), 0 4px 12px 0 rgba(30, 64, 175, 0.2);
    border-bottom-left-radius: 6px;
    border-bottom-right-radius: 6px;
    transform: translateY(0);
}

.custom-select-container.open .custom-select-selected::before {
    opacity: 1;
}

/* Placeholder */
.custom-select-selected.placeholder {
    color: #64748b;
}

/* Ícone */
.custom-select-icon {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: #64748b;
    transition: color 0.3s ease;
    pointer-events: none;
    z-index: 1;
}

.custom-select-selected:hover~.custom-select-icon,
.custom-select-container.open .custom-select-icon {
    color: #1e40af;
}

/* Seta do dropdown */
.custom-select-arrow {
    position: absolute;
    right: 18px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    color: #64748b;
    z-index: 1;
}

.custom-select-container.open .custom-select-arrow {
    transform: translateY(-50%) rotate(180deg);
    color: #1e40af;
}

/* Lista de opções */
.custom-select-options {
    position: absolute;
    top: calc(100% - 6px);
    left: 0;
    right: 0;
    background: white;
    border: 2px solid #1e40af;
    border-top: none;
    border-radius: 0 0 16px 16px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 4px 6px -2px rgba(0, 0, 0, 0.1);
    max-height: 280px;
    overflow-y: auto;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.custom-select-container.open .custom-select-options {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Opção individual */
.custom-select-option {
    padding: 16px 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #1e293b;
    font-size: 0.95rem;
    font-weight: 500;
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
}

.custom-select-option::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: #1e40af;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.custom-select-option:hover {
    background: linear-gradient(90deg, rgba(30, 64, 175, 0.08) 0%, rgba(30, 64, 175, 0.02) 100%);
    padding-left: 24px;
}

.custom-select-option:hover::before {
    opacity: 1;
}

.custom-select-option.selected {
    background: linear-gradient(90deg, rgba(30, 64, 175, 0.12) 0%, rgba(30, 64, 175, 0.04) 100%);
    color: #1e40af;
    font-weight: 600;
    padding-left: 24px;
}

.custom-select-option.selected::before {
    opacity: 1;
}

.custom-select-option.selected::after {
    content: '✓';
    margin-left: auto;
    color: #1e40af;
    font-weight: 700;
    font-size: 1.1rem;
}

.custom-select-option:active {
    background: linear-gradient(90deg, rgba(30, 64, 175, 0.15) 0%, rgba(30, 64, 175, 0.05) 100%);
}

/* Scrollbar personalizada (WebKit) */
.custom-select-options::-webkit-scrollbar {
    width: 8px;
}

.custom-select-options::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 0 0 16px 0;
}

.custom-select-options::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
    transition: background 0.3s ease;
}

.custom-select-options::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Estados de foco (acessibilidade) */
.custom-select-selected:focus {
    outline: none;
    border-color: #1e40af;
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
}

.custom-select-option:focus {
    outline: none;
    background: linear-gradient(90deg, rgba(30, 64, 175, 0.1) 0%, rgba(30, 64, 175, 0.03) 100%);
}

/* Animações */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        transform: scale(0.95);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Loading state */
.custom-select-container.loading .custom-select-arrow {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: translateY(-50%) rotate(0deg);
    }

    to {
        transform: translateY(-50%) rotate(360deg);
    }
}

/* Disabled state */
.custom-select-container.disabled .custom-select-selected {
    background: #f8fafc;
    border-color: #e2e8f0;
    cursor: not-allowed;
    opacity: 0.6;
}

.custom-select-container.disabled .custom-select-selected:hover {
    transform: none;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

/* Responsivo */
@media (max-width: 768px) {
    .custom-select-selected {
        padding: 16px 44px 16px 48px;
        font-size: 1rem;
        border-radius: 14px;
    }

    .custom-select-options {
        max-height: 240px;
        border-radius: 0 0 14px 14px;
    }

    .custom-select-option {
        padding: 14px 18px;
    }
}