/* --- CORE CSS DESIGN (Reference: Ultra-Slick Dark UI) --- */
:root {
    --bg-deep: #161616;
    --bg-panel: #1e1e1e;
    --accent-bronze: #c5a075;
    --text-main: #f0f0f0;
    --text-muted: #8c8c8c;
    --border-panel: rgba(255, 255, 255, 0.05);
    --shadow-panel: 0 10px 30px rgba(0,0,0,0.5);
    --ff-base: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--bg-deep);
    color: var(--text-main);
    font-family: var(--ff-base);
    margin: 0;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

/* --- THE DASHBOARD CONTAINER --- */
#sim-dashboard {
    display: grid;
    grid-template-columns: 1fr 340px; /* Chart Area / Control Panel */
    grid-template-rows: 60px auto 100px; /* Header / Main / Key Metrics */
    gap: 15px;
    width: 1000px; /* Compact, centralized width */
    max-width: 95vw;
    background-color: #0d0d0d;
    border-radius: 20px;
    padding: 20px;
    box-shadow: var(--shadow-panel);
    border: 1px solid var(--border-panel);
}

/* --- COMMON CARD STYLING (The Rounded Modules) --- */
.module {
    background-color: var(--bg-panel);
    border-radius: 15px;
    border: 1px solid var(--border-panel);
    padding: 15px;
    transition: border-color 0.3s;
}

.module:hover {
    border-color: rgba(197, 160, 117, 0.4); /* Subtle hover highlight */
}

/* --- SECTION 1: HEADER & SCENARIO --- */
#sim-header {
    grid-column: 1 / 3;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 10px;
}

#scenario-status {
    color: var(--accent-bronze);
    font-size: 1.1rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 10px;
}

#current-year {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-main);
}

/* --- SECTION 2: MAIN PYRAMID CHART AREA --- */
#sim-chart-container {
    grid-column: 1 / 2;
    grid-row: 2 / 3;
    display: grid;
    grid-template-rows: auto 1fr;
    gap: 10px;
    position: relative;
}

#chart-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: var(--text-muted);
    padding: 0 10px;
}

#chart-legend {
    display: flex;
    gap: 15px;
}

.male { color: #5090f0; }
.female { color: #f05090; }

/* Scaffolding Placeholder for D3.js or Chart.js canvas */
#pyramid-canvas-placeholder {
    border: 1px dashed var(--accent-bronze);
    border-radius: 10px;
    width: 100%;
    height: 480px; /* Main Simulation Viewport */
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-muted);
}

/* --- SECTION 3: KEY METRICS BAR (Bottom) --- */
#key-metrics-bar {
    grid-column: 1 / 2;
    grid-row: 3 / 4;
    display: flex;
    gap: 15px;
}

.key-metric-card {
    flex: 1;
    display: grid;
    grid-template-rows: auto auto auto;
    border-left: 2px solid transparent;
}

.key-metric-card:hover {
    border-left: 2px solid var(--accent-bronze);
}

.key-metric-icon {
    font-size: 1.2rem;
    color: var(--accent-bronze);
}

.key-metric-value {
    font-size: 1.8rem;
    font-weight: bold;
}

.key-metric-label {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* --- SECTION 4: CONTROL PANEL (Right Side) --- */
#control-panel {
    grid-column: 2 / 3;
    grid-row: 2 / 4; /* Spans multiple rows for space */
    display: grid;
    grid-template-rows: auto 1fr auto; /* Title / Inputs / Time controls */
    gap: 15px;
}

#control-panel-title {
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    padding-bottom: 5px;
    border-bottom: 1px solid var(--border-panel);
}

.control-group {
    margin-bottom: 12px;
}

.control-label {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 4px;
    display: block;
}

/* Scaffolding placeholders for form inputs and presets */
.control-input-placeholder, .control-button-placeholder {
    width: 100%;
    height: 35px;
    background-color: #0d0d0d;
    border-radius: 8px;
    border: 1px solid var(--border-panel);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    box-sizing: border-box;
    color: var(--text-muted);
}

.control-input-placeholder::after { content: '( Slider Placeholder )'; font-size: 0.75rem; }
.control-button-placeholder { 
    justify-content: center; 
    background: linear-gradient(135deg, #2a2a2a 0%, #1e1e1e 100%);
    cursor: pointer;
    transition: all 0.3s;
}
.control-button-placeholder:hover { border-color: rgba(197, 160, 117, 0.4); background: #222; color: #fff;}

/* --- TIME CONTROLS (Bottom of Side Panel) --- */
#time-controls {
    display: grid;
    grid-template-columns: 1fr auto auto; /* Reset / Play / Speed */
    gap: 10px;
    border-top: 1px solid var(--border-panel);
    padding-top: 10px;
}

.time-control-button {
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-panel);
    cursor: pointer;
    transition: 0.3s;
}

.time-control-button.primary {
    color: var(--accent-bronze);
    border-color: rgba(197, 160, 117, 0.3);
    font-weight: bold;
}

.time-control-button:hover {
    background-color: rgba(197, 160, 117, 0.1);
}

/* --- SVG CHART STYLING --- */
#chart-wrapper {
    width: 100%;
    height: 480px;
    position: relative;
}

#pyramid-svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

/* Age Category Axis Labels */
.axis-label {
    fill: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
    text-anchor: middle;
    dominant-baseline: middle;
}

/* Population Bar Styles */
.bar-male {
    fill: url(#male-gradient);
    rx: 3px; /* Rounded bar edges */
    transition: width 0.2s ease-out, x 0.2s ease-out;
}

.bar-female {
    fill: url(#female-gradient);
    rx: 3px;
    transition: width 0.2s ease-out;
}

/* Subtle background guide grid */
.grid-line {
    stroke: rgba(255, 255, 255, 0.03);
    stroke-dasharray: 2, 2;
}

/* --- BRACKET ANNOTATIONS --- */
.cohort-bracket {
    fill: none;
    stroke-width: 1.5px;
    stroke-dasharray: 4, 3; /* Techy dashed look */
    transition: stroke 0.3s;
}

.bracket-workforce {
    stroke: var(--accent-bronze);
}

.bracket-fertile {
    stroke: #ec4899; /* Matches female pink theme */
}

.bracket-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: middle;
}

.label-workforce {
    fill: var(--accent-bronze);
}

.label-fertile {
    fill: #ec4899;
}

/* --- PRESET BUTTONS --- */
.preset-btn {
    width: 100%;
    height: 38px;
    background: linear-gradient(135deg, #2a2a2a 0%, #1e1e1e 100%);
    border: 1px solid var(--border-panel);
    border-radius: 8px;
    color: var(--text-main);
    font-weight: 500;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.preset-btn:hover {
    border-color: rgba(197, 160, 117, 0.5);
    background: #252525;
    color: var(--accent-bronze);
    transform: translateY(-1px);
}

.preset-btn:active {
    transform: translateY(0);
}