/* Forest Theme Colors */
:root {
    --primary-color: #11998e;
    --primary-hover: #0d7a70;
    --secondary-color: #000000;
    --bg-color: #f0f9f4;
    --border-color: rgba(17, 153, 142, 0.2);
    --border-divider: #86efac;
    --text-dark: #14532d;
    --card-shadow: 0 4px 16px rgba(17, 153, 142, 0.2);
    --error-red: #dc3545;
}

/* Prevent CLS for h2 heading above calculator - spacing handled by margin-bottom */

/* Main Calculator Box (matching standalone) */
#savings_growth_calc.calculator-box {
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    box-shadow: var(--card-shadow);
    transition: box-shadow 0.3s ease;
    position: relative;
    overflow: hidden;
    margin-bottom: 15px;
    /* Removed 'all' transition to prevent CLS - only animate box-shadow */
    contain: layout style;
    /* CSS containment to prevent layout shifts from affecting parent */
}

/* Title with Money Emoji (matching standalone) */
#savings_growth_calc .calc-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--secondary-color);
    margin-bottom: 32px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--border-divider);
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 0px;
    min-height: 44px;
    /* Reserve space for emoji to prevent CLS */
}

#savings_growth_calc .calc-title::before {
    content: '💰';
    font-size: 32px;
    line-height: 1;
    display: inline-block;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    /* Fixed dimensions prevent layout shift */
}

/* Input Group Custom (matching standalone) */
#savings_growth_calc .input-group-custom {
    margin-bottom: 8px;
    position: relative;
}

#savings_growth_calc .input-label {
    font-size: 16px;
    font-weight: 600;
    color: var(--secondary-color);
    margin-bottom: 8px;
    display: block;
}

#savings_growth_calc .input-wrapper {
    position: relative;
}

#savings_growth_calc .input-wrapper:has(.percentage-field)::after,
#savings_growth_calc .input-wrapper.percentage-wrapper::after {
    content: '%';
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    font-weight: 700;
    color: var(--secondary-color);
    z-index: 2;
    pointer-events: none;
}

/* Form Control Custom (matching standalone) */
#savings_growth_calc .form-control-custom {
    width: 100%;
    padding: 12px 16px;
    padding-left: 40px;
    border: 1px solid var(--border-divider);
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    color: #11998e;
    background-color: #fff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    min-height: 48px;
    box-sizing: border-box;
    /* Fixed height and box-sizing prevent CLS */
}

#savings_growth_calc .form-control-custom:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(17, 153, 142, 0.1);
    /* Box-shadow doesn't affect layout, but ensure it's contained */
    box-sizing: border-box;
}

#savings_growth_calc .form-control-custom.error {
    border-color: var(--error-red);
}

/* Dollar Field */
#savings_growth_calc .dollar-field::before {
    content: "$";
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    font-weight: 700;
    color: var(--secondary-color);
    z-index: 2;
    pointer-events: none;
}

/* Percentage Field */
#savings_growth_calc .percentage-field {
    background-image: none !important;
    padding-right: 45px !important;
}

#savings_growth_calc .input-wrapper:has(.percentage-field)::after {
    content: '%';
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    font-weight: 700;
    color: var(--secondary-color);
    z-index: 2;
    pointer-events: none;
}

/* Year Field */
#savings_growth_calc .year-field::after {
    content: "Years";
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    font-weight: 400;
    color: var(--secondary-color);
    z-index: 2;
    pointer-events: none;
    opacity: 0.7;
}

#savings_growth_calc .year-field .form-control-custom {
    padding-right: 80px;
}

/* Error Message */
#savings_growth_calc .error-message {
    font-size: 12px;
    color: var(--error-red);
    margin-top: 6px;
    min-height: 18px;
    line-height: 1.5;
    /* Reserve space to prevent CLS when error messages appear/disappear */
    display: block;
    visibility: hidden;
}

#savings_growth_calc .error-message:not(:empty) {
    visibility: visible;
}

/* Calculate Button (matching standalone) */
#savings_growth_calc .calculate-btn {
    width: 100%;
    padding: 14px 24px;
    background-color: var(--primary-color);
    color: #ffffff;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    margin-top: 8px;
    position: relative;
    overflow: hidden;
    will-change: transform;
    /* Reserve space for hover shadow to prevent CLS - matches hover shadow dimensions */
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0);
}

#savings_growth_calc .calculate-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

#savings_growth_calc .calculate-btn:hover::before {
    width: 300px;
    height: 300px;
}

#savings_growth_calc .calculate-btn:hover {
    background-color: var(--primary-hover);
    /*transform: translateY(-2px);*/
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    /* CLS-safe: transform doesn't affect layout flow, shadow space already reserved */
}

#savings_growth_calc .calculate-btn:active {
    /*transform: translateY(0);*/
}

/* Results Section (matching standalone) */
#savings_growth_calc .results-section {
    min-height: 200px;
    /* Reserve space to prevent CLS when results are calculated */
}

#savings_growth_calc .result-earned-interest {
    text-align: center;
    padding-bottom: 24px;
    border-bottom: 2px solid var(--border-divider);
    min-height: 80px;
    /* Reserve space for earned interest display */
}

#savings_growth_calc .result-earned-interest-label {
    font-size: 18px;
    font-weight: 600;
    color: var(--secondary-color);
    margin-bottom: 12px;
}

#savings_growth_calc .result-earned-interest-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1.2;
    position: relative;
    display: inline-block;
    min-height: 1.2em;
    /* Reserve space to prevent CLS when values update */
}

#savings_growth_calc .result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-divider);
    min-height: 50px;
    /* Reserve space to prevent CLS when content updates */
}

#savings_growth_calc .result-item:last-child {
    border-bottom: none;
}

#savings_growth_calc .result-label {
    font-size: 16px;
    font-weight: 600;
    color: var(--secondary-color);
    flex: 0 0 58%;
}

#savings_growth_calc .result-value {
    font-size: 18px;
    font-weight: 600;
    color: var(--secondary-color);
    text-align: right;
    flex: 0 0 42%;
    word-break: break-word;
    min-width: 0;
    /* Prevent text overflow from causing layout shifts */
}

#savings_growth_calc .result-value.highlight {
    color: var(--primary-color);
    font-size: 20px;
    font-weight: 700;
}

/* Layout: Side-by-Side (matching standalone) */
#savings_growth_calc.layout-sidebyside .calculation-input-fields {
    border-right: 2px solid var(--border-divider);
    padding-right: 32px;
}


/* Responsive Design */
@media (max-width: 767.98px) {
    #savings_growth_calc .results-section {
        padding-left: 0;
        padding-top: 16px;
       /* margin-top: 16px;*/
        border-top: 2px solid var(--border-divider);
    }

    #savings_growth_calc.calculator-box {
        padding: 24px;
    }

    #savings_growth_calc .calc-title {
        font-size: 24px;
        margin-bottom: 24px;
    }
    
    #savings_growth_calc.layout-sidebyside .calculation-input-fields {
        border-right: none;
        padding-right: 0;
    }
    
    #savings_growth_calc.layout-sidebyside .results-section {
        padding-left: 0;
    }

    /* Error Message */
    #savings_growth_calc .error-message {
        min-height: 8px;
    }

    #savings_growth_calc .result-earned-interest {
        padding-bottom: 16px;
    }

    #savings_growth_calc .result-item {
        padding: 8px 0;
    }

    #savings_growth_calc .input-label {
        font-size: 14px;
    }
}

@media (max-width: 575.98px) {
    #savings_growth_calc.calculator-box {
        padding: 20px;
    }

    #savings_growth_calc .calc-title {
        font-size: 22px;
    }

    #savings_growth_calc .result-earned-interest-value {
        font-size: 28px;
    }

    #savings_growth_calc .input-group-custom {
        margin-bottom: 20px;
    }
}

@media (max-width: 419.98px) {
    #savings_growth_calc .form-control-custom {
        padding-left: 25px;
    }

    #savings_growth_calc .dollar-field:before {
        left: 10px;
    }

    #savings_growth_calc .input-label {
        font-size: 12px;
    }

    #savings_growth_calc .year-field .form-control-custom {
        padding-right: 70px;
    }
}

/* Legacy Support - Keep old class names working */
#savings_growth_calc .green_color {
    color: var(--primary-color) !important;
}

#savings_growth_calc .color-red {
    color: var(--error-red);
}

#savings_growth_calc .dark_grey {
    color: var(--text-dark);
}

#savings_growth_calc .recalculate_btn {
    border-radius: 6px;
    background-color: var(--primary-color);
    color: #ffffff;
    border: none;
    padding: 12px 20px;
    font-weight: 600;
    font-size: 16px;
    transition: all 0.3s ease;
    cursor: pointer;
}

#savings_growth_calc .recalculate_btn:hover {
    background-color: var(--primary-hover) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(17, 153, 142, 0.3);
}

/* Animation for results - CLS-safe */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

#savings_growth_calc .result-item {
    animation: fadeIn 0.3s ease;
    /* Removed translateY to prevent layout shifts - opacity only */
}
