/* AGS shell — khung nav/auth chung cho website ags.sh.
   Tông màu đồng bộ /khoe (nền sáng, chữ đậm, tab xanh). */
:root {
  --ags-bg: #f4f4f5;
  --ags-ink: #111;
  --ags-muted: #737373;
  --ags-line: #e5e5e5;
  --ags-panel: #fff;
  --ags-tab: #3b82f6;
  --ags-tab-idle: #d4d4d8;
  --ags-ok: #16a34a;
  --ags-danger: #dc2626;
  --ags-shell-h: 56px;
  --ags-font: 400 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.ags-shell {
  position: sticky;
  top: 0;
  z-index: 1000;
  height: var(--ags-shell-h);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--ags-line);
  font: var(--ags-font);
  color: var(--ags-ink);
  -webkit-font-smoothing: antialiased;
}

.ags-shell *,
.ags-shell *::before,
.ags-shell *::after {
  box-sizing: border-box;
}

.ags-shell-inner {
  max-width: 1100px;
  margin: 0 auto;
  height: 100%;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.ags-shell-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--ags-ink);
  font-weight: 700;
  letter-spacing: -0.02em;
  flex: 0 0 auto;
}

.ags-shell-logo {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--ags-ink);
  color: #fff;
}

.ags-shell-logo svg {
  width: 16px;
  height: 16px;
}

.ags-shell-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1 1 auto;
  min-width: 0;
}

.ags-shell-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--ags-muted);
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}

.ags-shell-nav a:hover {
  color: var(--ags-ink);
  background: #f4f4f5;
}

.ags-shell-nav a.active {
  color: var(--ags-tab);
  background: #eff6ff;
}

.ags-shell-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.ags-shell-burger {
  display: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--ags-line);
  border-radius: 10px;
  background: var(--ags-panel);
  color: var(--ags-ink);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.ags-shell-burger svg {
  width: 18px;
  height: 18px;
}

.ags-shell-auth {
  position: relative;
}

.ags-shell-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 11px;
  border: 1px solid var(--ags-line);
  background: var(--ags-panel);
  color: var(--ags-ink);
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
}

.ags-shell-btn:hover {
  border-color: #cbd5e1;
}

.ags-shell-btn.primary {
  background: var(--ags-tab);
  border-color: var(--ags-tab);
  color: #fff;
}

.ags-shell-btn.primary:hover {
  filter: brightness(0.96);
}

.ags-shell-av {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  object-fit: cover;
  background: #e2e8f0;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  color: var(--ags-ink);
  overflow: hidden;
  flex: 0 0 auto;
}

.ags-shell-av img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ags-shell-nm {
  max-width: 28vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ags-shell-caret {
  width: 14px;
  height: 14px;
  opacity: 0.65;
  transition: transform 0.15s;
}

.ags-shell-auth.open .ags-shell-caret {
  transform: rotate(180deg);
}

.ags-shell-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 220px;
  z-index: 40;
  background: var(--ags-panel);
  border: 1px solid var(--ags-line);
  border-radius: 14px;
  padding: 6px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
  display: none;
}

.ags-shell-auth.open .ags-shell-menu {
  display: block;
}

.ags-shell-menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--ags-ink);
  font-weight: 600;
  font-size: 14px;
}

.ags-shell-menu a:hover {
  background: #f4f4f5;
}

.ags-shell-menu a.danger {
  color: var(--ags-danger);
}

.ags-shell-menu hr {
  border: none;
  border-top: 1px solid var(--ags-line);
  margin: 4px 6px;
}

.ags-shell-menu .note {
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.4;
  color: #b45309;
}

.ags-shell-menu .ico {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

/* Mobile: thu gọn nav */
@media (max-width: 760px) {
  .ags-shell-burger {
    display: inline-flex;
  }

  .ags-shell-nav {
    display: none;
    position: absolute;
    left: 12px;
    right: 12px;
    top: calc(var(--ags-shell-h) + 6px);
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding: 8px;
    background: var(--ags-panel);
    border: 1px solid var(--ags-line);
    border-radius: 14px;
    box-shadow: 0 16px 36px rgba(15, 23, 42, 0.12);
  }

  .ags-shell.open .ags-shell-nav {
    display: flex;
  }

  .ags-shell-nav a {
    min-height: 44px;
  }

  .ags-shell-nm {
    max-width: 34vw;
  }
}

/* Trang dùng shell: đẩy nội dung khỏi sticky bar */
body.has-ags-shell {
  padding-top: 0;
}

/* shell sticky nằm trong flow (đã chiếm --ags-shell-h) — KHÔNG cộng thêm chiều cao nav
   vào padding main (tránh khoảng trống lớn trên /khoe 390). Chỉ chừa khe nhẹ dưới nav. */
body.has-ags-shell main {
  padding-top: 20px;
}
@media (max-width: 480px) {
  body.has-ags-shell main {
    padding-top: 8px;
  }
}
body.has-ags-shell .ags-shell {
  z-index: 1000;
}
body.has-ags-shell .race.full {
  z-index: 9999;
}

/* Toast nhẹ — thay alert() native */
.ags-toast-host {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: min(420px, calc(100% - 24px));
}

.ags-toast {
  pointer-events: auto;
  background: var(--ags-ink);
  color: #fff;
  border-radius: 12px;
  padding: 12px 16px;
  font: 600 14px/1.35 system-ui, -apple-system, "Segoe UI", sans-serif;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.18s, transform 0.18s;
}

.ags-toast.show {
  opacity: 1;
  transform: translateY(0);
}
