/* --- Base Calculator Styles --- */
/* Applies to all calculators using this class */
.roi-calculator {
    background-color: var(--wp--preset--color--base-2, #f9f9f9);
    border: 1px solid var(--wp--preset--color--contrast-3, #ccc);
    padding: 20px;
    margin-bottom: 30px;
    border-radius: var(--wp--preset--border--radius, 8px);
    font-family: sans-serif;
    max-width: 90%; /* Adjust as needed */
    box-sizing: border-box;
    margin-left: auto;
    margin-right: auto;
}

.roi-calculator h3 {
    margin-top: 0;
    color: var(--wp--preset--color--contrast, #333);
    border-bottom: 1px solid var(--wp--preset--color--contrast-3, #eee);
    padding-bottom: 10px;
    margin-bottom: 15px;
    font-size: 1.3em;
}

/* --- Input Field Styles --- */
div.roi-calculator > label {
    display: block !important;
    margin-bottom: 5px;
    font-weight: bold;
    color: var(--wp--preset--color--contrast-2, #555);
    font-size: 0.95em;
}

.roi-calculator label + input[type="number"] {
    margin-top: 2px;
}

.roi-calculator input[type="number"] {
    width: 100%;
    padding: 8px;
    margin-bottom: 15px;
    border: 1px solid var(--wp--preset--color--contrast-3, #ccc);
    border-radius: var(--wp--preset--border--radius, 5px);
    box-sizing: border-box;
    background-color: var(--wp--preset--color--base, #fff);
    color: var(--wp--preset--color--contrast, #333);
}

.roi-calculator input[type="number"]:focus {
   border-color: var(--wp--preset--color--primary, #0073aa);
   outline: 2px solid transparent;
   box-shadow: 0 0 0 1px var(--wp--preset--color--primary, #0073aa);
}

/* Input helper text style */
.roi-calculator p[style*="font-size:0.8em"] {
     color: var(--wp--preset--color--contrast-2, #555);
     /* Specific margins are set inline in PHP */
}

/* --- Button Styles --- */
.roi-calculator button {
    background-color: var(--wp--preset--color--primary, #4CAF50);
    color: var(--wp--preset--color--base, #ffffff);
    padding: 10px 15px;
    border: none;
    border-radius: var(--wp--preset--border--radius, 4px);
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.2s ease, filter 0.2s ease;
    display: block;
    width: 100%;
    margin-top: 10px;
}

.roi-calculator button:hover {
    filter: brightness(90%);
}

/* --- Chart Toggle Styles --- */
.roi-calculator .chart-toggle {
    margin-top: -5px; /* Adjust spacing relative to inputs */
    margin-bottom: 15px;
    padding: 5px 0;
    display: flex;
    align-items: center;
    gap: 8px; /* Space between checkbox and label */
}

.roi-calculator .chart-toggle input[type="checkbox"] {
    width: auto; /* Override default 100% width for inputs */
    margin: 0; /* Reset margins */
    cursor: pointer;
    flex-shrink: 0; /* Prevent checkbox from shrinking */
}

.roi-calculator .chart-toggle label {
    margin: 0; /* Reset margins */
    font-weight: normal; /* Make label less prominent than field labels */
    font-size: 0.9em;
    color: var(--wp--preset--color--contrast-2, #555);
    cursor: pointer;
    line-height: 1.3; /* Adjust line height if needed */
}


/* --- Results Area Styles --- */
.roi-calculator .results {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--wp--preset--color--contrast-3, #eee);
}

.roi-calculator .results h4 {
    margin-bottom: 10px;
    color: var(--wp--preset--color--contrast, #333);
    font-size: 1.1em;
}

.roi-calculator .results p,
.roi-calculator .results ul,
.roi-calculator .results table {
    margin-bottom: 15px;
    color: var(--wp--preset--color--contrast-2, #444);
    font-size: 0.95em;
    line-height: 1.5;
}

.roi-calculator .results ul {
    padding-left: 20px;
    list-style: disc;
    margin-top: 5px;
}
.roi-calculator .results ul li {
    margin-bottom: 5px;
}

.roi-calculator .results strong {
    color: var(--wp--preset--color--primary, #0073aa);
}

/* --- Table Styles --- */
.roi-calculator table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
    word-wrap: break-word;
    table-layout: auto; /* Allow columns to size naturally */
}

.roi-calculator th,
.roi-calculator td {
    border: 1px solid var(--wp--preset--color--contrast-3, #ddd);
    padding: 8px 6px;
    text-align: right;
    font-size: 0.85em; /* Default font size */
    vertical-align: middle;
}

.roi-calculator th {
    background-color: var(--wp--preset--color--base-2, #f2f2f2);
    font-weight: bold;
    color: var(--wp--preset--color--contrast, #333);
    text-align: center;
}

/* Left-align first column */
.roi-calculator td:first-child,
.roi-calculator th:first-child {
    text-align: left;
    font-weight: bold;
}

/* Specific alignments for Comparison tables (Net Profit/ROI) */
#qroi-di-results table thead th,
#qroi-as-results table thead th,
#qroi-es-results table thead th {
    text-align: center;
}
#qroi-di-results table thead th:first-child,
#qroi-as-results table thead th:first-child,
#qroi-es-results table thead th:first-child {
    text-align: left;
}
#qroi-di-results table tbody td,
#qroi-as-results table tbody td,
#qroi-es-results table tbody td {
    text-align: right;
}
#qroi-di-results table tbody td:first-child,
#qroi-as-results table tbody td:first-child,
#qroi-es-results table tbody td:first-child {
    text-align: left;
}

/* --- Other Result Elements --- */
.roi-calculator #qroi-di-summary,
.roi-calculator #qroi-es-optimal-point {
    font-size: 0.9em;
    line-height: 1.6;
    color: var(--wp--preset--color--contrast-2, #444);
    border-top: 1px dashed var(--wp--preset--color--contrast-3, #ccc);
    padding-top: 15px;
    margin-top: 15px;
}
.roi-calculator #qroi-di-summary strong,
.roi-calculator #qroi-es-optimal-point strong {
    color: var(--wp--preset--color--contrast, #333);
}
.roi-calculator #qroi-es-optimal-point {
    text-align: center;
    color: var(--wp--preset--color--primary, #0073aa);
}

/* Style for the model description paragraph */
.roi-calculator .model-description {
    font-size: 0.85em;
    color: var(--wp--preset--color--contrast-2, #555);
    margin-top: -5px;
    margin-bottom: 15px;
    padding: 10px 12px;
    background-color: var(--wp--preset--color--base-2, #f9f9f9);
    border-left: 3px solid var(--wp--preset--color--secondary, #f0b849);
    border-radius: 3px;
    line-height: 1.6;
}
.roi-calculator .model-description code {
    font-family: monospace;
    background-color: rgba(0,0,0,0.05);
    padding: 0.1em 0.3em;
    border-radius: 3px;
    font-size: 0.95em;
}
.roi-calculator .model-description sup {
    font-size: 0.75em;
    vertical-align: super;
}


.roi-calculator .assumption {
    font-size: 0.9em;
    color: var(--wp--preset--color--contrast-2, #666);
    margin-top: 20px;
    border-top: 1px dashed var(--wp--preset--color--contrast-3, #ccc);
    padding-top: 15px;
}
.roi-calculator .assumption ul {
    padding-left: 20px;
    margin-top: 5px;
}

.roi-calculator .error {
    color: var(--wp--preset--color--vivid-red, red);
    font-weight: bold;
    margin-top: 15px;
    padding: 10px;
    border: 1px solid var(--wp--preset--color--vivid-red, red);
    background-color: #ffeeee;
    border-radius: var(--wp--preset--border--radius, 4px);
}

/* --- Chart Styles --- */
.roi-calculator canvas {
    max-width: 100%; /* Default responsive behavior */
    margin-top: 20px;
    display: block;
    box-sizing: border-box;
    height: auto; /* Let width/height attributes control aspect ratio by default */
    width: auto; /* Default width sizing */
}

/* --- Responsive Styles --- */
/* Make tables scrollable on smaller screens */
.roi-calculator .results div[style*="overflow-x:auto"] {
     margin-bottom: 15px;
}

/* Mobile Chart Overrides */
@media (max-width: 767px) {
    .roi-calculator canvas {
        /* Override dimensions for taller mobile view */
        height: 60vh !important; /* ADJUST vh FOR DESIRED TALLNESS */
        width: 100% !important; /* Force full width */
        max-width: 100% !important; /* Ensure it doesn't overflow */
        margin-left: 0 !important; /* Reset desktop centering */
        margin-right: 0 !important;
        /* aspect-ratio: auto !important; -- Use if maintainAspectRatio:false isn't enough */
    }
    .roi-calculator { margin-bottom: 20px; }
}

/* Desktop Chart Size Constraint */
@media (min-width: 993px) {
    .roi-calculator { max-width: 80%; }
    .roi-calculator canvas {
        max-width: 85%; /* Limit width on large screens */
        margin-left: auto;
        margin-right: auto;
        /* Ensure height/width are auto to respect canvas attributes & maintainAspectRatio */
         height: auto !important;
         width: auto !important;
    }
}