:root {
    --primary: #C52726;
    --primary-dark: #991C1C;
    --text-light: #ffffff;
    --text-dark: #333333;
    --bg-light: #f8f9fa;
    --bg-dark: #212529;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--text-dark);
}

/* Mapa em tela cheia */
#map {
    height: 100vh;
    width: 100vw;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1;
}

/* Sidebar oculta por padrão */
.sidebar {
    position: fixed;
    top: 0;
    left: -400px;
    width: 400px;
    height: 100vh;
    background: white;
    box-shadow: 2px 0 15px rgba(0, 0, 0, 0.2);
    transition: left 0.3s ease;
    z-index: 1001;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar.open {
    left: 0;
}

/* Botão para abrir sidebar */
.sidebar-toggle {
    position: fixed;
    top: 80px;
    left: 20px;
    z-index: 1001;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 16px;
    box-shadow: 0 4px 15px rgba(197, 39, 38, 0.4);
    cursor: pointer;
    transition: all 0.3s ease;
    animation: pulse 2s infinite;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-toggle.hidden-for-popup {
    opacity: 0.3;
    pointer-events: none;
}

.sidebar-toggle:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

.sidebar-toggle.hidden {
    display: none;
}

@keyframes pulse {
    0% {
        box-shadow: 0 4px 15px rgba(197, 39, 38, 0.4);
    }

    50% {
        box-shadow: 0 4px 25px rgba(197, 39, 38, 0.7);
    }

    100% {
        box-shadow: 0 4px 15px rgba(197, 39, 38, 0.4);
    }
}

/* Controles do mapa sobrepostos */
.map-controls {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: opacity 0.3s ease;
}

.map-controls.hidden-for-popup {
    opacity: 0.3;
    pointer-events: none;
}

.map-control-btn {
    background: rgba(255, 255, 255, 0.95);
    border: none;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-dark);
    font-size: 16px;
    min-width: 50px;
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.map-control-btn:hover {
    background: rgba(255, 255, 255, 1);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.map-control-btn.active {
    background: var(--primary);
    color: white;
}

/* Seletor de camadas do mapa */
.map-layers {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    transition: opacity 0.3s ease;
}

.map-layers.hidden-for-popup {
    opacity: 0.3;
    pointer-events: none;
}

.layer-button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 15px;
    border: none;
    background: transparent;
    color: var(--text-dark);
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s ease;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.layer-button:last-child {
    border-bottom: none;
}

.layer-button:hover {
    background: rgba(197, 39, 38, 0.1);
}

.layer-button.active {
    background: var(--primary);
    color: white;
}

/* Sidebar header - com botão fechar inline */
.sidebar-header {
    background: var(--primary);
    color: white;
    padding: 1rem;
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.sidebar-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.sidebar-content {
    padding: 1rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

/* Logo */
.logo-container {
    background: #C52726;
    padding: 1rem;
    text-align: center;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.logo {
    height: 40px;
    width: auto;
}

/* Competidor simplificado */
.competitor-simple {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 12px;
    margin: 8px 0;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.competitor-simple:hover {
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 2px 8px rgba(197, 39, 38, 0.1);
}

.competitor-simple.selected {
    border-color: var(--primary);
    background: #fff5f5;
}

.competitor-check {
    position: absolute;
    top: 12px;
    right: 12px;
    color: var(--primary);
    font-size: 18px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.competitor-simple.selected .competitor-check {
    opacity: 1;
}

/* Modal de detalhes do competidor */
.competitor-details-modal .modal-dialog {
    max-width: 500px;
}

/* Overlay quando sidebar está aberta */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

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

/* Custom markers */
.custom-marker {
    border: none !important;
    background: transparent !important;
}

/* Estilos para popups */
.special-popup h6 {
    margin-bottom: 8px;
    color: var(--primary);
}

.special-popup .badge {
    font-size: 0.75rem;
}

.special-popup hr {
    margin: 8px 0;
}

.special-popup small {
    line-height: 1.4;
}

.support-popup h6 {
    margin-bottom: 8px;
    color: #28a745;
}

.support-popup .badge {
    font-size: 0.75rem;
}

/* Popups normais do Leaflet */
.leaflet-popup-content-wrapper {
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.leaflet-popup-content {
    margin: 12px 16px;
    line-height: 1.4;
}

/* Lista de competidores */
.competitors-list {
    flex-grow: 1;
    overflow-y: auto;
    padding-right: 4px;
}

/* Contador de selecionados */
.selected-counter {
    background: var(--bg-light);
    padding: 0.75rem;
    border-radius: 8px;
    margin-top: 1rem;
    text-align: center;
    font-size: 0.9rem;
}

/* Botão de rota personalizado */
.route-btn {
    background: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    margin-top: 8px;
    cursor: pointer;
    transition: background 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.route-btn:hover {
    background: #0056b3;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 100vw;
        left: -100vw;
    }

    .sidebar.open {
        left: 0;
    }

    .map-controls {
        bottom: 80px;
        right: 10px;
    }

    .sidebar-toggle {
        padding: 10px 12px;
        font-size: 14px;
        top: 60px;
    }

    .map-layers {
        right: 10px;
        top: 10px;
    }
}