/* =========================================================
   ViableFood.org Startup Capital Estimator
   Styles — brand-consistent with Trade Area Estimator
   ========================================================= */

* { box-sizing: border-box; }

body {
    font-family: 'Roboto', sans-serif;
    margin: 0; padding: 0;
    color: #333;
    background-color: #f4f6f9;
    min-height: 100vh;
}

/* ── Header ─────────────────────────────────────────────── */
.header {
    background: #fff;
    padding: 10px 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    height: 60px;
}
.logo-container {
    display: flex; align-items: center;
    text-decoration: none; color: #333;
}
.logo-container img { height: 40px; margin-right: 15px; }
.logo-container h1  { margin: 0; font-size: 1.5em; }
.logo-org { color: #007bff; }

/* ── Page layout ─────────────────────────────────────────── */
.page-wrapper {
    display: grid;
    grid-template-columns: 420px 1fr;
    gap: 0;
    min-height: calc(100vh - 60px);
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.inputs-panel {
    background: #f8f9fa;
    border-right: 1px solid #ddd;
    padding: 28px 24px;
    overflow-y: auto;
}

.results-panel {
    padding: 28px 28px;
    overflow-y: auto;
    background: #f4f6f9;
}

/* ── Cards ───────────────────────────────────────────────── */
.card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    border: 1px solid #e9ecef;
}
.card-title {
    font-size: 1.2em;
    border-bottom: 2px solid #007bff;
    padding-bottom: 8px;
    margin-top: 0; margin-bottom: 15px;
    color: #0056b3;
}

/* ── Form elements ───────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-row    { display: flex; gap: 10px; }
.form-row .form-group { flex: 1; }

label {
    display: block;
    font-size: 0.9em;
    font-weight: bold;
    color: #444;
    margin-bottom: 5px;
}
label .optional {
    font-weight: normal;
    color: #888;
    font-size: 0.85em;
}

input[type="number"],
input[type="range"],
select {
    width: 100%;
    padding: 9px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1em;
    background: #fff;
    transition: border-color 0.15s;
}
input[type="number"]:focus,
select:focus { border-color: #007bff; outline: none; box-shadow: 0 0 0 2px rgba(0,123,255,0.15); }

/* Sqft slider row */
.slider-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.slider-row input[type="range"] {
    flex: 1;
    padding: 0;
    accent-color: #007bff;
}
.slider-row input[type="number"] {
    width: 90px;
    flex-shrink: 0;
    text-align: right;
}
.slider-value {
    font-size: 0.85em;
    color: #555;
    text-align: right;
    margin-top: 3px;
}

select option[value=""] { color: #999; }

.field-note {
    font-size: 0.82em;
    color: #777;
    margin-top: 4px;
    line-height: 1.4;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
    background-color: #007bff; color: white;
    border: none; cursor: pointer;
    border-radius: 4px; font-weight: bold;
    padding: 11px 20px; font-size: 1em;
    transition: background 0.2s;
    width: 100%;
}
.btn:hover { background-color: #0056b3; }
.btn-outline {
    background: transparent;
    border: 2px solid #007bff; color: #007bff;
    padding: 8px 16px; width: auto;
    border-radius: 4px; font-weight: bold;
    cursor: pointer; font-size: 0.95em;
    transition: all 0.2s;
}
.btn-outline:hover { background: #007bff; color: white; }
.btn-green { background-color: #28a745; }
.btn-green:hover { background-color: #1e7e34; }

/* ── Undercapitalization banner (mandated by PRD) ──────── */
.undercap-banner {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-left: 5px solid #e6a800;
    border-radius: 6px;
    padding: 14px 18px;
    margin-bottom: 22px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}
.undercap-banner .icon { font-size: 1.4em; flex-shrink: 0; line-height: 1.3; }
.undercap-banner .text { font-size: 0.95em; line-height: 1.5; color: #6b4c00; }
.undercap-banner .text strong { font-size: 1.05em; display: block; margin-bottom: 3px; color: #4d3600; }

/* ── Results: metric values ──────────────────────────────── */
.metric-value {
    font-size: 2em;
    font-weight: bold;
    color: #2c3e50;
    margin: 6px 0 4px 0;
    line-height: 1.1;
}
.metric-range {
    font-size: 1.4em;
    font-weight: bold;
    color: #0056b3;
    margin: 6px 0 4px 0;
}
.metric-subtext {
    font-size: 0.82em;
    color: #666;
    line-height: 1.45;
    margin-top: 4px;
}

/* ── Capital breakdown chart ─────────────────────────────── */
.chart-wrapper {
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
}
.chart-canvas-wrap { flex-shrink: 0; width: 180px; height: 180px; }
.chart-legend { flex: 1; min-width: 180px; }
.legend-item {
    display: flex; align-items: center;
    gap: 8px; margin-bottom: 9px;
    font-size: 0.9em;
}
.legend-swatch {
    width: 14px; height: 14px;
    border-radius: 3px; flex-shrink: 0;
}
.legend-label { flex: 1; color: #444; }
.legend-amount { font-weight: bold; color: #2c3e50; }

/* ── Risk indicator ──────────────────────────────────────── */
.risk-box {
    padding: 14px 16px;
    border-radius: 6px;
    border-left: 5px solid;
    display: flex; align-items: flex-start; gap: 12px;
}
.risk-box .risk-icon { font-size: 1.3em; flex-shrink: 0; }
.risk-box .risk-content {}
.risk-box .risk-label { font-weight: bold; font-size: 1.05em; margin-bottom: 3px; }
.risk-box .risk-desc  { font-size: 0.88em; line-height: 1.45; }

.risk-box.high     { background: #fde8e8; border-color: #dc3545; color: #7b1010; }
.risk-box.tight    { background: #fff3cd; border-color: #ffc107; color: #6b4c00; }
.risk-box.good     { background: #d4edda; border-color: #28a745; color: #155724; }
.risk-box.pending  { background: #e9ecef; border-color: #adb5bd; color: #495057; }

/* ── Cost driver highlight ───────────────────────────────── */
.cost-driver-box {
    background: #e8f0fe;
    border: 1px solid #b3ccff;
    border-radius: 6px;
    padding: 12px 16px;
    font-size: 0.95em;
    color: #0056b3;
}
.cost-driver-box strong { font-size: 1.05em; }

/* ── Size vs Capital insight ─────────────────────────────── */
.insight-box {
    padding: 12px 16px;
    border-radius: 6px;
    border-left: 4px solid;
    font-size: 0.9em;
    line-height: 1.5;
}
.insight-box.warning  { background: #fff3cd; border-color: #ffc107; color: #6b4c00; }
.insight-box.healthy  { background: #d4edda; border-color: #28a745; color: #155724; }
.insight-box.tight    { background: #fde8e8; border-color: #dc3545; color: #7b1010; }

/* ── Bucket rows (input summary in results) ──────────────── */
.bucket-row {
    display: flex; justify-content: space-between;
    align-items: center; padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.92em;
}
.bucket-row:last-child { border-bottom: none; }
.bucket-row .bucket-name { color: #555; }
.bucket-row .bucket-amt  { font-weight: bold; color: #2c3e50; }

/* ── Results placeholder (before first calculation) ─────── */
.results-placeholder {
    text-align: center;
    padding: 60px 20px;
    color: #aaa;
}
.results-placeholder .placeholder-icon { font-size: 3em; margin-bottom: 12px; }
.results-placeholder p { font-size: 1em; }

/* ── Footer ──────────────────────────────────────────────── */
.footer-disclaimer {
    font-size: 0.82em; color: #888;
    margin-top: 20px; padding-top: 16px;
    border-top: 1px solid #ddd;
    line-height: 1.5;
}
.footer-disclaimer a { color: #007bff; }

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    justify-content: center; align-items: center;
    z-index: 2000;
}
.modal {
    background: white; width: 640px;
    max-width: 92%; max-height: 90vh;
    overflow-y: auto; border-radius: 8px;
    padding: 30px; position: relative;
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
}
.close-modal { position: absolute; top: 14px; right: 18px; font-size: 1.5em; cursor: pointer; color: #666; }
.close-modal:hover { color: #000; }

/* ── Trade Area import banner (reserved for future) ──────── */
.tae-import-banner {
    display: none; /* shown by JS when TAE data is present */
    background: #e8f4fd;
    border: 1px solid #b3d9f7;
    border-left: 4px solid #007bff;
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 20px;
    font-size: 0.9em;
    color: #0056b3;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 860px) {
    .page-wrapper {
        grid-template-columns: 1fr;
    }
    .inputs-panel { border-right: none; border-bottom: 1px solid #ddd; }
}
