/* ROOT VARIABLES & GLOBAL STYLES */
:root {
    --primary-color: #007bff;
    --primary-hover: #0056b3;
    --secondary-color: #6c757d;
    --secondary-hover: #5a6268;
    --bg-color: #f8f9fa;
    --card-bg-color: #ffffff;
    --text-color: #343a40;
    --border-color: #dee2e6;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

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

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

/* HEADER & NAVIGATION */
header {
    background-color: var(--card-bg-color);
    padding: 1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.header-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    /* Allows wrapping on small screens */
    gap: 1rem;
    max-width: 1400px;
    margin: 0 auto;
}

.header-brand h1 {
    font-size: 1.25rem;
    color: var(--primary-color);
    font-weight: 600;
}

.powered-by {
    font-size: 0.75rem;
    color: var(--secondary-color);
}

.btn-home {
    background-color: #e9ecef;
    color: var(--text-color);
    padding: 0.5rem 1rem;
    text-decoration: none;
}

.btn-home:hover {
    background-color: #dee2e6;
}

/* MAIN CONTAINER & LAYOUT (Mobile First) */
.container {
    max-width: 1400px;
    margin: 1.5rem auto;
    padding: 0 1rem;
}

.calculator-wrapper {
    display: grid;
    grid-template-columns: 1fr;
    /* Single column by default */
    gap: 1.5rem;
}

/* FORM & RESULTS SECTIONS */
.form-section,
.results-section,
.schedule-section {
    background: var(--card-bg-color);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--text-color);
}

/* FORM ELEMENTS STYLING */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

input[type="number"],
select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: 'Poppins', sans-serif;
    transition: border-color 0.3s, box-shadow 0.3s;
    background-color: white;
}

select {
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px 12px;
}

input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
}

input[type="range"] {
    padding: 0;
    margin-top: 0.5rem;
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    background: transparent;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
    background: #e9ecef;
    height: 8px;
    border-radius: 4px;
}

input[type="range"]::-moz-range-track {
    background: #e9ecef;
    height: 8px;
    border-radius: 4px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    margin-top: -6px;
    background-color: var(--primary-color);
    height: 20px;
    width: 20px;
    border-radius: 50%;
}

input[type="range"]::-moz-range-thumb {
    border: none;
    border-radius: 50%;
    background-color: var(--primary-color);
    height: 20px;
    width: 20px;
}

.tenure-group {
    position: relative;
}

.tenure-toggle {
    position: absolute;
    top: 38px;
    right: 8px;
    display: flex;
    background-color: #e9ecef;
    border-radius: 6px;
}

.toggle-btn {
    padding: 0.35rem 0.75rem;
    border: none;
    background: transparent;
    cursor: pointer;
    font-weight: 500;
    border-radius: 6px;
    transition: background-color 0.3s, color 0.3s;
}

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

.radio-group {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.radio-group input[type="radio"] {
    opacity: 0;
    position: fixed;
    width: 0;
}

.radio-group label {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}

.radio-group input[type="radio"]:checked+label {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.radio-group input[type="radio"]:focus+label {
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.btn {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s;
    text-align: center;
}

.btn:hover {
    transform: translateY(-2px);
}

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

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

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

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

/* RESULTS & CHART */
.results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.result-item {
    text-align: center;
}

.result-item p {
    font-size: 0.9rem;
    color: var(--secondary-color);
    margin-bottom: 0.25rem;
}

.result-item h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary-color);
}

.chart-container {
    max-height: 250px;
    margin: 0 auto;
}

/* AMORTIZATION SCHEDULE TABLE */
.schedule-section {
    margin-top: 1.5rem;
}

.schedule-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.table-container {
    margin-top: 1rem;
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

table {
    width: 100%;
    /* ADD THIS LINE BELOW to give the table a minimum width */
    min-width: 600px;
    border-collapse: collapse;
}

th,
td {
    padding: 0.75rem;
    text-align: right;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

thead th {
    background-color: #f1f3f5;
    position: sticky;
    top: 0;
    font-weight: 600;
}

tbody tr:nth-child(even) {
    background-color: var(--bg-color);
}

/* DESKTOP STYLES (for screens larger than 1024px) */
@media (min-width: 1024px) {
    .container {
        margin: 2rem auto;
        padding: 0 2rem;
    }

    .calculator-wrapper {
        grid-template-columns: 1fr 1.5fr;
        /* Two columns on large screens */
        gap: 2rem;
    }

    .form-section,
    .results-section,
    .schedule-section {
        padding: 2rem;
    }

    header {
        padding: 1rem 2rem;
    }

    .header-brand h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.75rem;
    }

    .result-item h3 {
        font-size: 1.5rem;
    }

    th,
    td {
        padding: 1rem;
    }
}

/* PRINT STYLES */
@media print {
    body {
        background-color: #fff;
    }

    header,
    .form-section,
    .btn {
        display: none;
    }

    main.container,
    .calculator-wrapper,
    .schedule-section {
        margin: 0;
        padding: 0;
        max-width: 100%;
        box-shadow: none;
    }

    .results-section {
        box-shadow: none;
        border: 1px solid var(--border-color);
    }
.table-container {
    margin-top: 1rem;
    max-height: 400px;
    overflow-y: auto;
    /* ADD THIS LINE BELOW to enable horizontal scroll */
    overflow-x: auto; 
    border: 1px solid var(--border-color);
    border-radius: 8px;
}
}




/* Add this new rule at the end of your style.css */
@media (max-width: 480px) {
    .header-nav {
        flex-direction: column; /* Stack items vertically */
        gap: 0.75rem;
    }

    .header-brand {
        text-align: center; /* Center the title and "powered by" text */
    }
}