/* ============================================
   GFR CALCULATOR - CSS
   Version 1.0
============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

.gfrcalc-wrap * { box-sizing: border-box; margin: 0; padding: 0; }

.gfrcalc-wrap {
    --blue:        #0D9488;
    --darkblue:    #0F2A3D;
    --cyan:        #14B8A6;
    --amber:       #E8A33D;
    --red:         #E0554F;
    --grad:        #0D9488;
    --grad-soft:   rgba(13,148,136,0.08);
    --white:       #FFFFFF;
    --bg:          #F2F7F6;
    --card-bg:     #FFFFFF;
    --border:      rgba(13,148,136,0.14);
    --text:        #0F2A3D;
    --text-muted:  #5C7A80;
    --shadow-card: 0 32px 80px rgba(15,42,61,0.16), 0 8px 24px rgba(13,148,136,0.10);
    --shadow-btn:  0 12px 32px rgba(13,148,136,0.40);
    --radius-xl:   24px;
    --radius-lg:   16px;
    --radius-md:   12px;
    --radius-sm:   8px;
    font-family: 'Inter', sans-serif;
    position: relative;
    padding: 32px 20px 60px;
    background: var(--bg);
    min-height: 100%;
    color: var(--text);
}

.gfrcalc-blob { position: absolute; border-radius: 50%; filter: blur(70px); pointer-events: none; z-index: 0; }
.gfrcalc-blob-1 { width: 380px; height: 380px; background: rgba(13,148,136,0.13); top: -100px; left: -100px; }
.gfrcalc-blob-2 { width: 320px; height: 320px; background: rgba(15,42,61,0.08); bottom: 0; right: -100px; }

.gfrcalc-card { position: relative; z-index: 1; max-width: 860px; margin: 0 auto; }

/* ---- Safety banner (always visible) ---- */
.gfrcalc-safety-banner { background: #FEF3E8; border: 1.5px solid var(--amber); border-radius: var(--radius-md); padding: 12px 16px; font-size: 12px; color: #7A4A0F; line-height: 1.55; margin-bottom: 16px; }
.gfrcalc-safety-banner strong { color: #5C3709; }

/* ---- Header ---- */
.gfrcalc-header { background: var(--grad); border-radius: var(--radius-xl); padding: 26px 32px; display: flex; align-items: center; justify-content: space-between; gap: 16px; position: relative; overflow: hidden; box-shadow: var(--shadow-card); margin-bottom: 20px; }
.gfrcalc-header::after { content: ''; position: absolute; width: 260px; height: 260px; background: rgba(255,255,255,0.06); border-radius: 50%; top: -100px; right: -60px; }
.gfrcalc-header-left { display: flex; align-items: center; gap: 16px; position: relative; z-index: 1; }
.gfrcalc-header-icon { width: 50px; height: 50px; background: rgba(255,255,255,0.18); border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; flex-shrink: 0; backdrop-filter: blur(10px); border: 1px solid rgba(255,255,255,0.25); }
.gfrcalc-header-text h1 { color: #fff; font-size: 19px; font-weight: 800; letter-spacing: -0.4px; }
.gfrcalc-header-text p { color: rgba(255,255,255,0.78); font-size: 12px; margin-top: 4px; }
.gfrcalc-icon-btn { width: 40px; height: 40px; background: rgba(255,255,255,0.16); border: 1px solid rgba(255,255,255,0.28); border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; position: relative; z-index: 1; transition: background 0.2s; }
.gfrcalc-icon-btn:hover { background: rgba(255,255,255,0.26); }

/* ---- History panel ---- */
.gfrcalc-history-panel { max-height: 0; overflow: hidden; transition: max-height 0.35s ease; background: var(--card-bg); border-radius: var(--radius-xl); box-shadow: var(--shadow-card); }
.gfrcalc-history-panel.gfrcalc-history-open { max-height: 420px; overflow-y: auto; margin-bottom: 20px; }
.gfrcalc-history-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 24px; font-size: 13px; font-weight: 800; color: var(--text); border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--card-bg); }
.gfrcalc-history-close { background: none; border: none; font-size: 20px; color: var(--text-muted); cursor: pointer; line-height: 1; }
.gfrcalc-history-list { padding: 14px 24px 20px; display: flex; flex-direction: column; gap: 10px; }
.gfrcalc-history-empty { font-size: 13px; color: var(--text-muted); padding: 20px 0; text-align: center; }
.gfrcalc-history-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--bg); border: 1.5px solid var(--border); border-radius: var(--radius-md); padding: 12px 16px; cursor: pointer; }
.gfrcalc-history-item:hover { border-color: var(--blue); }
.gfrcalc-history-item-name { font-size: 13.5px; font-weight: 700; color: var(--text); }
.gfrcalc-history-item-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 3px; }
.gfrcalc-history-item-btn { border: 1.5px solid var(--border); background: var(--white); color: var(--red); font-family: 'Inter', sans-serif; font-size: 11.5px; font-weight: 700; border-radius: 7px; padding: 6px 11px; cursor: pointer; flex-shrink: 0; }

/* ---- Explainer ---- */
.gfrcalc-explainer { background: var(--card-bg); border-radius: var(--radius-xl); box-shadow: var(--shadow-card); border: 1px solid var(--border); margin-bottom: 20px; overflow: hidden; }
.gfrcalc-explainer-toggle { width: 100%; display: flex; align-items: center; justify-content: space-between; padding: 16px 24px; background: var(--grad-soft); border: none; cursor: pointer; font-size: 13.5px; font-weight: 700; color: var(--text); font-family: 'Inter', sans-serif; }
.gfrcalc-explainer-toggle svg { color: var(--blue); transition: transform 0.25s ease; flex-shrink: 0; }
#gfrcalc_explainer_arrow.gfrcalc-explainer-arrow-open { transform: rotate(180deg); }
.gfrcalc-explainer-body { max-height: 0; overflow: hidden; transition: max-height 0.4s ease; padding: 0 24px; }
.gfrcalc-explainer-body.gfrcalc-explainer-open { max-height: 420px; padding: 16px 24px; }
.gfrcalc-explainer-body p { font-size: 12.5px; color: var(--text-muted); line-height: 1.65; margin-bottom: 10px; }
.gfrcalc-explainer-body p:last-child { margin-bottom: 0; }
.gfrcalc-explainer-body strong { color: var(--text); }

/* ---- Mode tabs ---- */
.gfrcalc-mode-tabs { display: flex; gap: 8px; margin-bottom: 20px; background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 6px; box-shadow: var(--shadow-card); }
.gfrcalc-mode-tab { flex: 1; background: none; border: none; color: var(--text-muted); font-family: 'Inter', sans-serif; font-size: 12.5px; font-weight: 700; border-radius: var(--radius-md); padding: 12px 6px; cursor: pointer; transition: all 0.15s; }
.gfrcalc-mode-tab:hover { color: var(--blue); }
.gfrcalc-mode-tab.gfrcalc-mode-active { background: var(--grad); color: #fff; }

/* ---- Fields ---- */
.gfrcalc-mode-panel { background: var(--card-bg); border-radius: var(--radius-xl); box-shadow: var(--shadow-card); border: 1px solid var(--border); padding: 24px 28px; margin-bottom: 20px; }
.gfrcalc-field-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.gfrcalc-field { margin-bottom: 16px; }
.gfrcalc-field:last-child { margin-bottom: 0; }
.gfrcalc-field label { display: block; font-size: 12px; font-weight: 700; color: var(--text-muted); margin-bottom: 7px; text-transform: uppercase; letter-spacing: 0.4px; }
.gfrcalc-hint-inline { text-transform: none; font-weight: 500; opacity: 0.75; font-size: 11px; }
.gfrcalc-input, .gfrcalc-plain-input {
    width: 100%; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    padding: 11px 12px; font-family: 'Inter', sans-serif; font-size: 13.5px; font-weight: 600; color: var(--text);
    background: var(--white); outline: none; transition: border-color 0.2s;
}
.gfrcalc-input:focus, .gfrcalc-plain-input:focus { border-color: var(--blue); }

.gfrcalc-unit-input-wrap { display: flex; gap: 6px; }
.gfrcalc-unit-input-wrap .gfrcalc-plain-input { flex: 1; min-width: 0; }
.gfrcalc-unit-static { display: flex; align-items: center; padding: 0 12px; font-size: 12.5px; font-weight: 700; color: var(--text-muted); background: var(--bg); border-radius: var(--radius-sm); border: 1.5px solid var(--border); flex-shrink: 0; white-space: nowrap; }

.gfrcalc-bsa-inputs { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.gfrcalc-acr-row { display: flex; gap: 10px; align-items: center; margin-top: 10px; }
.gfrcalc-acr-row .gfrcalc-unit-input-wrap { flex: 1.4; }
.gfrcalc-acr-units { flex: 1; margin: 0; }

/* ---- ACR range radio picker ---- */
.gfrcalc-acr-radio-grid { display: flex; flex-direction: column; gap: 8px; }
.gfrcalc-ckd-card label.gfrcalc-acr-radio { display: flex; align-items: center; gap: 9px; font-size: 12.5px; font-weight: 600; color: var(--text); cursor: pointer; text-transform: none; background: var(--white); border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 0; }
.gfrcalc-ckd-card label.gfrcalc-acr-radio:has(input:checked) { border-color: var(--blue); border-width: 2px; background: var(--white); color: var(--text); }
.gfrcalc-ckd-card label.gfrcalc-acr-radio input { accent-color: var(--blue); width: 16px; height: 16px; cursor: pointer; flex-shrink: 0; }
.gfrcalc-ckd-card .gfrcalc-acr-radio .gfrcalc-hint-inline { color: var(--text-muted); opacity: 0.75; }
.gfrcalc-acr-exact-toggle { margin-top: 10px; }
.gfrcalc-acr-exact-link { background: none; border: none; color: var(--blue); font-family: 'Inter', sans-serif; font-size: 11.5px; font-weight: 700; cursor: pointer; text-decoration: underline; padding: 0; }

/* ---- Segmented toggle ---- */
.gfrcalc-toggle-row { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; cursor: default; margin-bottom: 0; }
.gfrcalc-toggle-row span:first-child { font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; }
.gfrcalc-seg-toggle { display: flex; gap: 6px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 5px; width: 100%; }
.gfrcalc-seg-btn { flex: 1; background: none; border: none; color: var(--text-muted); font-family: 'Inter', sans-serif; font-size: 12px; font-weight: 700; border-radius: var(--radius-sm); padding: 9px 6px; cursor: pointer; }
.gfrcalc-seg-btn:hover { color: var(--blue); }
.gfrcalc-seg-btn.gfrcalc-seg-active { background: var(--grad); color: #fff; }

/* ---- Field label with help button ---- */
.gfrcalc-label-help { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.gfrcalc-label-help span:first-child { flex: 1; }
.gfrcalc-help-btn {
    width: 20px; height: 20px; border-radius: 50%;
    background: var(--grad-soft); border: 1px solid var(--border); color: var(--blue);
    font-size: 11px; font-weight: 800; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
    font-family: 'Inter', sans-serif; transition: all 0.2s;
}
.gfrcalc-help-btn:hover { background: var(--grad); color: white; border-color: transparent; }

/* ---- Help popover modal ---- */
.gfrcalc-help-overlay { display: none; position: fixed; inset: 0; background: rgba(15,42,61,0.55); z-index: 9999; align-items: center; justify-content: center; padding: 20px; }
.gfrcalc-help-overlay.gfrcalc-help-open { display: flex; }
.gfrcalc-help-popover { background: white; border-radius: var(--radius-lg); padding: 24px; max-width: 380px; width: 100%; box-shadow: 0 24px 60px rgba(0,0,0,0.3); }
.gfrcalc-help-popover-title { font-size: 16px; font-weight: 800; color: var(--blue); margin-bottom: 10px; }
.gfrcalc-help-popover-text { font-size: 13.5px; color: var(--text); line-height: 1.65; margin-bottom: 18px; }
.gfrcalc-help-close { width: 100%; padding: 10px; background: var(--grad); color: white; border: none; border-radius: var(--radius-sm); font-size: 13px; font-weight: 700; font-family: 'Inter', sans-serif; cursor: pointer; }

/* ---- Result ---- */
.gfrcalc-result { background: var(--card-bg); border-radius: var(--radius-xl); box-shadow: var(--shadow-card); border: 1px solid var(--border); padding: 24px 28px; }
.gfrcalc-result-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.gfrcalc-result-badge { font-size: 13px; font-weight: 800; color: var(--text); }
.gfrcalc-input-recap { font-size: 12px; color: var(--text-muted); margin-bottom: 14px; line-height: 1.5; }
.gfrcalc-input-recap:empty { display: none; margin: 0; }

.gfrcalc-due-card { background: var(--grad); border-radius: var(--radius-lg); padding: 22px; text-align: center; margin-bottom: 16px; position: relative; overflow: hidden; }
.gfrcalc-due-card::after { content: ''; position: absolute; width: 160px; height: 160px; background: rgba(255,255,255,0.06); border-radius: 50%; top: -70px; right: -50px; }
.gfrcalc-due-label { color: rgba(255,255,255,0.8); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; position: relative; }
.gfrcalc-due-value { color: #fff; font-size: 36px; font-weight: 900; letter-spacing: -0.5px; margin: 6px 0; position: relative; word-break: break-word; }
.gfrcalc-due-sub { color: rgba(255,255,255,0.85); font-size: 12px; font-weight: 500; position: relative; }

/* ---- All-equations comparison ---- */
.gfrcalc-equations-card { background: var(--bg); border-radius: var(--radius-md); border: 1px solid var(--border); padding: 16px; margin-bottom: 16px; }
.gfrcalc-equations-title { font-size: 12.5px; font-weight: 800; color: var(--text); margin-bottom: 12px; }
.gfrcalc-equations-list { display: flex; flex-direction: column; gap: 8px; }
.gfrcalc-equation-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--white); border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px; }
.gfrcalc-equation-row.gfrcalc-equation-active { border-color: var(--blue); background: var(--grad-soft); }
.gfrcalc-equation-name { font-size: 12.5px; font-weight: 700; color: var(--text); }
.gfrcalc-equation-value { font-size: 14px; font-weight: 800; color: var(--blue); white-space: nowrap; }
.gfrcalc-equation-unavailable { font-size: 11.5px; font-weight: 600; color: var(--text-muted); font-style: italic; }

/* ---- Is it CKD? ---- */
.gfrcalc-ckd-card { background: var(--darkblue); border-radius: var(--radius-md); padding: 18px 20px; margin-bottom: 16px; color: white; }
.gfrcalc-ckd-title { font-size: 13px; font-weight: 800; background: rgba(255,255,255,0.14); display: inline-block; padding: 5px 12px; border-radius: 6px; margin-bottom: 12px; }
.gfrcalc-ckd-note { font-size: 12.5px; color: rgba(255,255,255,0.85); margin-bottom: 8px; }
.gfrcalc-ckd-list { padding-left: 20px; margin-bottom: 16px; }
.gfrcalc-ckd-list li { font-size: 12.5px; color: rgba(255,255,255,0.92); line-height: 1.6; }
.gfrcalc-acr-field { padding-top: 14px; border-top: 1px solid rgba(255,255,255,0.2); }
.gfrcalc-acr-field label { color: rgba(255,255,255,0.85); }
.gfrcalc-acr-field .gfrcalc-hint-inline { color: rgba(255,255,255,0.6); }
.gfrcalc-acr-field .gfrcalc-help-btn { background: rgba(255,255,255,0.16); border-color: rgba(255,255,255,0.3); color: white; }

/* ---- Clinical summary ---- */
.gfrcalc-clinical-card { background: var(--bg); border-radius: var(--radius-md); border: 1px solid var(--border); padding: 16px; margin-bottom: 14px; }
.gfrcalc-clinical-title { font-size: 12.5px; font-weight: 800; color: var(--text); margin-bottom: 12px; }
.gfrcalc-clinical-rows { display: flex; flex-direction: column; }
.gfrcalc-clinical-row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--border); font-size: 12.5px; }
.gfrcalc-clinical-row:first-child { border-top: none; }
.gfrcalc-clinical-key { color: var(--text-muted); font-weight: 600; }
.gfrcalc-clinical-val { color: var(--text); font-weight: 800; text-align: right; }
.gfrcalc-clinical-footnote { font-size: 10.5px; color: var(--text-muted); margin-top: 10px; line-height: 1.5; }

.gfrcalc-stage-result { border-radius: var(--radius-md); padding: 14px 16px; font-size: 13px; font-weight: 700; line-height: 1.55; margin-bottom: 16px; text-align: center; }
.gfrcalc-stage-result.gfrcalc-stage-normal { background: rgba(45,106,79,0.10); border: 1.5px solid #2D6A4F; color: #2D6A4F; }
.gfrcalc-stage-result.gfrcalc-stage-mild { background: rgba(232,163,61,0.12); border: 1.5px solid var(--amber); color: #8A5A17; }
.gfrcalc-stage-result.gfrcalc-stage-severe { background: rgba(224,85,79,0.10); border: 1.5px solid var(--red); color: var(--red); }

.gfrcalc-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.gfrcalc-stats:empty { display: none; margin-bottom: 0; }
.gfrcalc-stat-card { background: var(--bg); border-radius: var(--radius-md); padding: 14px; text-align: center; border: 1px solid var(--border); }
.gfrcalc-stat-icon { font-size: 16px; margin-bottom: 4px; }
.gfrcalc-stat-value { font-size: 15.5px; font-weight: 800; color: var(--text); word-break: break-word; }
.gfrcalc-stat-label { font-size: 10.5px; font-weight: 600; color: var(--text-muted); margin-top: 2px; }

/* ---- KDIGO risk grid ---- */
.gfrcalc-grid-card { background: var(--bg); border-radius: var(--radius-md); border: 1px solid var(--border); padding: 16px; margin-bottom: 14px; }
.gfrcalc-grid-title { font-size: 12.5px; font-weight: 800; color: var(--text); margin-bottom: 12px; }
.gfrcalc-grid-wrap { overflow-x: auto; }
.gfrcalc-grid-table { border-collapse: collapse; font-size: 11px; margin: 0 auto; }
.gfrcalc-grid-table th, .gfrcalc-grid-table td { border: 1px solid rgba(255,255,255,0.6); padding: 8px 10px; text-align: center; white-space: nowrap; }
.gfrcalc-grid-table th { background: var(--darkblue); color: white; font-weight: 700; font-size: 10px; text-transform: uppercase; letter-spacing: 0.3px; }
.gfrcalc-grid-table td.gfrcalc-grid-corner { background: var(--darkblue); }
.gfrcalc-grid-table td.gfrcalc-grid-rowhead { background: var(--darkblue); color: white; font-weight: 700; text-align: left; }
.gfrcalc-grid-table td.gfrcalc-risk-low { background: #52B788; color: #fff; font-weight: 800; }
.gfrcalc-grid-table td.gfrcalc-risk-moderate { background: #E8C63D; color: #5C3709; font-weight: 800; }
.gfrcalc-grid-table td.gfrcalc-risk-high { background: #E8A33D; color: #fff; font-weight: 800; }
.gfrcalc-grid-table td.gfrcalc-risk-veryhigh { background: #E0554F; color: #fff; font-weight: 800; }
.gfrcalc-grid-table td.gfrcalc-grid-current { outline: 3px solid var(--darkblue); outline-offset: -3px; }
.gfrcalc-grid-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 12px; }
.gfrcalc-legend-item { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; color: var(--text); }
.gfrcalc-legend-swatch { width: 13px; height: 13px; border-radius: 3px; display: inline-block; }
.gfrcalc-legend-swatch.gfrcalc-risk-low { background: #52B788; }
.gfrcalc-legend-swatch.gfrcalc-risk-moderate { background: #E8C63D; }
.gfrcalc-legend-swatch.gfrcalc-risk-high { background: #E8A33D; }
.gfrcalc-legend-swatch.gfrcalc-risk-veryhigh { background: #E0554F; }

.gfrcalc-breakdown-card { background: var(--bg); border-radius: var(--radius-md); border: 1px solid var(--border); padding: 16px; margin-bottom: 14px; }
.gfrcalc-breakdown-title { font-size: 12.5px; font-weight: 800; color: var(--text); margin-bottom: 10px; }
.gfrcalc-table-wrap { overflow-x: auto; }
.gfrcalc-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.gfrcalc-table th { text-align: left; font-weight: 700; color: var(--text-muted); padding: 6px 8px; border-bottom: 1.5px solid var(--border); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.3px; white-space: nowrap; }
.gfrcalc-table td { padding: 8px; border-bottom: 1px solid var(--border); color: var(--text); font-weight: 600; }
.gfrcalc-table tr:last-child td { border-bottom: none; }
.gfrcalc-table tr.gfrcalc-table-current td { background: var(--grad-soft); font-weight: 800; color: var(--blue); }

.gfrcalc-actions-row { margin-bottom: 10px; }
.gfrcalc-save-btn { width: 100%; background: var(--grad); color: #fff; border: none; font-family: 'Inter', sans-serif; font-size: 14px; font-weight: 800; border-radius: var(--radius-md); padding: 14px; cursor: pointer; box-shadow: var(--shadow-btn); }
.gfrcalc-export-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.gfrcalc-export-btn { background: var(--white); border: 1.5px solid var(--border); color: var(--text); font-family: 'Inter', sans-serif; font-size: 12px; font-weight: 700; border-radius: var(--radius-sm); padding: 11px 6px; cursor: pointer; }
.gfrcalc-export-btn:hover { border-color: var(--blue); color: var(--blue); }

.gfrcalc-footer-note { font-size: 10.5px; color: var(--text-muted); text-align: center; line-height: 1.5; }

/* ---- Responsive ---- */
@media (max-width: 780px) {
    .gfrcalc-field-grid { grid-template-columns: 1fr; }
    .gfrcalc-stats { grid-template-columns: 1fr 1fr; }
    .gfrcalc-seg-toggle { flex-direction: column; }
    .gfrcalc-acr-row { flex-direction: column; align-items: stretch; }
}
