/**
 * custom-select-sheet.css
 * 
 * Estilos modernos Mobile-First para selectores tipo Bottom Sheet (Modal deslizable)
 * con diseño de lujo oscuro/dorado, buscador en vivo y tarjetas táctiles para Tienda IORO.
 */

/* =======================================================
   1. TRIGGER VISUAL DEL SELECTOR
   ======================================================= */
.custom-select-wrapper {
    position: relative;
    width: 100%;
    display: flex;
}

.custom-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 48px;
    padding: 0 14px 0 44px; /* Espacio exacto para el icono izquierdo */
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    color: #ffffff;
    font-family: 'Space Grotesk', system-ui, -apple-system, sans-serif;
    font-size: 0.95rem;
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
    text-align: left;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent !important;
    outline: none;
}

.input-with-icon:focus-within .custom-select-trigger,
.custom-select-trigger:hover,
.custom-select-trigger:focus-visible {
    border-color: #d4af37;
    background: #141c29;
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.2);
    outline: none;
}

.custom-select-trigger.is-open {
    border-color: #d4af37;
    background: #141c29;
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.25);
}

.input-with-icon .custom-select-wrapper {
    width: 100%;
}

.input-with-icon .input-icon {
    pointer-events: none;
    z-index: 3;
}

.custom-select-trigger .trigger-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #ffffff;
    font-weight: 500;
}

.custom-select-trigger .trigger-text.is-placeholder {
    color: #94a3b8;
    font-weight: 400;
}

.custom-select-trigger .trigger-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 10px;
    color: #94a3b8;
    font-size: 0.85rem;
    transition: transform 0.25s ease, color 0.25s ease;
}

.custom-select-trigger.is-open .trigger-arrow {
    transform: rotate(180deg);
    color: #d4af37;
}

/* =======================================================
   2. OVERLAY Y CONTENEDOR BOTTOM SHEET / MODAL
   ======================================================= */
.custom-select-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000010 !important;
    background: rgba(5, 10, 20, 0.78);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: flex-end; /* Mobile: Bottom Sheet */
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.24s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.24s cubic-bezier(0.16, 1, 0.3, 1);
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    will-change: opacity, visibility;
}

.custom-select-overlay.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.custom-select-sheet {
    width: 100%;
    max-width: 520px;
    max-height: 86vh;
    background: #141c29;
    border-radius: 24px 24px 0 0;
    border: 1px solid rgba(212, 175, 55, 0.25);
    border-bottom: none;
    box-shadow: 0 -10px 45px rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    transform: translate3d(0, 100%, 0);
    -webkit-transform: translate3d(0, 100%, 0);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    box-sizing: border-box;
    overflow: hidden;
    padding-bottom: env(safe-area-inset-bottom, 12px);
}

.custom-select-overlay.is-visible .custom-select-sheet {
    transform: translate3d(0, 0, 0);
    -webkit-transform: translate3d(0, 0, 0);
}

/* =======================================================
   3. BARRA DE AGARRE (DRAG HANDLE) Y CABECERA
   ======================================================= */
.custom-select-handle-bar {
    display: flex;
    justify-content: center;
    padding: 10px 0 4px 0;
    cursor: grab;
}

.custom-select-handle {
    width: 42px;
    height: 5px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 10px;
}

.custom-select-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px 12px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.custom-select-title-box {
    display: flex;
    align-items: center;
    gap: 12px;
}

.custom-select-title-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.2), rgba(212, 175, 55, 0.05));
    border: 1px solid rgba(212, 175, 55, 0.4);
    color: #d4af37;
    font-size: 1.1rem;
}

.custom-select-title-text h3 {
    margin: 0;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.2;
}

.custom-select-title-text p {
    margin: 2px 0 0 0;
    font-size: 0.78rem;
    color: #94a3b8;
    line-height: 1.2;
}

.custom-select-btn-close {
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: #94a3b8;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all 0.2s ease;
}

.custom-select-btn-close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    transform: scale(1.05);
}

/* =======================================================
   4. BUSCADOR EN TIEMPO REAL
   ======================================================= */
.custom-select-search-container {
    padding: 12px 18px 8px 18px;
}

.custom-select-search-box {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    background: #0b101e;
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 0 12px;
    box-sizing: border-box;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.custom-select-search-box:focus-within {
    border-color: #d4af37;
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.2);
}

.custom-select-search-box i.search-icon {
    color: #94a3b8;
    font-size: 0.95rem;
    margin-right: 8px;
}

.custom-select-search-input {
    flex: 1;
    height: 42px;
    background: transparent;
    border: none;
    color: #ffffff;
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
}

.custom-select-search-input::placeholder {
    color: #64748b;
    font-size: 0.9rem;
}

.custom-select-search-clear {
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 4px 6px;
    display: none;
}

.custom-select-search-clear.is-visible {
    display: block;
}

/* =======================================================
   5. LISTA DE OPCIONES TÁCTILES
   ======================================================= */
.custom-select-options-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 18px 20px 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    -webkit-overflow-scrolling: touch;
}

/* Scrollbar estilizada */
.custom-select-options-list::-webkit-scrollbar {
    width: 6px;
}
.custom-select-options-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.03);
}
.custom-select-options-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

/* Tarjeta individual de opción */
.custom-select-option-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    background: rgba(30, 43, 64, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 12px;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent !important;
}

.custom-select-option-item:hover {
    background: rgba(45, 66, 99, 0.85);
    border-color: rgba(212, 175, 55, 0.4);
    transform: translateY(-1px);
}

.custom-select-option-item:active {
    transform: scale(0.98);
}

/* Estado Seleccionado */
.custom-select-option-item.is-selected {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.16), rgba(30, 43, 64, 0.9));
    border-color: #d4af37;
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.2);
}

.custom-select-option-item.is-selected .option-name {
    color: #d4af37;
    font-weight: 700;
}

/* Contenido de la opción */
.option-left-content {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.option-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: #94a3b8;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.custom-select-option-item.is-selected .option-icon {
    background: rgba(212, 175, 55, 0.2);
    color: #d4af37;
}

.option-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.option-name {
    color: #ffffff;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.option-meta {
    font-size: 0.78rem;
    color: #94a3b8;
    margin-top: 2px;
}

/* Badges de Tarifas / Costos */
.option-right-content {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.option-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 9px;
    border-radius: 20px;
    font-size: 0.76rem;
    font-weight: 700;
    font-family: 'Space Grotesk', sans-serif;
}

.option-badge.badge-gratis {
    background: rgba(37, 211, 102, 0.15);
    color: #25d366;
    border: 1px solid rgba(37, 211, 102, 0.35);
}

.option-badge.badge-costo {
    background: rgba(212, 175, 55, 0.15);
    color: #d4af37;
    border: 1px solid rgba(212, 175, 55, 0.35);
}

.option-check-icon {
    color: #d4af37;
    font-size: 1rem;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.2s ease;
}

.custom-select-option-item.is-selected .option-check-icon {
    opacity: 1;
    transform: scale(1);
}

/* Estado Vacío de Búsqueda */
.custom-select-empty-state {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
}

.custom-select-empty-state.is-visible {
    display: flex;
}

.custom-select-empty-state i {
    font-size: 2.2rem;
    color: #64748b;
    margin-bottom: 10px;
}

.custom-select-empty-state p {
    color: #94a3b8;
    font-size: 0.9rem;
    margin: 0;
}

/* =======================================================
   6. RESPONSIVO Y MODO ESCRITORIO (MODAL CENTRADO)
   ======================================================= */
@media (min-width: 769px) {
    .custom-select-overlay {
        align-items: center;
        padding: 20px;
    }

    .custom-select-sheet {
        border-radius: 20px;
        border-bottom: 1px solid rgba(212, 175, 55, 0.25);
        max-height: 80vh;
        transform: translate3d(0, 14px, 0) scale(0.96);
        -webkit-transform: translate3d(0, 14px, 0) scale(0.96);
        transition: transform 0.24s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .custom-select-overlay.is-visible .custom-select-sheet {
        transform: translate3d(0, 0, 0) scale(1);
        -webkit-transform: translate3d(0, 0, 0) scale(1);
    }

    .custom-select-handle-bar {
        display: none; /* No drag handle on desktop */
    }
}
