/* Các mảnh giao diện kiểu Animate UI dùng chung cho Trang cổ điển và AI Terminal (2026-10-25) — xem xsg-ui.js.
   Đường cong spring xuất từ token của @animate-ui/react bằng css-timing.mjs. */
:root {
  --xu-spring-highlight: linear(0, 0.0233, 0.0813, 0.1598, 0.2483, 0.3396, 0.4288, 0.5126, 0.5894, 0.658, 0.7183, 0.7704, 0.8149, 0.8524, 0.8837, 0.9094, 0.9303, 0.9472, 0.9607, 0.9713, 0.9796, 0.986, 0.9908, 0.9944, 0.997, 0.9988, 1.0001, 1.001, 1.0015, 1);
  --xu-spring-selection: linear(0, 0.0141, 0.0509, 0.1035, 0.1663, 0.2349, 0.306, 0.3769, 0.4459, 0.5115, 0.573, 0.6297, 0.6814, 0.728, 0.7696, 0.8064, 0.8387, 0.8668, 0.8911, 0.9119, 0.9296, 0.9445, 0.957, 0.9673, 0.9758, 0.9827, 0.9882, 0.9926, 0.9961, 0.9987, 1.0007, 1.0021, 1.0031, 1.0038, 1.0041, 1, 1, 1, 1.004, 1.0038, 1.0035, 1.0032, 1.0029, 1.0026, 1.0023, 1.002, 1.0017, 1.0015, 1, 1);
  --xu-ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}

/* ---- Highlight trượt chung (Sidebar của Animate UI: các mục menu dùng chung 1 nền trượt theo chuột) ---- */
.xsg-hl {
  position: absolute; left: 0; top: 0; width: 0; height: 0; z-index: 0; pointer-events: none; opacity: 0;
  transition: transform 300ms var(--xu-spring-highlight), width 300ms var(--xu-spring-highlight),
    height 300ms var(--xu-spring-highlight), opacity 0.2s ease, background-color 0.2s ease;
}
.xsg-hl.xsg-hl-instant { transition: none; }
.xsg-glide > :not(.xsg-hl) { position: relative; z-index: 1; }
/* menu dọc: nền của mục do highlight vẽ; mục đang mở có thêm vạch vàng bên trái */
html.ewc .ewc-side-mid.xsg-glide > .ewc-item { background: transparent !important; }
html.ewc .ewc-side-mid > .xsg-hl { background: var(--ewc-bg); border-radius: 14px; margin: 0; }
html.ewc .ewc-side-mid.xsg-glide { padding: 0 6px; }
html.ewc .ewc-side-mid.xsg-glide > .ewc-item { border-radius: 14px; }
html.ewc .ewc-side-mid.xsg-glide > .ewc-item.active::before {
  content: ""; position: absolute; left: -6px; top: 22%; bottom: 22%; width: 3px; border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, var(--ewc-gold-2), var(--ewc-gold-deep));
}
html.ewc-dark .ewc-side-mid > .xsg-hl { background: var(--ewc-hover); }
/* thanh tab (Tổng quan / Lệnh đang theo dõi, M5/M3/M1…): nền mục đang chọn trượt sang mục mới (spring.selection) */
html.ewc .xsg-seg > .xsg-hl { background: var(--ewc-dark); border-radius: 10px; transition-duration: 500ms; transition-timing-function: var(--xu-spring-selection); }
html.ewc-dark .xsg-seg > .xsg-hl { background: var(--ewc-btn-bg); }
html.ewc body .xsg-seg > .sigtab, html.ewc body .xsg-seg > .dash-tab { transition: color 0.2s ease; }
/* chỉ bỏ nền của nút khi highlight đang có mặt — mất highlight thì nút vẫn tự tô như cũ, không bao giờ mất chữ */
html.ewc body .xsg-seg:has(> .xsg-hl) > .sigtab.active, html.ewc body .xsg-seg:has(> .xsg-hl) > .dash-tab.active { background: transparent !important; }

/* ---- Icon menu động khi rê chuột (kiểu animated icons của Animate UI) ---- */
@media (hover: hover) and (pointer: fine) {
  .ewc-item:hover .material-symbols-outlined[data-ic] { animation: xuPop 0.5s var(--xu-ease-out); }
  .ewc-item:hover [data-ic="home"] { animation-name: xuHop; }
  .ewc-item:hover [data-ic="monitoring"] { animation-name: xuGrow; transform-origin: 50% 85%; }
  .ewc-item:hover [data-ic="smart_toy"], .ewc-item:hover [data-ic="robot_2"] { animation-name: xuWiggle; }
  .ewc-item:hover [data-ic="calendar_month"] { animation-name: xuSwing; transform-origin: 50% 10%; }
  .ewc-item:hover [data-ic="school"] { animation-name: xuTilt; }
  .ewc-item:hover [data-ic="calculate"] { animation-name: xuShake; }
  .ewc-item:hover [data-ic="palette"] { animation-name: xuSpin; }
  .ewc-item:hover [data-ic="bolt"] { animation-name: xuFlash; }
}
@keyframes xuPop { 40% { transform: scale(1.14); } }
@keyframes xuHop { 35% { transform: translateY(-4px); } 65% { transform: translateY(0); } 80% { transform: translateY(-1.5px); } }
@keyframes xuGrow { 0% { transform: scaleY(0.6); } 60% { transform: scaleY(1.08); } }
@keyframes xuWiggle { 20% { transform: rotate(-12deg); } 45% { transform: rotate(10deg); } 70% { transform: rotate(-5deg); } }
@keyframes xuSwing { 25% { transform: rotate(10deg); } 55% { transform: rotate(-7deg); } 80% { transform: rotate(3deg); } }
@keyframes xuTilt { 40% { transform: rotate(-14deg) translateY(-2px); } }
@keyframes xuShake { 20% { transform: translateX(-2px) rotate(-6deg); } 40% { transform: translateX(2px) rotate(6deg); } 60% { transform: translateX(-1px); } }
@keyframes xuSpin { to { transform: rotate(360deg); } }
@keyframes xuFlash { 30% { opacity: 0.35; transform: scale(1.15); } }

/* ---- Nút đổi giao diện sáng / tối (Theme Toggler) ---- */
.xsg-mode-btn { width: 100%; border: none; background: none; cursor: pointer; font: inherit; color: inherit; }
.ewc-side-foot .xsg-mode-btn { border-top: 1px solid var(--ewc-line); }
.xsg-mode-ic { position: relative; display: inline-grid; place-items: center; width: 26px; height: 26px; }
.xsg-mode-ic svg { grid-area: 1 / 1; width: 23px; height: 23px; transition: transform 0.3s var(--xu-ease-out), opacity 0.3s var(--xu-ease-out), filter 0.3s var(--xu-ease-out); }
.xsg-mode-ic .moon, html.ewc-dark .xsg-mode-ic .sun { opacity: 1; transform: none; filter: none; }
.xsg-mode-ic .sun, html.ewc-dark .xsg-mode-ic .moon { opacity: 0; transform: rotate(90deg) scale(0.5); filter: blur(2px); }
.xsg-mode-btn:hover .xsg-mode-ic svg { color: var(--ewc-gold); }
.xsg-mode-btn .l-dark, html.ewc-dark .xsg-mode-btn .l-light { display: inline; }
.xsg-mode-btn .l-light, html.ewc-dark .xsg-mode-btn .l-dark { display: none; }
.ewc-mtop .xsg-mode-btn { width: 40px; height: 40px; border-radius: 12px; background: var(--ewc-bg); display: inline-grid; place-items: center; padding: 0; margin-left: auto; }
.ewc-mtop .xsg-mode-btn .l { display: none !important; }
/* hiệu ứng quét: lớp giao diện mới mở rộng thành vòng tròn từ chính nút bấm */
html.xsg-vt::view-transition-old(root), html.xsg-vt::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
html.xsg-vt::view-transition-new(root) { z-index: 2; }

/* ---- Avatar tài khoản: vuông, không bo góc (logo chữ XSG là ảnh vuông có khung + chữ XSG26 ở góc — bo góc làm mất ảnh) ---- */
.xsg-av { display: inline-block; flex-shrink: 0; line-height: 0; border-radius: 0; overflow: hidden; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35); }
.xsg-av svg, .xsg-av img { display: block; width: 100%; height: 100%; object-fit: cover; }
.ewc-side-foot .ewc-login .xsg-av { width: 34px; height: 34px; }
.ewc-sheet .ewc-item .xsg-av { width: 30px; height: 30px; }
.ewc-mtop .ewc-btn .xsg-av { width: 22px; height: 22px; margin: -4px 0; }
.ewc-login.ewc-logged-in .l { max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Mục "Tôi" trên menu chính (2026-10-25): đã đăng nhập thì ảnh đại diện thay icon, cỡ ngang icon. */
.ewc-item.ewc-me .xsg-av { width: 28px; height: 28px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3); }
.ewc-bottom .ewc-item.ewc-me .xsg-av { width: 24px; height: 24px; }

/* ---- Chữ lật kiểu Rolling Text (tiêu đề trang) ---- */
.xr-w { display: inline-block; white-space: nowrap; }
.xr-c { position: relative; display: inline-block; perspective: 9999999px; transform-style: preserve-3d; }
.xr-f, .xr-b { position: absolute; left: 0; top: 0; display: inline-block; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.xr-f { transform-origin: 50% 25%; animation: xrOut 0.5s cubic-bezier(0, 0, 0.58, 1) var(--d) both; }
.xr-b { transform-origin: 50% 100%; animation: xrIn 0.5s cubic-bezier(0, 0, 0.58, 1) calc(var(--d) + 0.3s) both; }
.xr-s { visibility: hidden; }
@keyframes xrOut { from { transform: rotateX(0deg); } to { transform: rotateX(90deg); } }
@keyframes xrIn { from { transform: rotateX(90deg); } to { transform: rotateX(0deg); } }
.ewc-hero h1.ewc-hero-title.xr-on { animation: none !important; }
.ewc-hero h1.ewc-hero-title.xr-on .g.xr-g { background: none !important; -webkit-text-fill-color: currentColor; }
.xr-g .xr-f, .xr-g .xr-b { -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
/* Tiêu đề line-height:1 → hộp chữ chỉ cao 1em, dấu chồng trên chữ hoa có mũ (Ế, Ờ, Ủ…) nhô ra ngoài
   hộp nên không được tô gradient (background-clip:text chỉ tô trong hộp) → trông như mất dấu.
   Nới hộp lên/xuống bằng padding, kéo ngược bằng top âm để chữ giữ nguyên chỗ. */
.xr-g .xr-f, .xr-g .xr-b { top: -0.45em; padding: 0.45em 0 0.3em; }
.ewc-hero h1.ewc-hero-title .g { padding: 0.45em 0 0.3em; }

@media (prefers-reduced-motion: reduce) {
  .xsg-hl, .xsg-mode-ic svg { transition: opacity 0.2s ease !important; }
  .ewc-item:hover .material-symbols-outlined[data-ic] { animation: none !important; }
  .xr-f { animation: none; opacity: 0; }
  .xr-b { animation: none; }
}

/* Màn thấp (laptop 768–900px): chân menu có 3 mục (sáng/tối, giao diện cũ, tài khoản) → thu gọn mục để
   menu dọc vừa khít, không phải cuộn mới thấy "Bot của bạn". */
@media (min-width: 1024px) and (max-height: 900px) {
  .ewc-logo { padding: 14px 6px 8px; }
  .ewc-logo .m { width: 40px; height: 40px; border-radius: 12px; }
  .ewc-item { padding: 7px 4px; gap: 3px; }
  .ewc-item .material-symbols-outlined { font-size: 23px; }
  .xsg-mode-ic { width: 23px; height: 23px; }
  .xsg-mode-ic svg { width: 20px; height: 20px; }
  .ewc-side-foot .ewc-login .xsg-av { width: 28px; height: 28px; }
}
