/* ToolBacSi — style dùng chung cho toàn site.
   Chủ đề y khoa: xanh mòng két (teal) + nền sáng, hỗ trợ chế độ tối. */

:root {
  color-scheme: light;
  --bg: #eef5fb;
  --surface: #ffffff;
  --surface-2: #f2f7fc;
  --border: #d3e3f1;
  --text: #12293d;
  --text-muted: #5a7286;
  --brand: #1568b8;
  --brand-dark: #0f4f8f;
  --brand-soft: #e5f0fb;
  --accent: #e2683c;
  --danger: #d64545;
  --warn: #d9971a;
  --ok: #1f9d57;
  --shadow: 0 1px 2px rgba(16, 52, 90, .05), 0 6px 20px rgba(16, 52, 90, .08);
  --radius: 14px;
  --radius-sm: 9px;
  --maxw: 1040px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Header ------------------------------------------------------------- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.site-header-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 20px;
  height: 62px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.22rem;
  color: var(--text);
  letter-spacing: -.01em;
}
.brand:hover { text-decoration: none; }
.brand-mark { font-size: 1.25em; line-height: 1; }
.brand-accent { color: var(--brand); }

.site-nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.site-nav-link {
  color: var(--text-muted);
  font-weight: 600;
  font-size: .93rem;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}
.site-nav-link:hover { color: var(--brand-dark); background: var(--brand-soft); text-decoration: none; }

.nav-toggle {
  display: none;
  margin-left: auto;
  flex-direction: column;
  gap: 5px;
  width: 42px;
  height: 40px;
  padding: 0;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.nav-toggle-bar { display: block; width: 20px; height: 2px; background: var(--text); border-radius: 2px; }

@media (max-width: 760px) {
  .nav-toggle { display: flex; }
  .site-nav {
    position: absolute;
    top: 62px;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 8px 16px 14px;
    box-shadow: var(--shadow);
    display: none;
  }
  .site-nav.open { display: flex; }
  .site-nav-link { padding: 11px 12px; }
}

/* ---- Layout ------------------------------------------------------------- */
#page-root {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.page-hero { text-align: center; padding: 22px 0 8px; }
.page-hero .eyebrow {
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: .74rem;
  font-weight: 700;
  color: var(--brand);
  margin: 0 0 8px;
}
.page-hero h1 { margin: 0 0 10px; font-size: clamp(1.7rem, 4vw, 2.5rem); letter-spacing: -.02em; }
.page-hero p { margin: 0 auto; max-width: 620px; color: var(--text-muted); }

/* ---- Tìm kiếm tool ------------------------------------------------------ */
.tool-search { max-width: 620px; margin: 26px auto 8px; }
.tool-search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 6px 6px 18px;
  box-shadow: var(--shadow);
}
.tool-search-box:focus-within { border-color: var(--brand); }
.tool-search-box svg { flex: none; color: var(--text-muted); }
.tool-search input {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 1.02rem;
  padding: 10px 0;
  outline: none;
  min-width: 0;
}
.tool-search-count { text-align: center; color: var(--text-muted); font-size: .86rem; margin-top: 12px; min-height: 1.2em; }

/* ---- Lưới tool ---------------------------------------------------------- */
.tool-grid {
  list-style: none;
  margin: 18px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}
.tool-card {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  transition: transform .12s ease, border-color .12s ease;
}
.tool-card:hover { transform: translateY(-2px); border-color: var(--brand); text-decoration: none; }
.tool-card-icon {
  flex: none;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  background: var(--brand-soft);
  border-radius: 12px;
}
.tool-card-name { margin: 2px 0 4px; font-size: 1.06rem; font-weight: 700; color: var(--text); }
.tool-card-desc { margin: 0; font-size: .9rem; color: var(--text-muted); }
.tool-card-cat {
  display: inline-block;
  margin-top: 9px;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--brand);
}
.tool-empty { text-align: center; color: var(--text-muted); padding: 40px 0; }

/* ---- Bookmark (ngôi sao) ------------------------------------------------ */
.bookmark-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px;
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  color: #c69a17;
  line-height: 0;
}
.bookmark-btn:hover { background: rgba(214, 170, 20, .16); }
.bookmark-btn svg { fill: none; stroke: currentColor; stroke-width: 1.6; }
.bookmark-btn.on { color: #eab308; }
.bookmark-btn.on svg { fill: #f6c945; stroke: #d9a406; }

/* Sao trên card ở trang chủ: góc trên phải, không cản click vào thẻ. */
.tool-card-wrap { position: relative; }
.tool-card-wrap .tool-card { padding-right: 46px; }
.tool-card-wrap .bookmark-btn { position: absolute; top: 10px; right: 10px; z-index: 2; }

/* Sao cạnh tiêu đề trang chi tiết tool. */
.bookmark-btn-title { vertical-align: middle; transform: translateY(-2px); }

/* ---- Trang tool: card tính toán ---------------------------------------- */
.tool-back { display: inline-block; margin-bottom: 6px; font-size: .9rem; font-weight: 600; }
.tool-layout { display: grid; grid-template-columns: 1fr; gap: 22px; margin-top: 18px; }
@media (min-width: 820px) { .tool-layout.has-aside { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; } }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.card h2 { margin-top: 0; font-size: 1.15rem; }
.card + .card { margin-top: 18px; }

.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; font-size: .95rem; }
.field .hint { font-size: .82rem; color: var(--text-muted); font-weight: 400; }
.field input[type="number"],
.field input[type="text"],
.field select {
  width: 100%;
  padding: 11px 13px;
  font-size: 1rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
}
.field input:focus, .field select:focus { border-color: var(--brand); }

.input-group { display: flex; gap: 8px; }
.input-group input { flex: 1; }
.input-group select { flex: none; width: auto; }

.radio-row { display: flex; flex-wrap: wrap; gap: 8px; }
.radio-row label {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 12px;
  margin: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 500;
}
.radio-row input { accent-color: var(--brand); }
.radio-row label:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-dark); font-weight: 700; }

.btn-row { display: flex; gap: 10px; margin-top: 4px; }
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.btn:hover { border-color: var(--brand); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }

/* ---- Kết quả ------------------------------------------------------------ */
.result {
  margin-top: 4px;
  padding: 20px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
  text-align: center;
}
.result .result-value { font-size: 2.3rem; font-weight: 800; line-height: 1.1; }
.result .result-unit { font-size: 1rem; color: var(--text-muted); font-weight: 600; }
.result .result-label { margin-top: 6px; font-size: 1.05rem; font-weight: 700; }
.result .result-sub { margin-top: 4px; color: var(--text-muted); font-size: .92rem; }
.result.is-empty { color: var(--text-muted); }
.result.is-empty .result-value { font-size: 1.05rem; font-weight: 600; color: var(--text-muted); }

.badge { display: inline-block; padding: 4px 12px; border-radius: 999px; font-weight: 700; font-size: .9rem; }
.badge.ok { background: rgba(46,158,91,.16); color: var(--ok); }
.badge.warn { background: rgba(224,160,33,.18); color: var(--warn); }
.badge.danger { background: rgba(214,69,69,.16); color: var(--danger); }
.badge.info { background: var(--brand-soft); color: var(--brand-dark); }

.result-value.ok { color: var(--ok); }
.result-value.warn { color: var(--warn); }
.result-value.danger { color: var(--danger); }
.result-value.info { color: var(--brand); }

/* ---- Bảng tham chiếu ---------------------------------------------------- */
.ref-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.ref-table th, .ref-table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); }
.ref-table th { color: var(--text-muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.ref-table tr:last-child td { border-bottom: 0; }
.ref-table .row-active { background: var(--brand-soft); }
.table-scroll { overflow-x: auto; }

.note { font-size: .88rem; color: var(--text-muted); }
.note strong { color: var(--text); }
ul.tight { margin: 8px 0; padding-left: 20px; }
ul.tight li { margin: 3px 0; }

/* ---- Footer ------------------------------------------------------------- */
.site-footer { background: var(--surface); border-top: 1px solid var(--border); margin-top: 40px; }
.site-footer-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 30px 20px;
  display: grid;
  gap: 16px;
}
.footer-brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.1rem; }
.footer-links h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin: 0 0 8px; }
.footer-links { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.footer-links a { color: var(--text-muted); font-size: .92rem; }
.footer-links a:hover { color: var(--brand-dark); }
.footer-note { margin: 0; font-size: .84rem; color: var(--text-muted); max-width: 640px; }
