/* ====================================
   Rent vs Buy Calculator - Style Sheet
   Dark Financial Dashboard Theme
   ==================================== */

:root {
    /* Core palette */
    --bg-primary: #0B1120;
    --bg-secondary: #111827;
    --bg-card: #1A2332;
    --bg-card-hover: #1F2A3C;
    --bg-input: #0F1923;
    --border-color: #1E2D3D;
    --border-hover: #2A3F55;

    /* Text */
    --text-primary: #F1F5F9;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;
    --text-dim: #475569;

    /* Accent colors */
    --teal: #00D4AA;
    --teal-bright: #00FFD0;
    --teal-dim: rgba(0, 212, 170, 0.15);
    --teal-glow: rgba(0, 212, 170, 0.3);
    --amber: #FFB547;
    --amber-dim: rgba(255, 181, 71, 0.15);
    --amber-glow: rgba(255, 181, 71, 0.3);
    --red: #FF6B6B;
    --red-dim: rgba(255, 107, 107, 0.15);

    /* Fonts */
    --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-heading: 'Sora', -apple-system, BlinkMacSystemFont, sans-serif;

    /* Spacing */
    --panel-gap: 28px;
    --section-gap: 20px;

    /* Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
}

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

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ====================================
   Background Grid Texture
   ==================================== */
.bg-grid {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image:
        radial-gradient(circle, rgba(100, 116, 139, 0.08) 1px, transparent 1px);
    background-size: 24px 24px;
}

/* ====================================
   Hero Section
   ==================================== */
.hero {
    position: relative;
    z-index: 1;
    padding: 56px 24px 40px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(180deg, rgba(0, 212, 170, 0.04) 0%, transparent 100%);
}

.hero-inner {
    max-width: 720px;
    margin: 0 auto;
}

.hero-badge {
    display: inline-block;
    font-family: var(--font-body);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1.5px;
    color: var(--teal);
    background: var(--teal-dim);
    border: 1px solid rgba(0, 212, 170, 0.2);
    padding: 5px 14px;
    border-radius: 100px;
    margin-bottom: 20px;
}

.hero-title {
    font-family: var(--font-heading);
    font-size: clamp(32px, 5vw, 52px);
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.hero-subtitle {
    font-size: clamp(15px, 2vw, 18px);
    color: var(--text-secondary);
    font-weight: 400;
}

.highlight {
    color: var(--teal);
    font-weight: 600;
}

/* ====================================
   Main Layout
   ==================================== */
.main-container {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: var(--panel-gap);
    max-width: 1440px;
    margin: 0 auto;
    padding: 28px 24px 60px;
    align-items: start;
}

/* ====================================
   Input Panel
   ==================================== */
.input-panel {
    position: sticky;
    top: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-hover) transparent;
}

.input-panel::-webkit-scrollbar {
    width: 5px;
}
.input-panel::-webkit-scrollbar-track {
    background: transparent;
}
.input-panel::-webkit-scrollbar-thumb {
    background: var(--border-hover);
    border-radius: 10px;
}

.panel-header {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.panel-title {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.panel-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Input sections */
.input-section {
    margin-bottom: var(--section-gap);
    padding-bottom: var(--section-gap);
    border-bottom: 1px solid var(--border-color);
}
.input-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.section-label {
    font-family: var(--font-heading);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 14px;
}

/* Zip code */
.zip-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}

.zip-icon {
    position: absolute;
    left: 12px;
    color: var(--text-muted);
    pointer-events: none;
    flex-shrink: 0;
}

.zip-input {
    flex: 1;
    font-family: var(--font-body);
    font-size: 15px;
    font-weight: 500;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 10px 12px 10px 38px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
}

.zip-input:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px var(--teal-dim);
}

.city-label {
    position: absolute;
    right: 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--teal);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transform: translateX(8px);
    transition: opacity 0.3s, transform 0.3s;
}
.city-label.visible {
    opacity: 1;
    transform: translateX(0);
}

.zip-message {
    font-size: 12px;
    color: var(--amber);
    margin-top: 6px;
    min-height: 0;
    opacity: 0;
    transition: opacity 0.3s;
}
.zip-message.visible {
    opacity: 1;
}

/* Input groups */
.input-group {
    margin-bottom: 16px;
}
.input-group:last-child {
    margin-bottom: 0;
}

.input-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.input-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Slider styling */
.slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--teal);
    cursor: pointer;
    border: 2px solid var(--bg-secondary);
    box-shadow: 0 0 0 2px rgba(0, 212, 170, 0.3);
    transition: box-shadow 0.2s;
}

.slider::-webkit-slider-thumb:hover {
    box-shadow: 0 0 0 4px rgba(0, 212, 170, 0.2);
}

.slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--teal);
    cursor: pointer;
    border: 2px solid var(--bg-secondary);
    box-shadow: 0 0 0 2px rgba(0, 212, 170, 0.3);
}

/* Input value fields */
.input-value-wrapper {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0 10px;
    min-width: 100px;
    transition: border-color 0.2s;
}

.input-value-wrapper:focus-within {
    border-color: var(--teal);
}

.input-prefix, .input-suffix {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    user-select: none;
    flex-shrink: 0;
}

.input-value {
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    background: transparent;
    border: none;
    outline: none;
    padding: 8px 4px;
    width: 70px;
    text-align: right;
}

.input-helper {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Toggle buttons */
.toggle-group {
    display: flex;
    gap: 0;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.toggle-btn {
    flex: 1;
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    background: transparent;
    border: none;
    padding: 8px 16px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.toggle-btn.active {
    background: var(--teal-dim);
    color: var(--teal);
}

.toggle-btn:not(.active):hover {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
}

/* Advanced toggle */
.advanced-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    font-family: var(--font-heading);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    margin-bottom: 0;
    transition: color 0.2s;
}

.advanced-toggle:hover {
    color: var(--text-secondary);
}

.advanced-toggle .chevron {
    transition: transform 0.3s;
}

.advanced-toggle.open .chevron {
    transform: rotate(180deg);
}

.advanced-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease, opacity 0.3s;
    opacity: 0;
}

.advanced-content.open {
    max-height: 2000px;
    opacity: 1;
    margin-top: 16px;
}

/* ====================================
   Results Panel
   ==================================== */
.results-panel {
    position: relative;
    min-height: 400px;
}

/* Loading overlay */
.loading-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(11, 17, 32, 0.85);
    backdrop-filter: blur(4px);
    z-index: 10;
    border-radius: var(--radius-lg);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.loading-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

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

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

.loading-text {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 12px;
}

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

.summary-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    transition: border-color 0.3s, transform 0.2s, box-shadow 0.3s;
    position: relative;
    overflow: hidden;
}

.summary-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--teal), transparent);
    opacity: 0.5;
}

.summary-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.card-label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.card-value {
    font-family: var(--font-heading);
    font-size: clamp(28px, 3vw, 36px);
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
    margin-bottom: 6px;
    min-height: 40px;
}

.card-value.buy-wins {
    color: var(--teal);
}

.card-value.rent-wins {
    color: var(--amber);
}

.card-sub {
    font-size: 12px;
    color: var(--text-dim);
    line-height: 1.4;
}

/* Chart sections */
.chart-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    margin-bottom: 20px;
}

.chart-title {
    font-family: var(--font-heading);
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.chart-desc {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.chart-container {
    position: relative;
    width: 100%;
    height: 360px;
}

.chart-container-bar {
    height: 260px;
}

/* Table section */
.table-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    font-family: var(--font-heading);
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    transition: color 0.2s;
}

.table-toggle:hover {
    color: var(--teal);
}

.table-toggle .chevron {
    transition: transform 0.3s;
    color: var(--text-muted);
}

.table-toggle.open .chevron {
    transform: rotate(180deg);
}

.table-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s ease;
}

.table-content.open {
    max-height: 2000px;
    margin-top: 16px;
}

.table-wrapper {
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-hover) transparent;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    white-space: nowrap;
}

.data-table th {
    font-family: var(--font-heading);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-muted);
    text-align: right;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    background: var(--bg-card);
}

.data-table th:first-child {
    text-align: center;
}

.data-table td {
    text-align: right;
    padding: 9px 12px;
    border-bottom: 1px solid rgba(30, 45, 61, 0.5);
    color: var(--text-secondary);
    font-weight: 400;
    font-variant-numeric: tabular-nums;
}

.data-table td:first-child {
    text-align: center;
    font-weight: 600;
    color: var(--text-primary);
}

.data-table tr:hover td {
    background: rgba(0, 212, 170, 0.03);
}

.data-table td.positive {
    color: var(--teal);
    font-weight: 500;
}
.data-table td.negative {
    color: var(--amber);
    font-weight: 500;
}

/* ====================================
   Footer
   ==================================== */
.footer {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 32px 24px 40px;
    border-top: 1px solid var(--border-color);
}

.footer p {
    font-size: 12px;
    color: var(--text-dim);
    max-width: 680px;
    margin: 0 auto;
    line-height: 1.6;
}

/* ====================================
   Mobile Responsive
   ==================================== */
@media (max-width: 1100px) {
    .main-container {
        grid-template-columns: 340px 1fr;
        gap: 20px;
    }
}

@media (max-width: 900px) {
    .main-container {
        grid-template-columns: 1fr;
    }

    .input-panel {
        position: static;
        max-height: none;
    }

    .summary-cards {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }

    .summary-card {
        padding: 14px;
    }

    .card-value {
        font-size: 24px;
    }
}

@media (max-width: 600px) {
    .summary-cards {
        grid-template-columns: 1fr;
        gap: 10px;
    }
}

@media (max-width: 768px) {
    .hero {
        padding: 40px 16px 28px;
    }

    .main-container {
        padding: 16px 12px 40px;
    }

    .input-panel {
        padding: 18px;
    }

    .chart-container {
        height: 280px;
    }

    .chart-container-bar {
        height: 220px;
    }

    .chart-section {
        padding: 16px;
    }

    .summary-card {
        padding: 16px;
    }

    .card-value {
        font-size: 28px;
    }

    .data-table {
        font-size: 12px;
    }
}

/* ====================================
   Count-up animation helper
   ==================================== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

/* Slider fill track (JS-driven) */
.slider {
    --pct: 50%;
    background: linear-gradient(to right, var(--teal) 0%, var(--teal) var(--pct), var(--border-color) var(--pct), var(--border-color) 100%);
}
