/**
 * AjudaAqui - Estilos Customizados
 *
 * Complementa Tailwind CSS com estilos específicos
 * Mobile-first, otimizado para conexões lentas
 */

/* === RESET/BASE === */
* {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* === ANIMAÇÃO PULSANTE (marker crítico) === */
@keyframes pulse-critical {
    0% {
        box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.7);
    }
    70% {
        box-shadow: 0 0 0 12px rgba(220, 38, 38, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(220, 38, 38, 0);
    }
}

.marker-critico {
    animation: pulse-critical 2s infinite;
}

/* === MARKERS DO MAPA === */
.custom-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    color: white;
    font-size: 14px;
    cursor: pointer;
    transition: transform 0.2s;
}

.custom-marker:hover {
    transform: scale(1.15);
}

.marker-critico { width: 40px; height: 40px; background-color: #DC2626; }
.marker-alto    { width: 36px; height: 36px; background-color: #F97316; }
.marker-medio   { width: 32px; height: 32px; background-color: #F59E0B; }
.marker-baixo   { width: 28px; height: 28px; background-color: #22C55E; }

/* Marker da posição do usuário */
.marker-usuario {
    width: 16px;
    height: 16px;
    background-color: #2563EB;
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.3);
}

/* === POPUP DO MAPA === */
.leaflet-popup-content-wrapper {
    border-radius: 12px !important;
    padding: 0 !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

.leaflet-popup-content {
    margin: 0 !important;
    min-width: 250px;
}

.popup-card {
    padding: 12px;
}

.popup-card .popup-title {
    font-weight: 600;
    font-size: 14px;
    color: #111827;
    margin-bottom: 6px;
    line-height: 1.3;
}

.popup-card .popup-info {
    font-size: 12px;
    color: #6B7280;
}

.popup-card .popup-btn {
    display: inline-block;
    margin-top: 8px;
    padding: 6px 12px;
    background-color: #DC2626;
    color: white;
    border-radius: 6px;
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
    transition: background-color 0.2s;
}

.popup-card .popup-btn:hover {
    background-color: #B91C1C;
}

/* === CARDS === */
.card-ocorrencia {
    transition: transform 0.2s, box-shadow 0.2s;
}

.card-ocorrencia:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

/* === BADGES DE URGÊNCIA === */
.badge-critico { background-color: #DC2626; color: white; }
.badge-alto    { background-color: #F97316; color: white; }
.badge-medio   { background-color: #F59E0B; color: white; }
.badge-baixo   { background-color: #22C55E; color: white; }

/* === CHAT === */
.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 180px);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    scroll-behavior: smooth;
}

.chat-bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 16px;
    margin-bottom: 8px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.chat-bubble-sent {
    background-color: #DC2626;
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.chat-bubble-received {
    background-color: #F3F4F6;
    color: #111827;
    margin-right: auto;
    border-bottom-left-radius: 4px;
}

.chat-input-area {
    padding: 12px 16px;
    border-top: 1px solid #E5E7EB;
    background: white;
}

/* === GALERIA DE FOTOS === */
.galeria-fotos {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 8px 0;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}

.galeria-foto-wrapper {
    position: relative;
    flex-shrink: 0;
    scroll-snap-align: start;
    width: 200px;
    height: 150px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    background: #F3F4F6;
}

.galeria-foto-wrapper .foto-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9CA3AF;
    font-size: 24px;
}

.galeria-foto-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.3s, transform 0.2s;
}

.galeria-foto-wrapper:hover img {
    transform: scale(1.05);
    opacity: 0.9;
}

.galeria-foto-count {
    position: absolute;
    bottom: 6px;
    right: 6px;
    background: rgba(0,0,0,0.6);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    pointer-events: none;
}

/* === LIGHTBOX === */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    user-select: none;
}

.lightbox img {
    max-width: 90%;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 8px;
}

.lightbox-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(255,255,255,0.15);
    color: white;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    z-index: 10;
}

.lightbox-close:hover {
    background: rgba(255,255,255,0.3);
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.15);
    color: white;
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    z-index: 10;
}

.lightbox-nav:hover {
    background: rgba(255,255,255,0.3);
}

.lightbox-prev { left: 16px; }
.lightbox-next { right: 16px; }

.lightbox-counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255,255,255,0.8);
    font-size: 14px;
    font-weight: 500;
    z-index: 10;
}

@media (max-width: 768px) {
    .lightbox-nav {
        width: 56px;
        height: 56px;
        font-size: 22px;
    }
    .lightbox-prev { left: 8px; }
    .lightbox-next { right: 8px; }
    .lightbox-close {
        top: 12px;
        right: 12px;
        width: 48px;
        height: 48px;
    }
}

/* Card foto count badge */
.card-foto-count {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    color: #6B7280;
}

/* === LOADING SKELETON === */
.skeleton {
    background: linear-gradient(90deg, #F3F4F6 25%, #E5E7EB 50%, #F3F4F6 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 8px;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* === FLASH MESSAGES === */
.flash-message {
    animation: flash-in 0.3s ease-out;
}

@keyframes flash-in {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Auto-fechar flash após 5s */
.flash-message {
    animation: flash-in 0.3s ease-out, flash-out 0.5s ease-in 5s forwards;
}

@keyframes flash-out {
    to {
        opacity: 0;
        transform: translateY(-10px);
        height: 0;
        padding: 0;
        margin: 0;
        overflow: hidden;
    }
}

/* === TABS === */
.tab-active {
    border-bottom: 2px solid #DC2626;
    color: #DC2626;
    font-weight: 600;
}

/* === RESPONSIVO: Mapa na home === */

/* Container principal — subtrai navbar (56px) + barra de visualização (~44px) */
.home-layout {
    display: flex;
    height: calc(100vh - 100px);
}

.home-mapa {
    flex: 1;
    min-height: 200px;
    position: relative;
}

.home-feed {
    width: 420px;
    overflow-y: auto;
    border-left: 1px solid #E5E7EB;
}

/* Modo: só mapa */
.home-layout.view-mapa .home-mapa {
    flex: 1;
    width: 100%;
}
.home-layout.view-mapa .home-feed {
    display: none;
}

/* Modo: só feed */
.home-layout.view-feed .home-mapa {
    display: none;
}
.home-layout.view-feed .home-feed {
    flex: 1;
    width: 100%;
    max-width: 100%;
    border-left: none;
}

/* Modo: ambos (lado a lado) */
.home-layout.view-ambos .home-mapa {
    flex: 1;
}
.home-layout.view-ambos .home-feed {
    display: block;
    width: 420px;
}

/* Mobile */
@media (max-width: 768px) {
    .home-layout {
        flex-direction: column;
        height: auto;
        min-height: calc(100vh - 56px);
        overflow-y: auto;
    }

    /* Mobile mapa: altura fixa, flex desligado para height% funcionar no filho */
    .home-mapa {
        flex: none !important;
        height: 55vh;
        min-height: 350px;
        width: 100%;
    }

    /* Mobile feed: cresce abaixo do mapa */
    .home-feed {
        width: 100%;
        border-left: none;
        flex: 1;
        min-height: 200px;
    }

    /* Modo só mapa: mapa ocupa tudo */
    .home-layout.view-mapa .home-mapa {
        height: calc(100vh - 56px);
    }

    /* Modo só feed: feed ocupa tudo */
    .home-layout.view-feed .home-feed {
        height: 100%;
        width: 100%;
    }
}

/* === SCROLLBAR CUSTOMIZADA === */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #D1D5DB;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #9CA3AF;
}

/* === FILTROS === */
.filtro-chip {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid #E5E7EB;
    background: white;
    color: #374151;
}

.filtro-chip.ativo {
    background: #DC2626;
    color: white;
    border-color: #DC2626;
}

.filtro-chip:hover {
    border-color: #DC2626;
}

/* === MARKERS PONTO DE APOIO (Pin com label) === */
.pa-marker-pin {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: transform 0.2s;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.pa-marker-pin:hover {
    transform: scale(1.12);
}

.pa-marker-top {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    border: 2px solid white;
}

.pa-marker-label {
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.5px;
    padding: 1px 6px;
    border-radius: 4px;
    margin-top: -2px;
    border: 1.5px solid;
    white-space: nowrap;
    line-height: 14px;
}

.pa-marker-arrow {
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid;
    margin-top: -1px;
}

.pa-marker-lotado {
    position: absolute;
    top: -4px;
    right: -8px;
    background: #F59E0B;
    color: white;
    font-size: 7px;
    font-weight: 800;
    padding: 1px 4px;
    border-radius: 3px;
    letter-spacing: 0.3px;
}

/* Toggle buttons para pontos de apoio */
.toggle-ponto-apoio {
    transition: all 0.2s;
}

.toggle-ponto-apoio.opacity-40 {
    opacity: 0.4;
}

/* Legenda do mapa */
.mapa-legenda {
    background: white;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 11px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    line-height: 1.6;
}

.mapa-legenda-item {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.mapa-legenda-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.15);
    flex-shrink: 0;
}

.mapa-legenda-pin {
    width: 12px;
    height: 16px;
    border-radius: 4px 4px 2px 2px;
    border: 2px solid white;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.15);
    flex-shrink: 0;
}

/* === EMPTY STATE === */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #9CA3AF;
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
}

/* === CLIMA TIMELINE === */
.clima-timeline {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    padding: 8px 0 4px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.clima-timeline::-webkit-scrollbar {
    height: 4px;
}

.clima-timeline::-webkit-scrollbar-thumb {
    background: #D1D5DB;
    border-radius: 2px;
}

.clima-timeline-slot {
    flex-shrink: 0;
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 10px;
    border-radius: 10px;
    background: #F9FAFB;
    border: 1px solid #F3F4F6;
    min-width: 64px;
    font-size: 11px;
    color: #6B7280;
    transition: background 0.2s, border-color 0.2s;
}

.clima-timeline-slot:hover {
    background: #F3F4F6;
    border-color: #E5E7EB;
}

.clima-timeline-slot .slot-hora {
    font-weight: 600;
    color: #374151;
    font-size: 12px;
}

.clima-timeline-slot .slot-icone {
    font-size: 16px;
}

.clima-timeline-slot .slot-temp {
    font-weight: 600;
    color: #111827;
    font-size: 13px;
}

.clima-timeline-slot .slot-chuva {
    color: #3B82F6;
    font-weight: 500;
}

.clima-timeline-slot.chuva-alta {
    background: #EFF6FF;
    border-color: #BFDBFE;
}

/* === HOME VOLUNTÁRIOS / HISTÓRICO === */
.home-voluntarios,
.home-historico {
    width: 420px;
    overflow-y: auto;
    border-left: 1px solid #E5E7EB;
}

/* Desktop: mesma largura que feed */
.home-layout.view-voluntarios .home-mapa,
.home-layout.view-historico .home-mapa {
    flex: 1;
}
.home-layout.view-voluntarios .home-feed,
.home-layout.view-historico .home-feed {
    display: none;
}

/* Card compacto de voluntário na home */
.vol-card-compact {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: white;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.vol-card-compact:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.vol-card-compact .vol-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.vol-card-compact .vol-avatar-placeholder {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    flex-shrink: 0;
}

.vol-card-compact .vol-info {
    flex: 1;
    min-width: 0;
}

.vol-card-compact .vol-nome {
    font-weight: 600;
    font-size: 14px;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.vol-card-compact .vol-habilidades {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.vol-card-compact .vol-hab-chip {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    background: #F3F4F6;
    color: #6B7280;
    white-space: nowrap;
}

/* Filtro chips de habilidade na home */
.hab-filter-chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid #E5E7EB;
    background: white;
    color: #374151;
    transition: all 0.2s;
}

.hab-filter-chip.ativo {
    background: #DC2626;
    color: white;
    border-color: #DC2626;
}

.hab-filter-chip:hover {
    border-color: #DC2626;
}

@media (max-width: 768px) {
    .home-voluntarios,
    .home-historico {
        width: 100%;
        border-left: none;
        flex: 1;
        min-height: 200px;
    }
}
