/* === GENERAL STYLES === */
:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --accent-color: #1abc9c;
    --light-gray: #f5f5f5;
    --medium-gray: #ddd;
    --dark-gray: #777;
    --text-color: #333;
    --positive-color: #27ae60;
    --negative-color: #e74c3c;
    --warning-color: #f39c12;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--light-gray);
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

h1, h2, h3, h4 {
    font-weight: 600;
    margin-bottom: 15px;
}

.required {
    color: var(--negative-color);
}

.hidden {
    display: none !important;
}

/* === HEADER === */
header {
    background-color: var(--primary-color);
    color: white;
    padding: 20px 0;
    margin-bottom: 30px;
}

header h1 {
    font-size: 2rem;
    margin-bottom: 5px;
}

header p {
    font-size: 1rem;
    opacity: 0.8;
}

/* Branding badge */
.brand-badge {
    display: inline-block;
    margin-top: 8px;
    background: rgba(255,255,255,0.12);
    color: #fff;
    padding: 6px 10px;
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 999px;
    font-size: 0.85rem;
}

/* === CALCULATOR CONTAINER === */
.calculator-container {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    margin-bottom: 30px;
}

/* === FORM NAVIGATION === */
.form-navigation {
    display: flex;
    background-color: var(--light-gray);
    border-bottom: 1px solid var(--medium-gray);
}

.nav-item {
    flex: 1;
    padding: 15px 10px;
    text-align: center;
    cursor: pointer;
    font-size: 0.9rem;
    position: relative;
}

.nav-item.active {
    background-color: white;
    font-weight: 600;
}

.nav-item .complete-icon {
    display: none;
    color: var(--accent-color);
    margin-right: 4px;
}

.nav-item.completed .complete-icon {
    display: inline-block;
}

/* === FORM SECTIONS === */
.form-section {
    display: none;
    padding: 25px;
}

.form-section.active {
    display: block;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.form-section h2 {
    color: var(--primary-color);
    font-size: 1.5rem;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--medium-gray);
    padding-bottom: 10px;
}

/* === FORM GROUPS === */
.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}

input, select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--medium-gray);
    border-radius: 4px;
    font-size: 1rem;
}

input:focus, select:focus {
    border-color: var(--secondary-color);
    outline: none;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.3);
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.checkbox-label input {
    width: auto;
    margin-right: 10px;
}

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-with-icon i, .input-with-icon .input-text {
    position: absolute;
    left: 12px;
    color: var(--dark-gray);
}

.input-with-icon input {
    padding-left: 28px;
}

.input-with-icon i.fa-percent, .input-with-icon i.fa-dollar-sign {
    left: 12px;
    color: var(--dark-gray);
}

.input-with-icon i.fa-percent {
    left: auto;
    right: 12px;
}

.input-with-icon input[id$="-percent"] {
    padding-right: 28px;
}

/* Suffix unit label (e.g., years) aligned to the right */
.input-with-icon.has-suffix .input-text {
    left: auto;
    right: 12px;
}

.input-with-icon.has-suffix input {
    padding-right: 46px; /* ensure text doesn't overlap suffix label */
}

/* Right-aligned icon (e.g., % for interest rate) */
.input-with-icon.has-icon-right i {
    left: auto;
    right: 12px;
}

.input-with-icon.has-icon-right input {
    padding-right: 46px; /* make room for the icon */
}

.inline-group {
    display: flex;
    gap: 15px;
}

.inline-group > div {
    flex: 1;
}

/* === SUMMARY & DETAILS === */
summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--dark-gray);
    margin: 15px 0;
    padding: 10px 0;
    border-top: 1px solid var(--medium-gray);
    outline: none;
}

details[open] summary {
    margin-bottom: 20px;
}

/* === UTILITY EXPENSES === */
.utility-expenses {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 20px;
}

.per-month {
    display: block;
    margin-top: 5px;
    font-size: 0.9rem;
    color: var(--dark-gray);
}

/* === FORM BUTTONS === */
.form-buttons {
    display: flex;
    justify-content: space-between;
    margin-top: 30px;
}

.btn {
    padding: 10px 20px;
    border-radius: 4px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.next-btn {
    background-color: var(--secondary-color);
    color: white;
}

.back-btn {
    background-color: var(--light-gray);
    color: var(--primary-color);
}

.calculate-btn {
    background-color: var(--accent-color);
    color: white;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.9rem;
}

.btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* === RESULTS CONTAINER === */
.results-container {
    padding: 25px;
}

/* === SIDE AD RAILS === */
.ad-rail {
    position: fixed;
    top: 110px; /* below header */
    width: 300px; /* typical medium rectangle width */
    z-index: 10;
}

.ad-left { left: 10px; }
.ad-right { right: 10px; }

.ad-box {
    background: #fff;
    border: 1px dashed var(--medium-gray);
    color: var(--dark-gray);
    padding: 12px;
    text-align: center;
    border-radius: 6px;
}

/* Only show ad rails on large screens to avoid overlap */
@media (max-width: 1400px) {
    .ad-rail { display: none; }
}

/* === IN-CONTENT ADS === */
.ad-incontent {
    margin: 16px 0 24px;
}

.ad-incontent .ad-box {
    width: 100%;
    min-height: 250px; /* reserve space to reduce CLS */
}

/* === MOBILE STICKY BOTTOM AD === */
.ad-mobile-sticky {
    display: none;
}

@media (max-width: 768px) {
    .ad-incontent {
        margin: 10px 0 18px;
    }
    .ad-incontent .ad-box, .ad-incontent ins.adsbygoogle {
        min-height: 280px; /* common mobile responsive height */
    }
    .ad-mobile-sticky {
        position: fixed;
        left: 0; right: 0; bottom: 0;
        background: #fff;
        border-top: 1px solid var(--medium-gray);
        padding: 6px 8px 4px;
        display: flex;
        justify-content: center;
        z-index: 999;
    }
    .ad-mobile-sticky .ad-close {
        position: absolute;
        right: 6px;
        top: 4px;
        background: transparent;
        border: none;
        font-size: 22px;
        line-height: 1;
        color: var(--dark-gray);
        cursor: pointer;
    }
    .ad-mobile-sticky .ad-close:hover { color: var(--primary-color); }
    .ad-mobile-sticky .ad-box {
        width: 100%;
        max-width: 728px; /* allow responsive ad to choose */
        min-height: 90px;  /* reserve space for banner */
        border: 1px dashed var(--medium-gray);
        border-radius: 6px;
    }
}

/* === PRINT === */
@media print {
    .ad-rail, .ad-incontent, .ad-mobile-sticky { display: none !important; }
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.results-tabs {
    display: flex;
    border-bottom: 1px solid var(--medium-gray);
    margin-bottom: 20px;
}

.tab {
    padding: 10px 20px;
    cursor: pointer;
}

.tab.active {
    border-bottom: 3px solid var(--secondary-color);
    font-weight: 600;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s;
}

/* === METRICS GRID === */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.metric {
    background-color: var(--light-gray);
    padding: 15px;
    border-radius: 8px;
    text-align: center;
}

.metric h4 {
    font-size: 0.9rem;
    color: var(--dark-gray);
    margin-bottom: 8px;
}

.metric-value {
    font-size: 1.5rem;
    font-weight: 700;
}

#monthly-cash-flow.positive {
    color: var(--positive-color);
}

#monthly-cash-flow.negative {
    color: var(--negative-color);
}

/* === SUMMARY DETAILS === */
.summary-details {
    display: flex;
    gap: 30px;
}

.summary-column {
    flex: 1;
}

.summary-column h4 {
    margin-bottom: 15px;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    padding: 5px 0;
    border-bottom: 1px solid var(--light-gray);
}

.summary-item.total {
    font-weight: 700;
    border-top: 1px solid var(--medium-gray);
    border-bottom: none;
    padding-top: 10px;
    margin-top: 5px;
}

/* === WARNINGS BOX & TOOLTIPS === */
.warnings-box {
    background-color: #fff8e6;
    border-left: 4px solid var(--warning-color);
    padding: 12px 14px;
    border-radius: 6px;
    margin-bottom: 16px;
}

.warnings-box strong {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--warning-color);
    margin-bottom: 6px;
}

.warnings-box ul {
    margin-left: 18px;
}

.warnings-box li {
    margin: 4px 0;
}

.info-tip {
    color: var(--dark-gray);
    margin-left: 6px;
    cursor: help;
}

.info-tip:hover {
    color: var(--secondary-color);
}

/* === CASH FLOW & RETURNS CHARTS === */
.cash-flow-chart, .returns-chart {
    height: 300px;
    margin-bottom: 30px;
}

.cash-flow-table {
    overflow-x: auto;
}

.cash-flow-table table {
    width: 100%;
    border-collapse: collapse;
}

.cash-flow-table th, .cash-flow-table td {
    padding: 10px;
    text-align: right;
}

.cash-flow-table th:first-child, .cash-flow-table td:first-child {
    text-align: left;
}

.cash-flow-table th {
    background-color: var(--light-gray);
}

.cash-flow-table tr:nth-child(even) {
    background-color: var(--light-gray);
}

/* === OPTIMIZATION === */
.optimization-sliders {
    margin: 20px 0;
}

.slider-group {
    margin-bottom: 20px;
}

.slider-group label {
    display: flex;
    justify-content: space-between;
}

.slider-value {
    font-weight: 600;
    color: var(--primary-color);
}

.optimization-results {
    background-color: var(--light-gray);
    padding: 20px;
    border-radius: 8px;
    margin-top: 20px;
}

.impact-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    padding: 5px 0;
}

#cash-flow-difference.positive {
    color: var(--positive-color);
}

#cash-flow-difference.negative {
    color: var(--negative-color);
}

/* === FOOTER === */
footer {
    text-align: center;
    padding: 20px;
    color: var(--dark-gray);
    margin-top: 20px;
}

/* === RESPONSIVE DESIGN === */
@media (max-width: 768px) {
    .form-navigation {
        flex-direction: column;
    }
    
    .utility-expenses {
        grid-template-columns: 1fr;
    }
    
    .summary-details {
        flex-direction: column;
    }
    
    .inline-group {
        flex-direction: column;
        gap: 10px;
    }
}
