/**
 * Health Metrics calculators
 *
 * Shared widget styles for every calculator post in the Health Metrics
 * category. Loaded only on those posts (see functions.php). Brand colors
 * live in the custom properties below so a future rebrand is a one-line
 * change.
 */

.bsw-calc {
    --bsw-calc-accent: #0d7377;
    --bsw-calc-accent-dark: #095357;
    --bsw-calc-header-from: #0d7377;
    --bsw-calc-header-to: #12294a;
    --bsw-calc-btn-from: #ef4444;
    --bsw-calc-btn-to: #dc2626;
    --bsw-calc-btn-edge: #991b1b;
    --bsw-calc-text: #1a1a1a;
    --bsw-calc-muted: #6b7280;
    --bsw-calc-border: #d1d5db;
    --bsw-calc-soft: #f9fafb;
    --bsw-calc-soft-border: #e5e7eb;

    border-radius: 16px;
    margin: 24px 0;
    background: #fff;
    color: var(--bsw-calc-text);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.bsw-calc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 20px 24px;
    background: linear-gradient(135deg, var(--bsw-calc-header-from), var(--bsw-calc-header-to));
}

.bsw-calc-header h3 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: #fff;
}

.bsw-calc-reset {
    background: transparent;
    border: 1.5px solid rgba(255, 255, 255, 0.6);
    color: #fff;
    padding: 6px 16px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.bsw-calc-reset:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: #fff;
}

.bsw-calc-body {
    padding: 24px;
}

.bsw-calc-pills {
    display: inline-flex;
    border: 1.5px solid var(--bsw-calc-accent);
    border-radius: 999px;
    overflow: hidden;
    margin: 0 12px 20px 0;
}

.bsw-calc-pills label {
    position: relative;
    margin: 0;
    padding: 10px 20px;
    font-weight: 600;
    cursor: pointer;
    color: var(--bsw-calc-accent);
    transition: background 0.15s ease, color 0.15s ease;
}

.bsw-calc-pills input[type="radio"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    margin: 0;
    cursor: pointer;
}

.bsw-calc-pills label:has(input:checked) {
    background: var(--bsw-calc-accent);
    color: #fff;
}

.bsw-calc-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0 16px;
}

.bsw-calc-field {
    margin-bottom: 14px;
}

.bsw-calc-field > label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 0.95rem;
    color: var(--bsw-calc-text);
}

.bsw-calc-hint {
    font-weight: 400;
    color: var(--bsw-calc-muted);
    font-size: 0.85rem;
}

.bsw-calc input[type="number"],
.bsw-calc input[type="time"],
.bsw-calc select {
    width: 100%;
    max-width: 220px;
    padding: 12px 14px;
    border: 1.5px solid var(--bsw-calc-border);
    border-radius: 10px;
    font-size: 1rem;
    background: #fff;
    color: var(--bsw-calc-text);
    box-sizing: border-box;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.bsw-calc select {
    max-width: 360px;
}

.bsw-calc .bsw-calc-short {
    max-width: 110px;
}

.bsw-calc input[type="number"]:focus,
.bsw-calc input[type="time"]:focus,
.bsw-calc select:focus {
    outline: none;
    border-color: var(--bsw-calc-accent);
    box-shadow: 0 0 0 3px rgba(13, 115, 119, 0.15);
}

.bsw-calc [hidden] {
    display: none !important;
}

.bsw-calc .bsw-calc-btn {
    background: linear-gradient(180deg, var(--bsw-calc-btn-from), var(--bsw-calc-btn-to));
    color: #fff;
    border: none;
    padding: 14px 32px;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    margin-top: 6px;
    box-shadow: 0 4px 0 var(--bsw-calc-btn-edge), 0 6px 12px rgba(220, 38, 38, 0.35);
    transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.bsw-calc .bsw-calc-btn:hover {
    background: linear-gradient(180deg, #f87171, var(--bsw-calc-btn-from));
    transform: translateY(-1px);
    box-shadow: 0 5px 0 var(--bsw-calc-btn-edge), 0 8px 14px rgba(220, 38, 38, 0.4);
}

.bsw-calc .bsw-calc-btn:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 var(--bsw-calc-btn-edge), 0 2px 4px rgba(220, 38, 38, 0.3);
}

.bsw-calc-result {
    display: none;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 2px dashed var(--bsw-calc-border);
}

.bsw-calc-result.is-visible {
    display: block;
}

.bsw-calc-value-row {
    display: flex;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.bsw-calc-value {
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1;
}

.bsw-calc-unit {
    font-size: 1rem;
    font-weight: 500;
    color: var(--bsw-calc-muted);
}

.bsw-calc-badge {
    display: inline-block;
    padding: 6px 16px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.95rem;
    color: #fff;
    background: var(--bsw-calc-accent);
}

.bsw-calc-box {
    background: var(--bsw-calc-soft);
    border: 1px solid var(--bsw-calc-soft-border);
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 10px;
}

.bsw-calc-box > strong {
    display: block;
    margin-bottom: 6px;
    font-size: 0.9rem;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.bsw-calc-box p {
    margin: 0 0 10px;
    line-height: 1.5;
}

.bsw-calc-box p:last-child {
    margin-bottom: 0;
}

.bsw-calc-box a {
    color: var(--bsw-calc-accent);
    font-weight: 600;
    text-decoration: underline;
}

.bsw-calc-box a:hover {
    color: var(--bsw-calc-accent-dark);
}

.bsw-calc-table-wrap {
    overflow-x: auto;
}

.bsw-calc-table {
    width: 100%;
    border-collapse: collapse;
    margin: 4px 0 0;
    font-size: 0.95rem;
}

.bsw-calc-table th {
    background: #111827;
    color: #fff;
    padding: 9px 12px;
    text-align: left;
}

.bsw-calc-table td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--bsw-calc-soft-border);
    background: #fff;
}

.bsw-calc-table tr:nth-child(even) td {
    background: var(--bsw-calc-soft);
}

.bsw-calc-table tr.is-highlight td {
    background: #e6f4f4;
    font-weight: 700;
}

@media (max-width: 600px) {
    .bsw-calc-header,
    .bsw-calc-body {
        padding: 18px 16px;
    }

    .bsw-calc-value {
        font-size: 2rem;
    }

    .bsw-calc .bsw-calc-btn {
        width: 100%;
    }
}
