/* Custom Styling für App-Feeling */
body {
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: #f3f4f6;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Dark Mode Styles */
body.dark-mode {
    background-color: #000000;
    color: #e5e5e5;
}

body.dark-mode .bg-gray-50 {
    background-color: #000000 !important;
}

body.dark-mode .bg-white {
    background-color: #0f0f0f !important;
}

body.dark-mode .text-gray-800 {
    color: #e5e5e5 !important;
}

body.dark-mode .text-gray-700 {
    color: #d4d4d4 !important;
}

body.dark-mode .text-gray-600 {
    color: #a3a3a3 !important;
}

body.dark-mode .text-gray-500 {
    color: #737373 !important;
}

body.dark-mode .border-gray-100,
body.dark-mode .border-gray-200 {
    border-color: #1a1a1a !important;
}

body.dark-mode .shadow-sm,
body.dark-mode .shadow-lg {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5) !important;
}

body.dark-mode input,
body.dark-mode textarea,
body.dark-mode select {
    background-color: #1a1a1a !important;
    color: #e5e5e5 !important;
    border-color: #2d2d2d !important;
}

body.dark-mode input::placeholder,
body.dark-mode textarea::placeholder {
    color: #737373 !important;
}

body.dark-mode .mobile-nav {
    background: #0a0a0a !important;
    border-color: #1a1a1a !important;
}

body.dark-mode header {
    background: #0a0a0a !important;
}

/* Glasmorphism im Dark Mode */
body.dark-mode .glass-panel {
    background: rgba(15, 15, 15, 0.95) !important;
    border-color: rgba(26, 26, 26, 0.2) !important;
}

/* Karten und Container */
body.dark-mode .rounded-2xl,
body.dark-mode .rounded-xl {
    background-color: #0f0f0f;
}

/* Text-Kontraste */
body.dark-mode h1,
body.dark-mode h2,
body.dark-mode h3,
body.dark-mode .font-bold {
    color: #f5f5f5 !important;
}

/* Buttons behalten ihre Farben (Rot bleibt Rot, Orange bleibt Orange) */
body.dark-mode .bg-red-600 {
    background-color: #dc2626 !important;
}

body.dark-mode .bg-red-700 {
    background-color: #b91c1c !important;
}

body.dark-mode .bg-red-600:hover {
    background-color: #b91c1c !important;
}

body.dark-mode .bg-red-700:hover {
    background-color: #991b1b !important;
}

/* Links und interaktive Elemente */
body.dark-mode .text-red-600 {
    color: #ef4444 !important;
}

body.dark-mode .text-red-700 {
    color: #dc2626 !important;
}

/* Hintergrund-Overlays */
body.dark-mode .bg-red-50 {
    background-color: #1a0a0a !important;
}

body.dark-mode .bg-green-50 {
    background-color: #0a1a0a !important;
}

body.dark-mode .bg-green-100 {
    background-color: #0d2e0d !important; /* Dunkles Grün für Umwelt-Held Badge */
}

body.dark-mode .text-green-700 {
    color: #4ade80 !important; /* Helleres Grün für Lesbarkeit auf dunklem Hintergrund */
}

body.dark-mode .text-green-600 {
    color: #22c55e !important; /* Grün bleibt grün im Dark Mode (z.B. CO2 eingespart) */
}

body.dark-mode .bg-blue-50 {
    background-color: #0a0f1a !important;
}

/* Border-Styling */
body.dark-mode .border-white {
    border-color: #1a1a1a !important;
}

/* Navigation Active State */
body.dark-mode .nav-item.active {
    background: rgba(220, 38, 38, 0.15) !important;
}

/* Toast im Dark Mode */
body.dark-mode #toast {
    background: #0f0f0f !important;
    border: 1px solid #1a1a1a !important;
}

body.dark-mode #toast-icon.text-red-400 {
    color: #f87171 !important; /* Helleres Rot für bessere Sichtbarkeit */
}

body.dark-mode #toast-icon.text-green-400 {
    color: #4ade80 !important; /* Helleres Grün für bessere Sichtbarkeit */
}

/* Luftqualitäts-Grid im Dark Mode */
body.dark-mode #airQualityChart .bg-white {
    background-color: #1a1a1a !important;
}

body.dark-mode #airQualityChart .border-gray-200 {
    border-color: #2a2a2a !important;
}

body.dark-mode #airQualityChart .text-gray-500 {
    color: #9ca3af !important;
}

body.dark-mode #airQualityChart .text-gray-400 {
    color: #6b7280 !important;
}

/* Rangliste im Dark Mode */
body.dark-mode #leaderboard-list .bg-gray-50 {
    background-color: #1a1a1a !important;
}

body.dark-mode #leaderboard-list .bg-red-50 {
    background-color: #2a0f0f !important;
}

body.dark-mode #leaderboard-list .border-red-300 {
    border-color: #dc2626 !important;
}

body.dark-mode #leaderboard-list .text-gray-800 {
    color: #e5e7eb !important;
}

body.dark-mode #leaderboard-list .text-gray-600 {
    color: #9ca3af !important;
}

body.dark-mode #leaderboard-list .text-gray-500 {
    color: #6b7280 !important;
}

/* Dark Mode: Buttons mit Border */
body.dark-mode button.border-2 {
    border-color: #2d2d2d !important;
    background-color: #1a1a1a !important;
}

body.dark-mode button.border-2:hover {
    background-color: #0f0f0f !important;
}

.glass-panel {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Glassmorphism für Schnellzugriff-Buttons */
.glass-card {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
}

.glass-card:hover {
    background: rgba(255, 255, 255, 0.85);
    box-shadow: 0 12px 40px 0 rgba(31, 38, 135, 0.25);
}

/* Dark Mode für Glass-Cards */
body.dark-mode .glass-card {
    background: rgba(15, 15, 15, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

body.dark-mode .glass-card:hover {
    background: rgba(15, 15, 15, 0.8);
    box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.5);
}

body.dark-mode .glass-card .text-gray-800 {
    color: #e5e5e5 !important;
}

/* Karte soll den verfügbaren Platz füllen */
#map {
    height: 100%;
    width: 100%;
    z-index: 1;
    min-height: 300px;
    flex: 1 1 auto;
}

/* Mobile Navigation unten */
.mobile-nav {
    position: fixed !important;
    bottom: 0;
    left: 0;
    width: 100%;
    background: white;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
    z-index: 200 !important;
    padding-bottom: env(safe-area-inset-bottom);
    min-height: 65px;
}

.mobile-nav > div {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-around;
}

.nav-item {
    color: #6b7280;
    transition: all 0.3s ease;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 48px;
}

/* Stelle sicher, dass alle Nav-Items auf gleicher Höhe sind */
.nav-item i {
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* Stelle sicher, dass alle Nav-Text-Labels auf einer Linie sind */
.nav-item span {
    line-height: 1;
    margin-top: 2px;
}

.nav-item.active {
    color: #dc2626 !important; /* Braunschweig Rot */
    transform: translateY(-2px);
    background: rgba(220, 38, 38, 0.05) !important;
    border: 2px solid rgba(220, 38, 38, 0.3) !important;
    border-radius: 12px;
}

/* Stelle sicher, dass aktive Navigation-Elemente immer sichtbar sind */
button.nav-item.active,
div.nav-item.active {
    color: #dc2626 !important;
    background: rgba(220, 38, 38, 0.05) !important;
    border: 2px solid rgba(220, 38, 38, 0.3) !important;
    transform: translateY(-2px);
}

/* Erhöhe Spezifität für Navigation-Buttons */
nav .nav-item.active {
    color: #dc2626 !important;
    background: rgba(220, 38, 38, 0.05) !important;
    border: 2px solid rgba(220, 38, 38, 0.3) !important;
}

.nav-item.active i {
    color: #dc2626 !important;
    background: rgba(220, 38, 38, 0.1) !important;
    padding: 8px;
    border-radius: 12px;
    position: relative;
    z-index: 2;
}

.nav-item.active span {
    color: #dc2626 !important;
    position: relative;
    z-index: 2;
}

/* Action Button (Kamera) */
.action-btn {
    background: linear-gradient(135deg, #dc2626, #ef4444);
    box-shadow: 0 4px 15px rgba(220, 38, 38, 0.4);
    transition: all 0.3s ease;
}

/* Kamera-Button Position anpassen */
@media (max-width: 768px) {
    .mobile-nav .relative.-top-4 {
        top: -14px; /* Etwas weniger als -top-5 (20px), etwas mehr als -top-3 (12px) */
    }
}
.action-btn:active {
    transform: scale(0.95);
}

.action-btn.nav-item.active {
    background: linear-gradient(135deg, #dc2626, #ef4444) !important;
    box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.3), 0 4px 15px rgba(220, 38, 38, 0.4) !important;
    border-color: rgba(220, 38, 38, 0.3) !important;
}

.action-btn.nav-item.active::before {
    display: none; /* Kein zusätzlicher Rahmen für Action-Button */
}

/* Gamification Animation */
@keyframes pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}
.pop-anim {
    animation: pop 0.3s ease-out;
}

/* Verstecke Scrollbars aber erlaube Scrollen */
.no-scrollbar::-webkit-scrollbar {
    display: none;
}
.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.page-section {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
    padding-bottom: 80px; /* Platz für Nav */
}

/* Mehr Platz am Ende für Login/Register/About/Imprint/Settings/Profile/Home auf Mobile */
#login.page-section,
#register.page-section,
#about.page-section,
#imprint.page-section,
#settings.page-section,
#profile.page-section,
#report.page-section,
#home.page-section {
    padding-bottom: 120px; /* Mehr Platz am Ende */
}
.page-section.active {
    display: block;
}

/* WICHTIG: Home muss auch scrollen können! */
#home.page-section.active {
    display: block !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    height: auto !important;
    max-height: calc(100vh - 60px) !important;
    /* Verstecke Scrollbar */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

/* Verstecke Scrollbar für Chrome/Safari/Opera */
#home.page-section.active::-webkit-scrollbar {
    display: none;
}

/* Login, Register, About, Imprint, Settings, Profile, Report und Home sollen den vollen Platz nutzen und scrollen können */
#login.page-section.active,
#register.page-section.active,
#about.page-section.active,
#imprint.page-section.active,
#settings.page-section.active,
#profile.page-section.active,
#report.page-section.active,
#home.page-section.active {
    display: block !important;
    /* Entferne flex, damit Scrollen besser funktioniert */
    min-height: 100vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling auf iOS */
}

/* Mobile-optimiert: Stelle sicher, dass Login/Register/About/Imprint/Settings/Profile/Report/Home scrollen können */
@media (max-height: 800px) {
    #login.page-section.active,
    #register.page-section.active,
    #about.page-section.active,
    #imprint.page-section.active,
    #settings.page-section.active,
    #profile.page-section.active,
    #report.page-section.active,
    #home.page-section.active {
        min-height: auto;
        padding-bottom: 8rem !important; /* Extra Platz am Ende für Mobile */
    }
}

/* Text auf Web-View nach oben verschieben (nur Desktop, nicht Mobile) */
@media (min-width: 768px) {
    #home.page-section {
        padding-top: 2rem !important;
    }
    
    #profile.page-section {
        padding-top: 2rem !important;
    }
    
    #settings.page-section {
        padding-top: 2rem !important;
    }
}

/* Reduziere Padding auf sehr kleinen Bildschirmen */
@media (max-height: 700px) {
    #login.page-section,
    #register.page-section,
    #about.page-section,
    #imprint.page-section,
    #settings.page-section,
    #profile.page-section,
    #report.page-section,
    #home.page-section {
        padding: 1rem !important;
        padding-bottom: 10rem !important; /* Noch mehr Platz am Ende */
    }
    
    #login.page-section .bg-white,
    #register.page-section .bg-white,
    #about.page-section .bg-white,
    #imprint.page-section .bg-white,
    #settings.page-section .bg-white,
    #profile.page-section .bg-white {
        padding: 1rem !important;
    }
}

/* Extra Platz für sehr kleine Bildschirme */
@media (max-height: 650px) {
    #register.page-section.active,
    #about.page-section.active,
    #imprint.page-section.active,
    #settings.page-section.active,
    #profile.page-section.active,
    #report.page-section.active,
    #home.page-section.active {
        padding-bottom: 12rem !important;
    }
}

/* Mobility Sektion - Karte soll volle Höhe haben */
#mobility.page-section {
    padding: 0 !important;
    position: relative;
    min-height: 0;
}

    #mobility.page-section.active {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 140px);
    min-height: 500px;
}

@media (max-width: 768px) {
    #mobility.page-section.active {
        height: calc(100vh - 120px);
        padding-top: 0 !important;
    }
}

/* Mobile Navigation z-index - bereits oben definiert, hier nur z-index erhöhen */
.mobile-nav {
    z-index: 200 !important;
}

/* Filter-Buttons auf Karte - unter Navigation auf Mobile */
@media (max-width: 768px) {
    #mobility .absolute[class*="bottom-"] {
        bottom: 56px !important;
        z-index: 50 !important;
    }
}

/* Scrollbalken verstecken beim Scrollen */
body {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}

body::-webkit-scrollbar {
    width: 8px;
}

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

body::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    transition: opacity 0.3s;
}

body::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* Scrollbalken beim Scrollen verstecken */
body.scrolling::-webkit-scrollbar-thumb {
    opacity: 0;
    background: transparent;
}

body.scrolling {
    scrollbar-width: none;
}

body.scrolling::-webkit-scrollbar {
    width: 0;
}

/* Level-Modal Scrollbar verstecken */
.level-modal-scroll {
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE und Edge */
}

.level-modal-scroll::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
    width: 0;
    height: 0;
}

/* Scroll-Begrenzung für Seiten */
.page-section {
    overflow-x: hidden;
}

@media (max-width: 768px) {
    .page-section.active {
        max-height: calc(100vh - 56px);
        overflow-y: auto;
        overflow-x: hidden;
    }
    
    /* Verhindere zu viel Scrollen nach unten */
    .page-section.active {
        padding-bottom: 6rem !important;
    }
    
    /* Scroll-Begrenzung: Verhindere zu viel Scrollen */
    main {
        max-height: 100vh;
        overflow: hidden;
    }
}

/* Stelle sicher, dass andere Sektionen wirklich versteckt sind */
#login.page-section:not(.active),
#register.page-section:not(.active) {
    display: none !important;
}

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

/* Konfetti Animation */
@keyframes confetti-fall {
    0% { transform: translateY(-100vh) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}
.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    background: #f0f;
    position: absolute;
    animation: confetti-fall 3s linear forwards;
    z-index: 9999;
}
.confetti:nth-child(1) { left: 10%; background: #ff0000; animation-delay: 0s; }
.confetti:nth-child(2) { left: 20%; background: #00ff00; animation-delay: 0.1s; }
.confetti:nth-child(3) { left: 30%; background: #0000ff; animation-delay: 0.2s; }
.confetti:nth-child(4) { left: 40%; background: #ffff00; animation-delay: 0.3s; }
.confetti:nth-child(5) { left: 50%; background: #ff00ff; animation-delay: 0.4s; }
.confetti:nth-child(6) { left: 60%; background: #00ffff; animation-delay: 0.5s; }
.confetti:nth-child(7) { left: 70%; background: #ff8800; animation-delay: 0.6s; }
.confetti:nth-child(8) { left: 80%; background: #8800ff; animation-delay: 0.7s; }
.confetti:nth-child(9) { left: 90%; background: #ff0088; animation-delay: 0.8s; }
.confetti:nth-child(10) { left: 15%; background: #00ff88; animation-delay: 0.9s; }
.confetti:nth-child(11) { left: 25%; background: #ff8800; animation-delay: 1s; }
.confetti:nth-child(12) { left: 35%; background: #0088ff; animation-delay: 1.1s; }
.confetti:nth-child(13) { left: 45%; background: #88ff00; animation-delay: 1.2s; }
.confetti:nth-child(14) { left: 55%; background: #ff0088; animation-delay: 1.3s; }
.confetti:nth-child(15) { left: 65%; background: #00ff88; animation-delay: 1.4s; }
.confetti:nth-child(16) { left: 75%; background: #8800ff; animation-delay: 1.5s; }
.confetti:nth-child(17) { left: 85%; background: #ff8800; animation-delay: 1.6s; }
.confetti:nth-child(18) { left: 95%; background: #00ffff; animation-delay: 1.7s; }

/* Erfolgs-Animation */
@keyframes success-bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}
.success-animation {
    animation: success-bounce 0.5s ease-in-out;
}

/* Welcome Card - Bild-Position auf Mobile */
@media (max-width: 768px) {
    .welcome-card-bg {
        background-position: center 65% !important;
    }
}
