
/* ========== BMI Calculator Page ========== */
.tool-container { max-width: 1100px; margin: 0 auto; padding: 24px; }
.tool-header { text-align: center; margin-bottom: 24px; }
.tool-header h1 { font-size: 32px; font-weight: 800; color: var(--color-heading); margin-bottom: 8px; }
.tool-header .tool-desc { font-size: 16px; color: var(--color-muted); max-width: 700px; margin: 0 auto; line-height: 1.6; }

/* Unit toggle */
.unit-toggle { display: flex; justify-content: center; gap: 8px; margin-bottom: 20px; }
.unit-toggle button { padding: 8px 24px; border: 2px solid var(--color-border); border-radius: 8px; background: #fff; color: var(--color-text); font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.2s; }
.unit-toggle button.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.unit-toggle button:hover:not(.active) { border-color: var(--color-primary); }

/* ===== BMI Calculator 2-Column Grid ===== */
.bmi-calc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 20px; align-items: start; }

/* Left column: inputs */
.bmi-inputs-col { display: flex; flex-direction: column; gap: 16px; flex: 1; }
.bmi-input-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.bmi-input-item { padding: 12px 16px; background: #f0f9ff; border: 1px solid #bae6fd; border-radius: 10px; }
.bmi-input-item label { font-size: 13px; font-weight: 600; color: #0369a1; display: block; margin-bottom: 4px; }
.bmi-input-item select, .bmi-input-item input { width: 100%; padding: 8px 12px; border: 1px solid #bae6fd; border-radius: 6px; font-size: 14px; background: #fff; color: var(--color-text); outline: none; }
.bmi-input-item select:focus, .bmi-input-item input:focus { border-color: var(--color-primary); }
.bmi-input-block { padding: 16px 20px; background: var(--color-bg-card); border: 1px solid var(--color-border); border-radius: 12px; }
.bmi-input-block label { display: block; font-size: 14px; font-weight: 700; color: var(--color-text); margin-bottom: 8px; }
.bmi-input-block label .unit-label { font-weight: 400; color: var(--color-muted); font-size: 13px; }
.input-row { display: flex; gap: 10px; align-items: center; }
.input-row input[type="number"] { flex: none; width: 85px; padding: 10px 14px; border: 2px solid var(--color-border); border-radius: 8px; font-size: 18px; font-weight: 700; outline: none; transition: border-color 0.2s; background: #fff; color: var(--color-text); min-width: 0; }
.input-row input[type="number"]:focus { border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.input-row input[type="range"] { flex: 1; min-width: 0; height: 6px; -webkit-appearance: none; appearance: none; background: #e2e8f0; border-radius: 3px; outline: none; }
.input-row input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%; background: var(--color-primary); cursor: pointer; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.2); }
.input-row input[type="range"]::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: var(--color-primary); cursor: pointer; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.2); }
.input-val { display: flex; align-items: center; gap: 4px; min-width: 70px; justify-content: flex-end; flex-shrink: 0; }
.input-val .num { font-size: 22px; font-weight: 800; color: var(--color-primary); min-width: 50px; text-align: right; }
.input-val .unit { font-size: 14px; color: var(--color-muted); font-weight: 600; }
.imperial-row { display: none; gap: 10px; align-items: center; }
.imperial-row.show { display: flex; }
.imperial-row input { flex: 1; padding: 10px 14px; border: 2px solid var(--color-border); border-radius: 8px; font-size: 16px; font-weight: 600; outline: none; background: #fff; color: var(--color-text); }
.imperial-row input:focus { border-color: var(--color-primary); }

/* Right column: results */
.bmi-results-col { display: flex; flex-direction: column; gap: 16px; flex: 1; }
.result-main { text-align: center; padding: 20px; background: var(--color-bg-card); border: 2px solid var(--color-border); border-radius: 16px; }
.bmi-number { font-size: 56px; font-weight: 900; line-height: 1; margin-bottom: 4px; transition: color 0.3s; }
.bmi-classification { font-size: 22px; font-weight: 700; margin-bottom: 8px; transition: color 0.3s; }
.bmi-prime { font-size: 14px; color: var(--color-muted); margin-bottom: 4px; }
.bmi-prime span { font-weight: 700; color: var(--color-text); }
.healthy-range { font-size: 14px; color: var(--color-muted); margin-bottom: 8px; }
.healthy-range span { font-weight: 700; color: #059669; }
.result-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }

/* Dual standards (2 columns inside panel) */
.standards-panel { padding: 16px 20px; background: var(--color-bg-card); border: 1px solid var(--color-border); border-radius: 12px; }
.standards-panel h3 { font-size: 14px; font-weight: 700; margin-bottom: 12px; color: var(--color-text); }
.standards-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.standards-col-title { font-size: 12px; font-weight: 600; color: var(--color-muted); margin-bottom: 6px; }
.standard-row { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; border-bottom: 1px solid #f1f5f9; }
.standard-row:last-child { border-bottom: none; }
.standard-name { font-size: 13px; color: var(--color-text); }
.standard-range { color: var(--color-muted); font-weight: 400; font-size: 12px; }
.standard-badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 20px; }
.badge-under { background: #dbeafe; color: #1e40af; }
.badge-normal { background: #bbf7d0; color: #166534; }
.badge-over { background: #fef3c7; color: #92400e; }
.badge-obese { background: #fecaca; color: #991b1b; }

/* BMI Scale Bar */
.scale-bar-wrap { position: relative; height: 40px; margin: 8px 0 12px; }
.scale-bar { display: flex; height: 24px; border-radius: 12px; overflow: hidden; }
.scale-seg { display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: rgba(255,255,255,0.85); }
.scale-seg-under { background: #3b82f6; flex: 18.5; }
.scale-seg-normal { background: #10b981; flex: 6.4; }
.scale-seg-over { background: #f59e0b; flex: 5; }
.scale-seg-obese { background: #ef4444; flex: 20; }
.scale-pointer { position: absolute; top: -4px; width: 6px; height: 32px; background: #1e293b; border-radius: 3px; transition: left 0.5s ease; z-index: 2; }
.scale-pointer::after { content: ''; position: absolute; top: -6px; left: -4px; width: 14px; height: 14px; background: #1e293b; border-radius: 50%; }
.scale-labels { display: flex; justify-content: space-between; font-size: 11px; color: var(--color-muted); padding: 0 2px; }
.scale-labels span { white-space: nowrap; }

/* Body Silhouette (fills available space to balance columns) */
.result-silhouette { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px; background: var(--color-bg-card); border: 1px solid var(--color-border); border-radius: 12px; flex: 1; min-height: 200px; }
.result-silhouette svg { width: 80px; height: 180px; display: block; }
.result-silhouette .silhouette-label { margin-top: 8px; font-size: 14px; font-weight: 700; transition: color 0.3s; }

/* BMI Scale Bar (inner, in right column) */
.scale-section-inner { padding: 12px 16px; background: var(--color-bg-card); border: 1px solid var(--color-border); border-radius: 12px; }

/* Health advice */
.advice-section { margin-bottom: 20px; }
.advice-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.advice-card { padding: 16px; border-radius: 12px; border: 1px solid var(--color-border); background: var(--color-bg-card); }
.advice-card-icon { font-size: 28px; margin-bottom: 8px; }
.advice-card h4 { font-size: 14px; font-weight: 700; margin-bottom: 6px; color: var(--color-text); }
.advice-card ul { margin: 0; padding-left: 16px; }
.advice-card li { font-size: 13px; color: var(--color-muted); line-height: 1.6; margin-bottom: 4px; }

/* Advanced metrics */
.advanced-section { display: none; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.advanced-section.show { display: grid; }
.metric-card { padding: 14px 16px; background: var(--color-bg-card); border: 1px solid var(--color-border); border-radius: 10px; text-align: center; }
.metric-card .metric-label { font-size: 12px; color: var(--color-muted); font-weight: 600; margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.3px; }
.metric-card .metric-value { font-size: 20px; font-weight: 800; color: var(--color-heading); }
.metric-card .metric-sub { font-size: 11px; color: var(--color-muted); margin-top: 2px; }

/* Trend chart */
.trend-section { display: none; margin-bottom: 20px; padding: 16px 20px; background: var(--color-bg-card); border: 1px solid var(--color-border); border-radius: 12px; }
.trend-section.show { display: block; }
.trend-section h3 { font-size: 14px; font-weight: 700; margin-bottom: 8px; color: var(--color-text); }
.trend-section canvas { width: 100%; height: 200px; border-radius: 8px; background: #fafafa; }

/* History */
.history-section { display: none; margin-bottom: 20px; }
.history-section.show { display: block; }
.history-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.history-header h3 { font-size: 14px; font-weight: 700; color: var(--color-text); }
.history-table-wrap { max-height: 250px; overflow-y: auto; border: 1px solid var(--color-border); border-radius: 10px; }
.history-table { width: 100%; border-collapse: collapse; }
.history-table th { background: #f8fafc; font-size: 12px; font-weight: 700; color: var(--color-muted); padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--color-border); }
.history-table td { padding: 8px 12px; font-size: 13px; border-bottom: 1px solid #f1f5f9; }
.history-table tr:hover td { background: #f8fafc; }

/* Reverse BMI */
.reverse-section { margin-bottom: 20px; padding: 16px 20px; background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 12px; display: none; }
.reverse-section.show { display: block; }
.reverse-section h3 { font-size: 14px; font-weight: 700; margin-bottom: 8px; color: #166534; }
.reverse-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.reverse-row label { font-size: 13px; font-weight: 600; color: #166534; }
.reverse-row input { padding: 8px 14px; border: 2px solid #bbf7d0; border-radius: 8px; font-size: 16px; font-weight: 700; outline: none; width: 120px; background: #fff; }
.reverse-row input:focus { border-color: #10b981; }
.reverse-row .result-text { font-size: 16px; font-weight: 700; color: #059669; }

/* FAQ */
.faq-section { margin-bottom: 20px; padding: 16px 20px; background: var(--color-bg-card); border: 1px solid var(--color-border); border-radius: 12px; }
.faq-section h3 { font-size: 14px; font-weight: 700; margin-bottom: 12px; color: var(--color-text); }
.faq-item { border-bottom: 1px solid #f1f5f9; }
.faq-item:last-child { border-bottom: none; }
.faq-q { padding: 12px 0; cursor: pointer; display: flex; justify-content: space-between; align-items: center; font-size: 14px; font-weight: 600; color: var(--color-text); }
.faq-q:hover { color: var(--color-primary); }
.faq-q .arrow { font-size: 12px; transition: transform 0.2s; }
.faq-item.open .faq-q .arrow { transform: rotate(180deg); }
.faq-a { display: none; padding: 0 0 12px 0; font-size: 13px; color: var(--color-muted); line-height: 1.7; }
.faq-item.open .faq-a { display: block; }

/* Tool info */
.tool-info { margin-bottom: 20px; padding: 16px 20px; background: var(--color-bg-card); border: 1px solid var(--color-border); border-radius: 12px; }
.tool-info h3 { font-size: 14px; font-weight: 700; margin-bottom: 8px; color: var(--color-text); }
.tool-info p, .tool-info li { font-size: 13px; color: var(--color-muted); line-height: 1.7; }
.tool-info ul { padding-left: 16px; margin: 6px 0; }

/* Footer bar */
.tool-footer-bar { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }

/* Buttons */
.tool-btn { display: inline-flex; align-items: center; gap: 5px; padding: 8px 16px; border: none; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.2s; white-space: nowrap; }
.tool-btn-primary { background: var(--color-primary); color: #fff; }
.tool-btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }
.tool-btn-success { background: #10b981; color: #fff; }
.tool-btn-success:hover { background: #059669; }
.tool-btn-outline { background: #fff; color: var(--color-text); border: 1px solid var(--color-border); }
.tool-btn-outline:hover { background: var(--color-bg-hover); border-color: var(--color-primary); }
.tool-btn-danger { background: #ef4444; color: #fff; }
.tool-btn-danger:hover { background: #dc2626; }
.tool-btn-warning { background: #f59e0b; color: #fff; }
.tool-btn-warning:hover { background: #d97706; }
.tool-btn-sm { padding: 6px 12px; font-size: 12px; }

/* Toast */
.toast-msg { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); padding: 10px 24px; border-radius: 8px; font-size: 14px; font-weight: 500; z-index: 999; opacity: 0; transition: opacity 0.3s; pointer-events: none; }
.toast-msg.show { opacity: 1; }
.toast-success { background: #059669; color: #fff; }
.toast-error { background: #dc2626; color: #fff; }
.toast-info { background: #2563eb; color: #fff; }

/* Status message */
.status-message { text-align: center; padding: 6px; font-size: 13px; color: var(--color-muted); min-height: 24px; margin-bottom: 12px; }

/* Responsive */
@media (max-width: 900px) {
  .bmi-calc-grid { grid-template-columns: 1fr; }
  .advice-grid { grid-template-columns: 1fr 1fr; }
  .advanced-section { grid-template-columns: 1fr 1fr; }
  .bmi-input-row { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .tool-container { padding: 16px; }
  .tool-header h1 { font-size: 24px; }
  .advice-grid { grid-template-columns: 1fr; }
  .advanced-section { grid-template-columns: 1fr; }
  .bmi-number { font-size: 42px; }
  .input-row { flex-direction: column; }
  .input-val { min-width: auto; }
  .scale-labels span { font-size: 9px; }
}
