:root {
    --kc-primary: #004d40;
    --kc-accent: #e0f2f1;
    --kc-text: #333;
    --kc-text-light: #666;
    --kc-bg: #fff;
    --kc-border: #e0e0e0;
}

/* Ensure wrapper height is stable & Width is normalized */
.keynivesh-calculator-wrapper {
    background: var(--kc-bg);
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.06);
    padding: 30px;
    width: 600px; /* Force full width up to max */
    max-width: 600px; /* Consistent max-width for both calculators */
    margin: 20px auto;
    position: relative; 
    min-height: 500px; /* Enforce min-height to prevent page shake */
    display: flex;
    flex-direction: column;
    justify-content: center; /* Center content vertically if short */
    box-sizing: border-box; /* Include padding in width */
}

.kc-input-field input {
	height: 30px;
}

/* Re-add missing selector */
.kc-header h3,
.kc-summary-item h4,
.kc-summary-item h3,
.kc-number-input,
.kc-btn-calculate {
    font-family: 'Outfit', sans-serif !important;
}

.keynivesh-calculator-wrapper,
.kc-header p,
.kc-label-row label,
.kc-summary-item span,
.kc-btn-primary {
    font-family: 'Montserrat', sans-serif !important;
}

.keynivesh-calculator-wrapper h1,
.keynivesh-calculator-wrapper h2,
.keynivesh-calculator-wrapper h3,
.keynivesh-calculator-wrapper h4,
.keynivesh-calculator-wrapper h5,
.keynivesh-calculator-wrapper h6 {
    font-family: 'Outfit', sans-serif !important;
}

.keynivesh-calculator-wrapper p,
.keynivesh-calculator-wrapper span,
.keynivesh-calculator-wrapper div,
.keynivesh-calculator-wrapper button,
.keynivesh-calculator-wrapper input {
    font-family: 'Montserrat', sans-serif; /* Fallback */
}
.kc-header {
    text-align: left; /* Align to left inside input column */
    margin-bottom: 40px;
}

/* Two-Column Layout for Desktop */
.kc-content {
    display: block; 
    position: relative;
    width: 100%;
}

/* Input Group Spacing */
.kc-input-group {
    margin-bottom: 25px; /* Reduced vertical spacing */
}

.kc-inputs-section {
    width: 100%;
}

/* Input Controls with +/- */
.kc-input-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f8f9fa;
    padding: 5px;
    border-radius: 8px;
    border: 1px solid #eee;
    width: auto !important;
    min-width: 140px; /* Slightly smaller min width */
    height: 40px !important;
    box-sizing: border-box !important;
    white-space: nowrap; /* Prevent wrapping inside */
}

/* Ensure currency symbol stays aligned */
.kc-input-field {
    background: transparent;
    padding: 0 5px;
    color: var(--kc-primary);
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: nowrap; /* Force single line */
}

.kc-input-field span {
    margin-right: 2px;
    font-size: 16px;
    line-height: 1;
    display: inline-block; /* Ensure it behaves like a block for alignment */
}

.kc-number-input {
    border: none;
    background: transparent;
    width: 80px; /* Fixed width to prevent jumping */
    text-align: center;
    font-weight: 700;
    color: var(--kc-primary);
    font-size: 18px;
    padding: 0;
    font-family: 'Outfit', sans-serif;
    -moz-appearance: textfield;
    appearance: textfield;
    line-height: 1;
}

.kc-adjust-btn {
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important; /* Prevent shrinking */
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 6px !important;
    border: none !important;
    background: #fff !important;
    color: var(--kc-primary) !important;
    font-weight: bold !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05) !important;
    transition: all 0.2s;
    line-height: 1 !important;
    font-size: 16px !important;
}

.kc-adjust-btn:hover {
    background: var(--kc-primary) !important;
    color: #fff !important;
}

/* Ensure range wrapper is relative for tooltip positioning */
.kc-range-wrapper {
    position: relative !important;
    width: 100%;
    height: 50px; /* Space for tooltip */
    display: flex;
    align-items: flex-end;
    margin-bottom: -15px; /* Pull back spacing slightly */
    z-index: 10;
}

/* Label Row - Side-by-side again */
.kc-label-row {
    display: flex;
    flex-direction: row; /* Restore side-by-side */
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px; /* Reduce gap between label/input and slider */
    gap: 15px; 
}

/* Ensure label doesn't wrap awkwardly */
.kc-label-row label {
    flex: 1;
    white-space: nowrap;
    margin-right: 10px;
}

/* Results Section - Seamless Integration */
.kc-results-section {
    width: calc(100% + 60px); /* Full width including wrapper padding */
    margin: -30px; /* Pull to edges */
    display: none; /* Hidden initially */
    background: var(--kc-bg); /* Match wrapper bg */
    padding: 30px; /* Restore inner padding */
    border-radius: 16px; /* Match wrapper radius */
    animation: smoothFadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border: none; 
    min-height: 520px; /* Match wrapper min-height to prevent jump */
    box-sizing: border-box;
    position: relative; /* Context for close button */
    z-index: 20; /* Ensure on top */
}

@keyframes smoothFadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Ensure Result View Matches Input View Dimensions to prevent layout shift */
/* Removed duplicate rule */

/* Close Result Button */
.kc-close-result {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0,0,0,0.05); /* Slight background for visibility */
    border: none;
    font-size: 20px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: var(--kc-text);
    cursor: pointer;
    line-height: 1;
    z-index: 30;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.kc-close-result:hover {
    background: var(--kc-text);
    color: #fff;
}

/* Range Slider - Minimalist Green Elegant */
.kc-range-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px; /* Thinner track */
    border-radius: 2px;
    background: transparent; /* Handled via JS gradient */
    outline: none;
    cursor: pointer;
    position: relative;
    z-index: 1;
    margin: 0 0 10px 0;
}

/* Chrome/Safari Thumb */
.kc-range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--kc-primary); /* Solid Green Thumb */
    cursor: pointer;
    border: 4px solid #fff; /* White inner border for elegance */
    box-shadow: 0 2px 6px rgba(0,0,0,0.15); /* Soft shadow */
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: -8px; /* Center on 4px track */
    position: relative;
    z-index: 2;
}

/* Firefox Thumb */
.kc-range-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--kc-primary);
    cursor: pointer;
    border: 4px solid #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    transition: transform 0.2s, box-shadow 0.2s;
}

/* Hover Effects */
.kc-range-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.kc-range-slider::-moz-range-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

/* Track styling fallback */
.kc-range-slider::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: #ccc; /* Darker Gray Track */
    border-radius: 2px;
}

.kc-range-slider::-moz-range-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: #ccc;
    border-radius: 2px;
}

/* Tooltip Positioning - ensure it is strictly bound */
.kc-slider-tooltip {
    position: absolute;
    bottom: 30px !important;
    left: 0; 
    transform: translateX(-50%);
    background: #fff;
    color: var(--kc-primary);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    font-family: 'Outfit', sans-serif !important;
    pointer-events: none;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s, left 0.1s;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    border: 1px solid var(--kc-accent);
    z-index: 20;
}

.keynivesh-calculator-wrapper .kc-range-wrapper {
    position: relative !important; /* Specificity boost */
    margin-bottom: 0;
}

.kc-range-wrapper:hover .kc-slider-tooltip,
.kc-range-slider:active + .kc-slider-tooltip,
.kc-range-slider:focus + .kc-slider-tooltip {
    opacity: 1;
}

.kc-slider-tooltip::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px 6px 0;
    border-style: solid;
    border-color: #fff transparent transparent transparent;
    filter: drop-shadow(0 2px 2px rgba(0,0,0,0.05));
}

/* Calculate Button */
.kc-btn-calculate {
    background: var(--kc-primary);
    color: #fff;
    border: none;
    padding: 15px 30px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    font-family: 'Outfit', sans-serif;
    margin-top: 10px;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 10px rgba(0,77,64,0.2);
}

.kc-btn-calculate:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0,77,64,0.3);
}

/* Results Section */
/* Removed duplicate rule */

.kc-chart-container {
    height: 220px;
    position: relative;
    margin-bottom: 25px;
    margin-top: 10px; /* Add space for close button */
    display: flex;
    justify-content: center;
}

.kc-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 25px;
    text-align: center;
}

.kc-summary-item span {
    display: block;
    font-size: 13px;
    color: var(--kc-text-light);
    margin-bottom: 8px;
    font-weight: 500;
}

.kc-summary-item h4 {
    margin: 0;
    font-size: 18px;
    color: var(--kc-text);
    font-family: 'Outfit', sans-serif;
}

.kc-summary-item.highlight {
    grid-column: span 2;
    background: var(--kc-accent);
    padding: 15px;
    border-radius: 8px;
    margin-top: 10px;
}

.kc-summary-item.highlight span {
    color: var(--kc-primary);
}

/* Result Summary Values - Fix Shake */
.kc-summary-item h3 {
    margin: 0;
    font-size: 28px;
    color: var(--kc-primary);
    font-family: 'Outfit', monospace !important; /* Use monospace fallback to keep width stable */
    font-variant-numeric: tabular-nums; /* Critical for preventing shake */
    letter-spacing: -0.5px;
}

.kc-btn-primary {
    background: var(--kc-text); /* Dark button for contrast */
    color: #fff;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    font-family: 'Montserrat', sans-serif;
    transition: background 0.2s;
}

.kc-btn-primary:hover {
    background: #000;
}

@media (max-width: 768px) {
    .kc-content {
        flex-direction: column;
        gap: 30px;
    }
    
    .kc-inputs-section, .kc-results-section {
        min-width: 100%;
        flex: 1;
    }
    
    .kc-results-section {
        position: static; /* Remove sticky on mobile */
        margin-top: 20px;
    }
    
    .keynivesh-calculator-wrapper {
        padding: 20px;
        margin: 15px auto;
    }
    
    .kc-label-row {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .kc-input-controls {
        width: 100%;
        max-width: 100%;
        justify-content: space-between;
        margin-top: 5px;
    }
    
    .kc-input-field {
        flex-grow: 1;
    }
}
