/* Ensure the container is isolated and has a modern font */
#dental-loan-calculator-container {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: #f4f7f9;
    padding: 2.5rem; /* Increased outer padding for more breathing room */
    border-radius: 15px;
    max-width: 900px;
    margin: 2rem auto;
    box-shadow: 0 10px 40px rgba(0, 64, 128, 0.1);
    color: #333;
    overflow: hidden;
}

.calculator-widget {
    display: flex;
    flex-direction: column;
}

.calculator-header h2 {
    text-align: center;
    font-size: 2rem;
    font-weight: 600;
    color: #003d73; /* A deep, professional blue */
    margin-bottom: 2rem; /* Increased space below header */
}

.calculator-body {
    display: flex;
    gap: 2.5rem; /* Increased gap between columns */
    flex-wrap: wrap; /* Allows stacking on smaller screens */
}

/* Input and results sections styling */
.calculator-inputs, .calculator-results {
    flex: 1;
    min-width: 300px; /* Prevents them from getting too squished */
    background: #ffffff;
    padding: 2rem; /* Increased inner padding */
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.input-group {
    margin-bottom: 1.5rem; /* Increased space between input fields */
}

.input-group:last-child {
    margin-bottom: 0;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #555;
}

.input-group input[type="number"],
.input-group input[type="text"] {
    width: 100%;
    padding: 0.8rem; /* Adjusted input field padding */
    border: 1px solid #ced4da;
    border-radius: 8px;
    font-size: 1.1rem;
    color: #003d73;
    font-weight: 600;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-group input[type="number"]:focus,
.input-group input[type="text"]:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.2);
}

/* Custom slider styles for a premium feel */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    background: #e9ecef;
    border-radius: 5px;
    outline: none;
    margin-top: 0.75rem;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    background: #007bff; /* Vibrant blue handle */
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: background-color 0.2s;
}

input[type="range"]::-moz-range-thumb {
    width: 22px;
    height: 22px;
    background: #007bff;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* Results Display */
.calculator-results h3 {
    color: #003d73;
    font-weight: 600;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 1rem;
    margin-top: 0;
    margin-bottom: 2rem;
}

.results-display {
    display: flex;
    justify-content: space-between;
    text-align: center;
    gap: 1rem;
    margin-bottom: 2.5rem;
}

.result-item p {
    margin: 0 0 0.5rem 0;
    font-size: 0.9rem;
    color: #555;
}

.result-item span {
    font-size: 1.75rem;
    font-weight: 700;
    color: #28a745; /* A positive green for results */
}

/* Pie Chart and Legend */
.chart-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
}

#loanChart {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    flex-shrink: 0;
}

.chart-legend {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.legend-item {
    display: flex;
    align-items: center;
    font-size: 0.9rem;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    margin-right: 0.5rem;
}
.legend-color.principal { background-color: #007bff; }
.legend-color.interest { background-color: #28a745; }

/* Amortization Table */
.amortization-schedule {
    margin-top: 2.5rem;
}

.amortization-schedule h3 {
    text-align: center;
    color: #003d73;
    margin-bottom: 1.5rem;
}

.table-container {
    max-height: 400px;
    overflow-y: auto;
    border-radius: 8px;
    border: 1px solid #ddd;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 0.8rem 1rem; /* Consistent rem-based padding */
    text-align: right;
    border-bottom: 1px solid #ddd;
}

td:first-child, th:first-child {
    text-align: center;
}

thead th {
    background-color: #007bff;
    color: white;
    font-weight: 500;
    position: sticky; /* Makes header stick during scroll */
    top: 0;
    z-index: 10;
}

tbody tr:nth-child(even) {
    background-color: #f8f9fa;
}

tbody tr:hover {
    background-color: #e9ecef;
}

/* Responsive Design */
@media (max-width: 768px) {
    #dental-loan-calculator-container {
        padding: 1.5rem; /* Better padding for mobile */
    }
    .calculator-body {
        gap: 1.5rem;
    }
    .calculator-inputs, .calculator-results {
        padding: 1.5rem;
    }
    .results-display {
        flex-direction: column;
        gap: 1.5rem;
    }
}