/* --- 1. THEME VARIABLES --- */
#cpcexx_calculator_wrapper {
    --primary: #0B1F51;      /* Navy */
    --text: #2B3445;         /* Body Text */
    --accent: #0B1F51;       /* Buttons: Navy */
    --accent-hover: #1e3a8a; /* Hover: Slightly lighter Navy */
    
    --bg: #F8FAFC;
    --border: #E2E8F0;
    --card: #FFFFFF;
    --success: #10B981;      /* Green for Hikes */
    --warning: #F59E0B;
    --error: #EF4444;
    --radius: 8px;
    
    --table-header: #F1F5F9;
    --table-border: #CBD5E1;
}

/* --- 2. RESET & BASE --- */
#cpcexx_calculator_wrapper * { box-sizing: border-box; margin: 0; padding: 0; }
#cpcexx_calculator_wrapper { 
    font-family: 'Inter', sans-serif; 
    background: var(--bg); 
    color: var(--text); 
    line-height: 1.6; 
    padding: 20px;
    -webkit-font-smoothing: antialiased;
}

/* --- 3. LAYOUT CONTAINER --- */
#cpcexx_calculator_wrapper .cpcexx_calculator-container { 
    max-width: 1100px; 
    margin: 2rem auto; 
    background: var(--card); 
    border-radius: 12px; 
    box-shadow: 0 4px 12px rgba(0,0,0,0.07); 
    border: 1px solid var(--border); 
    overflow: hidden; 
}

#cpcexx_calculator_wrapper .cpcexx_calculator-grid { 
    display: grid; 
    grid-template-columns: 1fr 1.3fr; /* Inputs Left, Detailed Results Right */
    min-height: 600px;
}

#cpcexx_calculator_wrapper .cpcexx_input-section { 
    padding: 35px; 
    background: var(--card); 
    border-right: 1px solid var(--border); 
    display: flex; 
    flex-direction: column;
}

#cpcexx_calculator_wrapper .cpcexx_results-section, 
#cpcexx_calculator_wrapper .cpcexx_results-placeholder { 
    padding: 35px; 
    background: var(--bg); 
    position: relative;
    display: flex;
    flex-direction: column;
}

/* --- 4. TYPOGRAPHY & HEADINGS --- */
#cpcexx_calculator_wrapper .cpcexx_section-title { 
    color: var(--primary); 
    font-size: 1.25rem; 
    font-weight: 800; 
    margin-bottom: 24px; 
    padding-bottom: 12px; 
    border-bottom: 2px solid var(--border);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* --- 5. INPUTS (DROPDOWN FIXES) --- */
#cpcexx_calculator_wrapper .cpcexx_input-group { margin-bottom: 20px; position: relative; }
#cpcexx_calculator_wrapper .cpcexx_input-group label { 
    display: flex; 
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px; 
    font-weight: 700; 
    color: var(--primary); 
    font-size: 0.9rem;
    text-transform: uppercase;
}

#cpcexx_calculator_wrapper .cpcexx_input-field {
    width: 100%; 
    padding: 12px 16px; 
    min-height: 50px; 
    border: 1px solid var(--border); 
    border-radius: var(--radius); 
    font-size: 16px; 
    line-height: 1.3;
    background: var(--bg); 
    color: var(--primary); 
    font-weight: 600;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
    display: flex;
    align-items: center;
}

#cpcexx_calculator_wrapper .cpcexx_input-field:focus { 
    outline: none; 
    border-color: var(--primary); 
    box-shadow: 0 0 0 3px rgba(11, 31, 81, 0.1); 
    background: white;
}

/* Error States */
#cpcexx_calculator_wrapper .cpcexx_input-group.cpcexx_error .cpcexx_input-field, 
#cpcexx_calculator_wrapper .cpcexx_input-group.cpcexx_error .cpcexx_manual-factor-input {
    border-color: var(--error);
    background-color: #FEF2F2;
}

#cpcexx_calculator_wrapper .cpcexx_error-msg {
    color: var(--error);
    font-size: 12px;
    margin-top: 5px;
    font-weight: 600;
    display: none;
}
#cpcexx_calculator_wrapper .cpcexx_input-group.cpcexx_error .cpcexx_error-msg { display: block; }

#cpcexx_calculator_wrapper select.cpcexx_input-field { 
    cursor: pointer; 
    appearance: none; 
    padding-right: 40px; 
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230B1F51' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e"); 
    background-repeat: no-repeat; 
    background-position: right 1rem center; 
    background-size: 1em; 
}

/* Tooltip */
#cpcexx_calculator_wrapper .cpcexx_tooltip-icon {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 18px;
    height: 18px;
    background: #E2E8F0;
    color: #64748B;
    border-radius: 50%;
    font-size: 11px;
    cursor: help;
    margin-left: 8px;
    position: relative;
}

#cpcexx_calculator_wrapper .cpcexx_tooltip-icon:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #334155;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 11px;
    width: 220px;
    text-align: center;
    line-height: 1.4;
    z-index: 10;
    font-weight: 400;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    text-transform: none;
    margin-top: 8px;
}

/* --- 6. SLIDER + INPUT SYNC --- */
#cpcexx_calculator_wrapper .cpcexx_slider-wrapper {
    background: #F1F5F9;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

#cpcexx_calculator_wrapper .cpcexx_slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

#cpcexx_calculator_wrapper .cpcexx_slider-controls {
    display: grid;
    grid-template-columns: 1fr 80px;
    gap: 15px;
    align-items: center;
}

#cpcexx_calculator_wrapper input[type="range"] { 
    -webkit-appearance: none; 
    width: 100%; 
    height: 6px; 
    background: #cbd5e1; 
    border-radius: 5px; 
    outline: none; 
    cursor: pointer;
}

#cpcexx_calculator_wrapper input[type="range"]::-webkit-slider-thumb { 
    -webkit-appearance: none; 
    width: 20px; 
    height: 20px; 
    background: var(--primary); 
    border-radius: 50%; 
    cursor: pointer; 
    transition: transform .1s; 
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

#cpcexx_calculator_wrapper input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.1); }

#cpcexx_calculator_wrapper .cpcexx_manual-factor-input {
    width: 100%;
    padding: 8px;
    text-align: center;
    font-weight: 800;
    color: var(--primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    min-height: 50px;
}

/* --- 7. BUTTONS --- */
#cpcexx_calculator_wrapper .cpcexx_btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 18px;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    width: 100%;
    transition: background 0.2s;
    display: block; /* Removed flex/svg alignment */
    text-align: center;
}

#cpcexx_calculator_wrapper .cpcexx_btn-primary:hover { background: var(--accent-hover); box-shadow: 0 4px 12px rgba(11, 31, 81, 0.2); }

/* Spacing between buttons */
#cpcexx_calculator_wrapper #cpcexx_btn_calculate { margin-top: 30px; }

#cpcexx_calculator_wrapper .cpcexx_btn-reset {
    background: transparent;
    color: #64748B;
    border: 1px solid var(--border);
    padding: 12px;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    margin-top: 15px;
}
#cpcexx_calculator_wrapper .cpcexx_btn-reset:hover { background: #F1F5F9; color: var(--text); }

/* --- 8. RESULTS SECTION --- */
#cpcexx_calculator_wrapper .cpcexx_results-placeholder {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    height: 100%;
    color: #94A3B8;
}
#cpcexx_calculator_wrapper .cpcexx_results-placeholder svg { width: 64px; height: 64px; margin-bottom: 20px; opacity: 0.5; }

/* Warning Banner */
#cpcexx_calculator_wrapper .cpcexx_warning-banner {
    background: #FFFBEB;
    border-left: 4px solid var(--warning);
    padding: 15px;
    margin-top: 25px; 
    border-radius: 4px;
    color: #92400E;
    font-size: 13px;
    line-height: 1.5;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
#cpcexx_calculator_wrapper .cpcexx_warning-banner svg { width: 20px; height: 20px; flex-shrink: 0; }

/* Single Result Box */
#cpcexx_calculator_wrapper .cpcexx_estimation-result-box {
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 25px;
    text-align: center;
    margin-bottom: 25px;
    border-left: 4px solid var(--success);
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
}

#cpcexx_calculator_wrapper .cpcexx_est-label {
    font-size: 14px;
    font-weight: 700;
    color: #64748B;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

#cpcexx_calculator_wrapper .cpcexx_est-amount {
    font-size: 32px;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 5px;
}

#cpcexx_calculator_wrapper .cpcexx_est-note {
    font-size: 12px;
    color: #94A3B8;
    font-style: italic;
}

/* --- CHART STYLES --- */
#cpcexx_calculator_wrapper .cpcexx_chart-wrapper {
    margin-bottom: 30px;
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid var(--border);
    /* No overflow here, we handle it in mobile wrapper */
}
#cpcexx_calculator_wrapper .cpcexx_chart-title {
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--primary);
    margin-bottom: 20px;
    text-align: center;
    letter-spacing: 0.5px;
}
#cpcexx_calculator_wrapper .cpcexx_chart-container {
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
    height: 200px;
    padding-bottom: 10px;
    border-bottom: 1px solid #E2E8F0;
    gap: 15px;
    min-width: 300px; /* Ensure chart doesn't squish too much */
}
#cpcexx_calculator_wrapper .cpcexx_bar-group {
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    gap: 4px;
    flex: 1;
    justify-content: center;
    height: 100%;
}
#cpcexx_calculator_wrapper .cpcexx_bar {
    width: 30px;
    background: #CBD5E1;
    border-radius: 4px 4px 0 0;
    transition: height 0.6s ease-out;
    position: relative;
    min-height: 2px;
}
#cpcexx_calculator_wrapper .cpcexx_bar.cpcexx_old { background: var(--primary); opacity: 0.8; }
#cpcexx_calculator_wrapper .cpcexx_bar.cpcexx_new { background: var(--success); }

#cpcexx_calculator_wrapper .cpcexx_bar:hover::after {
    content: attr(data-value);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #1E293B;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10px;
    white-space: nowrap;
    margin-bottom: 5px;
    z-index: 5;
}
#cpcexx_calculator_wrapper .cpcexx_chart-labels {
    display: flex;
    justify-content: space-around;
    margin-top: 10px;
    text-align: center;
    min-width: 300px; /* Align with container */
}
#cpcexx_calculator_wrapper .cpcexx_chart-label {
    font-size: 11px;
    font-weight: 700;
    color: #64748B;
    flex: 1;
}
#cpcexx_calculator_wrapper .cpcexx_chart-legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 15px;
    font-size: 11px;
}
#cpcexx_calculator_wrapper .cpcexx_legend-item { display: flex; align-items: center; gap: 6px; }
#cpcexx_calculator_wrapper .cpcexx_legend-color { width: 12px; height: 12px; border-radius: 3px; }

/* Comparison Grid */
#cpcexx_calculator_wrapper .cpcexx_salary-comparison-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr 1fr;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 25px;
    font-size: 14px;
    /* Ensure grid has minimum width so it triggers scrolling instead of squishing */
    min-width: 500px;
}

/* FIXED: Scroll Wrapper for Mobile with Visible Scrollbar */
#cpcexx_calculator_wrapper .cpcexx_mobile-scroll-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 25px;
    border-radius: 8px;
    border: 1px solid #E2E8F0; /* Slight border to define the slider area */
    padding-bottom: 5px;
}

/* Scrollbar Styling to look like a "Slider" */
#cpcexx_calculator_wrapper .cpcexx_mobile-scroll-wrapper::-webkit-scrollbar {
    height: 8px;
}
#cpcexx_calculator_wrapper .cpcexx_mobile-scroll-wrapper::-webkit-scrollbar-track {
    background: #F1F5F9;
    border-radius: 4px;
}
#cpcexx_calculator_wrapper .cpcexx_mobile-scroll-wrapper::-webkit-scrollbar-thumb {
    background: #CBD5E1;
    border-radius: 4px;
}
#cpcexx_calculator_wrapper .cpcexx_mobile-scroll-wrapper::-webkit-scrollbar-thumb:hover {
    background: #94A3B8;
}

/* Scroll Hint Text */
#cpcexx_calculator_wrapper .cpcexx_mobile-hint-text {
    display: none; /* Hidden on Desktop */
    font-size: 11px;
    color: #64748B;
    font-style: italic;
    text-align: center;
    margin-bottom: 8px;
    font-weight: 500;
}

#cpcexx_calculator_wrapper .cpcexx_grid-header {
    background: var(--table-header);
    padding: 12px 15px;
    font-weight: 800;
    color: var(--primary);
    text-transform: uppercase;
    font-size: 12px;
    border-bottom: 2px solid var(--table-border);
    text-align: right;
}
#cpcexx_calculator_wrapper .cpcexx_grid-header:first-child { text-align: left; }

#cpcexx_calculator_wrapper .cpcexx_grid-row {
    padding: 12px 15px;
    border-bottom: 1px solid #F1F5F9;
    color: var(--text);
    text-align: right;
    font-variant-numeric: tabular-nums;
}

#cpcexx_calculator_wrapper .cpcexx_grid-row.cpcexx_label { text-align: left; font-weight: 600; color: #475569; }
#cpcexx_calculator_wrapper .cpcexx_grid-row.cpcexx_total-row { 
    background: #F0F9FF; 
    font-weight: 800; 
    color: var(--primary); 
    border-top: 2px solid var(--border);
    font-size: 16px;
}
#cpcexx_calculator_wrapper .cpcexx_grid-row.cpcexx_diff-val { color: var(--success); font-weight: 700; }

#cpcexx_calculator_wrapper .cpcexx_sub-label {
    font-size: 11px; 
    font-weight: 700; 
    display: block; 
    color: #475569; 
    margin-top: 3px;
}

/* Logic Explainer */
#cpcexx_calculator_wrapper .cpcexx_logic-explainer {
    font-size: 13px;
    color: #475569;
    background: #F8FAFC;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 25px;
    border-left: 3px solid var(--primary);
    line-height: 1.6;
}

/* Summary Card */
#cpcexx_calculator_wrapper .cpcexx_summary-card {
    background: #F0F9FF;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 25px;
    border: 1px solid #BAE6FD;
}

/* Legal Disclaimer */
#cpcexx_calculator_wrapper .cpcexx_legal-disclaimer {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px dashed var(--border);
    font-size: 11px;
    color: #94A3B8;
    text-align: justify;
    line-height: 1.4;
}

/* Print Header - Hidden by default */
#cpcexx_calculator_wrapper .cpcexx_print-header { display: none; }

/* --- 10. RESPONSIVE --- */
@media (max-width: 900px) {
    #cpcexx_calculator_wrapper .cpcexx_calculator-container { margin: 0; border: none; border-radius: 0; width: 100%; }
    #cpcexx_calculator_wrapper .cpcexx_calculator-grid { grid-template-columns: 1fr; display: block; }
    #cpcexx_calculator_wrapper .cpcexx_input-section { border-right: none; border-bottom: 1px solid var(--border); padding: 25px; }
    #cpcexx_calculator_wrapper .cpcexx_results-section { padding: 25px; min-height: auto; }
    #cpcexx_calculator_wrapper .cpcexx_results-placeholder { padding: 40px 20px; }
    
    /* FIXED: Mobile Chart Adjustments to prevent "going out of box" */
    #cpcexx_calculator_wrapper .cpcexx_chart-container { gap: 5px; }
    #cpcexx_calculator_wrapper .cpcexx_bar { width: 15px; } /* Thinner bars on mobile */
    #cpcexx_calculator_wrapper .cpcexx_chart-labels { font-size: 10px; }

    /* FIXED: Show Scroll Hint and Slider */
    #cpcexx_calculator_wrapper .cpcexx_mobile-hint-text { display: block; }

    /* FIXED: Reduced Font Size for Summary on Mobile */
    #cpcexx_calculator_wrapper #cpcexx_summary_total_increase,
    #cpcexx_calculator_wrapper #cpcexx_summary_pct_increase {
        font-size: 20px !important; /* Reduced from 24px/32px */
    }
}

/* --- FIXED: PRINT REPORT NUCLEAR OPTION --- */
@media print {
    body * { visibility: hidden; height: 0; }
    body { background: white; padding: 0; margin: 0; }
    #cpcexx_calculator_wrapper, #cpcexx_calculator_wrapper * { visibility: visible; height: auto; }
    #cpcexx_calculator_wrapper { position: absolute; left: 0; top: 0; width: 100%; max-width: 100%; margin: 0; padding: 0; border: none; box-shadow: none; }
    #cpcexx_calculator_wrapper .cpcexx_input-section { display: none !important; }
    #cpcexx_calculator_wrapper .cpcexx_calculator-grid { display: block !important; }
    #cpcexx_calculator_wrapper .cpcexx_results-section { display: block !important; padding: 0 !important; }
    #cpcexx_calculator_wrapper .cpcexx_results-placeholder { display: none !important; }
    #cpcexx_calculator_wrapper .cpcexx_legal-disclaimer { display: block !important; color: #000; }
    #cpcexx_calculator_wrapper #cpcexx_btn_print_report { display: none !important; }
    
    /* Hide scroll hints and scrollbars in print */
    #cpcexx_calculator_wrapper .cpcexx_mobile-scroll-wrapper { overflow: visible !important; border: none !important; }
    #cpcexx_calculator_wrapper .cpcexx_mobile-hint-text { display: none !important; }
    
    /* Show Print Header */
    #cpcexx_calculator_wrapper .cpcexx_print-header { display: block !important; text-align: center; font-size: 14px; margin-bottom: 20px; color: #000; font-weight: bold; border-bottom: 2px solid #000; padding-bottom: 10px; }

    #cpcexx_calculator_wrapper .cpcexx_bar, #cpcexx_calculator_wrapper .cpcexx_legend-color { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    #cpcexx_calculator_wrapper .cpcexx_bar::after { content: attr(data-value); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); color: #fff; background: #1E293B; padding: 2px 4px; border-radius: 4px; font-size: 10px; font-weight: bold; white-space: nowrap; margin-bottom: 2px; display: block; }
    #cpcexx_calculator_wrapper .cpcexx_chart-wrapper { page-break-inside: avoid; border: 1px solid #ccc; overflow: visible; }
}