:root {
    --primary-color: #3498db;
    --primary-hover: #2980b9;
    --text-dark: #2c3e50;
    --text-muted: #666;
    --background-light: #f8f9fa;
    --background-section: #ecf0f1;
    --border-color: #ddd;
    --border-light: #eee;
    --success-color: #27ae60;
    --success-hover: #219a52;
    --shadow-light: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-medium: 0 4px 6px rgba(0, 0, 0, 0.1);
    --border-radius: 8px;
    --border-radius-small: 6px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

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

header {
    text-align: center;
    margin-bottom: 40px;
}

header h1 {
    font-size: 2.5rem;
    color: #2c3e50;
    margin-bottom: 10px;
}

header p {
    font-size: 1.1rem;
    color: #666;
}

.calculator-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.input-group {
    margin-bottom: 30px;
}

.input-group h3 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 1.3rem;
    border-bottom: 2px solid #3498db;
    padding-bottom: 8px;
}

label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #555;
}

input[type="number"] {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
    margin-bottom: 15px;
    transition: border-color 0.3s ease;
}

input[type="number"]:focus {
    outline: none;
    border-color: #3498db;
}

.calculate-btn {
    width: 100%;
    padding: 15px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s ease;
}

.calculate-btn:hover {
    background: #2980b9;
}


.results-section {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
}

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

.results-section h3 {
    color: #2c3e50;
    margin: 0;
    font-size: 1.3rem;
}

.share-icon-btn {
    padding: 8px;
    background: var(--success-color);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    box-shadow: var(--shadow-light);
}

.share-icon-btn:hover {
    background: var(--success-hover);
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.share-icon-btn:disabled {
    background: #95a5a6;
    cursor: not-allowed;
    transform: none;
    box-shadow: var(--shadow-light);
}

.share-icon-btn svg {
    transition: transform 0.2s ease;
    color: white;
    stroke: currentColor;
}

.share-icon-btn:hover:not(:disabled) svg {
    transform: scale(1.1);
}

/* Ad container styles */
.ad-container {
    max-width: 1200px;
    margin: 40px auto 20px auto;
    padding: 20px;
    text-align: center;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    width: 100%;
    min-height: 90px;
    display: block;
}

.ad-container .adsbygoogle {
    display: block !important;
    width: 100%;
    min-height: 90px;
    border-radius: var(--border-radius-small);
    overflow: hidden;
}

/* Loading spinner styles for dynamically created spinners */
.loading-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s ease-in-out infinite;
}

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

/* Updated indicator badge styles */
.updated-badge {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--success-color);
    color: white;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 12px;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1000;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.updated-badge.show {
    opacity: 1;
    transform: translateY(0);
}

.updated-badge.fade-out {
    opacity: 0;
    transform: translateY(-5px);
}

.results-header {
    position: relative;
}

/* Footer */
footer {
    text-align: center;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border-light);
}

footer p {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.results-container {
    font-size: 1rem;
    line-height: 1.8;
}

.result-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}

.result-label {
    font-weight: 500;
    color: #555;
}

.result-value {
    font-weight: 600;
    color: #2c3e50;
}

.summary-box {
    background: #e8f4fd;
    border: 2px solid #3498db;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
    text-align: center;
}

.summary-text {
    font-size: 1.2rem;
    font-weight: 600;
    color: #2c3e50;
}

.rent-better {
    background: #d4edda;
    border-color: #28a745;
}

.buy-better {
    background: #f8d7da;
    border-color: #dc3545;
}

/* Info icon and popup styles */
.label-with-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    position: relative;
    transition: background 0.2s ease;
}

.info-icon:hover {
    background: var(--primary-hover);
}

.info-popup {
    position: absolute;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-dark);
    color: white;
    padding: 12px 16px;
    border-radius: var(--border-radius);
    font-size: 13px;
    font-weight: normal;
    line-height: 1.4;
    width: 400px;
    z-index: 10000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    pointer-events: none;
}

.info-popup.show {
    opacity: 1;
    visibility: visible;
}

.info-popup::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--text-dark);
}

@media (max-width: 768px) {
    .calculator-container {
        grid-template-columns: 1fr;
        gap: 20px;
        padding: 20px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .container {
        padding: 10px;
    }
    
    .info-popup {
        max-width: 250px;
        font-size: 12px;
    }
    
    .dual-input-group {
        flex-direction: column;
        gap: 10px;
    }
    
    .updated-badge {
        top: 15px;
        right: 15px;
        font-size: 0.7rem;
        padding: 4px 8px;
        z-index: 10001; /* Ensure it's above all other elements on mobile */
    }
}

/* Dual input field styles */
.dual-input-group {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.dual-input-field {
    flex: 1;
}

/* Checkbox styles */
.checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 500;
    color: #555;
    margin-bottom: 0;
}

.checkbox-label input[type="checkbox"] {
    display: none;
}

.checkmark {
    width: 20px;
    height: 20px;
    border: 2px solid #ddd;
    border-radius: 4px;
    background: white;
    position: relative;
    transition: all 0.3s ease;
}

.checkbox-label input[type="checkbox"]:checked + .checkmark {
    background: #3498db;
    border-color: #3498db;
}

.checkbox-label input[type="checkbox"]:checked + .checkmark::after {
    content: '';
    position: absolute;
    left: 6px;
    top: 2px;
    width: 6px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.checkbox-label:hover .checkmark {
    border-color: #3498db;
}

/* Disabled input styling */
input[type="number"]:disabled {
    background-color: #f8f9fa;
    color: #6c757d;
    border-color: #e9ecef;
    cursor: not-allowed;
}

.label-with-info label[for*="disabled"] {
    color: #6c757d;
}

.dual-input-field label {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 3px;
}

/* Base table styles */
.table-base {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.table-base th {
    background: var(--primary-color);
    color: white;
    padding: 15px;
    text-align: center;
    font-weight: 600;
    font-size: 1.1rem;
    position: relative;
    border-right: 2px solid rgba(255, 255, 255, 0.4);
}

.table-base th:last-child {
    border-right: none;
}

.table-base td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-light);
    border-right: 2px solid var(--border-color);
    position: relative;
}

.table-base td:last-child {
    border-right: none;
}

/* Specific table type styles - only differences */
/* .results-table and .breakdown-table inherit all .table-base styles */

/* Header with info styling */
.header-with-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.header-with-info .info-icon {
    background: rgba(255, 255, 255, 0.2);
}

.header-with-info .info-icon:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Header info popups */
.header-with-info .info-popup {
    top: 120%;
    bottom: auto;
    max-width: 300px;
}

.header-with-info .info-popup::after {
    display: none;
}


/* Table cell specific styles */
.results-table td {
    text-align: center;
}

.breakdown-table td {
    text-align: left;
}

/* Two-line cost item styling */
.cost-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin-bottom: 8px;
}

/* Center details button in table cells */
.results-table td {
    text-align: center;
}

.results-table .details-toggle {
    margin: 4px auto 0 auto;
}

.cost-label {
    font-size: 0.85rem;
    color: #666;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1.2;
}

.cost-amount {
    font-size: 1.1rem;
    font-weight: 700;
    color: #2c3e50;
    line-height: 1.3;
}

.results-table .total-row {
    font-weight: bold;
    font-size: 1.2rem;
    color: #2c3e50;
    background: #f8f9fa;
}

.results-table .subheader-row td,
.breakdown-table .section-header td,
.results-table .section-header td {
    background: #e8eaf6;
    color: #5c6bc0;
    font-weight: 600;
    text-align: center;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.breakdown-table .section-header td {
    padding: 10px;
}

.breakdown-table .empty-cell {
    background: #f8f9fa;
}

/* Breakdown item styles */
.breakdown-item {
    color: #3498db;
    cursor: pointer;
    text-decoration: underline;
    transition: color 0.2s ease;
}

.breakdown-item:hover {
    color: #2980b9;
    text-decoration: none;
}

/* Savings amounts styling */
.savings-amount {
    color: #27ae60;
    font-weight: 600;
}

/* Breakdown popup styles */
.breakdown-popup {
    background: #2c3e50;
    color: white;
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 14px;
    max-width: 300px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 1000;
    line-height: 1.4;
    word-wrap: break-word;
}

.breakdown-popup::after {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-bottom-color: #2c3e50;
}

/* Expandable details styles */
.details-toggle {
    display: flex;
    width: fit-content;
    margin: 4px 0 0 0;
    align-items: center;
    gap: 5px;
    color: #3498db;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: normal;
    border: none;
    background: none;
    padding: 2px 6px;
    border-radius: 3px;
    transition: all 0.2s ease;
}

.details-toggle:hover {
    background: rgba(52, 152, 219, 0.1);
    color: #2980b9;
}

.details-toggle.expanded {
    color: #e74c3c;
}

.details-toggle.expanded:hover {
    background: rgba(231, 76, 60, 0.1);
    color: #c0392b;
}

.details-arrow {
    font-size: 0.8em;
    transition: transform 0.2s ease;
}

.details-toggle.expanded .details-arrow {
    transform: rotate(180deg);
}

.calculation-details {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-left: 3px solid #3498db;
    margin: 4px 0 0 0;
    padding: 12px 15px;
    font-size: 0.9em;
    line-height: 1.5;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 10;
}

.calculation-details.show {
    display: block;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
        padding-top: 0;
        padding-bottom: 0;
    }
    to {
        opacity: 1;
        max-height: 200px;
        padding-top: 12px;
        padding-bottom: 12px;
    }
}

.calculation-step {
    margin: 4px 0;
    color: #555;
}

.calculation-formula {
    font-family: 'Courier New', monospace;
    background: #e9ecef;
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 0.85em;
    color: #495057;
    margin: 4px 0;
    display: inline-block;
}

.calculation-highlight {
    font-weight: 600;
    color: #2c3e50;
}

@media (max-width: 768px) {
    .table-base th {
        padding: 8px;
        font-size: 0.9rem;
        border: 1px solid var(--primary-hover);
    }
    
    .table-base td {
        padding: 8px;
        font-size: 0.9rem;
        border: 1px solid var(--border-color);
    }
    
    .results-table .total-row {
        font-size: 1rem;
    }
    
    .breakdown-table .section-header td {
        border: 1px solid var(--border-color);
    }
    
    /* Mobile cost item adjustments */
    .cost-item {
        gap: 2px;
        margin-bottom: 6px;
    }
    
    .cost-label {
        font-size: 0.75rem;
    }
    
    .cost-amount {
        font-size: 1rem;
    }
    
    .breakdown-popup {
        max-width: 250px;
        font-size: 12px;
        padding: 10px 12px;
    }
    
    .calculation-details {
        margin-left: 10px;
        padding: 8px 10px;
        font-size: 0.8em;
    }
    
    .details-toggle {
        font-size: 0.75em;
    }
}

/* Tab Navigation Styles */
.tabs-container {
    margin-bottom: 20px;
}

.tabs-nav {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 20px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab-btn {
    background: none;
    border: none;
    padding: 12px 20px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.tab-btn:hover {
    color: var(--primary-color);
    background-color: var(--background-light);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    font-weight: 600;
}

/* Highlight the Calculator tab to make it more discoverable */
.tab-btn[onclick*="calculator"] {
    font-weight: 700;
    color: var(--primary-color);
}

.tab-btn[onclick*="calculator"]:after {
    content: " 🏠";
    animation: pulse 2s infinite;
}

.tab-btn[onclick*="calculator"].active:after {
    animation: none;
}

@keyframes pulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

.tab-content {
    min-height: 400px;
    display: block; /* Visible by default since How to Use is the default tab */
}

/* Hide calculator container by default since How to Use is default */
#calculator-container {
    display: none;
}

.tab-pane {
    display: none;
    animation: fadeIn 0.3s ease-in;
}

.tab-pane.active {
    display: block;
}

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

/* Content Section Styles */
.content-section {
    background: white;
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    line-height: 1.7;
}

.content-section h2 {
    color: var(--text-dark);
    margin-bottom: 20px;
    font-size: 1.8rem;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
}

.content-section h3 {
    color: var(--text-dark);
    margin: 25px 0 15px 0;
    font-size: 1.3rem;
}

.content-section h4 {
    color: var(--text-dark);
    margin: 20px 0 10px 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.content-section p {
    margin-bottom: 15px;
    color: #555;
}

.content-section ul {
    margin: 10px 0 20px 20px;
}

.content-section li {
    margin-bottom: 8px;
    color: #555;
}

.content-section strong {
    color: var(--text-dark);
}

.content-section em {
    color: var(--text-muted);
    font-style: italic;
    display: block;
    margin-top: 20px;
    padding: 15px;
    background: var(--background-light);
    border-radius: var(--border-radius-small);
    border-left: 4px solid var(--primary-color);
}

/* FAQ Specific Styles */
.faq-item {
    margin-bottom: 25px;
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius-small);
    padding: 20px;
    background: var(--background-light);
}

.faq-item h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: var(--primary-color);
}

/* How to Use Tab Specific Styles */
.step-guide {
    margin-bottom: 30px;
}

.step-item {
    margin-bottom: 30px;
    padding: 25px;
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius);
    background: var(--background-light);
    position: relative;
}

.step-item h3 {
    color: var(--primary-color);
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.tip {
    background: #e8f4fd;
    border: 1px solid #bee5eb;
    border-radius: var(--border-radius-small);
    padding: 12px 15px;
    margin-top: 15px;
    font-size: 0.9rem;
}

.important-notes {
    margin: 30px 0;
    padding: 25px;
    background: #f8f9fa;
    border-radius: var(--border-radius);
    border-left: 4px solid var(--primary-color);
}

.note-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 20px;
}

.note-item {
    background: white;
    padding: 20px;
    border-radius: var(--border-radius-small);
    box-shadow: var(--shadow-light);
}

.note-item h4 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1rem;
}

.getting-started {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    padding: 25px;
    border-radius: var(--border-radius);
    text-align: center;
    margin-top: 30px;
}

.getting-started h3 {
    color: white;
    margin-top: 0;
    margin-bottom: 15px;
}

.getting-started p {
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 10px;
}

.start-calculator-btn {
    background: white;
    color: var(--primary-color);
    border: none;
    padding: 15px 30px;
    font-size: 1.2rem;
    font-weight: 600;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin: 20px 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.start-calculator-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
    background: #f8f9fa;
}

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

.btn-text {
    font-size: 1.2rem;
}

.btn-arrow {
    font-size: 1.4rem;
    transition: transform 0.3s ease;
}

.start-calculator-btn:hover .btn-arrow {
    transform: translateX(3px);
}

.helper-text {
    font-size: 0.9rem;
    margin-top: 15px;
    opacity: 0.8;
}

/* Mobile Responsive for Tabs */
@media (max-width: 768px) {
    .tabs-nav {
        flex-wrap: nowrap;
        justify-content: flex-start;
    }
    
    .tab-btn {
        font-size: 0.9rem;
        padding: 10px 16px;
        min-width: auto;
    }
    
    .content-section {
        padding: 20px;
    }
    
    .content-section h2 {
        font-size: 1.5rem;
    }
    
    .content-section h3 {
        font-size: 1.2rem;
    }
    
    .faq-item {
        padding: 15px;
    }
    
    .note-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .step-item {
        padding: 20px;
    }
    
    .getting-started {
        padding: 20px;
    }
    
    .start-calculator-btn {
        padding: 12px 25px;
        font-size: 1.1rem;
    }
    
    .btn-text {
        font-size: 1.1rem;
    }
    
    .btn-arrow {
        font-size: 1.2rem;
    }
}

/* Base section styles - shared by all section types */
.section-base {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    background: white;
}

.section-base h3 {
    margin-top: 0;
    font-size: 1.1rem;
    color: var(--text-dark);
    border-bottom: none;
    padding-bottom: 0;
}

/* Always visible sections */
.always-visible {
    padding: 20px;
}

/* Collapsible sections */
.collapsible-section {
    overflow: visible;
}

.collapsible-header {
    padding: 15px 20px;
    background: var(--background-section);
    cursor: pointer;
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.3s ease;
}

.collapsible-header:hover {
    background: #e8ecf0;
}

.collapsible-header h3 {
    margin: 0;
}

.section-toggle {
    font-size: 1rem;
    color: var(--text-muted);
    transition: transform 0.3s ease;
}

.section-toggle.rotated {
    transform: rotate(-90deg);
}

.section-content {
    padding: 20px;
    max-height: 1000px;
    transition: max-height 0.3s ease, padding 0.3s ease;
}

.section-content.collapsed {
    max-height: 0;
    padding: 0 20px;
    overflow: hidden;
}

/* Allow tooltips to escape collapsible sections when expanded */
.section-content:not(.collapsed) {
    overflow: visible;
}

/* Mobile responsive for all sections */
@media (max-width: 768px) {
    .always-visible {
        padding: 15px;
    }
    
    .collapsible-header, .section-content {
        padding: 15px;
    }
    
    .section-content.collapsed {
        padding: 0 15px;
    }
}