/* ==========================================================================
   EcoWaste - Custom Stylesheet with Dark Mode & Digital Twin Gauges
   ========================================================================== */

:root {
    --eco-green: #22c55e;
    --eco-green-light: #f0fdf4;
    --eco-green-dark: #15803d;
    --eco-red: #ef4444;
    --eco-red-light: #fef2f2;
    --eco-yellow: #eab308;
    --eco-yellow-light: #fefce8;
    --bg-page: #f0fdf4;
    --bg-card: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
}

/* Dark Mode Variables */
body.dark-mode {
    --bg-page: #0b1320;
    --bg-card: #152238;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: #243552;
    background-color: var(--bg-page) !important;
    color: var(--text-primary) !important;
}

body.dark-mode .bg-white {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
}

body.dark-mode .bg-slate-50 {
    background-color: #111d30 !important;
    border-color: var(--border-color) !important;
}

body.dark-mode .text-slate-900,
body.dark-mode .text-slate-800,
body.dark-mode .text-slate-700 {
    color: #f1f5f9 !important;
}

body.dark-mode .text-slate-500,
body.dark-mode .text-slate-600,
body.dark-mode .text-slate-400 {
    color: #94a3b8 !important;
}

body.dark-mode .border-slate-100,
body.dark-mode .border-slate-200 {
    border-color: #243552 !important;
}

body.dark-mode header {
    background-color: rgba(21, 34, 56, 0.95) !important;
    border-color: #243552 !important;
}

/* General Typography */
* {
    font-family: 'Poppins', sans-serif;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-page);
    color: var(--text-primary);
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Tab Navigation */
.nav-tab {
    position: relative;
    color: var(--text-secondary);
    border-bottom: 3px solid transparent;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}

.nav-tab:hover {
    color: var(--eco-green-dark);
    background-color: rgba(34, 197, 94, 0.08);
}

.nav-tab.active {
    border-bottom: 3px solid var(--eco-green);
    color: var(--eco-green-dark);
    font-weight: 600;
    background-color: rgba(34, 197, 94, 0.12);
}

body.dark-mode .nav-tab.active {
    color: #4ade80 !important;
    border-bottom-color: #4ade80 !important;
    background-color: rgba(74, 222, 128, 0.15) !important;
}

/* KPI Cards */
.kpi-card {
    background: var(--bg-card);
    border-radius: 18px;
    padding: 24px;
    box-shadow: 0 4px 15px -2px rgba(0, 0, 0, 0.04);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.kpi-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 25px -4px rgba(34, 197, 94, 0.12);
}

/* Star Rating */
.star-rating {
    display: inline-flex;
    gap: 6px;
}

.star-rating .star {
    cursor: pointer;
    font-size: 28px;
    color: #cbd5e1;
    transition: transform 0.15s ease, color 0.15s ease;
    user-select: none;
}

.star-rating .star:hover {
    transform: scale(1.18);
}

.star-rating .star.active {
    color: var(--eco-yellow);
}

.star-rating .star.hovered {
    color: #facc15;
}

/* Bio Group Badges */
.badge-bio {
    background-color: #dcfce7;
    color: #15803d;
    padding: 6px 16px;
    border-radius: 9999px;
    border: 1px solid #bbf7d0;
}

.badge-nonbio {
    background-color: #fef2f2;
    color: #dc2626;
    padding: 6px 16px;
    border-radius: 9999px;
    border: 1px solid #fecaca;
}

/* Confidence Progress Bar */
.confidence-bar {
    height: 12px;
    border-radius: 6px;
    background-color: #e2e8f0;
    overflow: hidden;
    position: relative;
}

.confidence-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Camera Preview */
#camera-preview {
    width: 100% !important;
    height: 100% !important;
    min-height: 380px;
    object-fit: cover;
    background-color: #0f172a;
    border-radius: 16px;
    display: block;
}

#camera-preview.hidden {
    display: none !important;
}

/* Leaflet Maps */
#bins-map,
#twin-map {
    height: 440px;
    border-radius: 18px;
    z-index: 1;
    overflow: hidden;
}

.leaflet-popup-content-wrapper {
    border-radius: 14px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    font-family: 'Poppins', sans-serif;
}

/* Digital Twin Sensor Gauge Components */
.gauge-cylinder {
    position: relative;
    width: 38px;
    height: 90px;
    background-color: #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid #cbd5e1;
}

body.dark-mode .gauge-cylinder {
    background-color: #0f172a;
    border-color: #334155;
}

.gauge-liquid {
    position: absolute;
    bottom: 0;
    width: 100%;
    transition: height 0.6s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.4s ease;
    border-radius: 0 0 10px 10px;
}

.liquid-green { background: linear-gradient(180deg, #4ade80, #16a34a); }
.liquid-yellow { background: linear-gradient(180deg, #facc15, #ca8a04); }
.liquid-red { background: linear-gradient(180deg, #f87171, #dc2626); }

/* Pulse Animation for Critical Alerts */
@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6); }
    50% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
}

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

/* Chatbot Window Styling */
.chat-scroll {
    max-height: 420px;
    overflow-y: auto;
    scroll-behavior: smooth;
}

/* What-If Slider Styling */
input[type=range] {
    accent-color: #16a34a;
}

/* Loading Spinners & Empty States */
.spinner {
    border: 4px solid #e2e8f0;
    border-top: 4px solid var(--eco-green);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    display: inline-block;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Leaderboard Badges */
.rank-gold { background: linear-gradient(135deg, #fef3c7, #fde68a); }
.rank-silver { background: linear-gradient(135deg, #f1f5f9, #e2e8f0); }
.rank-bronze { background: linear-gradient(135deg, #fed7aa, #fdba74); }

body.dark-mode .rank-gold { background: linear-gradient(135deg, #78350f, #92400e) !important; color: #fef3c7 !important; }
body.dark-mode .rank-silver { background: linear-gradient(135deg, #1e293b, #334155) !important; }
body.dark-mode .rank-bronze { background: linear-gradient(135deg, #7c2d12, #9a3412) !important; }

/* Transitions */
.fade-in {
    animation: fadeIn 0.3s ease-out forwards;
}

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

/* ==========================================================================
   EcoBot Voice Assistant Animated Waveform & Glowing Pill Bar
   ========================================================================== */
.voice-bar {
    display: inline-block;
    width: 3px;
    height: 8px;
    background: #10b981;
    border-radius: 9999px;
    transition: height 0.2s ease, background 0.3s ease;
}

.voice-bar-1 { height: 6px; }
.voice-bar-2 { height: 14px; }
.voice-bar-3 { height: 18px; }
.voice-bar-4 { height: 12px; }
.voice-bar-5 { height: 8px; }

/* Listening State: Active Green/Teal Wave */
.voice-active-listening .voice-bar {
    background: #34d399;
    animation: voiceWaveActive 0.8s ease-in-out infinite alternate;
}
.voice-active-listening .voice-bar-1 { animation-delay: 0.1s; }
.voice-active-listening .voice-bar-2 { animation-delay: 0.3s; }
.voice-active-listening .voice-bar-3 { animation-delay: 0.0s; }
.voice-active-listening .voice-bar-4 { animation-delay: 0.4s; }
.voice-active-listening .voice-bar-5 { animation-delay: 0.2s; }

/* Speaking State: Active Violet/Cyan Wave */
.voice-active-speaking .voice-bar {
    background: #a855f7;
    animation: voiceWaveSpeak 0.65s ease-in-out infinite alternate;
}
.voice-active-speaking .voice-bar-1 { animation-delay: 0.15s; }
.voice-active-speaking .voice-bar-2 { animation-delay: 0.0s; }
.voice-active-speaking .voice-bar-3 { animation-delay: 0.35s; }
.voice-active-speaking .voice-bar-4 { animation-delay: 0.1s; }
.voice-active-speaking .voice-bar-5 { animation-delay: 0.25s; }

@keyframes voiceWaveActive {
    0% { height: 4px; }
    50% { height: 22px; }
    100% { height: 6px; }
}

@keyframes voiceWaveSpeak {
    0% { height: 6px; }
    50% { height: 26px; }
    100% { height: 8px; }
}

/* Modal Backdrop */
.modal-backdrop {
    background-color: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(8px);
}

/* ==========================================================================
   Executive Daily Municipal Report Printable Stylesheet
   ========================================================================== */
@media print {
    /* Hide navigation, buttons, voice bar, footer */
    header, footer, #ecobot-voice-bar-wrapper, #toast-container,
    .nav-tab, button, #report-export-toolbar, #btn-find-bins,
    #camera-section, #upload-section, #search-section, .no-print {
        display: none !important;
    }

    body {
        background-color: #ffffff !important;
        color: #0f172a !important;
        font-size: 11pt !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* Expand modal or report view container full width */
    #executive-report-modal, #executive-report-modal-content {
        position: static !important;
        max-width: 100% !important;
        width: 100% !important;
        border: none !important;
        box-shadow: none !important;
        display: block !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .modal-backdrop {
        background: transparent !important;
        backdrop-filter: none !important;
    }

    .print-break-inside {
        page-break-inside: avoid;
    }
}
