/* ── Moonshop Carbon Agent Styles ── */
@import url('/css/reset.css');

:root {
    --ink: #0a0f1a;
    --chalk: #f8f7f4;
    --accent: #d94432;
    --accent-light: #e8604f;
    --accent-pale: #fdecea;
    --warm: #d4a853;
    --warm-pale: #faf3e0;
    --slate: #3d4f5f;
    --mist: #e9ecef;
    --concrete: #6c757d;
    --white: #ffffff;
    --red: #c0392b;
    --radius: 10px;
    --radius-sm: 6px;
}

body {
    font-family: 'DM Sans', sans-serif;
    color: var(--ink);
    background: var(--chalk);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
    font-family: 'Space Grotesk', sans-serif;
    letter-spacing: -0.02em;
}

/* ── NAV ── */
nav {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 100;
    height: 60px;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(248, 247, 244, 0.9);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(10, 15, 26, 0.06);
}

@media (max-width: 768px) {
    nav { height: 56px; padding: 0 1.25rem; }
}

.logo {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--ink);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo-mark {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 0.35rem 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.nav-link {
    font-size: 0.875rem;
    color: var(--slate);
    text-decoration: none;
    font-weight: 500;
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
}
.nav-link:hover {
    background: transparent;
    color: var(--accent);
}
.nav-link.active {
    color: var(--accent);
    font-weight: 600;
    background: transparent;
}

/* ── MAIN ── */
.dashboard {
    max-width: 1000px;
    margin: 0 auto;
    padding: 5.5rem 1.5rem 3rem;
}

.section-header { margin-bottom: 1.5rem; }
.section-label {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--accent);
    display: block;
    margin-bottom: 0.5rem;
}
.section-header h2 {
    font-size: 1.6rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
}
.section-desc {
    color: var(--slate);
    font-size: 0.95rem;
    max-width: 550px;
}

/* ── UPLOAD ZONE ── */
.upload-section { margin-bottom: 3rem; }

.upload-zone {
    border: 2px dashed var(--mist);
    border-radius: var(--radius);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    background: var(--white);
}
.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--accent);
    background: var(--accent-pale);
}
.upload-zone.dragover { border-style: solid; }

.upload-icon { margin-bottom: 1rem; }
.upload-text {
    font-size: 1rem;
    color: var(--ink);
    margin-bottom: 0.25rem;
}
.upload-sub {
    font-size: 0.85rem;
    color: var(--concrete);
}

/* ── PROGRESS ── */
.upload-progress {
    margin-top: 1.25rem;
}
.progress-bar {
    height: 6px;
    background: var(--mist);
    border-radius: 3px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    width: 0%;
    transition: width 0.3s ease;
}
.progress-text {
    font-size: 0.85rem;
    color: var(--slate);
    margin-top: 0.5rem;
}

.pipeline-error {
    margin-top: 1rem;
    background: rgba(192, 57, 43, 0.1);
    border: 1px solid rgba(192, 57, 43, 0.38);
    border-radius: var(--radius);
    padding: 1rem 1rem 1.1rem;
}

.pipeline-error h3 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1rem;
    margin-bottom: 0.35rem;
    color: #ffd9d2;
}

.pipeline-error p {
    font-size: 0.92rem;
    color: rgba(248, 247, 244, 0.92);
    margin-bottom: 0.8rem;
}

.pipeline-error-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
}

.analysis-warning-card {
    margin: 0 0 1.25rem;
    background: rgba(212, 168, 83, 0.12);
    border: 1px solid rgba(212, 168, 83, 0.45);
    border-radius: var(--radius);
    padding: 0.95rem 1rem;
}

.analysis-warning-card h4 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.95rem;
    margin-bottom: 0.3rem;
    color: #ffe8bf;
}

.analysis-warning-card p {
    margin: 0 0 0.4rem;
    font-size: 0.88rem;
    color: rgba(248, 247, 244, 0.9);
}

.analysis-warning-card ul {
    margin: 0;
    padding-left: 1rem;
    color: rgba(248, 247, 244, 0.9);
    font-size: 0.85rem;
}

.analysis-warning-card li { margin: 0.2rem 0; }

.empty-state-cta {
    margin-top: 0.85rem;
    min-height: 44px;
}

/* ── RESULTS ── */
.results-section { margin-bottom: 2rem; }

.results-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
}
.results-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* ── BUTTONS ── */
.btn {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.55rem 1.2rem;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}
.btn-primary {
    background: var(--accent);
    color: white;
}
.btn-primary:hover { background: var(--accent-light); }
.btn-outline {
    background: transparent;
    color: var(--slate);
    border: 1px solid var(--mist);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

/* ── SUMMARY CARDS ── */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}
.summary-card {
    background: var(--white);
    border: 1px solid var(--mist);
    border-radius: var(--radius);
    padding: 1.25rem;
    transition: border-color 0.15s;
}
.summary-card:hover { border-color: var(--accent-light); }
.summary-card .card-label {
    font-size: 0.75rem;
    color: var(--concrete);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.4rem;
}
.summary-card .card-value {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--ink);
    line-height: 1.2;
}
.summary-card .card-unit {
    font-size: 0.8rem;
    color: var(--slate);
    margin-top: 0.15rem;
}
.summary-card.rating { border-left: 3px solid var(--accent); }
.card-rating {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    border-radius: 4px;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
}

/* ── TABLES ── */
.breakdown-section {
    margin-bottom: 2rem;
}
.breakdown-section h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--ink);
}
.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}
.element-count {
    font-size: 0.8rem;
    color: var(--concrete);
}

.table-wrap {
    background: var(--white);
    border: 1px solid var(--mist);
    border-radius: var(--radius);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}
.table-scroll {
    max-height: 500px;
    overflow-y: auto;
}

.data-table {
    width: 100%;
    min-width: 640px;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.data-table th {
    background: var(--accent-pale);
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent);
    padding: 0.6rem 1rem;
    text-align: left;
    position: sticky;
    top: 0;
    z-index: 1;
}
.data-table td {
    padding: 0.55rem 1rem;
    border-top: 1px solid var(--mist);
    color: var(--ink);
}
.data-table tbody tr:hover { background: rgba(217, 68, 50, 0.03); }

/* Element details: hover / keyboard focus shows native tooltip with full IFC name + type hint */
.element-detail-row {
  cursor: help;
}
.element-detail-row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.share-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.share-fill {
    height: 6px;
    border-radius: 3px;
    background: var(--accent);
    min-width: 2px;
}
.share-fill.warm { background: var(--warm); }
.share-pct {
    font-size: 0.75rem;
    color: var(--concrete);
    min-width: 35px;
}

/* ── OPPORTUNITIES ── */
.opportunities-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.75rem;
}
.opportunity-card {
    background: var(--white);
    border: 1px solid var(--mist);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    border-left: 3px solid var(--accent);
}
.opportunity-card .opp-element {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
    color: var(--ink);
}
.opportunity-card .opp-detail {
    font-size: 0.8rem;
    color: var(--slate);
    margin-bottom: 0.35rem;
}
.opportunity-card .opp-saving {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    color: var(--accent);
    font-size: 0.95rem;
}

#opportunitiesSummary {
    margin-top: 1rem;
    padding: 0.85rem 1rem;
    background: var(--chalk);
    border-top: 2px solid var(--accent);
    border-radius: 0 0 8px 8px;
}
#opportunitiesSummary .opp-summary-line {
    font-size: 0.9rem;
    color: var(--ink);
    line-height: 1.6;
}
#opportunitiesSummary .opp-summary-line strong {
    color: var(--accent);
    font-family: 'Space Grotesk', sans-serif;
}

/* ── HISTORY ── */
.history-section { margin-bottom: 2rem; }
.history-list { display: flex; flex-direction: column; gap: 0.5rem; }
.empty-state {
    font-size: 0.9rem;
    color: var(--concrete);
    padding: 1.5rem;
    text-align: center;
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--mist);
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.85rem 1.25rem;
    background: var(--white);
    border: 1px solid var(--mist);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color 0.15s;
}
.history-item:hover { border-color: var(--accent-light); }
.history-item .hi-name {
    font-weight: 600;
    font-size: 0.9rem;
}
.history-item .hi-meta {
    font-size: 0.8rem;
    color: var(--concrete);
}
.history-item .hi-carbon {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    color: var(--accent);
    font-size: 0.9rem;
}
.history-item .hi-rating {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 700;
    color: white;
    margin-left: 0.5rem;
}

/* ── ERROR ── */
.error-msg {
    background: #fdf2f2;
    border: 1px solid #fecaca;
    color: var(--red);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-top: 1rem;
}

/* ── FOOTER ── */
footer {
    padding: 2rem;
    text-align: center;
    font-size: 0.85rem;
    color: var(--concrete);
    border-top: 1px solid var(--mist);
    margin-top: 2rem;
}

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
    nav { padding: 0.85rem 1rem; }
    .dashboard { padding: 5rem 1rem 2rem; }
    .summary-cards { grid-template-columns: repeat(2, 1fr); }
    .opportunities-grid { grid-template-columns: 1fr; }
    .results-header-row { flex-direction: column; }
    .results-actions { width: 100%; flex-wrap: wrap; }
    .results-actions .btn { flex: 1 1 calc(50% - 0.4rem); justify-content: center; min-height: 44px; }
    .data-table { font-size: 0.8rem; }
    .data-table th, .data-table td { padding: 0.45rem 0.65rem; }
    .upload-zone { padding: 2rem 1rem; }
    .upload-text, .section-desc, .empty-state, .history-item .hi-name, .history-item .hi-meta { font-size: 1rem; }
    .history-item { align-items: flex-start; gap: 0.6rem; flex-direction: column; }
    .pipeline-error-actions .btn { min-height: 44px; }
}

@media (max-width: 480px) {
    .summary-cards { grid-template-columns: 1fr; }
    .results-actions .btn { flex: 1 1 100%; }
}
