/* === DESIGN TOKENS === */
#pccfx_calculator_wrapper {
    --primary: #0B1F51;      /* Navy */
    --text: #2B3445;         /* Body Text */
    --accent: #0B1F51;       /* Button/Header */
    --accent-hover: #AFC8FF; /* Hover State */
    
    --bg: #F8FAFC;
    --border: #cbd5e1;       
    --card: #FFFFFF;
    --success: #10B981;
    --warning: #F59E0B;
    --error: #EF4444;
    --radius: 6px;           
}

/* --- Reset & Base --- */
#pccfx_calculator_wrapper * { box-sizing: border-box; margin: 0; padding: 0; }
#pccfx_calculator_wrapper { 
    font-family: 'Inter', sans-serif; 
    background: var(--bg); 
    color: var(--text); 
    line-height: 1.6; 
    padding: 20px; 
}

/* --- Layout Container --- */
#pccfx_calculator_wrapper .pccfx_calculator-container { 
    max-width: 1200px; 
    margin: 2rem auto; 
    background: var(--card); 
    border-radius: 12px; 
    box-shadow: 0 4px 12px rgba(0,0,0,0.07); 
    border: 1px solid #e2e8f0; 
    position: relative;
}

/* Grid: Input Left (1fr), Results Right (1.1fr) */
#pccfx_calculator_wrapper .pccfx_calculator-grid { display: grid; grid-template-columns: 1fr 1.1fr; } 

#pccfx_calculator_wrapper .pccfx_input-section, 
#pccfx_calculator_wrapper .pccfx_results-section, 
#pccfx_calculator_wrapper .pccfx_results-placeholder { padding: 30px; }

/* Border Radius handling */
#pccfx_calculator_wrapper .pccfx_input-section { 
    border-right: 1px solid #e2e8f0; 
    background: var(--card); 
    border-top-left-radius: 12px;
    border-bottom-left-radius: 12px;
}
#pccfx_calculator_wrapper .pccfx_results-section, 
#pccfx_calculator_wrapper .pccfx_results-placeholder { 
    background: var(--bg); 
    border-top-right-radius: 12px;
    border-bottom-right-radius: 12px;
}

#pccfx_calculator_wrapper .pccfx_section-title { 
    color: var(--primary); 
    font-size: 1.25rem; 
    font-weight: 700; 
    margin-bottom: 24px; 
    padding-bottom: 12px; 
    border-bottom: 2px solid #e2e8f0; 
}

/* --- Form Elements --- */
#pccfx_calculator_wrapper .pccfx_form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 20px;
    row-gap: 20px;
}

#pccfx_calculator_wrapper .pccfx_full-width { grid-column: 1 / -1; }

#pccfx_calculator_wrapper .pccfx_input-group { position: relative; display: flex; flex-direction: column; }

#pccfx_calculator_wrapper .pccfx_input-group label { 
    display: block; 
    margin-bottom: 6px; 
    font-weight: 600; 
    color: #1e293b; 
    font-size: 0.85rem; 
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Inputs - FIXED HEIGHT to resolve clipping issue */
#pccfx_calculator_wrapper input[type="text"], 
#pccfx_calculator_wrapper input[type="number"], 
#pccfx_calculator_wrapper input[type="date"], 
#pccfx_calculator_wrapper select {
    width: 100%; 
    height: 48px; /* Fixed height stops dropdown text cutoff */
    padding: 10px 14px; 
    border: 1px solid var(--border); 
    border-radius: var(--radius);
    font-size: 16px; 
    background: #ffffff; 
    color: #334155; 
    transition: all 0.2s; 
    font-family: inherit;
    text-overflow: ellipsis;
    box-sizing: border-box;
}

#pccfx_calculator_wrapper input:focus, 
#pccfx_calculator_wrapper select:focus { 
    outline: none; border-color: #3b82f6; background: #fff; box-shadow: 0 0 0 3px #eff6ff; 
}

/* Custom Select Arrow */
#pccfx_calculator_wrapper .pccfx_select-wrapper { position: relative; }
#pccfx_calculator_wrapper .pccfx_select-wrapper::after {
    content: "▼"; font-size: 0.7rem; color: #475569;
    position: absolute; right: 14px; top: 50%; transform: translateY(-50%); pointer-events: none;
}
#pccfx_calculator_wrapper select { appearance: none; -webkit-appearance: none; padding-right: 30px; }

#pccfx_calculator_wrapper .pccfx_input-desc { font-size: 0.8rem; color: #64748b; margin-top: 4px; display: block; font-weight: 400; }
#pccfx_calculator_wrapper .pccfx_hidden { display: none !important; }

/* Error & Warning States */
#pccfx_calculator_wrapper .pccfx_input-group.pccfx_error input, 
#pccfx_calculator_wrapper .pccfx_input-group.pccfx_error select { border-color: var(--error); background-color: #fef2f2; }
#pccfx_calculator_wrapper .pccfx_inline-error { color: var(--error); font-size: 0.8rem; margin-top: 4px; display: none; font-weight: 500; }
#pccfx_calculator_wrapper .pccfx_input-group.pccfx_error .pccfx_inline-error { display: block; }

#pccfx_calculator_wrapper .pccfx_inline-warning { color: #d97706; font-size: 0.8rem; margin-top: 4px; display: none; font-weight: 500; }
#pccfx_calculator_wrapper .pccfx_input-group.pccfx_warning input { border-color: var(--warning); }
#pccfx_calculator_wrapper .pccfx_input-group.pccfx_warning .pccfx_inline-warning { display: block; }

/* --- Buttons --- */
#pccfx_calculator_wrapper .pccfx_action-buttons { margin-top: 30px; grid-column: 1 / -1; display: flex; gap: 15px; }
#pccfx_calculator_wrapper button {
    padding: 16px 24px; border-radius: var(--radius); cursor: pointer; 
    font-size: 16px; font-weight: 700; width: 100%; border: none; 
    transition: 0.2s; text-transform: uppercase; letter-spacing: 0.5px;
}

#pccfx_calculator_wrapper #pccfx_calculateBtn { flex: 2; background: var(--accent); color: white; box-shadow: 0 4px 6px -1px rgba(11, 31, 81, 0.2); }
#pccfx_calculator_wrapper #pccfx_calculateBtn:hover { background: var(--accent-hover); color: var(--primary); }

#pccfx_calculator_wrapper #pccfx_resetBtn { flex: 1; background: #f8fafc; color: #475569; border: 1px solid #cbd5e1; }
#pccfx_calculator_wrapper #pccfx_resetBtn:hover { background: #f1f5f9; color: #0f172a; border-color: #94a3b8; }

#pccfx_calculator_wrapper #pccfx_printReportBtn { background: var(--card); border: 2px solid var(--accent); color: var(--accent); margin-top: 15px; }
#pccfx_calculator_wrapper #pccfx_printReportBtn:hover { background: var(--bg); }

/* --- Results Area --- */
#pccfx_calculator_wrapper .pccfx_results-placeholder { 
    height: 100%; min-height: 400px; display: flex; flex-direction: column; 
    align-items: center; justify-content: center; text-align: center; color: #64748b; 
}
#pccfx_calculator_wrapper .pccfx_results-placeholder svg { width: 64px; height: 64px; margin-bottom: 1.5rem; opacity: 0.4; }

#pccfx_calculator_wrapper .pccfx_result-card {
    background: var(--card); padding: 24px; border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05); margin-bottom: 20px;
    border-left: 5px solid var(--primary); animation: pccfx_slideDown 0.4s ease-out;
}

@keyframes pccfx_slideDown { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }

#pccfx_calculator_wrapper .pccfx_result-header { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 1px; color: #64748b; margin-bottom: 8px; font-weight: 700; display: flex; align-items: center; justify-content: space-between; }
#pccfx_calculator_wrapper .pccfx_result-value { font-size: 2.2rem; font-weight: 700; color: var(--primary); line-height: 1.1; }
#pccfx_calculator_wrapper .pccfx_result-subtext { font-size: 0.95rem; color: #64748b; margin-top: 8px; }

/* Tooltip */
#pccfx_calculator_wrapper .pccfx_info-tooltip {
    cursor: help;
    color: #64748b;
    font-size: 1.1rem;
    margin-left: 5px;
    position: relative;
    display: inline-block;
}
#pccfx_calculator_wrapper .pccfx_info-tooltip:hover { color: var(--primary); }

/* --- Visual Bars --- */
#pccfx_calculator_wrapper .pccfx_chart-container { margin-top: 25px; }
#pccfx_calculator_wrapper .pccfx_bar-wrapper { margin-bottom: 15px; }
#pccfx_calculator_wrapper .pccfx_bar-label { display: flex; justify-content: space-between; font-size: 0.9rem; margin-bottom: 5px; font-weight: 600; }
#pccfx_calculator_wrapper .pccfx_progress-bg { background: #E2E8F0; height: 16px; border-radius: 8px; overflow: hidden; }
#pccfx_calculator_wrapper .pccfx_progress-fill { height: 100%; border-radius: 8px; transition: width 1s ease-out; }
#pccfx_calculator_wrapper .pccfx_fill-primary { background-color: var(--primary); }
#pccfx_calculator_wrapper .pccfx_fill-warning { background-color: var(--warning); }

#pccfx_calculator_wrapper .pccfx_breakdown-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 0.95rem; }
#pccfx_calculator_wrapper .pccfx_breakdown-table td { padding: 12px 0; border-bottom: 1px solid #eee; }
#pccfx_calculator_wrapper .pccfx_breakdown-table td:last-child { text-align: right; font-weight: 600; color: var(--text); }
#pccfx_calculator_wrapper .pccfx_breakdown-table tr:last-child td { border-bottom: none; }

#pccfx_calculator_wrapper .pccfx_disclaimer { font-size: 0.8rem; color: #64748b; background: #f1f5f9; padding: 15px; border-radius: 8px; margin-top: 20px; line-height: 1.5; border: 1px solid #e2e8f0; }
#pccfx_calculator_wrapper .pccfx_disclaimer ul { margin-left: 20px; margin-top: 5px; }
#pccfx_calculator_wrapper .pccfx_disclaimer li { margin-bottom: 4px; }

/* --- Responsive Adjustments (Mobile Fit Fixes) --- */
@media (max-width: 900px) { 
    #pccfx_calculator_wrapper { padding: 10px; } /* Prevent touching screen edges */
    #pccfx_calculator_wrapper .pccfx_calculator-container { 
        margin: 0; 
        border-radius: 10px; 
        border: 1px solid #e2e8f0; 
        box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    }
    #pccfx_calculator_wrapper .pccfx_calculator-grid { grid-template-columns: 1fr; } 
    #pccfx_calculator_wrapper .pccfx_input-section { 
        border-right: none; 
        border-bottom: 1px solid #e2e8f0; 
        border-radius: 10px 10px 0 0;
        padding: 20px 15px; /* Better mobile padding */
    }
    #pccfx_calculator_wrapper .pccfx_results-section, 
    #pccfx_calculator_wrapper .pccfx_results-placeholder {
        border-radius: 0 0 10px 10px;
        padding: 20px 15px;
        min-height: auto;
    }
    #pccfx_calculator_wrapper .pccfx_result-value { font-size: 2rem; }
    #pccfx_calculator_wrapper .pccfx_action-buttons { flex-direction: column; }
}

@media (max-width: 600px) {
    #pccfx_calculator_wrapper .pccfx_form-grid { 
        grid-template-columns: 1fr; 
        row-gap: 15px;
    }
    #pccfx_calculator_wrapper .pccfx_section-title { font-size: 1.15rem; margin-bottom: 15px; }
    #pccfx_calculator_wrapper .pccfx_breakdown-table { font-size: 0.85rem; }
}

/* --- Print Styles (A4 STRICT ONE PAGE, NO HEADERS) --- */
@media print {
    @page { 
        size: A4 portrait; 
        margin: 1cm; 
    }
    
    /* Hide entire website structure (Theme Headers, Footers, Sidebars) */
    body * { 
        visibility: hidden !important; 
    }
    
    /* Make ONLY the calculator visible */
    #pccfx_calculator_wrapper, 
    #pccfx_calculator_wrapper * { 
        visibility: visible !important; 
    }
    
    /* Position the calculator at the exact top-left of the printed page */
    #pccfx_calculator_wrapper { 
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        background: white !important; 
        padding: 0 !important; 
        margin: 0 !important;
        font-size: 10pt !important; 
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    #pccfx_calculator_wrapper .pccfx_calculator-container { 
        box-shadow: none !important; 
        border: none !important; 
        margin: 0 !important; 
        width: 100% !important; 
        display: block !important; 
    }
    
    /* Hide non-print elements to save space and force 1 page */
    #pccfx_calculator_wrapper .pccfx_input-section, 
    #pccfx_calculator_wrapper .pccfx_results-placeholder, 
    #pccfx_calculator_wrapper button, 
    #pccfx_calculator_wrapper .pccfx_action-buttons, 
    #pccfx_calculator_wrapper #pccfx_printReportBtn,
    #pccfx_calculator_wrapper .pccfx_info-tooltip { 
        display: none !important; 
    }
    
    /* Expand Results Section */
    #pccfx_calculator_wrapper .pccfx_calculator-grid { display: block !important; }
    
    #pccfx_calculator_wrapper .pccfx_results-section { 
        display: block !important; 
        padding: 0 !important; 
        width: 100% !important;
        background: white !important; 
        border-radius: 0 !important;
    }
    
    /* Compact the report visually to fit strict boundaries */
    #pccfx_calculator_wrapper .pccfx_section-title { 
        color: #000 !important; 
        border-bottom: 2px solid #000 !important; 
        margin-bottom: 12px !important; 
        font-size: 14pt !important; 
        padding-bottom: 5px !important; 
        margin-top: 0 !important;
    }
    
    #pccfx_calculator_wrapper .pccfx_result-card { 
        break-inside: avoid !important; 
        page-break-inside: avoid !important;
        border: 1px solid #ccc !important; 
        box-shadow: none !important; 
        margin-bottom: 10px !important; 
        padding: 10px 15px !important; 
        background: white !important; 
        border-radius: 4px !important;
        border-left-width: 5px !important;
    }
    
    #pccfx_calculator_wrapper .pccfx_result-value { font-size: 1.4rem !important; color: #000 !important; margin: 3px 0 !important; }
    #pccfx_calculator_wrapper .pccfx_result-header { color: #333 !important; margin-bottom: 2px !important; }
    #pccfx_calculator_wrapper .pccfx_result-subtext { margin-top: 2px !important; }
    
    #pccfx_calculator_wrapper .pccfx_progress-bg { background: #eee !important; border: 1px solid #ddd !important; }
    
    #pccfx_calculator_wrapper .pccfx_chart-container { margin-top: 10px !important; margin-bottom: 10px !important; }
    #pccfx_calculator_wrapper .pccfx_bar-wrapper { margin-bottom: 8px !important; }
    
    #pccfx_calculator_wrapper .pccfx_breakdown-table { margin-top: 5px !important; }
    #pccfx_calculator_wrapper .pccfx_breakdown-table td { padding: 4px 0 !important; font-size: 9.5pt !important; border-bottom: 1px solid #e2e8f0 !important; }
    
    #pccfx_calculator_wrapper .pccfx_disclaimer { 
        display: block !important; 
        border: 1px solid #000 !important; 
        background: #fff !important; 
        color: #000 !important; 
        margin-top: 15px !important; 
        break-inside: avoid !important;
        page-break-inside: avoid !important;
        font-size: 8.5pt !important;
        padding: 8px 12px !important;
        line-height: 1.3 !important;
    }
    
    #pccfx_calculator_wrapper .pccfx_disclaimer ul { margin-top: 2px !important; margin-bottom: 0 !important; }
    #pccfx_calculator_wrapper .pccfx_disclaimer li { margin-bottom: 2px !important; }
}
