/* ══════════════════════════════════════════════════════════════
   AI Sustainability Calculator v2 — Google Material Design Theme
   Adopts Google Sans / Roboto typography and Material Dark colors
══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Google+Sans:wght@400;500;700&family=Roboto:wght@300;400;500;700&display=swap');

:root {
    /* Material Dark Colors */
    --md-bg: #202124;
    --md-surface: #282a2d;
    --md-surface-2: #303134;
    --md-surface-3: #3c4043;
    
    /* Google Brand Colors (Dark Mode Variants) */
    --google-blue: #8ab4f8;
    --google-blue-dark: rgba(138, 180, 248, 0.12);
    --google-green: #81c995;
    --google-green-dark: rgba(129, 201, 149, 0.12);
    --google-yellow: #fdd663;
    --google-red: #f28b82;
    --google-red-dark: rgba(242, 139, 130, 0.12);
    
    /* Typography */
    --font-google: 'Google Sans', 'Roboto', Arial, sans-serif;
    --font-roboto: 'Roboto', Arial, sans-serif;
    
    /* Text */
    --text-primary: #e8eaed;
    --text-secondary: #9aa0a6;
    --text-disabled: #5f6368;
    
    /* Borders & Dividers */
    --md-divider: #5f6368;
    --md-border: #3c4043;
    
    /* Theme Aliases */
    --human: var(--google-yellow);
    --human-light: rgba(253, 214, 99, 0.12);
    --human-border: rgba(253, 214, 99, 0.35);
    
    --ai: var(--google-blue);
    --ai-light: var(--google-blue-dark);
    --ai-border: rgba(138, 180, 248, 0.35);
    
    --blue: var(--google-blue);
    --purple: #c58af9; /* Material Purple */
    --cyan: #78d9ec; /* Material Cyan */
    --green: var(--google-green);
    --orange: #fcad70; /* Material Orange */
    --red: var(--google-red);
}

body {
    background-color: var(--md-bg);
    color: var(--text-primary);
    font-family: var(--font-roboto);
    line-height: 1.5;
    margin: 0;
    -webkit-font-smoothing: antialiased;
}

.background-glow { display: none; } /* Remove old glow */

/* ── HERO ─────────────────────────────────────────────────── */
.hero {
    text-align: center;
    padding: 64px 24px 40px;
    background-color: var(--md-bg);
    border-bottom: 1px solid var(--md-border);
    animation: fadeIn .5s ease-out;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--google-green-dark);
    color: var(--google-green);
    padding: 6px 16px;
    border-radius: 16px; /* Material Chip */
    font-size: 0.875rem;
    font-family: var(--font-google);
    font-weight: 500;
    margin-bottom: 24px;
}

.hero h1 {
    font-family: var(--font-google);
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 400; /* Google uses lighter weights for large headers */
    margin-bottom: 16px;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.hero p {
    color: var(--text-secondary);
    font-size: 1.125rem;
    max-width: 640px;
    margin: 0 auto;
    font-weight: 400;
}

/* ── CONFIG BAR ───────────────────────────────────────────── */
.config-bar {
    max-width: 1240px;
    margin: 24px auto 0;
    padding: 16px 24px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    background: var(--md-surface);
    border: 1px solid var(--md-border);
    border-radius: 24px;
    position: sticky;
    top: 24px;
    z-index: 50;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

.config-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: none;
    color: var(--google-blue);
    font-size: 0.875rem;
    font-family: var(--font-google);
    font-weight: 500;
    cursor: pointer;
    padding: 8px 16px;
    border-radius: 16px;
    transition: background 0.2s;
}

.config-toggle:hover { background: var(--google-blue-dark); }
.toggle-chevron { transition: transform .3s; }
.config-toggle[aria-expanded="true"] .toggle-chevron { transform: rotate(180deg); }

.config-quick {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    flex: 1;
}

.quick-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 160px;
}

.quick-item label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: var(--font-roboto);
    font-weight: 500;
}

.quick-item input,
.quick-item select {
    background: var(--md-surface-2);
    border: 1px solid var(--md-border);
    border-radius: 4px; /* Material Input */
    color: var(--text-primary);
    padding: 10px 12px;
    font-size: 0.875rem;
    font-family: var(--font-roboto);
    outline: none;
    transition: border-color 0.2s;
}

.quick-item input:focus,
.quick-item select:focus {
    border-color: var(--google-blue);
    border-width: 2px;
    padding: 9px 11px; /* Compensate for border width */
}

.input-pfx {
    display: flex;
    align-items: center;
    background: var(--md-surface-2);
    border: 1px solid var(--md-border);
    border-radius: 4px;
    transition: border-color 0.2s;
}

.input-pfx:focus-within {
    border-color: var(--google-blue);
    border-width: 2px;
}

.input-pfx > span {
    padding: 10px 12px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    border-right: 1px solid var(--md-border);
}

.input-pfx:focus-within > span {
    padding: 9px 11px;
    border-right-width: 2px;
}

.input-pfx input {
    border: none !important;
    background: transparent;
    border-radius: 0 4px 4px 0 !important;
    flex: 1;
}

.input-pfx:focus-within input { padding: 9px 11px; }

.btn-run {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--google-blue);
    color: #202124;
    font-family: var(--font-google);
    font-weight: 500;
    font-size: 0.875rem;
    border: none;
    border-radius: 24px; /* Material Pill Button */
    padding: 10px 24px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s, box-shadow 0.2s;
}

.btn-run:hover {
    background: #aecbfa;
    box-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.btn-run-lg { font-size: 1rem; padding: 12px 32px; border-radius: 28px; }

/* ── EXPAND CONFIG PANEL ──────────────────────────────────── */
.config-panel {
    max-width: 1240px;
    margin: 16px auto 0;
    padding: 32px;
    background: var(--md-surface);
    border: 1px solid var(--md-border);
    border-radius: 24px;
}

.cfg-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
}

.cfg-col-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    font-family: var(--font-google);
    font-weight: 500;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--md-border);
}

.human-header { color: var(--google-yellow); }
.ai-header    { color: var(--google-blue); }

.cfg-fields { display: flex; flex-direction: column; gap: 16px; }

.cfg-field label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-primary);
    margin-bottom: 8px;
    font-family: var(--font-roboto);
}

.cfg-field input[type="number"],
.cfg-field input[type="text"],
.cfg-field select {
    width: 100%;
    background: var(--md-surface-2);
    border: 1px solid var(--md-border);
    border-radius: 4px;
    color: var(--text-primary);
    padding: 10px 12px;
    font-size: 0.875rem;
    font-family: var(--font-roboto);
    outline: none;
}

.cfg-field input:focus, .cfg-field select:focus {
    border-color: var(--google-blue);
    border-width: 2px;
    padding: 9px 11px;
}

select option { background: var(--md-surface); }

.range-row {
    display: flex;
    gap: 16px;
    align-items: center;
}

.range-row input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    height: 4px;
    background: var(--md-border);
    border-radius: 2px;
    outline: none;
}

.range-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px; height: 16px;
    border-radius: 50%;
    background: var(--google-blue);
    cursor: pointer;
}

.range-row input[type="number"] {
    width: 80px;
    text-align: center;
}

.hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 4px;
    display: block;
}

.cfg-actions {
    display: flex;
    justify-content: center;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--md-border);
}

/* ── LOADING ──────────────────────────────────────────────── */
.loading-overlay {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    min-height: 300px;
    color: var(--text-secondary);
    font-family: var(--font-google);
}

.spinner {
    width: 40px; height: 40px;
    border: 4px solid var(--md-surface-3);
    border-top-color: var(--google-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ── MODEL TAG ────────────────────────────────────────────── */
.model-tag {
    max-width: 1240px;
    margin: 24px auto 0;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--md-surface);
    border: 1px solid var(--md-border);
    border-radius: 12px;
    font-size: 0.875rem;
    font-family: var(--font-roboto);
}

.model-tag i { color: var(--google-blue); }
.model-tag-users { margin-left: auto; color: var(--text-secondary); }

/* ── TAB NAV ──────────────────────────────────────────────── */
.tab-nav {
    max-width: 1240px;
    margin: 24px auto 0;
    display: flex;
    border-bottom: 1px solid var(--md-border);
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 16px 24px;
    font-size: 0.875rem;
    font-family: var(--font-google);
    font-weight: 500;
    cursor: pointer;
    position: relative;
    transition: color 0.2s;
}

.tab-btn:hover { color: var(--text-primary); background: var(--md-surface); }
.tab-btn.active { color: var(--google-blue); }
.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--google-blue);
    border-radius: 3px 3px 0 0;
}

/* ── TAB PANES ────────────────────────────────────────────── */
.tab-pane {
    max-width: 1240px;
    margin: 0 auto;
    padding: 32px 0 64px;
}

.tab-pane.hidden { display: none; }

.tab-desc {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-bottom: 32px;
    font-family: var(--font-roboto);
}

.tab-desc strong { color: var(--text-primary); font-weight: 500; }

/* ── COMPARE GRID ─────────────────────────────────────────── */
.compare-grid {
    display: grid;
    grid-template-columns: 1fr 140px 1fr;
    gap: 24px;
    margin-bottom: 32px;
}

/* ── COMPARE COLUMNS ──────────────────────────────────────── */
.compare-col {
    background: var(--md-surface);
    border: 1px solid var(--md-border);
    border-radius: 24px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.human-col { border-top: 4px solid var(--google-yellow); }
.ai-col    { border-top: 4px solid var(--google-blue); }

.compare-col-header {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.125rem;
    font-family: var(--font-google);
    font-weight: 400;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--md-border);
}

/* ── METRIC ROWS ──────────────────────────────────────────── */
.metric-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 16px;
}

.metric-block {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: var(--md-bg);
    border: 1px solid var(--md-border);
    border-radius: 16px;
    padding: 16px;
}

.metric-block.full { grid-column: 1 / -1; }

.metric-icon {
    width: 40px; height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.human-icon { background: var(--human-light); color: var(--google-yellow); }
.ai-icon    { background: var(--ai-light);  color: var(--google-blue);    }

.metric-value {
    font-family: var(--font-google);
    font-size: 1.5rem;
    font-weight: 400;
    color: var(--text-primary);
    line-height: 1.2;
    margin-bottom: 4px;
}

.metric-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: var(--font-roboto);
}

/* ── CARBON BREAKDOWN LIST ────────────────────────────────── */
.carbon-breakdown {
    background: var(--md-bg);
    border: 1px solid var(--md-border);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.breakdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.875rem;
    font-family: var(--font-roboto);
}

.bd-dot {
    width: 12px; height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.bd-label { flex: 1; color: var(--text-secondary); }
.bd-val { font-weight: 500; color: var(--text-primary); }

.breakdown-chart { max-height: 200px; margin-top: 16px; }

/* ── VS DIVIDER ───────────────────────────────────────────── */
.vs-divider {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding-top: 80px;
}

.vs-circle {
    width: 48px; height: 48px;
    border-radius: 50%;
    background: var(--md-surface-2);
    border: 1px solid var(--md-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-family: var(--font-google);
    font-weight: 500;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.vs-line {
    flex: 1;
    width: 1px;
    background: var(--md-divider);
    min-height: 40px;
}

/* ── SAVINGS PILLS ────────────────────────────────────────── */
.savings-pills {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.savings-pill {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px;
    border-radius: 16px;
    background: var(--md-surface);
    border: 1px solid var(--md-border);
    text-align: center;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.savings-pill i   { font-size: 1.25rem; margin-bottom: 4px; }
.savings-pill span { 
    font-family: var(--font-google); 
    font-size: 1.125rem; 
    font-weight: 500; 
    color: var(--text-primary);
}
.savings-pill small { 
    font-size: 0.75rem; 
    color: var(--text-secondary);
    font-family: var(--font-roboto);
}

.time-pill i   { color: var(--cyan);   }
.cost-pill i   { color: var(--google-green); }
.carbon-pill i { color: var(--google-blue);  }
.water-pill i  { color: var(--google-blue);  }
.tree-pill i   { color: var(--google-green); }

/* ── CHART CARDS ──────────────────────────────────────────── */
.chart-card {
    background: var(--md-surface);
    border: 1px solid var(--md-border);
    border-radius: 24px;
    padding: 24px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.chart-card.full-width { margin-top: 24px; }

.charts-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-top: 24px;
}

.chart-title {
    font-size: 1rem;
    font-family: var(--font-google);
    font-weight: 500;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.chart-title i { color: var(--google-blue); font-size: 1.25rem; }

/* ── INSIGHT PANEL ────────────────────────────────────────── */
.insight-panel {
    display: flex;
    gap: 24px;
    background: var(--md-surface-2);
    border-left: 4px solid var(--google-blue);
    border-radius: 8px 16px 16px 8px;
    padding: 24px;
    margin-top: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.insight-icon { font-size: 2rem; color: var(--google-yellow); flex-shrink: 0; }
.insight-body { color: var(--text-primary); font-size: 1rem; line-height: 1.6; font-family: var(--font-roboto); }
.insight-body strong { font-weight: 500; color: var(--google-blue); }

/* ── UTILITIES ────────────────────────────────────────────── */
.positive { color: var(--google-green) !important; }
.negative { color: var(--google-red) !important; }
.text-gradient { color: var(--google-blue); }

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

/* ── RESPONSIVE ───────────────────────────────────────────── */
@media (max-width: 1024px) {
    .compare-grid {
        grid-template-columns: 1fr;
        gap: 32px;
    }

    .vs-divider {
        flex-direction: row;
        flex-wrap: wrap;
        padding-top: 0;
        justify-content: center;
        gap: 16px;
    }

    .vs-line { display: none; }
    .vs-circle { flex-shrink: 0; margin-bottom: 16px; }

    .savings-pills {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        width: auto;
    }

    .savings-pill { width: 140px; }

    .cfg-grid { grid-template-columns: 1fr; }
    .charts-2col { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    .hero { padding: 40px 16px 24px; }
    .hero h1 { font-size: 2rem; }
    
    .config-bar {
        top: 0;
        border-radius: 0 0 16px 16px;
        padding: 16px;
    }

    .tab-nav { overflow-x: auto; padding: 0 16px; margin: 16px -16px 0; }
    .tab-btn { white-space: nowrap; }

    .compare-col { padding: 16px; border-radius: 16px; }
    .metric-row { grid-template-columns: 1fr; }
    .metric-block { padding: 12px; }
    
    .chart-card { padding: 16px; border-radius: 16px; }
    .insight-panel { padding: 16px; flex-direction: column; gap: 16px; }
}
