/* Base Container Style */
.calculator-container {
    max-width: 700px;
    margin: 20px auto;
    padding: 30px;
    background-color: #f8f5e6;
    border: 2px solid #00082d;
    border-radius: 10px;
    font-family: Arial, sans-serif;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    position: relative;
    z-index: 1;
}

.calculator-main-title {
    text-align: center;
    font-size: 28px;
    color: #00082d;
    margin-bottom: 20px;
}

/* New class for section titles, replacing h6 inline style */
.drec-section-title {
    color: #00082d;
    margin-bottom: 15px;
    margin-top: 25px;
    font-weight: bold;
    font-size: 1.1em; /* Example size, adjust as needed */
}


/* --- Tabs Styles --- */
.calculator-tabs {
    display: flex;
    margin-bottom: 20px;
    border-bottom: 2px solid #00082d;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.calculator-tab {
    flex-shrink: 0;
    flex-basis: 0;
    flex-grow: 1;
    text-align: center;
    padding: 10px;
    cursor: pointer;
    background-color: #f8f5e6;
    color: #00082d;
    border: 1px solid #00082d;
    border-bottom: none;
    transition: background-color 0.3s ease, font-weight 0.3s ease;
    white-space: nowrap;
    min-width: fit-content;
}
.calculator-tab:first-child { border-top-left-radius: 8px; }
.calculator-tab:last-child { border-top-right-radius: 8px; border-right: 1px solid #00082d; }
.calculator-tabs .calculator-tab + .calculator-tab { border-left: none; }

.calculator-tab.active {
    background-color: #e1c474;
    font-weight: bold;
    border-color: #00082d;
    border-bottom-color: #e1c474; /* Or transparent to merge with panel */
}

.calculator-tabs::-webkit-scrollbar { height: 5px; }
.calculator-tabs::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 10px; }
.calculator-tabs::-webkit-scrollbar-thumb { background: #e1c474; border-radius: 10px; }
.calculator-tabs::-webkit-scrollbar-thumb:hover { background: #00082d; }

/* --- Panel Styles --- */
.calculator-panel { display: none; }
.calculator-panel.active { display: block; }

/* --- Field Styles --- */
.calculator-field {
    margin-bottom: 15px;
    position: relative;
    z-index: 2;
}
.calculator-field label {
    display: block;
    margin-bottom: 5px;
    color: #00082d;
    font-weight: bold;
}
.calculator-field .label-container {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
}
.calculator-field .label-container label {
     margin-bottom: 0;
     margin-right: 8px;
     flex-shrink: 0;
}
.calculator-field input,
.calculator-field select,
.calculator-field textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #e1c474;
    border-radius: 4px;
    box-sizing: border-box;
}
.calculator-field input:focus,
.calculator-field select:focus,
.calculator-field textarea:focus {
    outline: none;
    border-color: #00082d;
    box-shadow: 0 0 5px rgba(0, 8, 45, 0.2);
}

/* New class for the grid of percentage fields, replacing inline styles */
.drec-fields-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 20px; /* space between items */
    margin-bottom: 20px;
}
.drec-fields-grid .calculator-field {
    flex: 1 1 calc(50% - 10px); /* Two columns, accounting for gap. (gap/2) */
    min-width: calc(50% - 10px); /* Ensure it tries to be 2 columns */
}
@media (max-width: 500px) { /* On smaller screens, stack them */
    .drec-fields-grid .calculator-field {
        flex-basis: 100%;
        min-width: 100%;
    }
}


/* --- Button Style --- */
.calculator-button {
    width: 100%;
    background-color: #00082d;
    color: #f8f5e6;
    padding: 12px;
    border: none;
    border-radius: 5px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s ease, color 0.3s ease;
    margin-top: 10px;
}
.calculator-button:hover {
    background-color: #e1c474;
    color: #00082d;
}
.calculator-button.secondary {
     background-color: #e1c474;
     color: #00082d;
     margin-top: 15px;
}
.calculator-button.secondary:hover {
     background-color: #00082d;
     color: #f8f5e6;
}

/* --- Result Box Style --- */
.result-box {
    margin-top: 20px;
    background-color: #fff3cd;
    border-left: 5px solid #e1c474;
    padding: 15px;
    border-radius: 5px;
    color: #00082d;
    min-height: 50px;
    box-sizing: border-box;
}
.result-box p { margin: 8px 0; line-height: 1.5; }
.result-box p:first-child { margin-top: 0; }
.result-box p:last-child { margin-bottom: 0; }
.result-box strong { color: #00082d; }
.result-box small {
    display: block;
    margin-top: -2px; /* Adjust for closer spacing under main p */
    margin-bottom: 8px;
    color: #495057;
    font-size: 0.9em;
}
.result-box hr {
    margin: 10px 0;
    border-top: 1px solid rgba(0, 8, 45, 0.2);
}

/* --- Error Message Style --- */
.error-message { /* This is inside a p tag, so these styles are for the p itself */
    color: #721c24 !important; /* Override .result-box color */
    font-weight: bold;
    padding: 0; margin: 0; /* Reset padding/margin if result-box applies them */
}
/* The .result-box itself will have its border/background changed by JS for errors */


/* --- Info Text Style --- */
.info-text {
    font-size: 0.95em;
    color: #495057;
    margin-bottom: 15px;
}

/* --- Horizontal Rule Style --- */
hr {
    margin: 20px 0;
    border: 0;
    border-top: 1px solid #e1c474;
}

/* --- Tooltip Icon and Box Styles --- */
.tooltip-icon {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #00082d;
    color: #f8f5e6;
    font-size: 0.8em;
    font-style: normal;
    cursor: help;
    position: relative;
    z-index: 10;
    flex-shrink: 0;
    user-select: none;
}
.tooltip-icon:hover {
    background-color: #e1c474;
    color: #00082d;
}

#drec-help-tooltip {
    position: absolute;
    background-color: #fffbf0;
    border: 1px solid #e1c474;
    padding: 10px;
    border-radius: 5px;
    box-shadow: 2px 2px 7px rgba(0,0,0,0.3);
    z-index: 1000;
    display: none;
    max-width: 280px;
    font-size: 0.9em;
    color: #00082d;
    text-align: left;
    line-height: 1.4;
}

/* Tooltip triangle arrow - CORRECTED TO USE CSS VARIABLE */
#drec-help-tooltip::before,
#drec-help-tooltip::after {
    content: '';
    position: absolute;
    bottom: 100%; /* Points upwards from the tooltip box */
    left: var(--drec-arrow-left, 50%); /* JS sets this. Fallback to 50% */
    border-style: solid;
}
#drec-help-tooltip::before { /* Outer border */
    border-width: 8px;
    margin-left: -8px; /* Half of border-width to center the arrow base */
    border-color: transparent transparent #e1c474 transparent;
    z-index: 1001;
}
#drec-help-tooltip::after { /* Inner fill */
    border-width: 7px;
    margin-left: -7px; /* Half of its border-width */
    border-color: transparent transparent #fffbf0 transparent;
    z-index: 1002;
    /* Adjust if direct overlap is not perfect, e.g., margin-bottom: 1px or top: 1px relative to before */
    /* This should be bottom: 100% still, but adjust its margin-bottom if needed or top property of ::after */
    /* For precise alignment, often the inner arrow is shifted by 1px.
       If ::before is at bottom: 100%, ::after can be at bottom: calc(100% - 1px) if border is thick
       or more simply, just ensure the points align.
       Given border-width difference, they should align well.
    */
}


/* --- Mobile Responsiveness --- */
@media (max-width: 600px) {
    .calculator-container { padding: 20px; }
    .calculator-tab { padding: 8px 10px; font-size: 0.9em; }
    .calculator-field {
         /* flex-direction: column; */ /* Only if fields themselves are flex containers */
         /* align-items: flex-start; */
    }
    .calculator-field .label-container label {
        /* flex-basis: auto; */ /* If it was fixed before */
    }
}