/* ==========================================
   CALCULATORS (shared by every calculator page)
========================================== */

.calc-page .tool-page-title {
    font-size: 2.25rem;
    font-weight: 700;
}

.calc-page .tool-page-description {
    font-size: 1.075rem;
    max-width: 780px;
}

/* ---------- Input card ---------- */
.calc-card {
    border: 0;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(15, 23, 42, 0.07);
}

.calc-card .card-header {
    background: #fff;
    border-bottom: 1px solid #eef2f7;
    border-radius: 16px 16px 0 0;
    padding: 1rem 1.25rem;
}

.calc-card .form-label {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.35rem;
}

.calc-card .form-text {
    font-size: 0.8rem;
}

/* Segmented toggle (units, sex, modes) built from Bootstrap btn-check */
.calc-toggle {
    display: flex;
    width: 100%;
}

.calc-toggle .btn {
    flex: 1 1 0;
    font-weight: 600;
    font-size: 0.875rem;
}

/* ---------- Results ---------- */
.calc-result-hero {
    background: linear-gradient(135deg, var(--primary-color, #2563eb) 0%, var(--primary-dark, #1e40af) 100%);
    color: #fff;
    border-radius: 16px;
    padding: 1.75rem 1.5rem;
    text-align: center;
}

.calc-result-hero .calc-result-label {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    opacity: 0.85;
}

.calc-result-hero .calc-result-value {
    font-size: 2.75rem;
    font-weight: 800;
    line-height: 1.15;
    word-break: break-word;
}

.calc-result-hero .calc-result-sub {
    font-size: 0.95rem;
    opacity: 0.9;
}

.calc-result-hero.is-success {
    background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
}

.calc-result-hero.is-danger {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
}

.calc-stat {
    background: #f8fafc;
    border: 1px solid #eef2f7;
    border-radius: 12px;
    padding: 0.9rem 1rem;
    height: 100%;
}

.calc-stat-label {
    font-size: 0.78rem;
    color: var(--gray-color, #6b7280);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.calc-stat-value {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--dark-color, #1f2937);
    word-break: break-word;
}

.calc-error {
    display: none;
}

.calc-error.show {
    display: block;
}

/* Tables (activity levels, schedules) */
.calc-table {
    font-size: 0.9rem;
    margin-bottom: 0;
}

.calc-table th {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gray-color, #6b7280);
    font-weight: 600;
    white-space: nowrap;
}

.calc-table td,
.calc-table th {
    padding: 0.6rem 0.75rem;
}

.calc-table tr.is-active td {
    background: rgba(37, 99, 235, 0.08);
    font-weight: 600;
}

.calc-table-scroll {
    max-height: 420px;
    overflow: auto;
}

.calc-table-scroll thead th {
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 1;
}

/* Formula / worked steps */
.calc-steps {
    background: #f8fafc;
    border-left: 4px solid var(--primary-color, #2563eb);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.9rem;
    line-height: 1.8;
    overflow-x: auto;
}

/* Stacked bar for breakdowns (payment split, macros) */
.calc-bar {
    display: flex;
    height: 14px;
    border-radius: 999px;
    overflow: hidden;
    background: #e9ecef;
}

.calc-bar span {
    display: block;
    height: 100%;
    transition: width 0.3s ease;
}

.calc-legend {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
}

.calc-legend i {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    display: inline-block;
}

/* Range gauge (BMI etc.): coloured track with a marker */
.calc-gauge {
    position: relative;
    padding-top: 18px;
}

.calc-gauge-track {
    display: flex;
    height: 16px;
    border-radius: 999px;
    overflow: hidden;
}

.calc-gauge-track span {
    display: block;
    height: 100%;
}

.calc-gauge-marker {
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    border-left: 9px solid transparent;
    border-right: 9px solid transparent;
    border-top: 14px solid var(--dark-color, #1f2937);
    transform: translateX(-9px);
    transition: left 0.3s ease;
}

/* Tick labels placed at their real position on the gauge (left: x%) */
.calc-gauge-ticks {
    position: relative;
    height: 1.4em;
}

.calc-gauge-ticks span {
    position: absolute;
    transform: translateX(-50%);
    white-space: nowrap;
}

.calc-gauge-ticks span:first-child {
    transform: none;
}

.calc-gauge-ticks span:last-child {
    transform: translateX(-100%);
}

/* Long division written layout */
.ld-layout {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 1.15rem;
    line-height: 1.45;
    background: #f8fafc;
    border-radius: 10px;
    padding: 1rem 1.25rem;
    overflow-x: auto;
    color: var(--dark-color, #1f2937);
}

.ld-layout .ld-q {
    color: var(--primary-color, #2563eb);
    font-weight: 700;
}

.ld-layout .ld-sub {
    color: #b91c1c;
}

.ld-layout .ld-rem {
    color: #15803d;
    font-weight: 700;
}

.ld-steps li {
    margin-bottom: 0.4rem;
}

.ld-repeat {
    text-decoration: overline;
}

/* System of equations: coefficient grid and graph */
.soe-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
}

.soe-row input {
    width: 64px;
    min-width: 0;
    flex: 1 1 64px;
    text-align: center;
    padding-left: 4px;
    padding-right: 4px;
}

.soe-row .soe-var {
    font-family: "SFMono-Regular", Consolas, monospace;
    font-weight: 700;
    color: var(--gray-color, #6b7280);
    white-space: nowrap;
}

.soe-graph svg {
    width: 100%;
    height: auto;
    display: block;
    background: #fff;
    border: 1px solid #eef2f7;
    border-radius: 10px;
}

/* ---------- Content below the tool ---------- */
.calc-content h2 {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.calc-content h3 {
    font-size: 1.15rem;
    font-weight: 700;
}

.calc-content p,
.calc-content li {
    color: #374151;
    line-height: 1.75;
}

.calc-faq .accordion-button {
    font-weight: 600;
}

.calc-faq .accordion-button:not(.collapsed) {
    background: rgba(37, 99, 235, 0.06);
    color: var(--primary-dark, #1e40af);
}

/* Keep the inputs beside long result columns on desktop */
@media (min-width: 992px) {
    .calc-sticky {
        position: sticky;
        top: 100px;
        /* Tall forms scroll inside the card instead of running off screen */
        max-height: calc(100vh - 120px);
        overflow-y: auto;
    }
}

/* ---------- Responsive ---------- */
@media (max-width: 991px) {
    .calc-page .tool-page-title {
        font-size: 1.75rem;
    }
}

@media (max-width: 575px) {
    .calc-result-hero .calc-result-value {
        font-size: 2.1rem;
    }

    .calc-stat-value {
        font-size: 1.15rem;
    }
}
