/* AHappy Care P0 — trợ lý hướng dẫn tĩnh cho ahappy.net.
 *
 * Mọi lớp mang tiền tố ahc- để không chạm vào CSS của trang. Không biến toàn
 * cục, không ghi đè thẻ nào của trang chủ, không đặt lại :root.
 * z-index chọn 2147483000: dưới trần 32 bit nhưng trên menu di động của trang.
 */

.ahc-root {
  --ahc-ink: #1f2933;
  --ahc-ink-soft: #52606d;
  --ahc-line: #d5dbe3;
  --ahc-bg: #ffffff;
  --ahc-bg-soft: #f5f7fa;
  --ahc-brand: #0f766e;
  --ahc-brand-ink: #ffffff;
  --ahc-focus: #0b5bd3;
  --ahc-radius: 12px;
  --ahc-shadow: 0 10px 30px rgba(31, 41, 51, .18);
  font-family: inherit;
  color: var(--ahc-ink);
}

/* Nút nổi ------------------------------------------------------------- */
.ahc-launcher {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 2147483000;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100vw - 32px);
  padding: 12px 16px;
  border: 1px solid var(--ahc-brand);
  border-radius: 999px;
  background: var(--ahc-brand);
  color: var(--ahc-brand-ink);
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  box-shadow: var(--ahc-shadow);
}
.ahc-launcher:hover { filter: brightness(1.07); }
.ahc-launcher[aria-expanded="true"] { display: none; }
.ahc-launcher-icon { font-size: 1.1em; }

/* Hộp thoại ----------------------------------------------------------- */
.ahc-panel {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 2147483000;
  display: flex;
  flex-direction: column;
  width: min(380px, calc(100vw - 32px));
  max-height: min(620px, calc(100vh - 32px));
  border: 1px solid var(--ahc-line);
  border-radius: var(--ahc-radius);
  background: var(--ahc-bg);
  box-shadow: var(--ahc-shadow);
  overflow: hidden;
}
.ahc-panel[hidden] { display: none; }

.ahc-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--ahc-line);
  background: var(--ahc-bg-soft);
}
.ahc-title { margin: 0; font-size: 1rem; font-weight: 700; }
.ahc-note { margin: 4px 0 0; font-size: .78rem; color: var(--ahc-ink-soft); }
.ahc-close {
  margin-left: auto;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border: 1px solid var(--ahc-line);
  border-radius: 8px;
  background: var(--ahc-bg);
  color: var(--ahc-ink);
  font: inherit;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.ahc-body { padding: 12px 14px 14px; overflow-y: auto; -webkit-overflow-scrolling: touch; }

.ahc-field { display: block; }
.ahc-label { display: block; margin-bottom: 6px; font-size: .85rem; font-weight: 600; }
.ahc-input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid var(--ahc-line);
  border-radius: 8px;
  background: var(--ahc-bg);
  color: var(--ahc-ink);
  font: inherit;
  font-size: 1rem; /* 16px: iOS không tự thu phóng khi gõ */
}

.ahc-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 0; padding: 0; list-style: none; }
.ahc-chip {
  padding: 6px 10px;
  border: 1px solid var(--ahc-line);
  border-radius: 999px;
  background: var(--ahc-bg-soft);
  color: var(--ahc-ink);
  font: inherit;
  font-size: .82rem;
  cursor: pointer;
}
.ahc-chip[aria-pressed="true"] { border-color: var(--ahc-brand); background: var(--ahc-brand); color: var(--ahc-brand-ink); }

.ahc-status { margin: 12px 0 0; font-size: .82rem; color: var(--ahc-ink-soft); }

.ahc-results { margin: 10px 0 0; padding: 0; list-style: none; }
.ahc-item { padding: 12px 0; border-top: 1px solid var(--ahc-line); }
.ahc-q { margin: 0 0 6px; font-size: .92rem; font-weight: 700; }
.ahc-a { margin: 0; font-size: .9rem; line-height: 1.55; }
.ahc-src { margin: 8px 0 0; font-size: .84rem; }
.ahc-src a { color: var(--ahc-focus); }

.ahc-suggest { margin: 10px 0 0; padding: 0; list-style: none; }
.ahc-suggest-btn {
  display: block;
  width: 100%;
  padding: 9px 10px;
  margin: 0 0 6px;
  border: 1px solid var(--ahc-line);
  border-radius: 8px;
  background: var(--ahc-bg);
  color: var(--ahc-ink);
  font: inherit;
  font-size: .88rem;
  text-align: left;
  cursor: pointer;
}

.ahc-foot { margin: 14px 0 0; padding-top: 10px; border-top: 1px solid var(--ahc-line); font-size: .8rem; color: var(--ahc-ink-soft); }
.ahc-foot a { color: var(--ahc-focus); }
.ahc-warn { margin: 8px 0 0; font-size: .78rem; color: var(--ahc-ink-soft); }

.ahc-root :focus-visible { outline: 3px solid var(--ahc-focus); outline-offset: 2px; }
.ahc-sr {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

@media (max-width: 420px) {
  .ahc-launcher { right: 12px; bottom: 12px; padding: 11px 14px; }
  .ahc-panel { right: 8px; left: 8px; bottom: 8px; width: auto; max-height: calc(100vh - 16px); }
}

@media (prefers-reduced-motion: no-preference) {
  .ahc-launcher, .ahc-chip, .ahc-suggest-btn { transition: filter .15s ease, background-color .15s ease; }
}

@media (prefers-color-scheme: dark) {
  .ahc-root {
    --ahc-ink: #e8edf2;
    --ahc-ink-soft: #aab4c0;
    --ahc-line: #3a4654;
    --ahc-bg: #141a21;
    --ahc-bg-soft: #1d252e;
    --ahc-focus: #8ab4ff;
  }
}

@media print { .ahc-root { display: none; } }
