/* Modern Professional Styles */

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

:root {
    --primary: #3498db;
    --secondary: #2c3e50;
    --danger: #e74c3c;
    --warning: #f39c12;
    --success: #27ae60;
    --light: #ecf0f1;
    --dark: #2c3e50;
    --text: #34495e;
    --border-radius: 10px;
    --shadow: 0 4px 6px rgba(0,0,0,0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    line-height: 1.6;
    color: var(--text);
    background-color: #f5f7fa;
}

/* Navigation */
.navbar {
    background: white;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary);
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav-links a {
    text-decoration: none;
    color: var(--text);
    font-weight: 500;
    transition: color 0.3s;
}

.nav-links a:hover {
    color: var(--primary);
}

/* Hero Section */
.hero {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 6rem 2rem;
    text-align: center;
}

.hero-content h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
    font-weight: 700;
}

.hero-content p {
    font-size: 1.3rem;
    margin-bottom: 2rem;
    opacity: 0.9;
}

.hero-cta {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Container & Grid */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.mt-3 { margin-top: 3rem; }

/* Buttons */
.btn {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

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

.btn-primary:hover {
    background-color: #2980b9;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background-color: white;
    color: var(--primary);
    border: 2px solid var(--primary);
}

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

.btn-block {
    width: 100%;
}

/* Cards */
.card {
    background: white;
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    transition: transform 0.3s, box-shadow 0.3s;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

.card h3 {
    color: var(--secondary);
    margin-bottom: 1.5rem;
    font-size: 1.3rem;
}


.input-card {
    grid-column: span 1;
}

.chart-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.chart-card.hidden {
    display: none;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--secondary);
}

.form-group input {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.form-group small {
    display: block;
    margin-top: 0.3rem;
    color: #7f8c8d;
    font-size: 0.85rem;
}

/* Sections */
.calculator-section,
.results-section,
.faq-section,
.content-section {
    padding: 3rem 0;
}

.results-section {
    background: #f5f7fa;
}

.faq-section {
    background: white;
    border-top: 1px solid #ddd;
}

.content-section {
    background: white;
}

section > .container > h2 {
    font-size: 2rem;
    margin-bottom: 2rem;
    color: var(--secondary);
    text-align: center;
}

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.metric-card {
    background: white;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.metric-card.danger {
    background: linear-gradient(135deg, #fee 0%, #fdd 100%);
    border-left: 4px solid var(--danger);
}

.metric-icon {
    font-size: 2rem;
}

.metric-content small {
    color: #7f8c8d;
    display: block;
    margin-bottom: 0.3rem;
}

.metric-content h3 {
    font-size: 1.5rem;
    color: var(--secondary);
}

/* Breakdown */
.breakdown-item {
    display: flex;
    justify-content: space-between;
    padding: 0.8rem 0;
    border-bottom: 1px solid #eee;
}

.breakdown-item:last-child {
    border-bottom: none;
}

.breakdown-item .value {
    font-weight: bold;
    color: var(--primary);
}

/* Risk Meter */
.risk-meter {
    margin-bottom: 1rem;
}

.risk-label {
    font-weight: 600;
    margin-bottom: 0.5rem;
    display: block;
}

.progress-bar {
    width: 100%;
    height: 10px;
    background: #eee;
    border-radius: 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #27ae60, #f39c12, #e74c3c);
    transition: width 0.5s ease;
}

.risk-details {
    margin-top: 1rem;
    padding: 1rem;
    background: #f5f7fa;
    border-radius: 6px;
    border-left: 3px solid var(--warning);
}

/* Insights */
.insight-list {
    list-style: none;
}

.insight-item {
    padding: 1.5rem;
    margin-bottom: 1rem;
    border-radius: var(--border-radius);
    border-left: 4px solid #ddd;
}

.insight-item.danger {
    background: #fee;
    border-left-color: var(--danger);
}

.insight-item.warning {
    background: #ffeaa7;
    border-left-color: var(--warning);
}

.insight-item.safe {
    background: #d1ecf1;
    border-left-color: var(--success);
}

.insight-item.success {
    background: #d4edda;
    border-left-color: var(--success);
}

.insight-item.suggestion {
    background: #e7f3ff;
    border-left-color: var(--primary);
}

.insight-item.info {
    background: #e7f3ff;
    border-left-color: #3498db;
}

.insight-header {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 0.5rem;
}

.insight-icon {
    font-size: 1.5rem;
}

.insight-title {
    font-weight: 700;
    color: var(--secondary);
}

.insight-message {
    margin: 0.5rem 0;
    font-size: 0.95rem;
}

.insight-action {
    font-size: 0.9rem;
    color: #555;
    margin-top: 0.5rem;
}

/* Charts */
canvas {
    max-height: 300px;
}

/* Prepayment Scenarios */
.prepayment-scenarios {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.scenario-item {
    padding: 1.5rem;
    background: linear-gradient(135deg, #667eea15 0%, #764ba215 100%);
    border-radius: 8px;
    border-left: 4px solid var(--primary);
}

.scenario-item h4 {
    color: var(--secondary);
    margin-bottom: 0.5rem;
}

.scenario-item p {
    color: var(--text);
    font-size: 0.95rem;
}

/* FAQ */
.faq-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.faq-item {
    padding: 1.5rem;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.faq-item h4 {
    color: var(--primary);
    margin-bottom: 0.8rem;
    font-size: 1.1rem;
}

.faq-item p {
    color: var(--text);
    line-height: 1.8;
}

/* Content/Article */
article {
    line-height: 1.8;
    color: var(--text);
}

article h3 {
    color: var(--secondary);
    margin-top: 2rem;
    margin-bottom: 1rem;
    font-size: 1.3rem;
}

article p {
    margin-bottom: 1rem;
    text-align: justify;
}

article ul {
    margin-left: 2rem;
    margin-bottom: 1rem;
}

article li {
    margin-bottom: 0.5rem;
}

/* Footer */
.footer {
    background: var(--dark);
    color: white;
    padding: 2rem 0;
    margin-top: 3rem;
    text-align: center;
}

.footer-links {
    margin-top: 1rem;
}

.footer-links a {
    color: var(--primary);
    text-decoration: none;
    margin: 0 0.5rem;
}

/* Loading Spinner */
.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.spinner.hidden {
    display: none;
}

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

/* Utility Classes */
.hidden {
    display: none !important;
}

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

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

    .nav-links {
        flex-direction: column;
        gap: 1rem;
    }

    .hero-content h1 {
        font-size: 2rem;
    }

    .hero-cta {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    section > .container > h2 {
        font-size: 1.5rem;
    }

    article h3 {
        font-size: 1.1rem;
    }

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

/* Tenure inputs */
.tenure-inputs {
    display: flex;
    gap: 1rem;
}

.tenure-inputs input {
    flex: 1;
}

/* Formula box */
.formula-box {
    background: #f5f7fa;
    border-left: 4px solid var(--primary);
    padding: 1rem;
    margin: 1rem 0;
    font-family: 'Courier New', monospace;
}

/* Subscription specific styles */
.subscription-list {
    margin-top: 2rem;
}

.subscription-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    border-left: 4px solid var(--primary);
}

.sub-info {
    flex: 1;
}

.sub-info strong {
    display: block;
    color: var(--secondary);
    margin-bottom: 0.3rem;
}

.sub-category {
    background: var(--primary);
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-size: 0.8rem;
    margin-right: 0.5rem;
}

.sub-usage {
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-size: 0.8rem;
    text-transform: capitalize;
}

.sub-usage.usage-daily { background: #27ae60; color: white; }
.sub-usage.usage-weekly { background: #3498db; color: white; }
.sub-usage.usage-monthly { background: #f39c12; color: white; }
.sub-usage.usage-rarely { background: #e74c3c; color: white; }
.sub-usage.usage-never { background: #95a5a6; color: white; }

.sub-cost {
    text-align: right;
    margin-right: 1rem;
}

.sub-cost .monthly {
    display: block;
    font-weight: bold;
    color: var(--secondary);
}

.sub-cost .annual {
    display: block;
    font-size: 0.9rem;
    color: #7f8c8d;
}

.btn-small {
    padding: 0.4rem 0.8rem;
    font-size: 0.9rem;
}

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

.btn-danger:hover {
    background-color: #c0392b;
}

/* Summary items */
.summary-item {
    display: flex;
    justify-content: space-between;
    padding: 0.8rem 0;
    border-bottom: 1px solid #eee;
}

.summary-item:last-child {
    border-bottom: none;
}

.summary-item .value {
    font-weight: bold;
    color: var(--primary);
}

/* Usage breakdown */
.usage-breakdown {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.usage-item {
    display: flex;
    justify-content: space-between;
    padding: 0.8rem;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 3px solid #ddd;
}

.usage-item.warning {
    border-left-color: var(--warning);
}

.usage-item.danger {
    border-left-color: var(--danger);
}

.usage-item .value {
    font-weight: bold;
}

/* Expensive services */
.expensive-list {
    display: grid;
    gap: 0.5rem;
}

.expensive-item {
    display: flex;
    align-items: center;
    padding: 1rem;
    background: white;
    border: 1px solid #eee;
    border-radius: 6px;
}

.rank {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--primary);
    margin-right: 1rem;
    min-width: 40px;
}

.service-details {
    flex: 1;
}

.service-details strong {
    display: block;
    color: var(--secondary);
    margin-bottom: 0.3rem;
}

.service-details .category {
    background: var(--light);
    color: var(--secondary);
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-size: 0.8rem;
}

.cost {
    text-align: right;
}

.cost .monthly-cost {
    display: block;
    font-weight: bold;
    color: var(--secondary);
}

.cost .annual-cost {
    display: block;
    font-size: 0.9rem;
    color: #7f8c8d;
}

/* Cancellation list */
.cancellation-list {
    display: grid;
    gap: 0.5rem;
}

.cancel-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: #fee;
    border: 1px solid #fcc;
    border-radius: 6px;
    border-left: 4px solid var(--danger);
}

.cancel-info strong {
    display: block;
    color: var(--secondary);
    margin-bottom: 0.3rem;
}

.cancel-reason {
    color: var(--danger);
    font-size: 0.9rem;
}

.cancel-savings {
    text-align: right;
}

.cancel-savings .monthly-save {
    display: block;
    font-weight: bold;
    color: var(--danger);
}

.cancel-savings .annual-save {
    display: block;
    font-size: 0.9rem;
    color: #7f8c8d;
}

.no-cancellations {
    text-align: center;
    color: var(--success);
    font-style: italic;
    padding: 2rem;
}

/* Comparison items */
.comparison-item {
    display: flex;
    justify-content: space-between;
    padding: 0.8rem 0;
    border-bottom: 1px solid #eee;
}

.comparison-item:last-child {
    border-bottom: none;
}

.comparison-item .value {
    font-weight: bold;
    color: var(--primary);
}

/* Empty state */
.empty-state {
    text-align: center;
    color: #7f8c8d;
    font-style: italic;
    padding: 2rem;
}

/* Financial Health Score */
.health-score-display {
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 1.5rem;
    background: linear-gradient(135deg, #f5f7fa 0%, #e8f4f8 100%);
    border-radius: 12px;
    border: 2px solid #e1e8ed;
}

.health-score-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    position: relative;
}

.health-score-circle::before {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border-radius: 50%;
    background: conic-gradient(
        currentColor 0deg,
        transparent calc(var(--score) * 3.6deg),
        transparent calc(var(--score) * 3.6deg + 10deg)
    );
    mask: radial-gradient(circle at center, transparent 45%, black 55%);
    -webkit-mask: radial-gradient(circle at center, transparent 45%, black 55%);
}

.health-score-number {
    font-size: 2.5rem;
    line-height: 1;
    margin-bottom: 0.25rem;
    z-index: 1;
    position: relative;
}

.health-score-label {
    font-size: 0.9rem;
    text-align: center;
    z-index: 1;
    position: relative;
}

.health-score-details {
    flex: 1;
}

.health-factor {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid #e1e8ed;
}

.health-factor:last-child {
    border-bottom: none;
}

.health-factor span:first-child {
    font-weight: 600;
    color: var(--secondary);
}

.health-factor span:last-child {
    color: var(--primary);
    font-weight: bold;
}

/* Export buttons */
.export-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1rem;
}

/* Interactive scenario slider */
.interactive-scenario {
    border: 2px solid var(--primary) !important;
    background: linear-gradient(135deg, #e8f4f8 0%, #f0f8ff 100%) !important;
}

.slider-values {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: #666;
}

#extra-payment-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

#extra-payment-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

#extra-payment-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

/* Insight savings */
.insight-savings {
    background: #e8f8e8;
    padding: 0.5rem;
    border-radius: 6px;
    margin-top: 0.5rem;
    font-weight: bold;
    color: var(--success);
    border: 1px solid #c3e6c3;
}

/* Sticky results */
.sticky-results {
    position: sticky;
    top: 80px;
    z-index: 10;
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

/* Enhanced chart responsiveness */
@media (max-width: 768px) {
    .health-score-display {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }

    .health-score-circle {
        width: 100px;
        height: 100px;
    }

    .health-score-number {
        font-size: 2rem;
    }

    .export-buttons {
        flex-direction: column;
    }

    .export-buttons .btn {
        width: 100%;
    }
}

/* Amortization Schedule Table */
.amortization-container {
    max-height: 400px;
    overflow-y: auto;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    background: white;
}

.amortization-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.amortization-table thead {
    position: sticky;
    top: 0;
    background: var(--primary);
    color: white;
    z-index: 10;
}

.amortization-table th,
.amortization-table td {
    padding: 0.75rem 0.5rem;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.amortization-table th {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
}

.amortization-table tbody tr:nth-child(even) {
    background-color: #f8f9fa;
}

.amortization-table tbody tr:hover {
    background-color: #e3f2fd;
    transition: background-color 0.2s ease;
}

.amortization-table .currency {
    text-align: right;
    font-family: 'Courier New', monospace;
    font-weight: 500;
}

.amortization-table .principal {
    color: var(--success);
    font-weight: 600;
}

.amortization-table .interest {
    color: var(--danger);
    font-weight: 600;
}

.amortization-table .balance {
    font-weight: bold;
}

.amortization-table .summary-row {
    background: var(--light);
    border-top: 2px solid var(--primary);
}

.amortization-table .summary-row td {
    padding: 1rem 0.5rem;
}

/* Schedule toggle */
.schedule-toggle {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    justify-content: center;
}

.schedule-toggle .btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.schedule-toggle .btn-small.active {
    background-color: var(--primary);
    color: white;
}

/* Mobile responsiveness for table */
@media (max-width: 768px) {
    .amortization-container {
        max-height: 300px;
        overflow-x: auto;
    }

    .amortization-table {
        min-width: 600px; /* Ensure horizontal scroll */
        font-size: 0.8rem;
    }

    .amortization-table th,
    .amortization-table td {
        padding: 0.5rem 0.25rem;
    }

    .schedule-toggle {
        flex-direction: column;
        align-items: center;
    }
}
