/* =====================================================
   EDIFICEX — Brand Theme aligned with EdificeX Landing Page
   ===================================================== */

/* --- Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* --- CSS Variables (mirrored from landing page SCSS) --- */
:root {
    /* Brand colors — exact match to landing page $primary palette */
    --maroon: #800020;
    --maroon-light: #a00030;
    --maroon-dark: #500000;
    --maroon-glow: rgba(128, 0, 32, 0.15);

    /* Backgrounds — white, matching landing page $light */
    --bg-primary: #ffffff;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f5f5f5;
    --bg-card: #ffffff;

    /* Text — matching landing page $dark / $text / $text-light */
    --text-primary: #111111;
    --text-secondary: #333333;
    --text-muted: #666666;

    /* Accents */
    --accent-buyer: #800020;
    --accent-buyer-light: rgba(128, 0, 32, 0.08);
    --accent-investor: #2D6A4F;
    --accent-investor-light: rgba(45, 106, 79, 0.1);
    --accent-property: #6B4C9A;
    --accent-property-light: rgba(107, 76, 154, 0.1);
    --accent-warning: #D4770B;
    --accent-danger: #C0392B;
    --accent-blue: #2563eb;

    /* Gradient — exact match to landing page $gradient */
    --gradient-brand: linear-gradient(90deg, rgb(128, 0, 32) 0%, #500000 100%);

    /* Borders */
    --border-color: rgba(0, 0, 0, 0.08);
    --border-maroon: rgba(128, 0, 32, 0.12);
    --border-focus: rgba(128, 0, 32, 0.4);

    /* Spacing */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;

    /* Shadows — matching landing page card shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.05);
    --shadow-card: 0 10px 30px rgba(0, 0, 0, 0.05);
    --shadow-card-hover: 0 15px 40px rgba(0, 0, 0, 0.1);
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* --- Layout --- */
.dashboard {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 0;
    min-height: 100vh;
    position: relative;
}

/* Particles canvas — full-page background, matches landing page BlockchainParticles */
.particles-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    opacity: 0.08;
    pointer-events: none;
}

/* All panels sit above particles */
.form-panel,
.results-panel,
.header {
    position: relative;
    z-index: 1;
}

/* --- Header — black background --- */
.header {
    grid-column: 1 / -1;
    padding: 8px 32px;
    background: #000000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(128, 0, 32, 0.4);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5), 0 1px 6px rgba(0, 0, 0, 0.3);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header__logo {
    display: flex;
    align-items: center;
}

.header__logo--wordmark {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

/* Logo image — invert(1)+hue-rotate(180deg) makes white bg → black
   (blends away on the black header) and preserves the maroon accent. */
.header__logo-img {
    height: 80px;
    width: auto;
    display: block;
    filter: invert(1) hue-rotate(180deg);
}

.header__logo-img--mark {
    height: 56px;
}

.header__logo-img--wordmark {
    height: 56px;
    width: auto;
    max-height: none;
}

/* Badge — white text on black header, maroon accent border */
.header__badge {
    background: rgba(128, 0, 32, 0.25);
    padding: 6px 14px;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    letter-spacing: 0.5px;
    border: 1px solid rgba(128, 0, 32, 0.6);
}

/* --- Form Panel --- */
.form-panel {
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    padding: 24px;
    overflow-y: auto;
    max-height: calc(100vh - 60px);
}

/* Section title — matches landing page .sectionLabel */
.form-section {
    margin-bottom: 20px;
}

.form-section__title {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--maroon);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-section__title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-maroon);
}

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

.form-group label {
    display: block;
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
    font-weight: 500;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(128, 0, 32, 0.1);
}

/* Input with integrated toggle - Grid Layout */
.input-with-toggle {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    border: none;
    background: transparent;
    padding: 0;
    overflow: visible;
}

.input-with-toggle:focus-within {
    border-color: transparent;
    box-shadow: none;
}

.input-with-toggle input {
    /* Restore standard input styles */
    width: 100% !important;
    border: 1px solid var(--border-color) !important;
    background: var(--bg-tertiary) !important;
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    box-shadow: none;
    transition: all 0.2s ease;
    height: 100%;
}

.input-with-toggle input:focus {
    border-color: var(--border-focus) !important;
    box-shadow: 0 0 0 3px rgba(128, 0, 32, 0.1) !important;
}

.unit-toggle {
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    color: var(--text-secondary);
    padding: 0 12px;
    height: 100%;
    /* Match input height */
    min-height: 38px;
    cursor: pointer;
    font-weight: 500;
    width: auto;
    min-width: 60px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.unit-toggle:hover {
    color: var(--text-primary);
    border-color: var(--border-focus);
    background: var(--bg-secondary);
}

.unit-toggle:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(128, 0, 32, 0.1);
}

.form-group input[type="checkbox"] {
    width: auto;
    accent-color: var(--accent-buyer);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* Collapsible advanced section */
.form-section--advanced {
    border: 1px solid var(--border-maroon);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.form-section--advanced .form-section__toggle {
    width: 100%;
    padding: 10px 16px;
    background: rgba(128, 0, 32, 0.04);
    border: none;
    color: var(--maroon);
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
}

.form-section--advanced .form-section__toggle:hover {
    background: rgba(128, 0, 32, 0.08);
}

.form-section--advanced .form-section__toggle .chevron {
    transition: transform 0.3s ease;
}

.form-section--advanced.is-open .form-section__toggle .chevron {
    transform: rotate(180deg);
}

.form-section--advanced .form-section__body {
    padding: 0 16px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
}

.form-section--advanced.is-open .form-section__body {
    padding: 16px;
    max-height: 600px;
}

/* Submit button — matches landing page .ctaBtn */
.btn-simulate {
    width: 100%;
    padding: 14px 32px;
    background: var(--gradient-brand);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    margin-top: 8px;
    box-shadow: 0 4px 15px rgba(128, 0, 32, 0.2);
}

/* Glow overlay on hover — matches landing page .btnGlow */
.btn-simulate::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    background: radial-gradient(circle at center, rgba(255, 255, 255, 0.8) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.btn-simulate:hover {
    background: linear-gradient(90deg, var(--maroon-light) 0%, var(--maroon) 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(128, 0, 32, 0.3);
}

.btn-simulate:hover::after {
    opacity: 0.3;
}

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

.btn-simulate:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Export button — matches landing page .linkBtn */
.btn-export {
    width: 100%;
    padding: 10px;
    background: transparent;
    color: var(--accent-blue);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-export:hover {
    color: var(--accent-blue);
    background: rgba(37, 99, 235, 0.05);
    border-color: rgba(37, 99, 235, 0.3);
}

/* --- Results Panel --- */
.results-panel {
    padding: 24px;
    overflow-y: auto;
    max-height: calc(100vh - 60px);
    background: var(--bg-primary);
}

/* Welcome state */
.results-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 60vh;
    text-align: center;
    opacity: 0.6;
}

.results-welcome__icon {
    font-size: 4rem;
    margin-bottom: 16px;
}

.results-welcome__text {
    font-size: 1.1rem;
    color: var(--text-secondary);
    max-width: 360px;
}

/* Loading spinner */
.spinner {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 60vh;
}

.spinner.is-active {
    display: flex;
}

.spinner__ring {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border-color);
    border-top-color: var(--maroon);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.spinner__text {
    margin-top: 16px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Error display */
.error-banner {
    display: none;
    background: rgba(192, 57, 43, 0.08);
    border: 1px solid rgba(192, 57, 43, 0.25);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 20px;
    color: var(--accent-danger);
}

.error-banner.is-visible {
    display: block;
}

/* --- Summary Cards — matches landing page .techCard / .processStep --- */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.summary-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-maroon);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.summary-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-card-hover);
}

.summary-card__header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-color);
}

.summary-card__icon {
    font-size: 1.2rem;
}

/* Section label style — matches landing page .sectionLabel */
.summary-card__title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.summary-card--property .summary-card__header {
    border-bottom-color: var(--accent-property);
}

.summary-card--property .summary-card__title {
    color: var(--accent-property);
}

.summary-card--buyer .summary-card__header {
    border-bottom-color: var(--accent-buyer);
}

.summary-card--buyer .summary-card__title {
    color: var(--accent-buyer);
}

.summary-card--investor .summary-card__header {
    border-bottom-color: var(--accent-investor);
}

.summary-card--investor .summary-card__title {
    color: var(--accent-investor);
}

.summary-card__items {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.summary-item {
    display: flex;
    flex-direction: column;
}

.summary-item--full {
    grid-column: 1 / -1;
}

.summary-item__label {
    font-size: 0.68rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 2px;
}

.summary-item__value {
    font-size: 1.1rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: -0.02em;
}

.summary-item__sub {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 1px;
}

.summary-item__value--property {
    color: var(--accent-property);
}

.summary-item__value--buyer {
    color: var(--accent-buyer);
}

.summary-item__value--investor {
    color: var(--accent-investor);
}

/* Legacy metrics-grid ID (for test compatibility) */
.metrics-grid {
    display: none;
}

/* Chart tabs — matches landing page .tabHeaders / .tabHeader */
.chart-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    background: var(--bg-card);
    padding: 4px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
    border: 1px solid var(--border-maroon);
}

.chart-tab {
    padding: 8px 16px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.chart-tab:hover {
    color: var(--text-primary);
    background: rgba(128, 0, 32, 0.05);
    border-color: var(--border-maroon);
}

/* Active tab — matches landing page .tabHeader.active */
.chart-tab.is-active {
    background: var(--gradient-brand);
    color: white;
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(128, 0, 32, 0.25);
}

/* Chart container — matches landing page .techCard */
.chart-area {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px;
    min-height: 400px;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-maroon);
    overflow: visible;
    width: 100%;
    max-width: 100%;
    transition: box-shadow 0.3s ease;
}

.chart-area:hover {
    box-shadow: var(--shadow-card-hover);
}

/* Termination badge */
.termination-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 50px;
    font-size: 0.78rem;
    font-weight: 600;
    margin-bottom: 20px;
}

.termination-badge--complete {
    background: rgba(45, 106, 79, 0.1);
    color: var(--accent-investor);
    border: 1px solid rgba(45, 106, 79, 0.25);
}

.termination-badge--horizon {
    background: rgba(212, 119, 11, 0.1);
    color: var(--accent-warning);
    border: 1px solid rgba(212, 119, 11, 0.25);
}

/* --- IRR Warning --- */
.irr-warning {
    display: none;
    background: rgba(212, 119, 11, 0.08);
    border: 1px solid rgba(212, 119, 11, 0.25);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin-bottom: 16px;
    color: var(--accent-warning);
    font-size: 0.82rem;
}

.irr-warning.is-visible {
    display: block;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .dashboard {
        grid-template-columns: 1fr;
    }

    .form-panel {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        max-height: none;
    }

    .results-panel {
        max-height: none;
    }

    .header {
        padding: 12px 16px;
    }

    .header__badge {
        display: none;
    }

    .header__logo--wordmark {
        position: static;
        transform: none;
        margin-left: 12px;
    }

    .header__logo-img--wordmark {
        height: 36px;
        width: auto;
    }

    .header__logo-img--mark {
        height: 40px;
    }

    .summary-grid {
        grid-template-columns: 1fr;
    }

    .chart-area {
        min-height: 300px;
    }
}

/* --- Animations --- */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Pulse animation — matches landing page .iconPulse */
@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.7; }
    50% { transform: scale(1.08); opacity: 1; }
}

.animate-in {
    animation: fadeInUp 0.4s ease forwards;
}

.animate-in:nth-child(1) {
    animation-delay: 0s;
}

.animate-in:nth-child(2) {
    animation-delay: 0.08s;
}

.animate-in:nth-child(3) {
    animation-delay: 0.16s;
}

/* Gradient text utility — matches landing page .gradientText */
.gradient-text {
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* Blockchain grid background — matches landing page .blockchainGrid */
.blockchain-grid-bg {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(rgba(128, 0, 32, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(128, 0, 32, 0.04) 1px, transparent 1px);
    background-size: 40px 40px;
    z-index: 0;
    pointer-events: none;
}