/* ==============================================
   SOS87 Mapa de Ocorrências - CSS Principal
   Versão: 1.2
   Responsivo e otimizado para mobile/desktop
   Com suporte a usuários online
=============================================== */

/* Container principal do mapa */
.sos87-mapa-container {
    position: relative;
    width: 100%;
    height: 600px;
    min-height: 400px;
    border: 2px solid #0073aa;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 25px rgba(0, 115, 170, 0.15);
    margin: 20px 0;
    background: #f8fafc;
}

/* Mapa Leaflet */
#sos87-mapa {
    width: 100% !important;
    height: 100% !important;
    z-index: 1;
    background: #e9ecef !important;
}

/* Estado de carregamento do mapa */
.sos87-mapa-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 20px 30px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    text-align: center;
    z-index: 2;
    border: 2px solid #0073aa;
}

/* Botões de controle */
.sos87-fullscreen-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 1000;
    background: linear-gradient(135deg, #0073aa 0%, #005a87 100%);
    color: white;
    border: 2px solid white;
    border-radius: 8px;
    padding: 12px 18px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.sos87-fullscreen-btn:hover {
    background: linear-gradient(135deg, #005a87 0%, #004670 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.4);
}

/* Botão de abrir painel */
.sos87-toggle-painel {
    position: absolute;
    top: 15px;
    right: 165px;
    z-index: 1000;
    background: linear-gradient(135deg, #28a745 0%, #218838 100%);
    color: white;
    border: 2px solid white;
    border-radius: 8px;
    padding: 12px 15px;
    cursor: pointer;
    font-size: 16px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    transition: all 0.3s ease;
}

.sos87-toggle-painel:hover {
    background: linear-gradient(135deg, #218838 0%, #1e7e34 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.4);
}

/* Botão de fechar painel */
.sos87-toggle-painel-fechar {
    position: absolute;
    top: 15px;
    right: 165px;
    z-index: 1001;
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: white;
    border: 2px solid white;
    border-radius: 8px;
    padding: 12px 15px;
    cursor: pointer;
    font-size: 16px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    transition: all 0.3s ease;
}

.sos87-toggle-painel-fechar:hover {
    background: linear-gradient(135deg, #c82333 0%, #bd2130 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.4);
}

/* Botão de usuários online */
.sos87-toggle-usuarios {
    position: absolute;
    top: 15px;
    left: 15px;
    z-index: 1000;
    background: linear-gradient(135deg, #17a2b8 0%, #138496 100%);
    color: white;
    border: 2px solid white;
    border-radius: 8px;
    padding: 12px 18px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.sos87-toggle-usuarios:hover {
    background: linear-gradient(135deg, #138496 0%, #117a8b 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.4);
}

/* Painel lateral */
.sos87-painel {
    position: absolute;
    top: 0;
    right: -420px;
    width: 400px;
    height: 100%;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    z-index: 999;
    box-shadow: -5px 0 25px rgba(0,0,0,0.15);
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    padding: 0;
    border-left: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
}

.sos87-painel.open {
    right: 0;
}

/* Cabeçalho do painel */
.sos87-painel-header {
    background: linear-gradient(135deg, #0073aa 0%, #005a87 100%);
    padding: 20px;
    color: white;
    border-bottom: 3px solid #004670;
}

.sos87-painel-header h3 {
    margin: 0 0 15px 0;
    font-size: 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Container de busca */
.sos87-search-container {
    position: relative;
}

.sos87-search {
    width: 100%;
    padding: 14px 20px 14px 50px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

.sos87-search:focus {
    outline: none;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    background: white;
}

.sos87-search::placeholder {
    color: #94a3b8;
}

.sos87-search-container::before {
    content: '🔍';
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    color: #64748b;
    z-index: 2;
}

/* Estatísticas */
.sos87-stats {
    display: flex;
    justify-content: space-between;
    margin: 20px;
    padding: 20px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    border: 1px solid #e2e8f0;
}

.sos87-stat {
    text-align: center;
    flex: 1;
    padding: 0 10px;
}

.sos87-stat-num {
    display: block;
    font-size: 28px;
    font-weight: 700;
    color: #0073aa;
    margin-bottom: 5px;
    line-height: 1;
}

.sos87-stat-label {
    font-size: 13px;
    color: #64748b;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Seção de usuários online */
.sos87-usuarios-online {
    flex: 1;
    overflow-y: auto;
    padding: 0 20px 20px;
    display: none;
}

.sos87-usuarios-header {
    margin-bottom: 20px;
}

.sos87-usuarios-header h4 {
    color: #2c3e50;
    font-size: 18px;
    margin: 0 0 15px 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sos87-usuarios-search-container {
    position: relative;
}

.sos87-usuarios-search {
    width: 100%;
    padding: 12px 20px 12px 45px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    background: white;
    transition: all 0.3s ease;
}

.sos87-usuarios-search:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}

.sos87-usuarios-search::placeholder {
    color: #94a3b8;
}

.sos87-usuarios-search-container::before {
    content: '🔍';
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    color: #64748b;
    z-index: 2;
}

/* Lista de usuários */
.sos87-usuarios-lista {
    flex: 1;
    overflow-y: auto;
}

.sos87-usuario-item {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 18px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 3px 8px rgba(0,0,0,0.05);
}

.sos87-usuario-item:hover {
    background: #f8fafc;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.1);
    border-color: #cbd5e1;
}

.sos87-usuario-item.ativo {
    background: #e3f2fd;
    border-color: #0073aa;
    border-left: 4px solid #0073aa;
}

.sos87-usuario-item.status-online {
    border-left: 4px solid #28a745;
}

.sos87-usuario-item.status-away {
    border-left: 4px solid #ffc107;
}

.sos87-usuario-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.sos87-usuario-nome {
    font-weight: 600;
    color: #1e293b;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sos87-usuario-tempo {
    font-size: 12px;
    color: #64748b;
    background: #f1f5f9;
    padding: 4px 8px;
    border-radius: 4px;
}

.sos87-usuario-content {
    margin-bottom: 12px;
}

.sos87-usuario-content p {
    margin: 6px 0;
    color: #475569;
    font-size: 13px;
    line-height: 1.4;
}

.sos87-usuario-content strong {
    color: #2c3e50;
    font-weight: 600;
}

.sos87-usuario-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.sos87-btn-focar-usuario {
    background: linear-gradient(135deg, #007bff 0%, #0069d9 100%);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
    flex: 1;
    min-width: 100px;
    justify-content: center;
}

.sos87-btn-focar-usuario:hover {
    background: linear-gradient(135deg, #0069d9 0%, #005cbf 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.sos87-sem-localizacao {
    font-size: 12px;
    color: #94a3b8;
    font-style: italic;
    text-align: center;
    padding: 10px;
    background: #f8fafc;
    border-radius: 6px;
    border: 1px dashed #e2e8f0;
    margin: 0;
}

/* Lista de ocorrências */
.sos87-lista {
    flex: 1;
    overflow-y: auto;
    padding: 0 20px 20px;
}

.sos87-loading {
    text-align: center;
    padding: 40px 20px;
    color: #64748b;
    font-size: 16px;
    background: white;
    border-radius: 8px;
    border: 2px dashed #e2e8f0;
}

.sos87-loading i {
    margin-right: 10px;
    color: #0073aa;
    font-size: 18px;
}

/* Itens de ocorrência */
.sos87-ocorrencia {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 3px 8px rgba(0,0,0,0.05);
    position: relative;
}

.sos87-ocorrencia:hover {
    background: #f1f5f9;
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.1);
    border-color: #cbd5e1;
}

.sos87-ocorrencia.ativo {
    background: #dbf0ff;
    border-color: #0073aa;
    border-left: 5px solid #0073aa;
}

.sos87-ocorrencia-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.sos87-ocorrencia-id {
    font-weight: 700;
    color: #1e293b;
    font-size: 16px;
    background: #f1f5f9;
    padding: 4px 10px;
    border-radius: 6px;
}

.sos87-ocorrencia-data {
    font-size: 12px;
    color: #64748b;
    background: #f8fafc;
    padding: 4px 8px;
    border-radius: 4px;
}

.sos87-ocorrencia-content {
    margin-bottom: 15px;
}

.sos87-ocorrencia-content p {
    margin: 8px 0;
    color: #475569;
    font-size: 14px;
    line-height: 1.5;
}

.sos87-ocorrencia-content strong {
    color: #1e293b;
    font-weight: 600;
}

/* Botões de ação */
.sos87-action-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.sos87-btn {
    padding: 10px 15px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    flex: 1;
    justify-content: center;
    text-decoration: none;
    min-width: 80px;
}

.sos87-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    text-decoration: none;
}

.sos87-btn-chat {
    background: linear-gradient(135deg, #17a2b8 0%, #138496 100%);
    color: white;
}

.sos87-btn-chat:hover {
    background: linear-gradient(135deg, #138496 0%, #117a8b 100%);
}

.sos87-btn-rota {
    background: linear-gradient(135deg, #28a745 0%, #218838 100%);
    color: white;
}

.sos87-btn-rota:hover {
    background: linear-gradient(135deg, #218838 0%, #1e7e34 100%);
}

.sos87-btn-focar {
    background: linear-gradient(135deg, #007bff 0%, #0069d9 100%);
    color: white;
}

.sos87-btn-focar:hover {
    background: linear-gradient(135deg, #0069d9 0%, #005cbf 100%);
}

/* Prioridades */
.prioridade-baixa {
    border-left: 5px solid #28a745;
}

.prioridade-media {
    border-left: 5px solid #ffc107;
}

.prioridade-alta {
    border-left: 5px solid #fd7e14;
}

.prioridade-maximo {
    border-left: 5px solid #dc3545;
}

/* Notificações */
.sos87-notificacao {
    position: fixed;
    top: 30px;
    right: 30px;
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 8px 25px rgba(220, 53, 69, 0.4);
    z-index: 9999;
    animation: sos87SlideIn 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 15px;
    min-width: 300px;
    max-width: 400px;
    border: 2px solid white;
}

.sos87-notificacao i {
    font-size: 24px;
    background: rgba(255, 255, 255, 0.2);
    padding: 10px;
    border-radius: 50%;
}

.sos87-notificacao-conteudo {
    flex: 1;
    font-size: 14px;
    line-height: 1.5;
}

.sos87-notificacao-conteudo strong {
    display: block;
    font-size: 16px;
    margin-bottom: 5px;
}

@keyframes sos87SlideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Estilos dos marcadores */
.custom-marker {
    filter: drop-shadow(0 3px 5px rgba(0,0,0,0.3));
}

.marker-prioridade-baixa .leaflet-marker-icon {
    background-color: #28a745 !important;
}

.marker-prioridade-media .leaflet-marker-icon {
    background-color: #ffc107 !important;
}

.marker-prioridade-alta .leaflet-marker-icon {
    background-color: #fd7e14 !important;
}

.marker-prioridade-maximo .leaflet-marker-icon {
    background-color: #dc3545 !important;
}

/* Estilos para marcadores de usuários */
.sos87-usuario-marker {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.7);
    }
    70% {
        transform: scale(1.05);
        box-shadow: 0 0 0 10px rgba(40, 167, 69, 0);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0);
    }
}

/* Popup de usuário online */
.sos87-usuario-popup .leaflet-popup-content {
    font-family: Arial, sans-serif;
    line-height: 1.4;
}

.sos87-usuario-status {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 5px;
}

.sos87-usuario-status.online {
    background-color: #28a745;
    animation: status-pulse 1.5s infinite;
}

.sos87-usuario-status.away {
    background-color: #ffc107;
}

@keyframes status-pulse {
    0% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
    100% {
        opacity: 1;
    }
}

/* Scrollbar personalizada */
.sos87-painel::-webkit-scrollbar,
.sos87-lista::-webkit-scrollbar,
.sos87-usuarios-lista::-webkit-scrollbar {
    width: 8px;
}

.sos87-painel::-webkit-scrollbar-track,
.sos87-lista::-webkit-scrollbar-track,
.sos87-usuarios-lista::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

.sos87-painel::-webkit-scrollbar-thumb,
.sos87-lista::-webkit-scrollbar-thumb,
.sos87-usuarios-lista::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.sos87-painel::-webkit-scrollbar-thumb:hover,
.sos87-lista::-webkit-scrollbar-thumb:hover,
.sos87-usuarios-lista::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Responsividade */
@media (max-width: 1024px) {
    .sos87-painel {
        width: 350px;
        right: -370px;
    }
    
    .sos87-stats {
        flex-direction: column;
        gap: 15px;
    }
    
    .sos87-stat {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0;
    }
    
    .sos87-stat-num {
        margin-bottom: 0;
    }
}

@media (max-width: 768px) {
    .sos87-mapa-container {
        height: 500px;
        border-radius: 8px;
    }
    
    .sos87-painel {
        width: 85%;
        right: -90%;
        max-width: 320px;
    }
    
    .sos87-toggle-painel,
    .sos87-toggle-painel-fechar {
        right: 70px;
        width: 44px;
        height: 44px;
        padding: 10px;
    }
    
    .sos87-toggle-usuarios {
        left: 10px;
        padding: 10px 15px;
    }
    
    .sos87-fullscreen-btn {
        right: 10px;
        padding: 10px 15px;
    }
    
    .sos87-fullscreen-btn .sos87-btn-text,
    .sos87-toggle-usuarios .sos87-btn-text {
        display: none;
    }
    
    .sos87-action-buttons,
    .sos87-usuario-actions {
        flex-direction: column;
    }
    
    .sos87-btn,
    .sos87-btn-focar-usuario {
        width: 100%;
    }
    
    .sos87-notificacao {
        left: 20px;
        right: 20px;
        min-width: auto;
        max-width: none;
    }
}

@media (max-width: 480px) {
    .sos87-mapa-container {
        height: 400px;
    }
    
    .sos87-painel {
        width: 95%;
        right: -100%;
    }
    
    .sos87-painel.open {
        right: 0;
    }
    
    .sos87-stats {
        margin: 15px;
        padding: 15px;
    }
    
    .sos87-painel-header {
        padding: 15px;
    }
    
    .sos87-ocorrencia,
    .sos87-usuario-item {
        padding: 15px;
    }
    
    .sos87-ocorrencia-header,
    .sos87-usuario-header {
        flex-direction: column;
        gap: 8px;
    }
    
    .sos87-ocorrencia-id,
    .sos87-ocorrencia-data,
    .sos87-usuario-nome,
    .sos87-usuario-tempo {
        width: 100%;
        text-align: center;
    }
}

/* Modo tela cheia */
.sos87-mapa-container:fullscreen {
    height: 100vh !important;
    border-radius: 0;
    border: none;
}

.sos87-mapa-container:fullscreen #sos87-mapa {
    height: 100vh !important;
}

/* Estados dos botões */
.sos87-btn:active,
.sos87-btn-focar-usuario:active {
    transform: translateY(0);
}

/* Texto escondido em mobile */
@media (max-width: 768px) {
    .sos87-btn-text {
        display: none;
    }
}

/* Animações de transição */
.sos87-ocorrencia,
.sos87-usuario-item {
    animation: sos87FadeIn 0.5s ease-out;
}

@keyframes sos87FadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}