/* General Styles */
#retirement-calculator {
    margin: 20px;
    padding: 20px;
    border: 1px solid #ccc;
    display: flex;
    flex-wrap: wrap; /* Wrap items if they don't fit */
    align-items: stretch; /* Stretch items to fill available height */
    box-sizing: border-box; /* Include padding and border in element's total width and height */
}

#calculator-form {
    width: 40%;
    padding-right: 20px;
    box-sizing: border-box;
}

#chart-container {
    width: 60%;
    box-sizing: border-box;
    display: flex;        /* Use flexbox to center content */
    align-items: center;   /* vertically */
    justify-content: center;/* horizontally, if needed */
}

#growthChart {
    width: 100%;            /* Canvas takes full width */
    height: 100%;           /* Canvas takes full height */
    box-sizing: border-box; /* Crucial for accurate width calculation */
}


#result {
    width: 100%;
    margin-top: 10px;
    box-sizing: border-box;
}

.results-container {
    width: 100%;
    margin: 20px 0;
    padding: 15px;
    background-color: #f9f9f9;
    border-radius: 5px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    position: relative;
    padding-bottom: 50px; /* Space for the calculate button */
}

/* Mobile responsiveness */
@media screen and (max-width: 768px) {
    .results-grid {
        grid-template-columns: 1fr;
        gap: 10px;
        padding-bottom: 60px; /* More space for the calculate button on mobile */
    }
    
    .result-item {
        flex-direction: column;
        align-items: stretch;
    }
    
    .result-value {
        margin-right: 0;
        margin-bottom: 5px;
    }
    
    .result-label {
        text-align: center;
    }
    
    .calculate-button-container {
        bottom: 15px;
        right: 50%;
        transform: translateX(50%);
        width: 80%;
    }
    
    #main-calculate-btn {
        width: 100%;
    }
}

.result-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    background-color: white;
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.result-value {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    font-weight: bold;
    text-align: right;
    background-color: #f8f8f8;
    min-width: 120px;
    margin-right: 15px;
}

.result-label {
    flex: 2;
    padding: 0 12px;
    font-size: 14px;
    color: #555;
    line-height: 1.4;
}

.calculate-button-container {
    position: absolute;
    bottom: 10px;
    right: 10px;
    display: flex;
    justify-content: flex-end;
    margin-top: 15px;
    grid-column: span 2;
}

#main-calculate-btn {
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 10px 25px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
}

#main-calculate-btn:hover {
    background-color: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

#main-calculate-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.result-item {
    margin: 10px 0;
    text-align: left; /* Ensure left alignment */
    display: flex;
    justify-content: flex-start; /* Left align content */
    align-items: center;
}

.input-group {
    margin-bottom: 10px;
    box-sizing: border-box;
}

.input-group label {
    display: block;
    font-weight: bold;
    margin-bottom: 5px;
    box-sizing: border-box;
}

.input-group input[type="range"] {
    width: 100%;
    box-sizing: border-box;
    -webkit-appearance: none;  /* Override default appearance */
    appearance: none;
    background: #d3d3d3;  /* Light grey background */
    height: 8px;
    border-radius: 5px;
    outline: none;
}

.input-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #DCA54A;  /* Golden color as requested */
    cursor: pointer;
    margin-top: -5px;  /* Center the thumb vertically on the track */
    border: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.input-group input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border: none;
    border-radius: 50%;
    background: #DCA54A;  /* Golden color as requested */
    cursor: pointer;
}

.input-group input[type="range"]::-moz-range-track {
    background: #d3d3d3;
    height: 8px;
    border-radius: 5px;
}

.input-group input[type="range"]:focus {
    outline: none;
}

.input-group span {
    display: inline-block;
    margin-left: 10px;
    font-weight: normal;
    box-sizing: border-box;
}

/* Accordion and table styling */
#post-retirement-section, #annuity-explanation {
    width: 100%;
    text-align: center;
    margin: 20px 0;
}
.accordion, .calculate-btn, .calculate-contribution-btn {
    background-color: #28a745;
    color: #fff;
    border: none;
    padding: 10px 40px 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
    position: relative;
}
.accordion::after {
    content: "▼";
    font-size: 0.8em;
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    transition: transform 0.2s ease;
}
.accordion.active::after {
    transform: translateY(-50%) rotate(180deg);
}
.panel {
    display: none;
    width: 100%;
}
.returns-table {
    margin: 10px auto;
    border-collapse: collapse;
    width: 100%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Make the table responsive */
@media screen and (max-width: 600px) {
    .returns-table {
        font-size: 12px;
    }
    
    .returns-table th,
    .returns-table td {
        padding: 6px 4px;
    }
}

.returns-table th {
    padding: 12px 8px;
    border: 1px solid #ddd;
    text-align: center;
    background-color: #f5f5f5;
    font-weight: bold;
    color: #333;
}

.returns-table td {
    padding: 10px 8px;
    border: 1px solid #ddd;
    text-align: right;
}

.returns-table tr:nth-child(even) {
    background-color: #f9f9f9;
}

.returns-table tr:hover {
    background-color: #f1f1f1;
}

/* Override accordion button colors */
.accordion {
    background-color: #808080;
}
.accordion:hover {
    background-color: #323b43;
}

/* Media Query for Smaller Screens */
@media (max-width: 768px) {
    #retirement-calculator {
        flex-direction: column; /* Stack items vertically */
        align-items: stretch;    /* Re-establish default stretching */
    }

    #calculator-form {
        width: 100%;
        padding-right: 0;
    }

    #chart-container {
        width: 100%;
        height: auto; /* Reset height for stacked layout */
    }

    #growthChart {
        width: 100%;   /* Canvas takes full width */
        height: auto;  /* And defaults to auto height */
    }
}
#monthly-income-display, #total-funds-display {
    margin-top: 10px;
    margin-bottom: 10px;
    display: flex; /* Add flexbox for layout */
    align-items: center; /* Vertically center the elements */
    justify-content: flex-start; /* Align items to the start of the line */
    flex-wrap: nowrap; /* Prevent wrapping */
    width: 100%; /* Ensure it takes full width */
    padding: 5px 0; /* Add some padding */
}
  
#total-funds-display, #annuity-monthly-payout-display {
    font-size: 1.1em; /* Make it slightly larger */
    border-bottom: 1px solid #eee; /* Add a subtle border */
    padding: 15px; /* Consistent padding */
    margin: 10px; /* Consistent margin */
    justify-content: flex-start; /* Left align the content */
    text-align: left; /* Left align the text */
    display: flex;
    align-items: center; /* Ensure vertical alignment */
    flex-wrap: nowrap; /* Prevent wrapping */
    background-color: white; /* Consistent background */
    border-radius: 4px; /* Rounded corners */
    box-shadow: 0 1px 2px rgba(0,0,0,0.05); /* Subtle shadow */
}

#monthly-income-display {
    display: flex;
    align-items: center;
    justify-content: flex-start; /* Left align the content */
    text-align: left; /* Left align the text */
    flex-wrap: nowrap; /* Prevent wrapping */
}

.label-container {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start; /* Left align the content */
    margin-right: 10px;
    height: 100%; /* Match height */
}

.label-container span {
    display: inline-block;
    vertical-align: middle;
    text-align: left; /* Left align the text */
}

#total-funds-display .income-box, #monthly-income-display .income-box, #annuity-monthly-payout-display .income-box {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    margin-left: 10px;
    padding: 8px 12px;
    min-width: 120px;
    justify-content: center;
}

#total-funds-display span, #monthly-income-display span, #annuity-monthly-payout-display span {
    margin-right: 0;
    font-weight: bold;
    text-align: center;
}

.income-box {
    background-color: #f9f9f9; /* Or whatever the slider background color is */
    padding: 15px;
    border: 1px solid #ccc; /* Optional: Add a border */
    border-radius: 4px;
    font-weight: bold;
    box-sizing: border-box;
    margin: 10px; /* Consistent margin */
    display: inline-flex;
    align-items: center;
    justify-content: center; /* Center content horizontally */
    height: 100%; /* Match height */
    min-width: 150px; /* Ensure minimum width */
    text-align: center; /* Center text */
}

.total-funds-input {
    background: transparent;
    border: none;
    font-weight: bold;
    font-size: inherit;
    width: 100%;
    text-align: left;
    padding: 0;
    margin: 0;
    cursor: pointer;
    position: relative;
    z-index: 1;
}

.total-funds-input:focus, .monthly-income-input:focus, .monthly-contribution-input:focus {
    outline: none;
    background: #fff;
    border: 1px solid #ccc;
    padding: 2px 4px;
    border-radius: 3px;
    z-index: 2;
}

.total-funds-input:read-only, .monthly-income-input:read-only, .monthly-contribution-input:read-only {
    cursor: pointer;
}

.total-funds-input:not(:read-only), .monthly-income-input:not(:read-only), .monthly-contribution-input:not(:read-only) {
    cursor: text;
    background: #fff;
    border: 1px solid #ccc;
    padding: 2px 4px;
    border-radius: 3px;
    z-index: 2;
}

#total-funds-display .income-box, #monthly-income-display .income-box {
    position: relative;
    z-index: 1;
    cursor: pointer;
}

#total-funds-display .income-box:hover, #monthly-income-display .income-box:hover {
    background-color: #f0f0f0;
}

.calculate-btn, .calculate-contribution-btn {
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 3px;
    cursor: pointer;
    margin-left: 10px;
    font-size: 14px;
    transition: background-color 0.3s;
}

.calculate-btn:hover, .calculate-contribution-btn:hover {
    background-color: #45a049;
}

#total-funds-display .income-box, #monthly-income-display .income-box {
    display: flex;
    align-items: center;
    gap: 10px;
}

.total-funds-input, .monthly-income-input, .monthly-contribution-input {
    flex: 1;
    background: transparent;
    border: none;
    font-weight: bold;
    font-size: inherit;
    width: 100%;
    text-align: left;
    padding: 0;
    margin: 0;
    cursor: pointer;
    position: relative;
    z-index: 1;
}

.annuity-payout-input {
    background-color: #DEF2F2 !important;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 8px 12px;
    font-weight: bold;
    font-size: inherit;
    text-align: right;
    cursor: text;
}