/* --- CSS Variables (Navy Theme) --- */
#cggcx_calculator_wrapper {
    --primary: #0B1F51;      
    --text: #2B3445;         
    --accent: #0B1F51;       
    --accent-hover: #AFC8FF; 
    
    --bg: #F8FAFC;
    --border: #cbd5e1;       
    --card: #FFFFFF;
    --success: #10B981;
    --warning: #F59E0B;
    --error: #EF4444;
    --radius: 8px;           
}

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

#cggcx_calculator_wrapper .cggcx_calculator-container { 
    max-width: 1200px; 
    margin: 2rem auto; 
    background: var(--card); 
    border-radius: 12px; 
    box-shadow: 0 4px 12px rgba(11, 31, 81, 0.08); 
    border: 1px solid #e2e8f0; 
    overflow: hidden; 
}

/* Split Layout for Desktop */
#cggcx_calculator_wrapper .cggcx_calculator-grid { display: grid; grid-template-columns: 1fr 1.1fr; } 

#cggcx_calculator_wrapper .cggcx_input-section, #cggcx_calculator_wrapper .cggcx_results-section, #cggcx_calculator_wrapper .cggcx_results-placeholder { padding: 30px; }
#cggcx_calculator_wrapper .cggcx_input-section { border-right: 1px solid #e2e8f0; background: #fff; }
#cggcx_calculator_wrapper .cggcx_results-section, #cggcx_calculator_wrapper .cggcx_results-placeholder { background: #F8FAFC; }

#cggcx_calculator_wrapper .cggcx_section-title { 
    color: var(--primary); 
    font-size: 1.35rem; 
    font-weight: 700; 
    margin-bottom: 24px; 
    padding-bottom: 12px; 
    border-bottom: 2px solid #e2e8f0; 
    letter-spacing: -0.5px;
}

#cggcx_calculator_wrapper .cggcx_form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 20px;
    row-gap: 24px;
}

#cggcx_calculator_wrapper .cggcx_full-width { grid-column: 1 / -1; }

#cggcx_calculator_wrapper .cggcx_input-group { position: relative; display: flex; flex-direction: column; }

#cggcx_calculator_wrapper .cggcx_input-group label { 
    display: block; 
    margin-bottom: 8px; 
    font-weight: 600; 
    color: var(--primary); 
    font-size: 0.9rem; 
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Checkbox Style - Enhanced Visibility */
#cggcx_calculator_wrapper .cggcx_checkbox-group {
    background: #eef4ff; /* Light blue background for visibility */
    padding: 15px;
    border-radius: var(--radius);
    border: 2px solid #dae5f5; /* Distinct border */
    margin-top: -10px;
}
#cggcx_calculator_wrapper .cggcx_checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: 700; /* Bolder */
    color: var(--primary);
}
#cggcx_calculator_wrapper .cggcx_checkbox-label input {
    width: 20px;
    height: 20px;
    margin-right: 12px;
    cursor: pointer;
}

/* FIX ISSUE 1: Dropdown clipping & fat finger friendly inputs */
#cggcx_calculator_wrapper input[type="text"], 
#cggcx_calculator_wrapper input[type="number"], 
#cggcx_calculator_wrapper input[type="date"], 
#cggcx_calculator_wrapper select, 
#cggcx_calculator_wrapper .cggcx_input-display {
    width: 100%; 
    padding: 14px 16px; 
    border: 2px solid #e2e8f0; 
    border-radius: var(--radius);
    font-size: 16px; 
    background: #ffffff; 
    color: #334155; 
    transition: all 0.2s ease; 
    font-family: inherit;
    height: 54px; /* Explicit height to prevent clipping */
    line-height: normal;
}

#cggcx_calculator_wrapper ::placeholder { color: #94a3b8; }

#cggcx_calculator_wrapper input:focus, #cggcx_calculator_wrapper select:focus { 
    outline: none; 
    border-color: var(--primary); 
    box-shadow: 0 0 0 4px rgba(11, 31, 81, 0.1); 
}

#cggcx_calculator_wrapper .cggcx_input-display {
    background-color: #f1f5f9;
    color: #0f172a;
    font-weight: 700;
    cursor: default;
    border-color: #cbd5e1;
    display: flex;
    align-items: center;
}

/* Custom Select Arrow */
#cggcx_calculator_wrapper .cggcx_select-wrapper { position: relative; }
#cggcx_calculator_wrapper .cggcx_select-wrapper::after {
    content: "▼"; 
    font-size: 0.8rem; 
    color: var(--primary);
    position: absolute; 
    right: 16px; 
    top: 50%; 
    transform: translateY(-50%); 
    pointer-events: none;
}
#cggcx_calculator_wrapper select { appearance: none; -webkit-appearance: none; cursor: pointer; }

#cggcx_calculator_wrapper .cggcx_date-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

#cggcx_calculator_wrapper .cggcx_input-desc { font-size: 0.85rem; color: #64748b; margin-top: 6px; display: block; line-height: 1.4; }

#cggcx_calculator_wrapper .cggcx_hidden { display: none !important; }

/* Validation Styles */
#cggcx_calculator_wrapper .cggcx_input-group.cggcx_error input, #cggcx_calculator_wrapper .cggcx_input-group.cggcx_error select { border-color: var(--error); background-color: #fff5f5; }
#cggcx_calculator_wrapper .cggcx_inline-error { color: var(--error); font-size: 0.85rem; margin-top: 6px; display: none; font-weight: 500; }
#cggcx_calculator_wrapper .cggcx_input-group.cggcx_error .cggcx_inline-error { display: block; }

/* Action Buttons */
#cggcx_calculator_wrapper .cggcx_action-buttons { margin-top: 30px; grid-column: 1 / -1; display: flex; gap: 15px; }
#cggcx_calculator_wrapper button {
    padding: 18px 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: 1px;
}

#cggcx_calculator_wrapper #cggcx_calculateBtn { 
    flex: 2; 
    background: var(--primary); 
    color: white; 
    box-shadow: 0 4px 6px rgba(11, 31, 81, 0.2); 
}
#cggcx_calculator_wrapper #cggcx_calculateBtn:active { transform: translateY(2px); }
#cggcx_calculator_wrapper #cggcx_calculateBtn:hover { background-color: #1a3675; }

#cggcx_calculator_wrapper #cggcx_resetBtn { 
    flex: 1; 
    background: #fff; 
    color: var(--primary); 
    border: 2px solid var(--border); 
}
#cggcx_calculator_wrapper #cggcx_resetBtn:hover { background: #f8fafc; border-color: var(--primary); }

#cggcx_calculator_wrapper #cggcx_printReportBtn { 
    background: white; 
    border: 2px solid var(--primary); 
    color: var(--primary); 
    margin-top: 20px; 
}
#cggcx_calculator_wrapper #cggcx_printReportBtn:hover { background: #f0f4ff; }

/* Results Section */
#cggcx_calculator_wrapper .cggcx_results-placeholder { 
    height: 100%; min-height: 400px; display: flex; flex-direction: column; 
    align-items: center; justify-content: center; text-align: center; color: #94a3b8; 
}
#cggcx_calculator_wrapper .cggcx_results-placeholder svg { width: 80px; height: 80px; margin-bottom: 1.5rem; opacity: 0.5; color: var(--primary); }

#cggcx_calculator_wrapper .cggcx_result-card {
    background: #fff; padding: 24px; border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05); margin-bottom: 20px;
    border-left: 6px solid var(--primary); 
    animation: slideDown 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

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

#cggcx_calculator_wrapper .cggcx_result-header { font-size: 0.9rem; text-transform: uppercase; letter-spacing: 1px; color: #64748b; margin-bottom: 8px; font-weight: 700; }
#cggcx_calculator_wrapper .cggcx_result-value { font-size: 2.5rem; font-weight: 800; color: var(--primary); line-height: 1.1; margin-bottom: 5px; }
#cggcx_calculator_wrapper .cggcx_result-subtext { font-size: 1rem; color: #64748b; font-weight: 500; }

/* Calculation Breakdown Table */
#cggcx_calculator_wrapper .cggcx_breakdown-table { width: 100%; border-collapse: collapse; margin-top: 15px; font-size: 15px; }
#cggcx_calculator_wrapper .cggcx_breakdown-table td { padding: 14px 0; border-bottom: 1px solid #f1f5f9; }
#cggcx_calculator_wrapper .cggcx_breakdown-table td:first-child { color: #475569; }
#cggcx_calculator_wrapper .cggcx_breakdown-table td:last-child { text-align: right; font-weight: 700; color: var(--text); }
#cggcx_calculator_wrapper .cggcx_breakdown-table tr:last-child td { border-bottom: none; }

/* Progress Bar */
#cggcx_calculator_wrapper .cggcx_chart-container { margin-top: 25px; }
#cggcx_calculator_wrapper .cggcx_bar-wrapper { margin-bottom: 15px; }
#cggcx_calculator_wrapper .cggcx_bar-label { display: flex; justify-content: space-between; font-size: 0.9rem; margin-bottom: 6px; font-weight: 600; color: #475569; }
#cggcx_calculator_wrapper .cggcx_progress-bg { background: #E2E8F0; height: 12px; border-radius: 6px; overflow: hidden; }
#cggcx_calculator_wrapper .cggcx_progress-fill { height: 100%; border-radius: 6px; transition: width 1s ease-out; }
#cggcx_calculator_wrapper .cggcx_fill-primary { background-color: var(--primary); }
#cggcx_calculator_wrapper .cggcx_fill-warning { background-color: var(--warning); }
#cggcx_calculator_wrapper .cggcx_fill-error { background-color: var(--error); }

#cggcx_calculator_wrapper .cggcx_disclaimer { 
    font-size: 0.85rem; color: #64748b; background: #f8fafc; padding: 16px; 
    border-radius: 8px; margin-top: 24px; line-height: 1.5; border: 1px solid #e2e8f0; 
}

/* Print Specifics */
#cggcx_calculator_wrapper .cggcx_print-only-disclaimer { display: none; }

/* FIX ISSUE 3: Mobile Responsive Layout Adjustment */
@media (max-width: 900px) { 
    #cggcx_calculator_wrapper { padding: 10px; }
    #cggcx_calculator_wrapper .cggcx_calculator-container { margin: 0; border-radius: 8px; border: 1px solid #e2e8f0; }
    #cggcx_calculator_wrapper .cggcx_calculator-grid { grid-template-columns: 1fr; } 
    #cggcx_calculator_wrapper .cggcx_input-section { border-right: none; border-bottom: 1px solid #e2e8f0; padding: 20px 15px; }
    #cggcx_calculator_wrapper .cggcx_results-section, 
    #cggcx_calculator_wrapper .cggcx_results-placeholder { padding: 20px 15px; }
    
    #cggcx_calculator_wrapper .cggcx_form-grid { grid-template-columns: 1fr; gap: 16px; }
    
    /* Adjust date grid for smaller screens */
    #cggcx_calculator_wrapper .cggcx_date-grid { gap: 8px; grid-template-columns: repeat(3, 1fr); }
    #cggcx_calculator_wrapper .cggcx_date-grid input { padding: 12px 8px; font-size: 14px; text-align: center; }
    
    #cggcx_calculator_wrapper input[type="text"], 
    #cggcx_calculator_wrapper input[type="number"], 
    #cggcx_calculator_wrapper input[type="date"], 
    #cggcx_calculator_wrapper select, 
    #cggcx_calculator_wrapper button,
    #cggcx_calculator_wrapper .cggcx_input-display { 
        padding: 12px 14px; 
        font-size: 16px; 
        height: 50px; 
    } 
    
    #cggcx_calculator_wrapper .cggcx_result-value { font-size: 2rem; }
    #cggcx_calculator_wrapper .cggcx_action-buttons { flex-direction: column; gap: 12px; margin-top: 20px; }
}

/* FIX ISSUE 2: Isolate Print Report and Hide Site Content */
@media print {
    body * {
        visibility: hidden;
    }
    #cggcx_calculator_wrapper, #cggcx_calculator_wrapper * {
        visibility: visible;
    }
    #cggcx_calculator_wrapper {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        margin: 0;
        padding: 0;
        background: white;
    }
    #cggcx_calculator_wrapper .cggcx_calculator-container { box-shadow: none; border: none; margin: 0; width: 100%; max-width: 100%; }
    
    /* Explicitly hide non-result elements inside the wrapper */
    #cggcx_calculator_wrapper .cggcx_input-section,
    #cggcx_calculator_wrapper .cggcx_input-section *,
    #cggcx_calculator_wrapper .cggcx_results-placeholder,
    #cggcx_calculator_wrapper .cggcx_results-placeholder *,
    #cggcx_calculator_wrapper button,
    #cggcx_calculator_wrapper button *,
    #cggcx_calculator_wrapper .cggcx_chart-container,
    #cggcx_calculator_wrapper .cggcx_chart-container * {
        display: none !important;
        visibility: hidden !important;
        height: 0 !important;
    }
    
    #cggcx_calculator_wrapper .cggcx_results-section { display: block !important; padding: 0; }
    #cggcx_calculator_wrapper .cggcx_result-card { border: 1px solid #ccc; border-left: 6px solid #000; box-shadow: none; break-inside: avoid; margin-bottom: 20px;}
    
    /* Disclaimer for Print */
    #cggcx_calculator_wrapper .cggcx_print-only-disclaimer {
        display: block;
        margin-top: 20px;
        padding: 10px;
        border-top: 1px solid #ccc;
        font-size: 10pt;
        color: #555;
        text-align: center;
        font-style: italic;
    }
}
