/* ============================================
   UI7 — Tiểu Mai SPA AI PRO
   Mobile-first | System fonts | 0KB overhead
   ============================================ */
.ui7 {
  --primary: #0D9488;
  --primary-light: #14B8A6;
  --primary-dark: #0F766E;
  --secondary: #F0FDF4;
  --bg: #FFFFFF;
  --bg-warm: #FAFBFC;
  --text: #1F2937;
  --text-light: #6B7280;
  --text-muted: #9CA3AF;
  --accent: #059669;
  --warning: #DC2626;
  --warning-bg: #FEF2F2;
  --border: #E5E7EB;
  --border-cat: #DD9933;
  --border-light: #F3F4F6;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-full: 9999px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --ease: 0.2s ease;

  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  max-width: 640px;
  margin: 0 auto;
  overflow: hidden;
}
.ui7 *, .ui7 *::before, .ui7 *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* === VIEWS === */
.ui7-view { display: none; flex-direction: column; min-height: 0; }
.ui7-view.on { display: flex; }

/* ============================================
   VIEW 1: DANH MỤC
   ============================================ */
.ui7-hdr {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; padding: 12px 16px;
  transition: margin-top 0.3s ease;
}
.ui7-hdr.hide { margin-top: -60px; }
.ui7-hdr-row { display: flex; align-items: center; gap: 8px; }
.ui7-hdr-avatar { font-size: 22px; line-height: 1; }
.ui7-hdr-name { font-size: 16px; font-weight: 400; opacity: .9; white-space: nowrap; }
.ui7-hdr-tabs {
  display: flex; background: rgba(0,0,0,.1);
  border-radius: var(--r-sm); padding: 3px; margin-left: auto;
}
.ui7-hdr-tab {
  flex-shrink: 0; padding: 7px 12px; border: none; border-radius: 6px;
  background: transparent; color: rgba(255,255,255,.65);
  font-size: 14px; font-weight: 600; font-family: var(--font);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.ui7-hdr-tab.on {
  background: rgba(255,255,255,.2); color: #fff;
  border: 1px solid var(--border-cat); border-radius: 6px;
}

/* Lang dropdown */
.ui7-lang { position: relative; flex-shrink: 0; margin-left: 4px; }
.ui7-lang-btn { display: flex; align-items: center; gap: 3px; padding: 4px 8px; border: 1px solid rgba(255,255,255,.25); border-radius: 6px; background: rgba(255,255,255,.1); color: rgba(255,255,255,.85); font-size: 12px; font-family: var(--font); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.ui7-lang-btn:active { background: rgba(255,255,255,.2); }
.ui7-lang-btn .arrow { font-size: 8px; opacity: .7; }
.ui7-lang-dd { display: none; position: absolute; top: 100%; right: 0; margin-top: 4px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-sm); box-shadow: 0 8px 24px rgba(0,0,0,.12); overflow: hidden; z-index: 50; min-width: 130px; }
.ui7-lang-dd.open { display: block; }
.ui7-lang-opt { display: flex; align-items: center; gap: 8px; width: 100%; padding: 10px 14px; border: none; background: none; font-size: 13px; font-family: var(--font); color: var(--text); cursor: pointer; text-align: left; }
.ui7-lang-opt:active, .ui7-lang-opt.on { background: var(--secondary); }
.ui7-lang-opt.on { font-weight: 600; color: var(--primary); }
.ui7-lang-opt:not(:last-child) { border-bottom: 1px solid var(--border-light); }

/* Scroll area */
.ui7-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* Search */
.ui7-srch { padding: 10px 16px; background: var(--bg); border-bottom: 1px solid var(--border-light); position: sticky; top: 0; z-index: 5; }
.ui7-srch-box { display: flex; align-items: center; gap: 8px; padding: 11px 14px; background: var(--bg-warm); border: 1px solid var(--border); border-radius: var(--r-md); }
.ui7-srch-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(13,148,136,.1); }
.ui7-srch-ico { font-size: 16px; }
.ui7-srch-in { flex: 1; border: none; background: transparent; font-size: 16px; font-family: var(--font); color: var(--text); outline: none; }
.ui7-srch-in::placeholder { color: var(--text-muted); }

/* Category cards + scroll track */
.ui7-cats-wrap { position: relative; background: var(--bg); border-bottom: 1px solid var(--border-light); padding-bottom: 2px; }
.ui7-cats { display: flex; gap: 6px; padding: 12px 16px 8px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; cursor: grab; }
.ui7-cats::-webkit-scrollbar { display: none; }
.ui7-cat {
  flex-shrink: 0; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 12px; min-width: 64px;
  border: 1px solid var(--border-cat); border-radius: var(--r-md);
  background: var(--bg); font-family: var(--font);
  cursor: pointer; -webkit-tap-highlight-color: transparent; transition: all var(--ease);
}
.ui7-cat-ico { font-size: 20px; line-height: 1; }
.ui7-cat-lbl { font-size: 11px; font-weight: 500; color: var(--text); white-space: nowrap; }
.ui7-cat.on { background: var(--primary); border-color: var(--primary); box-shadow: 0 2px 8px rgba(13,148,136,.3); }
.ui7-cat.on .ui7-cat-lbl { color: #fff; font-weight: 600; }
.ui7-cat:active { transform: scale(.95); }
.ui7-cats-track { margin: 0 16px; height: 3px; background: var(--border-light); border-radius: 2px; position: relative; overflow: hidden; }
.ui7-cats-thumb { position: absolute; top: 0; left: 0; height: 100%; background: var(--primary); border-radius: 2px; transition: left .1s ease, width .1s ease; }

/* HOT NEWS — top 5, warm amber tone */
.ui7-hotnews { padding: 8px 16px 0; }
.ui7-hotnews-hdr { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: #B45309; padding: 2px 0 6px; }
.ui7-hn-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin-bottom: 4px; background: var(--bg); border: 1px solid #FDE68A; border-radius: var(--r-md); cursor: pointer; -webkit-tap-highlight-color: transparent; min-height: 40px; }
.ui7-hn-item:active { background: #FFFBEB; }
.ui7-hn-rank { width: 20px; height: 20px; border-radius: 50%; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ui7-hn-rank.r1, .ui7-hn-rank.r2, .ui7-hn-rank.r3 { background: #D97706; color: #fff; }
.ui7-hn-rank.r4, .ui7-hn-rank.r5 { background: #FEF3C7; color: #92400E; }
.ui7-hn-ico { font-size: 18px; flex-shrink: 0; }
.ui7-hn-body { flex: 1; min-width: 0; }
.ui7-hn-txt { font-size: 14px; font-weight: 500; line-height: 1.35; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ui7-hn-meta { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.ui7-hn-views { color: #B45309; font-weight: 600; }
.ui7-hn-arr { color: var(--text-muted); font-size: 14px; flex-shrink: 0; }
.ui7-hn-sep { height: 1px; background: var(--border-light); margin: 6px 0 2px; }
.ui7-views { font-size: 11px; color: var(--text-muted); }

/* Items list */
.ui7-lst { padding: 6px 16px 16px; }
.ui7-lst-hdr { font-size: 14px; color: var(--text-muted); padding: 6px 0; }
.ui7-itm {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; margin-bottom: 6px;
  background: var(--bg); border: 1px solid var(--border-light);
  border-radius: var(--r-md); cursor: pointer;
  -webkit-tap-highlight-color: transparent; min-height: 44px;
}
.ui7-itm:active { background: var(--secondary); border-color: var(--primary); }
.ui7-itm-ico { font-size: 20px; flex-shrink: 0; width: 28px; text-align: center; }
.ui7-itm-body { flex: 1; min-width: 0; }
.ui7-itm-txt { font-size: 15px; font-weight: 500; line-height: 1.4; }
.ui7-itm-meta { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.ui7-itm-arr { color: var(--text-muted); font-size: 16px; flex-shrink: 0; }
.ui7-risk { display: inline-block; padding: 1px 6px; border-radius: var(--r-full); font-size: 11px; font-weight: 600; }
.ui7-risk-low { background: #ECFDF5; color: #059669; }
.ui7-risk-medium { background: #FFF7ED; color: #D97706; }
.ui7-risk-high { background: #FEF2F2; color: #DC2626; }
.ui7-hot { display: inline-block; padding: 1px 6px; border-radius: var(--r-full); font-size: 10px; font-weight: 700; background: #FEF3C7; color: #92400E; margin-left: 4px; }
.ui7-itm.new { animation: ui7SlideUp .3s ease forwards; }
@keyframes ui7SlideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* Loader */
.ui7-loader { display: flex; align-items: center; justify-content: center; padding: 20px 0; gap: 6px; }
.ui7-ldot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); animation: ui7Pulse 1s infinite; }
.ui7-ldot:nth-child(2) { animation-delay: .2s; }
.ui7-ldot:nth-child(3) { animation-delay: .4s; }
@keyframes ui7Pulse { 0%,80%,100% { opacity: .2; transform: scale(.8); } 40% { opacity: 1; transform: scale(1); } }
.ui7-end { text-align: center; padding: 16px 0; font-size: 13px; color: var(--text-muted); display: none; }

/* ============================================
   VIEW 2: TRẢ LỜI
   ============================================ */
.ui7-ans-hdr {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--border-light); background: var(--bg);
}
.ui7-ans-back {
  width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--bg);
  font-size: 18px; cursor: pointer; font-family: var(--font); color: var(--text);
}
.ui7-ans-info { flex: 1; }
.ui7-ans-cat { font-size: 13px; color: var(--primary); font-weight: 500; }
.ui7-ans-by { font-size: 13px; color: var(--text-muted); }
.ui7-ans-title { font-size: 20px; font-weight: 700; line-height: 1.4; padding: 16px 16px 6px; }
.ui7-ans-meta { padding: 0 16px 12px; font-size: 13px; color: var(--text-muted); }

/* Accordion sections */
.ui7-sec { margin: 0 16px 8px; border: 1px solid var(--border-light); border-radius: var(--r-md); overflow: hidden; }
.ui7-sec-head {
  display: flex; align-items: center; gap: 10px; padding: 14px;
  background: var(--bg); border: none; width: 100%; text-align: left;
  font-family: var(--font); font-size: 15px; font-weight: 600; color: var(--text);
  cursor: pointer; -webkit-tap-highlight-color: transparent; min-height: 48px;
}
.ui7-sec-head:active { background: var(--secondary); }
.ui7-sec-ico { font-size: 18px; flex-shrink: 0; }
.ui7-sec-lbl { flex: 1; }
.ui7-sec-arr { font-size: 12px; color: var(--text-muted); transition: transform var(--ease); }
.ui7-sec.open .ui7-sec-arr { transform: rotate(180deg); }
.ui7-sec-body { display: none; padding: 0 14px 14px; font-size: 15px; line-height: 1.75; }
.ui7-sec.open .ui7-sec-body { display: block; }

/* Red flag items */
.ui7-rflag {
  display: flex; gap: 8px; padding: 10px 12px;
  background: var(--warning-bg); border-radius: var(--r-sm);
  border-left: 3px solid var(--warning); margin-bottom: 8px;
  font-size: 14px; line-height: 1.55;
}

/* Related links */
.ui7-related-link { display: block; color: var(--primary); text-decoration: none; padding: 4px 0; font-size: 14px; }
.ui7-related-link:hover { text-decoration: underline; }

/* E-E-A-T */
.ui7-eeat {
  margin: 0 16px 12px; padding: 10px 12px; background: var(--bg-warm);
  border-radius: var(--r-sm); border: 1px solid var(--border-light);
  font-size: 13px; color: var(--text-light); line-height: 1.55;
}
.ui7-eeat b { color: var(--text); font-weight: 600; }

/* CTA affiliate */
.ui7-cta {
  display: flex; align-items: center; gap: 12px; margin: 12px 16px; padding: 14px 16px;
  background: linear-gradient(135deg,#FFF7ED,#FFFBEB); border: 1px solid #FDE68A;
  border-radius: var(--r-md); cursor: pointer; min-height: 44px;
}
.ui7-cta:active { transform: scale(.98); }
.ui7-cta-ico { font-size: 24px; }
.ui7-cta-body { flex: 1; }
.ui7-cta-lbl { font-size: 15px; font-weight: 600; color: #92400E; }
.ui7-cta-plat { font-size: 12px; color: #B45309; margin-top: 2px; }
.ui7-cta-disc { font-size: 12px; color: var(--text-muted); padding: 0 16px; margin-bottom: 8px; font-style: italic; }

/* Toolbar */
.ui7-tbar { display: flex; border-top: 1px solid var(--border-light); }
.ui7-tbar-btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 0; border: none; background: var(--bg); font-family: var(--font);
  font-size: 14px; color: var(--text-light); cursor: pointer; min-height: 44px;
}
.ui7-tbar-btn:not(:last-child) { border-right: 1px solid var(--border-light); }
.ui7-tbar-btn:active { background: var(--secondary); color: var(--primary); }

/* Ask more */
.ui7-askm { padding: 16px; background: var(--secondary); border-top: 1px solid var(--border-light); }
.ui7-askm-lbl { font-size: 14px; color: var(--primary-dark); font-weight: 600; margin-bottom: 8px; }
.ui7-askm-row { display: flex; gap: 8px; }
.ui7-askm-in {
  flex: 1; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--r-md);
  font-size: 15px; font-family: var(--font); background: var(--bg); outline: none; min-height: 44px;
}
.ui7-askm-in:focus { border-color: var(--primary); }
.ui7-askm-btn {
  padding: 10px 16px; border: none; border-radius: var(--r-md);
  background: var(--primary); color: #fff; font-size: 15px; font-weight: 600;
  font-family: var(--font); cursor: pointer; min-height: 44px; white-space: nowrap;
}
.ui7-askm-btn:active { background: var(--primary-dark); }

/* ============================================
   VIEW 3: AI CHAT
   ============================================ */
.ui7-ch-hdr {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; background: var(--primary); color: #fff;
}
.ui7-ch-back {
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  border: 1px solid rgba(255,255,255,.3); border-radius: var(--r-sm);
  background: transparent; color: #fff; font-size: 18px; cursor: pointer; font-family: var(--font);
}
.ui7-ch-info { flex: 1; min-width: 0; }
.ui7-ch-name { font-size: 15px; font-weight: 600; }
.ui7-ch-ctx { font-size: 12px; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ui7-ch-msgs { flex: 1; padding: 16px; overflow-y: auto; background: var(--bg-warm); }
.ui7-ch-msg { display: flex; gap: 8px; margin-bottom: 14px; max-width: 88%; }
.ui7-ch-msg.u { margin-left: auto; flex-direction: row-reverse; }
.ui7-ch-ava { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 15px; flex-shrink: 0; background: var(--secondary); }
.ui7-ch-msg.u .ui7-ch-ava { background: #EEF2FF; }
.ui7-ch-bub { padding: 10px 14px; border-radius: var(--r-md); font-size: 15px; line-height: 1.65; }
.ui7-ch-msg.b .ui7-ch-bub { background: var(--bg); border: 1px solid var(--border-light); border-top-left-radius: 4px; }
.ui7-ch-msg.u .ui7-ch-bub { background: var(--primary); color: #fff; border-top-right-radius: 4px; }
.ui7-ch-typing { display: none; gap: 6px; padding: 8px 14px; background: var(--bg); border: 1px solid var(--border-light); border-radius: var(--r-md); border-top-left-radius: 4px; margin: 0 16px 8px; width: fit-content; }
.ui7-ch-typing.on { display: flex; }
.ui7-tdot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted); animation: ui7Bounce 1.2s infinite; }
.ui7-tdot:nth-child(2) { animation-delay: .2s; }
.ui7-tdot:nth-child(3) { animation-delay: .4s; }
@keyframes ui7Bounce { 0%,80%,100% { transform: translateY(0); opacity: .4; } 40% { transform: translateY(-4px); opacity: 1; } }
.ui7-ch-bar { display: flex; gap: 8px; padding: 10px 16px; background: var(--bg); border-top: 1px solid var(--border-light); }
.ui7-ch-in { flex: 1; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--r-md); font-size: 16px; font-family: var(--font); outline: none; min-height: 44px; }
.ui7-ch-in:focus { border-color: var(--primary); }
.ui7-ch-send { width: 44px; height: 44px; border: none; border-radius: var(--r-md); background: var(--primary); color: #fff; font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.ui7-ch-send:active { background: var(--primary-dark); }
.ui7-ch-disc { padding: 6px 16px 10px; font-size: 12px; color: var(--text-muted); text-align: center; background: var(--bg); }

/* ============================================
   VIEW 4: CHATBOX
   ============================================ */
.ui7-cb-wrap { padding: 16px; flex: 1; display: flex; flex-direction: column; }
.ui7-cb-fab {
  width: 56px; height: 56px; border: none; border-radius: 50%;
  background: var(--primary); color: #fff; font-size: 28px; cursor: pointer;
  box-shadow: 0 8px 24px rgba(0,0,0,.12); display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
}
.ui7-cb { border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; flex: 1; display: flex; flex-direction: column; min-height: 0; }
.ui7-cb-hdr { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--primary); color: #fff; }
.ui7-cb-ava { font-size: 22px; }
.ui7-cb-info { flex: 1; }
.ui7-cb-name { font-size: 15px; font-weight: 600; }
.ui7-cb-status { font-size: 12px; opacity: .85; display: flex; align-items: center; gap: 4px; }
.ui7-cb-dot { width: 6px; height: 6px; background: #34D399; border-radius: 50%; }
.ui7-cb-close { width: 32px; height: 32px; border: none; border-radius: var(--r-sm); background: rgba(255,255,255,.15); color: #fff; font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.ui7-cb-msgs { flex: 1; padding: 14px; overflow-y: auto; background: var(--bg-warm); }
.ui7-cb-msg { display: flex; gap: 8px; margin-bottom: 12px; max-width: 88%; }
.ui7-cb-msg.u { margin-left: auto; flex-direction: row-reverse; }
.ui7-cb-bub { padding: 10px 14px; border-radius: var(--r-md); font-size: 15px; line-height: 1.6; }
.ui7-cb-msg.b .ui7-cb-bub { background: var(--bg); border: 1px solid var(--border-light); border-top-left-radius: 4px; }
.ui7-cb-msg.u .ui7-cb-bub { background: var(--primary); color: #fff; border-top-right-radius: 4px; }
.ui7-cb-sugg { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 10px; background: var(--bg-warm); }
.ui7-cb-pill {
  padding: 8px 14px; border: 1px solid var(--border); border-radius: var(--r-full);
  background: var(--bg); font-size: 13px; font-family: var(--font); color: var(--primary); cursor: pointer;
}
.ui7-cb-pill:active { background: var(--secondary); border-color: var(--primary); }
.ui7-cb-bar { display: flex; gap: 8px; padding: 10px 12px; background: var(--bg); border-top: 1px solid var(--border-light); }
.ui7-cb-in { flex: 1; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-md); font-size: 15px; font-family: var(--font); outline: none; min-height: 44px; }
.ui7-cb-send { width: 44px; height: 44px; border: none; border-radius: var(--r-md); background: var(--primary); color: #fff; font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
