/* ==============================================================
   assets/css/carb-theory.css
   Style riêng cho tools/hoa-12-chuong-2.php — khung lý thuyết tĩnh
   Chương 2 (Carbohydrate). Dùng chung biến màu với tool-common.css
   (--blue, --ink, --card, --line...) để đồng bộ giao diện site.
   ============================================================== */

/* --- Mục lục + khung 1 bài học (giống mẫu bond-lab.css của Ch.3) --- */
.theory-toc { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }
.theory-toc-item {
  font-size: 13px; padding: 6px 14px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--ink-soft); text-decoration: none;
  transition: all 0.15s;
}
.theory-toc-item:hover { border-color: var(--blue); color: var(--blue); }
.theory-lesson { margin-bottom: 36px; scroll-margin-top: 16px; }
.theory-lesson-title { font-size: 19px; font-weight: 700; margin-bottom: 12px; border-bottom: 2px solid var(--line); padding-bottom: 8px; }
.theory-body p { line-height: 1.7; margin: 0 0 12px; font-size: 15px; }
.theory-body ul { margin: 0 0 14px; padding-left: 20px; line-height: 1.7; font-size: 15px; }
.theory-body li { margin-bottom: 6px; }

/* --- Thẻ lý thuyết (theory-card) + lưới nhiều thẻ --- */
.theory-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; margin-top: 4px; }
.theory-card {
  background: #f7f8fd; border-radius: var(--radius); padding: 20px 24px;
  border-left: 6px solid var(--blue); box-shadow: 0 2px 8px rgba(0,0,0,0.02);
}
.theory-card h3 { font-size: 18px; color: var(--blue-dark); margin-bottom: 12px; display: flex; align-items: center; gap: 10px; }
.theory-card ul, .theory-card p { line-height: 1.7; color: var(--ink); }
.theory-card ul { padding-left: 20px; }
.theory-card .highlight {
  background: #e4e9fb; padding: 2px 10px; border-radius: 6px; font-weight: 600; color: var(--blue-dark);
}

/* --- Bảng thông tin / công thức / cảnh báo / ghi chú --- */
.info-table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 14px; }
.info-table th { background: #e4e9fb; color: var(--blue-dark); padding: 6px 10px; text-align: left; }
.info-table td { padding: 6px 10px; border-bottom: 1px solid var(--line); }
.formula-box {
  font-family: "IBM Plex Mono", monospace; background: #eef0fa; border-radius: 8px;
  padding: 10px 14px; margin: 8px 0; font-size: 14px; text-align: center;
}
.warning-box {
  background: #fff7e6; border: 1px solid #f2d38a; border-radius: var(--radius);
  padding: 14px 18px; margin-bottom: 18px; font-size: 14.5px; color: #7a5b12;
}
.note-box {
  background: #eef0fa; border-radius: 8px; padding: 10px 14px; margin-top: 10px;
  font-size: 13.5px; color: var(--ink-soft);
}

/* --- So sánh 2 cột (dùng ở Bài 6: Tinh bột vs Cellulose) --- */
.compare-box { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 12px 0; }
.compare-box .col { border-radius: 14px; padding: 16px; text-align: center; }
.compare-box .starch { background: #e8f4f8; border: 2px solid var(--blue); }
.compare-box .cellulose { background: #f3eefc; border: 2px solid var(--violet); }
.compare-box .col h4 { font-size: 17px; margin-bottom: 8px; }
.compare-box .col .icon { font-size: 32px; }
.compare-box .col ul { list-style: none; padding: 0; font-size: 14px; line-height: 1.7; }
.compare-box .col ul li { border-bottom: 1px dashed rgba(0,0,0,0.08); padding: 4px 0; }

/* --- Poster ảnh tổng hợp (bấm để xem full) --- */
.poster-gallery { display: grid; grid-template-columns: 1fr; gap: 22px; margin-top: 6px; }
.poster-link { display: block; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); position: relative; }
.poster-link img { display: block; width: 100%; height: auto; }
.poster-link .poster-zoom-hint {
  position: absolute; right: 10px; bottom: 10px; background: rgba(20,20,30,0.65);
  color: #fff; font-size: 12px; padding: 4px 10px; border-radius: 999px;
}
.poster-caption { font-size: 12.5px; color: var(--ink-soft); text-align: center; margin-top: 6px; }

/* --- Sơ đồ cấu trúc (SVG) + khối cân bằng vòng/mạch hở (Bài 4/5) --- */
.structure-svg { display: flex; justify-content: center; margin: 12px 0; }
.structure-svg svg { max-width: 100%; height: auto; }
.ring-open-container {
  display: flex; align-items: center; justify-content: space-around; gap: 12px;
  margin: 16px 0 8px; background: #eef0fa; padding: 16px; border-radius: 16px; border: 1px solid var(--line);
}
.ring-open-box {
  flex: 1; background: var(--card); border-radius: 12px; padding: 14px 10px; text-align: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.04); border: 2px solid var(--line);
}
.ring-open-box.active-state { border-color: var(--blue); background: #f5f6fd; }
.ring-open-title { font-size: 17px; font-weight: 700; color: var(--blue-dark); margin-bottom: 6px; }
.ring-open-formula { font-family: "IBM Plex Mono", monospace; font-size: 15px; font-weight: 700; color: var(--blue); margin-bottom: 6px; }
.ring-open-desc { font-size: 13.5px; color: #c0392b; font-weight: 600; }
.ring-open-arrow {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 26px; font-weight: bold; color: var(--violet); min-width: 36px;
}
.ring-open-arrow span { font-size: 12px; color: var(--ink-soft); font-weight: 600; }

@media (max-width: 640px) {
  .theory-grid { grid-template-columns: 1fr; }
  .compare-box { grid-template-columns: 1fr; }
  .ring-open-container { flex-direction: column; gap: 8px; }
  .ring-open-arrow { transform: rotate(90deg); margin: 4px 0; }
}

/* ==============================================================
   CÔNG CỤ TRA CỨU & NHẬN BIẾT (tab mới) — bộ lọc chip + lưới thẻ
   chất + panel chi tiết khi bấm vào 1 thẻ. Thuần JS phía client,
   không gọi API/tính toán backend.
   ============================================================== */
.pt-filters { display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: center; margin-bottom: 20px; }
.filter-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filter-label { font-size: 12.5px; color: var(--ink-soft); font-weight: 600; }
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 7px 14px; font-size: 13px; cursor: pointer; color: var(--ink-soft);
  min-height: 38px; transition: all 0.12s; display: inline-flex; align-items: center; gap: 6px;
  font-family: inherit;
}
.chip:hover { border-color: var(--blue); color: var(--blue); }
.chip.active { background: var(--blue); border-color: var(--blue); color: white; }
.chip-clear { background: #eef0fa; }

.subst-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 22px; }
.subst-card {
  border: 1.5px solid var(--line); border-radius: var(--radius); padding: 14px 12px; text-align: center;
  cursor: pointer; background: var(--card); transition: all 0.15s; min-height: 84px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
}
.subst-card:hover { border-color: var(--blue); }
.subst-card.selected { border-color: var(--blue); background: #eef0fa; box-shadow: 0 0 0 2px var(--blue) inset; }
.subst-card.dim { opacity: 0.32; }
.subst-card .subst-icon { font-size: 22px; }
.subst-card .subst-name { font-size: 14px; font-weight: 700; color: var(--ink); }
.subst-card .subst-formula { font-size: 12px; color: var(--ink-soft); font-family: "IBM Plex Mono", monospace; }

.subst-detail { border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 22px; background: var(--card); }
.subst-detail .subst-detail-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.subst-detail .subst-detail-icon { font-size: 30px; }
.subst-detail .subst-detail-title { font-size: 19px; font-weight: 700; color: var(--blue-dark); }
.subst-detail .subst-detail-formula { font-size: 13.5px; color: var(--ink-soft); font-family: "IBM Plex Mono", monospace; }
.subst-reagent-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.subst-reagent-row:last-child { border-bottom: none; }
.subst-reagent-icon { flex-shrink: 0; font-size: 18px; width: 26px; text-align: center; }
.subst-reagent-name { font-size: 13.5px; font-weight: 700; color: var(--ink); min-width: 130px; }
.subst-reagent-text { font-size: 13.5px; color: var(--ink); line-height: 1.55; }
.subst-empty-hint { color: var(--ink-soft); font-size: 14px; text-align: center; padding: 20px 10px; }

/* ==============================================================
   CHUỖI CHUYỂN HÓA TƯƠNG TÁC (tab mới)
   ============================================================== */
.chain-track { display: flex; align-items: center; gap: 4px; overflow-x: auto; padding: 8px 2px 16px; margin-bottom: 6px; }
.chain-node {
  flex-shrink: 0; border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 16px; text-align: center;
  background: var(--card); cursor: pointer; min-width: 108px; transition: all 0.15s;
}
.chain-node .chain-node-name { font-size: 13.5px; font-weight: 700; color: var(--ink); }
.chain-node .chain-node-formula { font-size: 11.5px; color: var(--ink-soft); font-family: "IBM Plex Mono", monospace; margin-top: 2px; }
.chain-node.active { border-color: var(--blue); background: #eef0fa; box-shadow: 0 0 0 2px var(--blue) inset; }
.chain-node.done { border-color: var(--blue); }
.chain-arrow { flex-shrink: 0; font-size: 20px; color: var(--ink-soft); padding: 0 2px; }
.chain-arrow.done { color: var(--blue); }
.chain-step-panel {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 22px; background: var(--card); margin-bottom: 16px;
}
.chain-step-eq { font-family: "IBM Plex Mono", monospace; font-size: 15px; text-align: center; background: #eef0fa; border-radius: 8px; padding: 12px; margin-bottom: 10px; }
.chain-step-text { font-size: 14.5px; line-height: 1.6; color: var(--ink); }
.chain-controls { display: flex; gap: 10px; }
.chain-controls .lab-cta-btn { flex: 1; }
.lab-cta-btn {
  display: block; padding: 13px 20px; font-size: 15px; font-weight: 700; color: white;
  background: var(--blue); border: none; border-radius: 12px; cursor: pointer;
  min-height: 46px; font-family: inherit;
}
.lab-cta-btn:disabled { background: #b8bfe0; cursor: not-allowed; }
.lab-cta-btn:hover:not(:disabled) { background: var(--blue-dark); }
.lab-cta-btn.secondary { background: #eef0fa; color: var(--ink); }
.lab-cta-btn.secondary:hover:not(:disabled) { background: #dde2f5; }

@media (max-width: 640px) {
  .pt-filters { flex-direction: column; align-items: stretch; gap: 10px; }
  .filter-group { flex-direction: column; align-items: flex-start; gap: 5px; }
  .chip-row { width: 100%; }
  .subst-grid { grid-template-columns: repeat(2, 1fr); }
  .subst-detail { padding: 14px 16px; }
}
