/**
 * Estilos para MapViewer
 * Sistema de mapa interativo para favoritos geolocalizados
 */

/* Container do mapa */
.map-container {
    width: 100%;
    height: 400px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    position: relative;
}

.map-container.fullscreen {
    height: 80vh;
    min-height: 500px;
}

/* Marcador de localização do usuário */
.user-location-marker {
    background: transparent !important;
    border: none !important;
}

.user-marker-container {
    position: relative;
    width: 20px;
    height: 20px;
}

.user-marker-dot {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 12px;
    height: 12px;
    background: #2563eb;
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    z-index: 2;
}

.user-marker-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    background: rgba(37, 99, 235, 0.3);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    70% {
        transform: translate(-50%, -50%) scale(2);
        opacity: 0;
    }
    100% {
        transform: translate(-50%, -50%) scale(2);
        opacity: 0;
    }
}

/* Marcadores de favoritos */
.favorite-marker {
    background: transparent !important;
    border: none !important;
}

.favorite-marker-container {
    width: 30px;
    height: 30px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    border: 3px solid white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.2s ease;
}

.favorite-marker-container:hover {
    transform: rotate(-45deg) scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.favorite-marker-icon {
    transform: rotate(45deg);
    color: white;
    font-weight: bold;
    font-size: 14px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Cores dos marcadores por distância */
.favorite-marker-very-close .favorite-marker-container {
    background-color: #16a34a;
}

.favorite-marker-close .favorite-marker-container {
    background-color: #2563eb;
}

.favorite-marker-moderate .favorite-marker-container {
    background-color: #ca8a04;
}

.favorite-marker-far .favorite-marker-container {
    background-color: #dc2626;
}

/* Popup de favorito */
.favorite-popup .leaflet-popup-content-wrapper {
    border-radius: 8px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.favorite-popup .leaflet-popup-content {
    margin: 0;
    padding: 16px;
    font-family: inherit;
}

.favorite-popup-content {
    min-width: 250px;
}

.favorite-popup-content img {
    border-radius: 6px;
}

.favorite-popup-content h3 {
    margin: 0 0 4px 0;
    font-size: 16px;
}

.favorite-popup-content p {
    margin: 0 0 8px 0;
}

.favorite-popup-content .flex {
    display: flex;
}

.favorite-popup-content .gap-1 {
    gap: 4px;
}

.favorite-popup-content .gap-2 {
    gap: 8px;
}

.favorite-popup-content .gap-3 {
    gap: 12px;
}

.favorite-popup-content .flex-1 {
    flex: 1;
}

.favorite-popup-content .min-w-0 {
    min-width: 0;
}

.favorite-popup-content .truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.favorite-popup-content .flex-wrap {
    flex-wrap: wrap;
}

.favorite-popup-content .items-center {
    align-items: center;
}

.favorite-popup-content .justify-center {
    justify-content: center;
}

.favorite-popup-content .text-center {
    text-align: center;
}

.favorite-popup-content .mt-3 {
    margin-top: 12px;
}

.favorite-popup-content .mb-2 {
    margin-bottom: 8px;
}

.favorite-popup-content .mb-3 {
    margin-bottom: 12px;
}

/* Popup de localização do usuário */
.user-location-popup h3 {
    margin: 0 0 8px 0;
    color: #2563eb;
}

.user-location-popup p {
    margin: 0 0 4px 0;
}

/* Controles do mapa */
.map-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.map-control-btn {
    background: white;
    border: 2px solid rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.map-control-btn:hover {
    background: #f3f4f6;
    border-color: rgba(0, 0, 0, 0.3);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.map-control-btn.active {
    background: #dc2626;
    color: white;
    border-color: #dc2626;
}

/* Filtros de distância no mapa */
.map-distance-filters {
    position: absolute;
    bottom: 10px;
    left: 10px;
    right: 10px;
    z-index: 1000;
    background: white;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: none;
}

.map-distance-filters.active {
    display: block;
}

.map-distance-filters h4 {
    margin: 0 0 8px 0;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
}

.distance-filter-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.distance-filter-btn {
    padding: 6px 12px;
    border: 1px solid #d1d5db;
    border-radius: 20px;
    background: white;
    color: #374151;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.distance-filter-btn:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}

.distance-filter-btn.active {
    background: #dc2626;
    color: white;
    border-color: #dc2626;
}

/* Legenda do mapa */
.map-legend {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 1000;
    background: white;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-size: 12px;
    max-width: 200px;
}

.map-legend h4 {
    margin: 0 0 8px 0;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.legend-color.very-close { background-color: #16a34a; }
.legend-color.close { background-color: #2563eb; }
.legend-color.moderate { background-color: #ca8a04; }
.legend-color.far { background-color: #dc2626; }
.legend-color.user { background-color: #2563eb; }

/* Loading do mapa */
.map-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    border-radius: 8px;
}

.map-loading-content {
    text-align: center;
    color: #6b7280;
}

.map-loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f4f6;
    border-top: 4px solid #dc2626;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 12px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsividade */
@media (max-width: 768px) {
    .map-container {
        height: 300px;
    }
    
    .map-container.fullscreen {
        height: 70vh;
        min-height: 400px;
    }
    
    .map-controls {
        top: 5px;
        right: 5px;
        gap: 4px;
    }
    
    .map-control-btn {
        width: 36px;
        height: 36px;
    }
    
    .map-distance-filters {
        bottom: 5px;
        left: 5px;
        right: 5px;
        padding: 8px;
    }
    
    .map-legend {
        top: 5px;
        left: 5px;
        padding: 8px;
        max-width: 150px;
        font-size: 11px;
    }
    
    .favorite-popup-content {
        min-width: 200px;
    }
    
    .distance-filter-buttons {
        gap: 4px;
    }
    
    .distance-filter-btn {
        padding: 4px 8px;
        font-size: 11px;
    }
}

/* Customização do Leaflet */
.leaflet-container {
    font-family: inherit;
}

.leaflet-popup-content-wrapper {
    border-radius: 8px !important;
}

.leaflet-popup-tip {
    background: white !important;
}

.leaflet-control-zoom {
    border: none !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
}

.leaflet-control-zoom a {
    border-radius: 4px !important;
    border: none !important;
    background: white !important;
    color: #374151 !important;
    font-weight: bold !important;
}

.leaflet-control-zoom a:hover {
    background: #f3f4f6 !important;
    color: #111827 !important;
}

.leaflet-control-attribution {
    background: rgba(255, 255, 255, 0.8) !important;
    font-size: 10px !important;
}

/* Animações */
.favorite-marker {
    animation: markerAppear 0.3s ease-out;
}

@keyframes markerAppear {
    0% {
        transform: scale(0) rotate(-45deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.2) rotate(-45deg);
        opacity: 0.8;
    }
    100% {
        transform: scale(1) rotate(-45deg);
        opacity: 1;
    }
}

/* Estados especiais */
.map-container.no-favorites {
    background: #f9fafb;
    display: flex;
    align-items: center;
    justify-content: center;
}

.no-favorites-message {
    text-align: center;
    color: #6b7280;
    padding: 40px 20px;
}

.no-favorites-message svg {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    color: #d1d5db;
}

.no-favorites-message h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 8px 0;
    color: #374151;
}

.no-favorites-message p {
    margin: 0 0 16px 0;
    font-size: 14px;
}

/* Estilos para componentes interativos */

/* Modal de preview do anúncio */
.ad-preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.ad-preview-modal.active {
    opacity: 1;
    visibility: visible;
}

.ad-preview-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.ad-preview-content {
    background: white;
    border-radius: 12px;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.ad-preview-modal.active .ad-preview-content {
    transform: scale(1);
}

.close-preview {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 10;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.close-preview:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
}

.ad-preview-header {
    position: relative;
    height: 250px;
    overflow: hidden;
    border-radius: 12px 12px 0 0;
}

.ad-preview-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ad-preview-placeholder {
    width: 100%;
    height: 100%;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ad-preview-body {
    padding: 24px;
}

.ad-preview-title {
    font-size: 24px;
    font-weight: bold;
    color: #111827;
    margin: 0 0 12px 0;
}

.ad-preview-info {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}

.info-item {
    background: #f3f4f6;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 14px;
    color: #6b7280;
}

.info-item.price {
    background: #dcfce7;
    color: #16a34a;
    font-weight: 600;
}

.ad-preview-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.ad-preview-description {
    color: #6b7280;
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 20px;
}

.ad-preview-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btn-primary {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    text-align: center;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #b91c1c, #991b1b);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

.btn-secondary {
    background: #f3f4f6;
    color: #374151;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    text-align: center;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
}

.btn-secondary:hover {
    background: #e5e7eb;
    transform: translateY(-1px);
}

.btn-favorite {
    background: #fef2f2;
    color: #dc2626;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    text-align: center;
    transition: all 0.2s ease;
    border: 2px solid #fecaca;
    cursor: pointer;
}

.btn-favorite:hover {
    background: #fee2e2;
    border-color: #fca5a5;
}

.btn-favorite.active {
    background: #dc2626;
    color: white;
    border-color: #dc2626;
}

/* Controles interativos */
.map-interactive-controls {
    position: relative;
    width: 100%;
    height: 100%;
}

.map-control-btn.active {
    background: #dc2626;
    color: white;
    border-color: #dc2626;
}

/* Mensagem temporária */
.temporary-message {
    text-align: center;
    padding: 8px 12px;
}

.leaflet-popup-content-wrapper .temporary-message {
    margin: 0;
}

/* Animações aprimoradas */
.favorite-marker-container {
    animation: markerBounce 0.6s ease-out;
}

@keyframes markerBounce {
    0% {
        transform: rotate(-45deg) scale(0) translateY(20px);
        opacity: 0;
    }
    50% {
        transform: rotate(-45deg) scale(1.2) translateY(-5px);
        opacity: 0.8;
    }
    100% {
        transform: rotate(-45deg) scale(1) translateY(0);
        opacity: 1;
    }
}

/* Hover effects aprimorados */
.favorite-marker-container:hover {
    transform: rotate(-45deg) scale(1.15);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
    z-index: 1000;
}

/* Destaque do marcador clicado */
.favorite-marker-container.marker-highlighted {
    transform: rotate(-45deg) scale(1.2);
    box-shadow: 0 8px 25px rgba(220, 38, 38, 0.6);
    animation: markerPulse 2s ease-in-out;
    z-index: 1001;
}

@keyframes markerPulse {
    0%, 100% {
        transform: rotate(-45deg) scale(1.2);
        box-shadow: 0 8px 25px rgba(220, 38, 38, 0.6);
    }
    50% {
        transform: rotate(-45deg) scale(1.3);
        box-shadow: 0 12px 35px rgba(220, 38, 38, 0.8);
    }
}

/* Estados de filtro */
.distance-filter-btn {
    position: relative;
    overflow: hidden;
}

.distance-filter-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s ease;
}

.distance-filter-btn:hover::before {
    left: 100%;
}

.distance-filter-btn.active {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: white;
    border-color: #dc2626;
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.3);
}

.distance-filter-btn.reset-filters {
    background: #f59e0b;
    color: white;
    border-color: #f59e0b;
    font-weight: 600;
}

.distance-filter-btn.reset-filters:hover {
    background: #d97706;
    border-color: #d97706;
    transform: scale(1.05);
}

.distance-filter-btn.reset-filters:active {
    transform: scale(0.95);
}

/* Loading states */
.map-loading-markers {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1500;
    text-align: center;
}

.loading-dots {
    display: inline-flex;
    gap: 4px;
    margin-left: 8px;
}

.loading-dot {
    width: 6px;
    height: 6px;
    background: #dc2626;
    border-radius: 50%;
    animation: loadingDots 1.4s infinite ease-in-out;
}

.loading-dot:nth-child(1) { animation-delay: -0.32s; }
.loading-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes loadingDots {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Responsividade para modal */
@media (max-width: 768px) {
    .ad-preview-overlay {
        padding: 10px;
    }
    
    .ad-preview-content {
        max-width: 100%;
        max-height: 95vh;
    }
    
    .ad-preview-header {
        height: 200px;
    }
    
    .ad-preview-body {
        padding: 16px;
    }
    
    .ad-preview-title {
        font-size: 20px;
    }
    
    .ad-preview-actions {
        gap: 8px;
    }
    
    .btn-primary,
    .btn-secondary,
    .btn-favorite {
        padding: 10px 20px;
        font-size: 14px;
    }
    
    .info-item {
        font-size: 12px;
        padding: 4px 8px;
    }
}

/* Melhorias de acessibilidade */
.map-control-btn:focus,
.distance-filter-btn:focus,
.btn-primary:focus,
.btn-secondary:focus,
.btn-favorite:focus {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

/* Transições suaves para filtros */
.favorite-marker {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.favorite-marker.filtered-out {
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
}

/* Indicador de carregamento para navegação */
.navigation-loading {
    position: relative;
    overflow: hidden;
}

.navigation-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: navigationShimmer 1.5s infinite;
}

@keyframes navigationShimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Modal de navegação aprimorado */
.navigation-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10001;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.navigation-modal.active {
    opacity: 1;
    visibility: visible;
}

.navigation-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
}

@media (min-width: 768px) {
    .navigation-overlay {
        align-items: center;
        padding: 20px;
    }
}

.navigation-content {
    background: white;
    border-radius: 20px 20px 0 0;
    width: 100%;
    max-width: 500px;
    padding: 24px;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

@media (min-width: 768px) {
    .navigation-content {
        border-radius: 20px;
        transform: translateY(20px);
    }
}

.navigation-modal.active .navigation-content {
    transform: translateY(0);
}

.navigation-title {
    font-size: 22px;
    font-weight: bold;
    color: #111827;
    margin: 0 0 8px 0;
    text-align: center;
}

.navigation-subtitle {
    font-size: 14px;
    color: #6b7280;
    margin: 0 0 20px 0;
    text-align: center;
}

.navigation-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.navigation-btn {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    background: white;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.navigation-btn:hover {
    border-color: #dc2626;
    background: #fef2f2;
    transform: translateX(4px);
}

.navigation-btn:active {
    transform: translateX(4px) scale(0.98);
}

.nav-icon {
    font-size: 32px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f3f4f6;
    border-radius: 12px;
    flex-shrink: 0;
}

.navigation-btn.google-maps:hover .nav-icon {
    background: #e8f5e9;
}

.navigation-btn.waze:hover .nav-icon {
    background: #e3f2fd;
}

.navigation-btn.apple-maps:hover .nav-icon {
    background: #f3e5f5;
}

.navigation-btn.copy-coords:hover .nav-icon {
    background: #fff3e0;
}

.nav-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-info strong {
    font-size: 16px;
    color: #111827;
    font-weight: 600;
}

.nav-info span {
    font-size: 13px;
    color: #6b7280;
}

.navigation-close {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 12px;
    background: #f3f4f6;
    color: #374151;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.navigation-close:hover {
    background: #e5e7eb;
}

.navigation-close:active {
    transform: scale(0.98);
}

/* Animações para botões de navegação */
.navigation-btn {
    position: relative;
    overflow: hidden;
}

.navigation-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(220, 38, 38, 0.1);
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
}

.navigation-btn:active::before {
    width: 300px;
    height: 300px;
}

/* Responsividade para modal de navegação */
@media (max-width: 768px) {
    .navigation-content {
        padding: 20px;
        max-height: 80vh;
        overflow-y: auto;
    }
    
    .navigation-title {
        font-size: 20px;
    }
    
    .navigation-btn {
        padding: 14px;
        gap: 12px;
    }
    
    .nav-icon {
        font-size: 28px;
        width: 44px;
        height: 44px;
    }
    
    .nav-info strong {
        font-size: 15px;
    }
    
    .nav-info span {
        font-size: 12px;
    }
}