/*
 * EcoTrack - Carbon Footprint Tracker
 * Simplified and focused styles
 * Built for Region Hacks 2025
 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #10b981;
    --primary-dark: #059669;
    --secondary: #3b82f6;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.8);
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: rgba(148, 163, 184, 0.2);
    --radius: 12px;
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: linear-gradient(135deg, var(--bg) 0%, #1e293b 100%);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
}

/* Layout */
.app {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 220px;
    background: rgba(15, 23, 42, 0.95);
    border-right: 1px solid var(--border);
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 0.5rem;
    margin-bottom: 2rem;
}

.logo-icon {
    width: 28px;
    height: 28px;
    color: var(--primary);
}

.logo span {
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary) 0%, #3b82f6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav {
    list-style: none;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    margin-bottom: 0.25rem;
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s;
}

.nav-item svg {
    width: 20px;
    height: 20px;
}

.nav-item:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text);
}

.nav-item.active {
    background: linear-gradient(135deg, var(--primary) 0%, #0d9668 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
}

.sidebar-footer {
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}

/* Main Content */
.main {
    flex: 1;
    margin-left: 220px;
    padding: 2rem;
    min-height: 100vh;
}

/* Pages */
.page {
    display: none;
    animation: fadeIn 0.3s ease;
}

.page.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.page-header {
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.page-header p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Stats Row */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.stat-card.highlight {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border: none;
    box-shadow: 0 8px 32px rgba(16, 185, 129, 0.3);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.stat-card.highlight .stat-label {
    color: rgba(255,255,255,0.85);
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
}

.stat-value small {
    font-size: 0.875rem;
    font-weight: 400;
    opacity: 0.8;
}

.stat-sub {
    font-size: 0.75rem;
    margin-top: 0.5rem;
    opacity: 0.8;
}

/* Charts Row */
.charts-row {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    backdrop-filter: blur(10px);
}

.chart-card h3 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.chart-container {
    height: 200px;
    position: relative;
}

/* Bottom Row - Impact + Earth */
.bottom-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.impact-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.impact-card h3 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.impact-stats {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.impact-item {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.impact-num {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.impact-text {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.quick-tip {
    margin-top: 1.25rem;
    padding: 0.75rem;
    background: rgba(16, 185, 129, 0.1);
    border-radius: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.quick-tip strong {
    color: var(--primary);
}

/* Earth Card */
.earth-card {
    background: linear-gradient(180deg, #0a1628 0%, #1a2744 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
}

.earth-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 30% 30%, rgba(16, 185, 129, 0.1) 0%, transparent 50%);
    pointer-events: none;
}

#earth-container {
    width: 100%;
    height: 280px;
    position: relative;
}

#earth-container canvas {
    display: block;
}

.earth-status {
    transition: color 0.5s ease;
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}


/* ========== LOG PAGE ========== */
.log-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.section-header svg {
    width: 22px;
    height: 22px;
    color: var(--primary);
}

.section-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.log-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
}

.log-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text);
    font-family: inherit;
}

.log-btn:hover {
    background: rgba(255,255,255,0.08);
    border-color: var(--primary);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.log-btn:active {
    transform: translateY(0);
}

.log-btn.eco {
    border-color: rgba(16, 185, 129, 0.3);
    background: rgba(16, 185, 129, 0.05);
}

.log-btn.eco:hover {
    background: rgba(16, 185, 129, 0.15);
}

.log-btn.high {
    border-color: rgba(239, 68, 68, 0.3);
    background: rgba(239, 68, 68, 0.05);
}

.log-icon {
    font-size: 1.75rem;
}

.log-name {
    font-size: 0.8rem;
    font-weight: 500;
}

.log-co2 {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.log-btn.eco .log-co2 {
    color: var(--primary);
}

.log-btn.high .log-co2 {
    color: var(--danger);
}

/* Recent Activity */
.recent-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.recent-section h3 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.activity-list {
    max-height: 250px;
    overflow-y: auto;
}

.activity-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: rgba(255,255,255,0.02);
    border-radius: 8px;
    margin-bottom: 0.5rem;
}

.activity-info {
    display: flex;
    flex-direction: column;
}

.activity-type {
    font-size: 0.875rem;
    font-weight: 500;
}

.activity-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.activity-co2 {
    font-weight: 600;
    font-size: 0.875rem;
}

.activity-co2.positive { color: var(--danger); }
.activity-co2.negative { color: var(--primary); }

.empty-msg {
    color: var(--text-muted);
    font-size: 0.875rem;
    text-align: center;
    padding: 2rem;
}

/* ========== RESOURCES PAGE ========== */
.compare-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 2rem;
}

.compare-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem 2.5rem;
    text-align: center;
}

.compare-card.you {
    border-color: var(--primary);
}

.compare-card.region {
    border-color: var(--warning);
}

.compare-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.compare-value {
    display: block;
    font-size: 2.5rem;
    font-weight: 700;
}

.compare-card.you .compare-value { color: var(--primary); }
.compare-card.region .compare-value { color: var(--warning); }

.compare-unit {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.compare-vs {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-muted);
}

.resources-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.resource-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s;
}

.resource-card:hover {
    border-color: var(--primary);
    transform: translateY(-5px);
    box-shadow: 0 12px 30px rgba(16, 185, 129, 0.15);
}

.resource-card:hover .resource-icon {
    transform: scale(1.1);
}

.resource-icon {
    transition: transform 0.2s;
}

.resource-icon {
    font-size: 2rem;
    margin-bottom: 0.75rem;
}

.resource-card h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.resource-card p {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    line-height: 1.5;
}

.resource-link {
    font-size: 0.8rem;
    color: var(--primary);
    font-weight: 500;
}

.facts-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.facts-card h3 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.facts-card ul {
    list-style: none;
}

.facts-card li {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--text-muted);
    padding-left: 1.25rem;
    position: relative;
}

.facts-card li:last-child {
    border-bottom: none;
}

.facts-card li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 1rem;
    width: 6px;
    height: 6px;
    background: var(--primary);
    border-radius: 50%;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--bg-card);
    border: 1px solid var(--primary);
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s;
    z-index: 1000;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

/* Responsive */
@media (max-width: 1100px) {
    .stats-row { grid-template-columns: repeat(2, 1fr); }
    .charts-row { grid-template-columns: 1fr; }
    .bottom-row { grid-template-columns: 1fr; }
    .log-grid { grid-template-columns: repeat(2, 1fr); }
    .resources-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar { display: none; }
    .main { margin-left: 0; padding: 1rem; }
    .stats-row { grid-template-columns: 1fr; }
    .compare-section { flex-direction: column; gap: 1rem; }
}


/* ========== ANIMATIONS ========== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.stats-row .stat-card {
    animation: fadeInUp 0.5s ease backwards;
}

.stats-row .stat-card:nth-child(1) { animation-delay: 0s; }
.stats-row .stat-card:nth-child(2) { animation-delay: 0.1s; }
.stats-row .stat-card:nth-child(3) { animation-delay: 0.2s; }
.stats-row .stat-card:nth-child(4) { animation-delay: 0.3s; }

.chart-card {
    animation: fadeInUp 0.5s ease 0.2s backwards;
}

.impact-card, .earth-card {
    animation: fadeInUp 0.5s ease 0.3s backwards;
}

/* Glowing effect for highlight card */
.stat-card.highlight {
    animation: fadeInUp 0.5s ease backwards;
}

.stat-card.highlight::after {
    content: "";
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 14px;
    z-index: -1;
    opacity: 0.5;
    filter: blur(10px);
}

.stat-card.highlight {
    position: relative;
    z-index: 1;
}

/* Toast animation */
.toast {
    animation: none;
}

.toast.show {
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Log button click effect */
.log-btn.clicked {
    animation: buttonPop 0.3s ease;
}

@keyframes buttonPop {
    0% { transform: scale(1); }
    50% { transform: scale(0.95); }
    100% { transform: scale(1); }
}
