/* Base Variables & Theme */
:root {
    --bg-surface: #0a0e12;
    --bg-glass: rgba(18, 25, 33, 0.65);
    --border-glass: rgba(255, 255, 255, 0.08);
    
    --text-primary: #ffffff;
    --text-secondary: #94a3b8;
    
    --accent-primary: #10b981; /* Emerald Green */
    --accent-primary-glow: rgba(16, 185, 129, 0.2);
    
    --accent-env: #34d399; /* Green for environment */
    --accent-waste: #fbbf24; /* Amber for waste */
    --accent-energy: #38bdf8; /* Blue for energy */
    --accent-social: #a78bfa; /* Purple for social */

    --font-base: 'Outfit', sans-serif;
    --radius-lg: 20px;
    --radius-md: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-surface);
    color: var(--text-primary);
    font-family: var(--font-base);
    min-height: 100vh;
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(16, 185, 129, 0.06), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(56, 189, 248, 0.06), transparent 25%);
    overflow-x: hidden;
}

/* Layout */
.dashboard-container {
    display: flex;
    min-height: 100vh;
}

/* Glassmorphism Utilities */
.glass-panel {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.interactive-hover {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
}

.interactive-hover:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
    border-color: rgba(255, 255, 255, 0.15);
}

/* Sidebar */
.sidebar {
    width: 280px;
    min-width: 280px;
    margin: 20px 0 20px 20px;
    padding: 30px 24px;
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease, min-width 0.3s ease, padding 0.3s ease;
    position: relative;
    z-index: 10;
}

/* Sidebar Toggle Button */
.sidebar-toggle {
    display: none;
    position: absolute;
    top: 18px;
    right: 14px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-glass);
    color: var(--text-secondary);
    border-radius: 8px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text-primary);
}

.sidebar-toggle i {
    width: 18px;
    height: 18px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 50px;
}

.brand-logo {
    width: 32px;
    height: auto;
}

.brand h2 {
    font-weight: 700;
    font-size: 24px;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, #fff, #94a3b8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex-grow: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
    font-weight: 500;
}

.nav-item i {
    width: 20px;
    height: 20px;
}

.nav-item:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.05);
}

.nav-item.active {
    color: var(--accent-primary);
    background: var(--accent-primary-glow);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid var(--border-glass);
}

.sidebar-footer p {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 8px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
}

.dot {
    width: 8px;
    height: 8px;
    background-color: var(--accent-primary);
    border-radius: 50%;
}

.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Main Content Area */
.main-content {
    flex: 1;
    padding: 20px 40px;
    height: 100vh;
    overflow-y: auto;
}

/* Header */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 30px;
}

.page-title {
    font-size: 32px;
    font-weight: 600;
    margin-bottom: 6px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 15px;
}

.date-filter {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-md);
}

.date-filter i {
    width: 16px;
    height: 16px;
}

/* KPI Grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.kpi-card {
    padding: 24px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    min-height: 120px;
}

.kpi-details {
    min-width: 0;
}

.kpi-icon-wrapper {
    flex-shrink: 0;
}

.kpi-icon-wrapper {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.kpi-icon-wrapper i {
    width: 24px;
    height: 24px;
}

.env-accent { background: rgba(52, 211, 153, 0.15); color: var(--accent-env); }
.waste-accent { background: rgba(251, 191, 36, 0.15); color: var(--accent-waste); }
.energy-accent { background: rgba(56, 189, 248, 0.15); color: var(--accent-energy); }
.social-accent { background: rgba(167, 139, 250, 0.15); color: var(--accent-social); }

.kpi-label {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kpi-value {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 6px;
    white-space: nowrap;
}

.kpi-value .unit {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 400;
}

.kpi-trend {
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.kpi-trend i { width: 14px; height: 14px; }
.kpi-trend.positive { color: var(--accent-primary); }
.kpi-trend.neutral { color: var(--text-secondary); }

/* Charts Area */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

.chart-card {
    padding: 24px;
    display: flex;
    flex-direction: column;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.chart-header h3 {
    font-size: 16px;
    font-weight: 500;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s;
}

.icon-btn:hover { color: var(--text-primary); }

.chart-container {
    position: relative;
    width: 100%;
    flex-grow: 1;
}

.main-chart {
    min-height: 400px;
}

.side-chart {
    min-height: 400px;
}

.bottom-chart {
    min-height: 250px;
}

/* Custom Chart Legend for Doughnut */
.chart-legend {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 20px;
}

.legend-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
}

.legend-label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
}

.legend-color {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.legend-value {
    font-weight: 600;
}

/* Circular Progress Chart SVG */
.goal-container {
    display: flex;
    align-items: center;
    gap: 24px;
    height: 100%;
}

.circular-progress {
    width: 120px;
    height: 120px;
}

.circular-chart {
    display: block;
    margin: 0 auto;
    max-width: 80%;
    max-height: 250px;
}

.circle-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.1);
    stroke-width: 3.8;
}

.circle {
    fill: none;
    stroke-width: 3.8;
    stroke-linecap: round;
    stroke: var(--accent-primary);
    animation: progress 2s ease-out forwards;
}

@keyframes progress {
    0% { stroke-dasharray: 0 100; }
}

.percentage {
    fill: var(--text-primary);
    font-family: var(--font-base);
    font-size: 8px;
    font-weight: 600;
    text-anchor: middle;
}

.goal-details p {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 4px;
}

.goal-details span {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Project Profile & Financials Extras */
.profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.profile-panel {
    padding: 24px;
}

.specs-list {
    list-style: none;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 10px;
}

.specs-list li {
    background: rgba(255, 255, 255, 0.03);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    color: var(--text-secondary);
}

.specs-list li strong {
    display: block;
    color: var(--text-primary);
    margin-bottom: 4px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.budget-stats {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    margin-bottom: 16px;
}

.value-emerald { color: var(--accent-primary); }
.value-amber { color: var(--accent-waste); }

.progress-bar-container {
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 16px;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 4px;
}

.emerald-bg { background-color: var(--accent-primary); box-shadow: 0 0 10px var(--accent-primary-glow); }

.budget-note {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* --- Tab System & Project Header --- */
.project-summary-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 30px;
    margin-bottom: 30px;
}

.detail-item {
    display: flex;
    align-items: center;
    gap: 16px;
}

.detail-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.detail-icon i {
    width: 22px;
    height: 22px;
}

.detail-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-value {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.detail-divider {
    width: 1px;
    height: 40px;
    background: var(--border-glass);
}

.tab-content {
    display: none;
    animation: fadeIn 0.4s ease forwards;
}

.tab-content.active {
    display: block;
}

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

/* Responsive */
@media (max-width: 1200px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .charts-grid, .profile-grid { grid-template-columns: 1fr; }
    .project-summary-header { flex-wrap: wrap; gap: 16px; justify-content: flex-start; }
    .detail-divider { display: none; }

    /* Show toggle button */
    .sidebar-toggle { display: flex; }

    /* AUTO-COLLAPSE: sidebar is collapsed by default on small screens */
    .sidebar {
        width: 72px;
        min-width: 72px;
        padding: 30px 12px;
    }

    .sidebar .brand-text,
    .sidebar .nav-label {
        display: none;
    }

    .sidebar .brand {
        justify-content: center;
        margin-bottom: 30px;
    }

    .sidebar .nav-item {
        justify-content: center;
        padding: 14px;
        gap: 0;
    }

    .sidebar .status-indicator {
        justify-content: center;
    }

    .sidebar .sidebar-footer p {
        display: none;
    }

    .sidebar .sidebar-toggle {
        position: static;
        margin: 0 auto 10px;
    }

    /* EXPANDED state: when user clicks the toggle */
    .sidebar.expanded {
        width: 280px;
        min-width: 280px;
        padding: 30px 24px;
    }

    .sidebar.expanded .brand-text,
    .sidebar.expanded .nav-label {
        display: inline;
    }

    .sidebar.expanded .brand {
        justify-content: flex-start;
        margin-bottom: 50px;
    }

    .sidebar.expanded .nav-item {
        justify-content: flex-start;
        padding: 14px 18px;
        gap: 14px;
    }

    .sidebar.expanded .status-indicator {
        justify-content: flex-start;
    }

    .sidebar.expanded .sidebar-footer p {
        display: block;
    }

    .sidebar.expanded .sidebar-toggle {
        position: absolute;
        top: 18px;
        right: 14px;
        margin: 0;
    }
}

@media (max-width: 900px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .main-content { padding: 16px 20px; }
    .page-title { font-size: 24px; }
}
