/* ============================================================
 * IT LEARN — Page navigation utilities (reusable)
 *   • Section nav (right-side dot navigation)
 *   • Back-to-top button
 *   • Footer social icons
 *   • Active state for cross-page nav links
 * ============================================================ */

/* Offset cho sticky header khi scroll tới section */
section[id] { scroll-margin-top: 80px; }

/* External link arrow indicator (Portal, Bài tập...) */
.nav-ext {
  display: inline-block;
  margin-left: 2px;
  font-size: 0.85em;
  opacity: 0.6;
  transition: transform .15s ease, opacity .15s ease;
}
.nav-links a:hover .nav-ext {
  opacity: 1;
  transform: translate(1px, -1px);
}

/* Active state cho nav link đang ở trang hiện tại — underline mảnh, không tô nền */
.nav-links a.active {
  color: var(--text, #f1f5f9);
  background: none;
  position: relative;
}
.nav-links a.active::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 2px;
  height: 2px;
  border-radius: 1px;
  background: var(--red-2, #ef4444);
}

/* ====================================
 * DROPDOWN MENU (Khóa học)
 * Desktop: hover hoặc click toggle.
 * Mobile: nested list trong drawer.
 * ==================================== */
.nav-dropdown { position: relative; }
.nav-dropdown-toggle {
  background: transparent;
  border: 0;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-dim, #94a3b8);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color .2s, background .2s;
}
.nav-dropdown-toggle:hover {
  color: var(--text, #f1f5f9);
  background: rgba(255,255,255,.05);
}
.nav-dropdown-caret {
  transition: transform .2s ease;
  flex-shrink: 0;
  margin-top: 1px;
}
.nav-dropdown.is-open .nav-dropdown-caret {
  transform: rotate(180deg);
}

/* Active state — page hiện tại nằm trong dropdown → toggle nổi bật */
.nav-dropdown.is-active > .nav-dropdown-toggle {
  color: var(--text, #f1f5f9);
  position: relative;
}
.nav-dropdown.is-active > .nav-dropdown-toggle::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 26px;
  bottom: 2px;
  height: 2px;
  border-radius: 1px;
  background: var(--red-2, #ef4444);
}

/* Desktop dropdown panel */
@media (min-width: 980px) {
  .nav-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(-6px);
    min-width: 220px;
    padding: 8px;
    background: rgba(14, 22, 46, .96);
    backdrop-filter: blur(18px) saturate(140%);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
    border: 1px solid var(--line, rgba(255,255,255,.08));
    border-radius: 14px;
    box-shadow: 0 24px 48px -12px rgba(0,0,0,.5);
    display: flex;
    flex-direction: column;
    gap: 2px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .18s ease, transform .18s ease, visibility 0s linear .18s;
    z-index: 100;
  }
  /* Bridge phủ vùng gap 8px giữa toggle và menu — tránh cursor "rơi" ra ngoài
     khi di chuyển từ toggle xuống submenu → submenu bị đóng. */
  .nav-dropdown-menu::before {
    content: "";
    position: absolute;
    top: -12px;
    left: 0;
    right: 0;
    height: 12px;
  }
  .nav-dropdown:hover .nav-dropdown-menu,
  .nav-dropdown:focus-within .nav-dropdown-menu,
  .nav-dropdown.is-open .nav-dropdown-menu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
    transition: opacity .18s ease, transform .18s ease, visibility 0s;
  }
  .nav-dropdown-menu a {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-dim, #94a3b8);
    white-space: nowrap;
    transition: color .15s, background .15s;
  }
  .nav-dropdown-menu a:hover,
  .nav-dropdown-menu a:focus-visible {
    color: var(--text, #f1f5f9);
    background: rgba(255,255,255,.06);
  }
  .nav-dropdown-menu a.active {
    color: var(--text, #f1f5f9);
    background: linear-gradient(135deg, rgba(220,38,38,.18), rgba(220,38,38,.08));
  }
  .nav-dropdown-menu a.active::after { display: none; }

  /* Light mode dropdown */
  [data-theme="light"] .nav-dropdown-menu {
    background: rgba(255, 255, 255, .98);
    border-color: rgba(15, 23, 42, .10);
    box-shadow: 0 24px 48px -12px rgba(15, 23, 42, .18);
  }
  [data-theme="light"] .nav-dropdown-menu a { color: var(--text-dim); }
  [data-theme="light"] .nav-dropdown-menu a:hover {
    color: var(--text);
    background: rgba(15, 23, 42, .05);
  }
  [data-theme="light"] .nav-dropdown-menu a.active {
    color: var(--text);
    background: linear-gradient(135deg, rgba(220,38,38,.14), rgba(220,38,38,.06));
  }
}

/* Mobile: dropdown render inline trong drawer (không float, không position absolute) */
@media (max-width: 979px) {
  .nav-dropdown { display: contents; }
  .nav-dropdown-toggle { display: none; }
  .nav-dropdown-menu {
    display: contents;
  }
  .nav-dropdown-menu a {
    /* Nhận style từ drawer rules ở dưới */
  }
}

/* ====================================
 * PER-PAGE BACKGROUND TINT
 *   Mỗi trang có ambient màu riêng để phân biệt nhanh
 *   bằng mắt — brand đỏ vẫn giữ ở buttons & text.
 * ==================================== */

/* Trang chủ: red + navy mix (full brand) */
body.page-home {
  --bg-glow-1: rgba(220, 38, 38, .42);   /* red strong top-right */
  --bg-glow-2: rgba(37, 99, 235, .38);   /* navy strong left */
  --bg-glow-3: rgba(255, 108, 55, .15);  /* orange hint bottom (Postman accent) */
}

/* Manual Testing: đỏ chủ đạo */
body.page-manual {
  --bg-glow-1: rgba(220, 38, 38, .35);   /* red strong */
  --bg-glow-2: rgba(30, 64, 175, .25);   /* navy */
  --bg-glow-3: rgba(220, 38, 38, .18);   /* red soft */
}

/* ISTQB CTFL: navy chủ đạo (match logo ISTQB) */
body.page-istqb {
  --bg-glow-1: rgba(37, 99, 235, .50);   /* navy strong top-right */
  --bg-glow-2: rgba(96, 165, 250, .35);  /* light blue accent */
  --bg-glow-3: rgba(220, 38, 38, .12);   /* red brand hint */
}

/* AI for Tester: tím chủ đạo (theme AI) — override --red-* tokens với violet
   để tận dụng toàn bộ component reuse mà không cần class-rename. */
body.page-ai {
  --bg-glow-1: rgba(139, 92, 246, .48);   /* violet strong top-right */
  --bg-glow-2: rgba(168, 85, 247, .35);   /* lighter violet left */
  --bg-glow-3: rgba(56, 189, 248, .22);   /* cyan accent bottom */

  --red:        #8b5cf6;
  --red-2:      #a855f7;
  --red-bright: #c4b5fd;
  --red-soft:   #ddd6fe;
  --red-deep:   #6d28d9;
  --grad:       linear-gradient(135deg, #a855f7 0%, #8b5cf6 60%, #6d28d9 100%);
  --shadow-red: 0 20px 60px -20px rgba(139, 92, 246, .55);
}
body.page-ai .gradient-text {
  background-image: linear-gradient(120deg, #ddd6fe 0%, #a855f7 40%, #c4b5fd 100%);
}
/* page-ai: underline tự dùng màu violet vì --red-2 đã override sang #a855f7 — không cần rule riêng */
/* Override price-card featured red gradient → violet */
body.page-ai .price-card.feat {
  background: linear-gradient(180deg, #4c1d95 0%, #2e1065 100%);
  border-color: rgba(196, 181, 253, .35);
}

/* API Postman: cam chủ đạo (match Postman #ff6c37) */
body.page-api {
  --bg-glow-1: rgba(255, 108, 55, .45);  /* postman orange top-right */
  --bg-glow-2: rgba(30, 64, 175, .22);   /* navy left */
  --bg-glow-3: rgba(251, 146, 60, .20);  /* light orange bottom */
}

/* Automation Playwright: green chủ đạo (match Playwright leaf logo).
   Tông xanh lá đậm/sáng theo brand spec; phân biệt với emerald của Performance bằng tone vàng-xanh ấm hơn.
   Override --red-* tokens để toàn bộ component (button, badge, gradient) đổi màu mà không cần class-rename. */
body.page-playwright {
  --bg-glow-1: rgba(35, 173, 45, .45);    /* playwright bright green top-right */
  --bg-glow-2: rgba(28, 137, 32, .30);    /* playwright dark green left */
  --bg-glow-3: rgba(134, 239, 172, .18);  /* mint green bottom (soft accent) */

  --red:        #1c8920;
  --red-2:      #23ad2d;
  --red-bright: #4ade80;
  --red-soft:   #86efac;
  --red-deep:   #14532d;
  --grad:       linear-gradient(135deg, #23ad2d 0%, #1c8920 60%, #14532d 100%);
  --shadow-red: 0 20px 60px -20px rgba(35, 173, 45, .55);
}
body.page-playwright .gradient-text {
  background-image: linear-gradient(120deg, #86efac 0%, #23ad2d 40%, #4ade80 100%);
}
body.page-playwright .price-card.feat {
  background: linear-gradient(180deg, #14532d 0%, #052e16 100%);
  border-color: rgba(134, 239, 172, .35);
}
/* Module-tag global hard-code bg đỏ (rgba(220,38,38,.12)) — clash với green theme.
   Override bg + border sang green tint, đồng thời chỉnh text-color light/dark mode để đảm bảo WCAG AA. */
body.page-playwright .module-tag {
  color: #4ade80;                              /* dark mode: bright green trên bg tối */
  background: rgba(35, 173, 45, .16);
  border: 1px solid rgba(74, 222, 128, .28);
}
[data-theme="light"] body.page-playwright .module-tag {
  color: #15803d;                              /* light mode: green-700 — contrast ≥ 4.8:1 trên white */
  background: rgba(35, 173, 45, .12);
  border-color: rgba(28, 137, 32, .35);
}

/* Quality Engineer Combo: fuchsia/magenta chủ đạo — khoá flagship combo Manual + Automation + AI.
   Phân biệt với violet (ai-tester) bằng tone hồng-tím ấm hơn. */
body.page-qe {
  --bg-glow-1: rgba(192, 38, 211, .42);    /* fuchsia strong top-right */
  --bg-glow-2: rgba(162, 28, 175, .30);    /* darker magenta left */
  --bg-glow-3: rgba(232, 121, 249, .18);   /* light fuchsia bottom */

  --red:        #c026d3;
  --red-2:      #d946ef;
  --red-bright: #e879f9;
  --red-soft:   #f5d0fe;
  --red-deep:   #86198f;
  --grad:       linear-gradient(135deg, #d946ef 0%, #c026d3 60%, #86198f 100%);
  --shadow-red: 0 20px 60px -20px rgba(192, 38, 211, .55);
}
body.page-qe .gradient-text {
  background-image: linear-gradient(120deg, #f5d0fe 0%, #c026d3 40%, #e879f9 100%);
}
body.page-qe .price-card.feat {
  background: linear-gradient(180deg, #4a044e 0%, #2e1065 100%);
  border-color: rgba(245, 208, 254, .35);
}
body.page-qe .module-tag {
  color: #e879f9;
  background: rgba(192, 38, 211, .16);
  border: 1px solid rgba(232, 121, 249, .28);
}
[data-theme="light"] body.page-qe .module-tag {
  color: #86198f;                              /* fuchsia-800 — contrast trên white */
  background: rgba(192, 38, 211, .12);
  border-color: rgba(162, 28, 175, .35);
}

/* ====================================
 * MOBILE BURGER MENU
 *   Auto-injected vào .site-header .nav bởi page-nav.js.
 *   Hiện <980px (cùng breakpoint với .nav-links).
 * ==================================== */
.nav-burger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  margin-left: 8px;
  padding: 0;
  border: 1px solid var(--line, rgba(255,255,255,.08));
  background: rgba(255,255,255,.04);
  border-radius: 10px;
  color: var(--text, #f1f5f9);
  cursor: pointer;
  transition: background .2s, border-color .2s;
}
.nav-burger:hover {
  background: rgba(255,255,255,.08);
  border-color: var(--line-strong, rgba(255,255,255,.14));
}
.nav-burger .bar,
.nav-burger .bar::before,
.nav-burger .bar::after {
  display: block;
  width: 20px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: transform .25s ease, top .25s ease, background .15s ease;
}
.nav-burger .bar { position: relative; }
.nav-burger .bar::before,
.nav-burger .bar::after {
  content: '';
  position: absolute;
  left: 0;
}
.nav-burger .bar::before { top: -7px; }
.nav-burger .bar::after  { top:  7px; }
.nav-burger.is-active .bar { background: transparent; }
.nav-burger.is-active .bar::before { top: 0; transform: rotate(45deg); }
.nav-burger.is-active .bar::after  { top: 0; transform: rotate(-45deg); }

@media (min-width: 980px) {
  .nav-burger { display: none; }
}

/* Safety net: nếu có theme toggle bị clone nhầm vào nav-links → ẩn cứng */
.nav-links [data-theme-toggle] { display: none !important; }

/* Mobile drawer khi .nav-links có class .is-open */
@media (max-width: 979px) {
  .nav-links.is-open {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    padding: 14px 18px 20px;
    background: rgba(8, 13, 31, .96);
    backdrop-filter: blur(18px) saturate(140%);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
    border-top: 1px solid var(--line, rgba(255,255,255,.08));
    border-bottom: 1px solid var(--line, rgba(255,255,255,.08));
    box-shadow: 0 18px 40px rgba(0,0,0,.5);
    animation: navSlideDown .22s ease-out;
  }
  .nav-links.is-open a {
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 15px;
  }

  /* Light mode: drawer white bg + dark text */
  [data-theme="light"] .nav-links.is-open {
    background: rgba(255, 255, 255, .96);
    border-top-color: rgba(15, 23, 42, .10);
    border-bottom-color: rgba(15, 23, 42, .10);
    box-shadow: 0 18px 40px rgba(15, 23, 42, .15);
  }
  [data-theme="light"] .nav-links.is-open a {
    color: var(--text);
  }
  [data-theme="light"] .nav-links.is-open a:hover {
    background: rgba(15, 23, 42, .05);
  }
}
@keyframes navSlideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ====================================
 * SECTION NAV (right-side dots, desktop only)
 * ==================================== */
.section-nav {
  position: fixed;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 40;
  display: none;
}
@media (min-width: 1100px) {
  .section-nav { display: block; }
}
.section-nav ul {
  list-style: none;
  margin: 0;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: rgba(8, 13, 31, .55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line, rgba(255,255,255,.08));
  border-radius: 999px;
}
.section-nav a {
  display: flex;
  align-items: center;
  padding: 8px;
  border-radius: 999px;
  color: var(--text-dim, #94a3b8);
  text-decoration: none;
  position: relative;
  transition: background .2s;
}
.section-nav a:hover { background: rgba(255, 255, 255, .04); }
.section-nav .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .25);
  flex-shrink: 0;
  transition: all .3s ease;
}
.section-nav a:hover .dot,
.section-nav a.active .dot {
  background: var(--red-bright, #f87171);
  box-shadow: 0 0 12px rgba(248, 113, 113, .55);
}
.section-nav a.active .dot {
  width: 22px;
  border-radius: 4px;
}
.section-nav .label {
  position: absolute;
  right: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%) translateX(8px);
  font-size: 11px;
  font-family: var(--mono, monospace);
  color: var(--text, #f1f5f9);
  background: rgba(8, 13, 31, .94);
  border: 1px solid var(--line-strong, rgba(255,255,255,.14));
  border-radius: 6px;
  padding: 6px 10px;
  white-space: nowrap;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-weight: 500;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s, transform .2s;
}
.section-nav a:hover .label {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

/* ── Light mode override cho section-nav ── */
[data-theme="light"] .section-nav ul {
  background: rgba(255, 255, 255, .85);
  border-color: rgba(15, 23, 42, .12);
}
[data-theme="light"] .section-nav a:hover { background: rgba(15, 23, 42, .05); }
[data-theme="light"] .section-nav .dot { background: rgba(15, 23, 42, .25); }
[data-theme="light"] .section-nav a:hover .dot,
[data-theme="light"] .section-nav a.active .dot {
  background: #ef4444;
  box-shadow: 0 0 8px rgba(220, 38, 38, .25);  /* dịu hơn, đỡ chóe */
}
[data-theme="light"] .section-nav .label {
  background: #ffffff;
  color: #0f172a;
  border-color: rgba(15, 23, 42, .14);
  box-shadow: 0 4px 12px rgba(15, 23, 42, .08);
}

/* ====================================
 * BACK-TO-TOP BUTTON
 * ==================================== */
.btn-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 50;
  width: 100px;
  height: 100px;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity .3s, transform .3s ease, filter .25s ease;
  filter: drop-shadow(0 8px 18px rgba(220, 38, 38, .35));
}
.btn-to-top img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
}
.btn-to-top.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.btn-to-top:hover {
  transform: translateY(-4px) scale(1.06);
  filter: drop-shadow(0 14px 24px rgba(220, 38, 38, .55));
}
@media (max-width: 480px) {
  .btn-to-top {
    width: 60px;
    height: 60px;
    bottom: 16px;
    right: 16px;
  }
}

/* ====================================
 * FOOTER SOCIAL ICONS
 * ==================================== */
.foot-social {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin: 18px 0 0;
}
.foot-social a {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--line, rgba(255,255,255,.08));
  display: grid;
  place-items: center;
  color: var(--text-dim, #94a3b8);
  transition: all .25s ease;
}
.foot-social a:hover {
  background: rgba(248, 113, 113, .14);
  border-color: rgba(248, 113, 113, .4);
  color: var(--red-bright, #f87171);
  transform: translateY(-2px);
}
.foot-social svg {
  width: 18px;
  height: 18px;
}

/* ====================================
 * FLOATING ACTION BUTTONS (Facebook / Zalo / Phone)
 * Stacked above .btn-to-top, hidden when footer enters viewport.
 * ==================================== */
.float-actions {
  position: fixed;
  left: 24px;
  bottom: 24px;
  z-index: 49;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: opacity .3s ease, transform .3s ease;
}
.float-actions.footer-visible {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
}
.float-actions a {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  transition: transform .2s ease, box-shadow .25s ease, filter .2s ease;
  /* Entrance: slide in from left, staggered via :nth-child below */
  animation: fab-slide-in .55s cubic-bezier(.34, 1.56, .64, 1) backwards;
}
.float-actions a:nth-child(1) { animation-delay: .15s; }
.float-actions a:nth-child(2) { animation-delay: .25s; }
.float-actions a:nth-child(3) { animation-delay: .35s; }
.float-actions a:hover {
  transform: translateY(-3px) scale(1.08);
  filter: brightness(1.1);
}
.float-actions svg {
  width: 22px;
  height: 22px;
  transition: transform .25s cubic-bezier(.34, 1.56, .64, 1);
}
.float-actions a:hover svg {
  transform: rotate(-12deg) scale(1.12);
}

/* Brand-aligned gradients matching site palette (navy + red) */
.float-actions .fab-facebook {
  background: linear-gradient(135deg, #3b82f6 0%, #1e40af 100%);
  box-shadow: 0 8px 20px -4px rgba(30, 64, 175, .55);
}
.float-actions .fab-zalo {
  background: linear-gradient(135deg, #60a5fa 0%, #2563eb 100%);
  box-shadow: 0 8px 20px -4px rgba(37, 99, 235, .5);
}
.float-actions .fab-phone {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 60%, #991b1b 100%);
  box-shadow: 0 8px 20px -4px rgba(220, 38, 38, .55);
  /* Continuous "ring" pulse — the call-me cue */
  animation: fab-slide-in .55s cubic-bezier(.34, 1.56, .64, 1) backwards,
             fab-ring-pulse 2s ease-out 1s infinite;
}
.float-actions .fab-phone svg {
  /* Periodic gentle shake (mostly idle, ~10% of the cycle) */
  animation: fab-phone-shake 5s ease-in-out 2s infinite;
  transform-origin: 50% 60%;
}

@keyframes fab-slide-in {
  from { opacity: 0; transform: translateX(-24px) scale(.8); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes fab-ring-pulse {
  0%   { box-shadow: 0 8px 20px -4px rgba(220, 38, 38, .55), 0 0 0 0 rgba(239, 68, 68, .55); }
  70%  { box-shadow: 0 8px 20px -4px rgba(220, 38, 38, .55), 0 0 0 18px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 8px 20px -4px rgba(220, 38, 38, .55), 0 0 0 0 rgba(239, 68, 68, 0); }
}
@keyframes fab-phone-shake {
  0%, 88%, 100% { transform: rotate(0); }
  90% { transform: rotate(-14deg); }
  92% { transform: rotate(12deg); }
  94% { transform: rotate(-10deg); }
  96% { transform: rotate(8deg); }
  98% { transform: rotate(-4deg); }
}

@media (prefers-reduced-motion: reduce) {
  .float-actions a,
  .float-actions .fab-phone,
  .float-actions .fab-phone svg,
  .float-actions svg {
    animation: none !important;
    transition: opacity .3s ease, transform .3s ease !important;
  }
}
@media (max-width: 480px) {
  .float-actions {
    left: 16px;
    bottom: 16px;
    gap: 10px;
  }
  .float-actions a {
    width: 44px;
    height: 44px;
  }
  .float-actions svg {
    width: 20px;
    height: 20px;
  }
}
