﻿/* rotas-modal.css - Estilos específicos para o Modal de Rotas no Blazor */
/* Caminho: wwwroot/css/rotas-modal.css */

/* ===================================== */
/* NAMESPACE: .rm-* (Rotas Modal)       */
/* ===================================== */

/* Reset e isolamento do modal */
#rotas-modal {
    z-index: 1050 !important;
}

    #rotas-modal .modal-dialog {
        z-index: 1051 !important;
    }

    #rotas-modal .modal-content {
        border: 1px solid rgba(0, 0, 0, 0.125);
        border-radius: 0.5rem;
        box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    }

/* ===== AUTOCOMPLETE CONTAINERS ===== */
/* Forçar visibilidade dos pac-containers relacionados ao modal de rotas */
.pac-container {
    z-index: 9999 !important;
    position: fixed !important;
}

    /* Container específico do modal de rotas */
    .rm-pac-container,
    #rotas-modal ~ .pac-container,
    .pac-container[data-rm-container="true"] {
        z-index: 9999 !important;
        position: fixed !important;
        background-color: white !important;
        border: 1px solid #ccc !important;
        border-radius: 0.375rem !important;
        box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075), 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1) !important;
        font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
        max-height: 280px !important;
        overflow-y: auto !important;
        min-width: 300px !important;
        font-size: 14px !important;
    }

        /* Estado ativo do container */
        .rm-pac-container.rm-active {
            display: block !important;
            opacity: 1 !important;
            visibility: visible !important;
        }

        /* ===== ITENS DO AUTOCOMPLETE ===== */
        .rm-pac-container .pac-item,
        .pac-container[data-rm-container="true"] .pac-item {
            padding: 12px 16px !important;
            cursor: pointer !important;
            font-size: 14px !important;
            line-height: 1.5 !important;
            border-bottom: 1px solid #f0f0f0 !important;
            transition: background-color 0.2s ease !important;
            display: flex !important;
            align-items: center !important;
        }

            .rm-pac-container .pac-item:last-child {
                border-bottom: none !important;
            }

            .rm-pac-container .pac-item:hover,
            .pac-container[data-rm-container="true"] .pac-item:hover {
                background-color: #f8f9fa !important;
            }

            .rm-pac-container .pac-item-selected,
            .rm-pac-container .pac-item:active {
                background-color: #e9ecef !important;
            }

        /* Ícone nos itens */
        .rm-pac-container .pac-icon {
            width: 20px !important;
            height: 20px !important;
            margin-right: 12px !important;
            background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%230d6efd"><path d="M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z"/></svg>') !important;
            background-size: contain !important;
            background-repeat: no-repeat !important;
            background-position: center !important;
            flex-shrink: 0 !important;
        }

        /* Texto dos itens */
        .rm-pac-container .pac-item-main {
            font-weight: 500 !important;
            color: #212529 !important;
            margin-right: 4px !important;
        }

        .rm-pac-container .pac-item-secondary {
            color: #6c757d !important;
            font-size: 13px !important;
        }

/* ===== INPUTS DO AUTOCOMPLETE ===== */
#rotas-modal .rm-autocomplete-input {
    position: relative !important;
    z-index: 1 !important;
    background-color: white !important;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out !important;
}

    #rotas-modal .rm-autocomplete-input:focus {
        border-color: #86b7fe !important;
        outline: 0 !important;
        box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25) !important;
    }

    /* Input com erro */
    #rotas-modal .rm-autocomplete-input.rm-error {
        border-color: #dc3545 !important;
    }

        #rotas-modal .rm-autocomplete-input.rm-error:focus {
            border-color: #dc3545 !important;
            box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, 0.25) !important;
        }

/* ===== LOADING INDICATOR ===== */
.rm-autocomplete-wrapper {
    position: relative !important;
}

.rm-autocomplete-loading {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    pointer-events: none;
}

    .rm-autocomplete-loading::after {
        content: "";
        display: block;
        width: 16px;
        height: 16px;
        margin: 2px;
        border: 2px solid #f3f3f3;
        border-top: 2px solid #0d6efd;
        border-radius: 50%;
        animation: rm-spin 1s linear infinite;
    }

@keyframes rm-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* ===== MAPA NO MODAL ===== */
#rotas-modal #rota-map {
    border: 1px solid #dee2e6 !important;
    border-radius: 0.375rem !important;
    overflow: hidden !important;
    background-color: #f8f9fa;
    position: relative;
}

    #rotas-modal #rota-map::before {
        content: "Carregando mapa...";
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        color: #6c757d;
        font-size: 14px;
        z-index: 0;
    }

/* ===== MENSAGENS DE STATUS ===== */
.rm-status-message {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(13, 110, 253, 0.9);
    color: white;
    padding: 12px 24px;
    border-radius: 0.375rem;
    font-size: 14px;
    z-index: 10000;
    display: none;
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.2);
}

    .rm-status-message.rm-show {
        display: block;
        animation: rm-fade-in 0.3s ease;
    }

    .rm-status-message.rm-error {
        background: rgba(220, 53, 69, 0.9);
    }

    .rm-status-message.rm-success {
        background: rgba(25, 135, 84, 0.9);
    }

@keyframes rm-fade-in {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* ===== SCROLLBAR CUSTOMIZADA ===== */
.rm-pac-container::-webkit-scrollbar {
    width: 6px;
}

.rm-pac-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.rm-pac-container::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

    .rm-pac-container::-webkit-scrollbar-thumb:hover {
        background: #555;
    }

/* ===== RESPONSIVIDADE ===== */
@media (max-width: 768px) {
    .rm-pac-container,
    .pac-container[data-rm-container="true"] {
        max-width: calc(100vw - 20px) !important;
        left: 10px !important;
        right: 10px !important;
        min-width: auto !important;
    }

    #rotas-modal .modal-dialog {
        margin: 0.5rem;
    }

    #rotas-modal #rota-map {
        height: 150px !important;
    }
}

@media (max-width: 576px) {
    .rm-pac-container .pac-item {
        padding: 10px 12px !important;
        font-size: 13px !important;
    }

    .rm-pac-container .pac-icon {
        width: 16px !important;
        height: 16px !important;
        margin-right: 8px !important;
    }
}

/* ===== FIXES PARA SOBREPOSIÇÃO ===== */
#rotas-modal .form-control:focus + .rm-pac-container {
    margin-top: 5px;
}

/* Garantir que o autocomplete apareça sobre outros elementos */
.pac-container {
    z-index: 9999 !important;
}

/* Fix para Bootstrap modals */
.modal-open .pac-container {
    z-index: 10000 !important;
}

/* ===== ANIMAÇÕES SUAVES ===== */
.rm-pac-container {
    animation: rm-slide-down 0.2s ease-out;
}

@keyframes rm-slide-down {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== INDICADORES VISUAIS ===== */
#rotas-modal .rm-required-indicator {
    color: #dc3545;
    font-weight: bold;
    margin-left: 2px;
}

/* Badge de rotas encontradas */
.rm-routes-found-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #28a745;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* ===== AJUSTES PARA BLAZOR ===== */
/* Fix para renderização do Blazor */
#rotas-modal .pac-container {
    font-family: inherit !important;
}

/* Garantir visibilidade durante re-renderização */
.blazor-error-boundary {
    z-index: 9998 !important;
}

/* ===== TEMA ESCURO (OPCIONAL) ===== */
@media (prefers-color-scheme: dark) {
    .rm-pac-container,
    .pac-container[data-rm-container="true"] {
        background-color: #212529 !important;
        border-color: #495057 !important;
        color: #f8f9fa !important;
    }

        .rm-pac-container .pac-item {
            border-bottom-color: #343a40 !important;
            color: #f8f9fa !important;
        }

            .rm-pac-container .pac-item:hover {
                background-color: #343a40 !important;
            }

        .rm-pac-container .pac-item-main {
            color: #f8f9fa !important;
        }

        .rm-pac-container .pac-item-secondary {
            color: #adb5bd !important;
        }
}
