/* ===================================
   UX FEATURES STYLES
   Dark Mode, Animations, Filters
   =================================== */

/* ===================================
   DARK MODE
   =================================== */

/* Dark mode toggle button */
#dark-mode-toggle {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9998;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid #e2e8f0;
    border-radius: 50%;
    width: 3rem;
    height: 3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

#dark-mode-toggle:hover {
    transform: scale(1.1) rotate(15deg);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

#dark-mode-toggle:focus {
    outline: 3px solid #667eea;
    outline-offset: 2px;
}

/* Dark mode styles */
body.dark-mode {
    background-color: #1a202c;
    color: #e2e8f0;
}

body.dark-mode header {
    background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
}

body.dark-mode main {
    background-color: #1a202c;
}

body.dark-mode .hero,
body.dark-mode .card,
body.dark-mode .dados-faro-section,
body.dark-mode #mapa-section {
    background-color: #2d3748;
    color: #e2e8f0;
    border-color: #4a5568;
}

body.dark-mode .hero h2,
body.dark-mode .card h3,
body.dark-mode section h2,
body.dark-mode .dados-municipio h3,
body.dark-mode .favorite-title {
    color: #f7fafc;
}

body.dark-mode .hero p,
body.dark-mode .card p,
body.dark-mode p {
    color: #cbd5e0;
}

body.dark-mode .info-item {
    background: #1a202c;
    border-left-color: #667eea;
}

body.dark-mode .info-label {
    color: #a0aec0;
}

body.dark-mode .info-value {
    color: #e2e8f0;
}

body.dark-mode .card {
    border-color: #4a5568;
}

body.dark-mode .card:hover {
    border-color: #667eea;
    background-color: #374151;
}

body.dark-mode nav a:not(.active):not([aria-current="page"]) {
    color: #ffffff;
}

body.dark-mode footer {
    background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
}

body.dark-mode .btn-secondary {
    background-color: #4a5568;
    color: #e2e8f0;
    border-color: #718096;
}

body.dark-mode .search-input-wrapper,
body.dark-mode .search-input,
body.dark-mode .search-results {
    background-color: #2d3748;
    color: #e2e8f0;
    border-color: #4a5568;
}

body.dark-mode .search-result-item:hover {
    background-color: #374151;
}

body.dark-mode .favorite-item {
    background-color: #2d3748;
    border-color: #4a5568;
}

body.dark-mode .favorite-item:hover {
    background-color: #374151;
}

body.dark-mode .empty-favorites {
    background-color: #2d3748;
}

body.dark-mode #dark-mode-toggle {
    background: rgba(45, 55, 72, 0.95);
    border-color: #4a5568;
}

body.dark-mode .premium-notice {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.2) 0%, rgba(118, 75, 162, 0.2) 100%);
    border-left-color: #667eea;
}

/* ===================================
   SCROLL TO TOP BUTTON
   =================================== */

.scroll-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 9997;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 50%;
    width: 3.5rem;
    height: 3.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transform: translateY(100px);
    transition: all 0.3s ease;
    pointer-events: none;
}

.scroll-to-top.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.scroll-to-top:hover {
    transform: translateY(-5px) scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.scroll-to-top:focus {
    outline: 3px solid #ffd54f;
    outline-offset: 2px;
}

.scroll-icon {
    font-weight: bold;
}

/* ===================================
   ANIMATIONS
   =================================== */

/* Fade in animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-on-scroll {
    opacity: 0;
}

.animate-on-scroll.animate-fade-in {
    animation: fadeIn 0.6s ease-out forwards;
}

/* Stagger animation for cards */
.cards-grid .card:nth-child(1).animate-fade-in { animation-delay: 0.1s; }
.cards-grid .card:nth-child(2).animate-fade-in { animation-delay: 0.2s; }
.cards-grid .card:nth-child(3).animate-fade-in { animation-delay: 0.3s; }
.cards-grid .card:nth-child(4).animate-fade-in { animation-delay: 0.4s; }
.cards-grid .card:nth-child(5).animate-fade-in { animation-delay: 0.5s; }
.cards-grid .card:nth-child(6).animate-fade-in { animation-delay: 0.6s; }
.cards-grid .card:nth-child(7).animate-fade-in { animation-delay: 0.7s; }
.cards-grid .card:nth-child(8).animate-fade-in { animation-delay: 0.8s; }
.cards-grid .card:nth-child(9).animate-fade-in { animation-delay: 0.9s; }

/* Hover animations */
.animate-hover {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.animate-hover:hover {
    transform: translateY(-3px);
}

/* Loading animation */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.loading {
    animation: pulse 1.5s ease-in-out infinite;
}

/* ===================================
   FILTER STYLES
   =================================== */

.filter-container {
    margin-bottom: 2rem;
    text-align: center;
}

.filter-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 1rem;
}

.filter-btn {
    padding: 0.625rem 1.25rem;
    background-color: white;
    color: #4a5568;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.3s ease;
    font-family: inherit;
}

.filter-btn:hover {
    border-color: #667eea;
    background-color: #f7fafc;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.filter-btn:focus {
    outline: 3px solid #667eea;
    outline-offset: 2px;
}

.filter-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

body.dark-mode .filter-btn {
    background-color: #2d3748;
    color: #e2e8f0;
    border-color: #4a5568;
}

body.dark-mode .filter-btn:hover {
    background-color: #374151;
    border-color: #667eea;
}

body.dark-mode .filter-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

/* Fade in/out for filtered items */
.fade-in {
    animation: fadeIn 0.4s ease-out;
}

/* ===================================
   RESPONSIVE
   =================================== */

@media (max-width: 768px) {
    #dark-mode-toggle {
        top: 0.75rem;
        right: 0.75rem;
        width: 2.5rem;
        height: 2.5rem;
        font-size: 1.25rem;
    }

    .scroll-to-top {
        bottom: 1.5rem;
        right: 1.5rem;
        width: 3rem;
        height: 3rem;
        font-size: 1.25rem;
    }

    .filter-buttons {
        gap: 0.5rem;
    }

    .filter-btn {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }
}

@media (max-width: 480px) {
    #dark-mode-toggle {
        width: 2.25rem;
        height: 2.25rem;
        font-size: 1rem;
    }

    .scroll-to-top {
        bottom: 1rem;
        right: 1rem;
        width: 2.5rem;
        height: 2.5rem;
        font-size: 1rem;
    }

    .filter-btn {
        padding: 0.4rem 0.875rem;
        font-size: 0.8rem;
    }
}

/* ===================================
   SMOOTH TRANSITIONS
   =================================== */

html {
    scroll-behavior: smooth;
}

/* Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
