/* =========================================================
   TRANG DANH SÁCH ĐỀ THI JLPT N4
   Tất cả class đều có tiền tố n4- để tránh ghi đè CSS hiện tại.
   ========================================================= */

.n4-exam-page {
  --n4-page-bg: #fbfbfe;
  --n4-surface: #ffffff;
  --n4-surface-soft: #faf7ff;
  --n4-text: #12183b;
  --n4-muted: #7e83a2;
  --n4-border: #ece9f7;
  --n4-primary: #2563eb;
  --n4-primary-2: #3b82f6;
  --n4-primary-soft: #eff6ff;
  --n4-track: #e8f0ff;
  --n4-shadow: 0 12px 32px rgba(43, 31, 91, 0.08);

  min-height: 100vh;
  margin: 0;
  background: var(--n4-page-bg);
  color: var(--n4-text);
  font-family: "Poppins", "Noto Sans JP", sans-serif;
}

.n4-exam-page *,
.n4-exam-page *::before,
.n4-exam-page *::after {
  box-sizing: border-box;
}


/* =========================================================
   HEADER TRANG DANH SÁCH ĐỀ N4
   ========================================================= */

.n4-page-header {
  position: sticky;
  top: 0;
  z-index: 1000;

  min-height: 74px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 20px;

  padding: 12px clamp(22px, 3.2vw, 54px);

  border-bottom: 1px solid #e5eaf3;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.07);
  backdrop-filter: blur(14px);
}

.n4-header-back {
  min-width: 126px;
  min-height: 46px;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  justify-self: start;
  gap: 10px;

  padding: 0 18px;

  border: 1px solid #dbe3ef;
  border-radius: 11px;
  background: #ffffff;
  color: #475569;
  box-shadow: 0 4px 13px rgba(15, 23, 42, 0.04);

  text-decoration: none;
  font-size: 14px;
  font-weight: 600;

  transition:
    border-color 0.2s ease,
    color 0.2s ease,
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.n4-header-back svg {
  width: 20px;
  height: 20px;

  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.n4-header-back:hover {
  transform: translateX(-3px);
  border-color: #93c5fd;
  color: var(--n4-primary);
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.1);
}

.n4-header-brand {
  display: inline-flex;
  align-items: center;
  justify-self: center;
  gap: 11px;

  color: var(--n4-text);
  text-decoration: none;
  white-space: nowrap;
}

.n4-brand-flower {
  font-size: 29px;
  line-height: 1;
}

.n4-header-brand strong {
  font-size: 25px;
  font-weight: 800;
  letter-spacing: -0.035em;
}

.n4-brand-level {
  min-width: 47px;
  min-height: 34px;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  padding: 0 13px;

  border-radius: 9px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #ffffff;
  box-shadow: 0 7px 16px rgba(37, 99, 235, 0.22);

  font-size: 15px;
  font-weight: 800;
}

.n4-header-actions {
  display: flex;
  align-items: center;
  justify-self: end;
  gap: 10px;
}

.n4-header-icon-button {
  position: relative;

  width: 46px;
  height: 46px;

  display: grid;
  place-items: center;

  padding: 0;

  border: 1px solid #dbe3ef;
  border-radius: 12px;
  background: #ffffff;
  color: #334155;
  box-shadow: 0 4px 13px rgba(15, 23, 42, 0.04);

  cursor: pointer;

  transition:
    border-color 0.2s ease,
    background 0.2s ease,
    color 0.2s ease,
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.n4-header-icon-button:hover {
  transform: translateY(-2px);
  border-color: #93c5fd;
  color: var(--n4-primary);
  box-shadow: 0 9px 20px rgba(37, 99, 235, 0.12);
}

.n4-header-icon-button svg {
  width: 22px;
  height: 22px;

  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.n4-theme-sun {
  display: none;
}

.n4-notification-dot {
  position: absolute;
  top: 8px;
  right: 8px;

  width: 8px;
  height: 8px;

  border: 2px solid #ffffff;
  border-radius: 50%;
  background: #2563eb;
}

/* Header trong Dark Mode */
html.dark .n4-page-header,
body.dark .n4-page-header {
  border-bottom-color: #26354b;
  background: rgba(10, 20, 36, 0.96);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.26);
}

html.dark .n4-header-back,
html.dark .n4-header-icon-button,
body.dark .n4-header-back,
body.dark .n4-header-icon-button {
  border-color: #334155;
  background: #111c30;
  color: #e2e8f0;
  box-shadow: none;
}

html.dark .n4-header-back:hover,
html.dark .n4-header-icon-button:hover,
body.dark .n4-header-back:hover,
body.dark .n4-header-icon-button:hover {
  border-color: #60a5fa;
  background: #17233a;
  color: #93c5fd;
}

html.dark .n4-header-brand,
body.dark .n4-header-brand {
  color: #f8fafc;
}

html.dark .n4-theme-moon,
body.dark .n4-theme-moon {
  display: none;
}

html.dark .n4-theme-sun,
body.dark .n4-theme-sun {
  display: block;
}

html.dark .n4-notification-dot,
body.dark .n4-notification-dot {
  border-color: #111c30;
}

/* Không dùng nút quay lại cũ bên trong phần nội dung */
.n4-back-link {
  display: none !important;
}

.n4-exam-shell {
  width: min(1500px, calc(100% - 48px));
  margin: 0 auto;
  padding: 32px 0 56px;

  display: grid;
  grid-template-columns: minmax(0, 1.9fr) minmax(360px, 0.95fr);
  gap: 42px;
  align-items: start;
}

/* ---------- Tiêu đề ---------- */

.n4-exam-heading {
  margin-bottom: 24px;
}

.n4-back-link {
  display: none;
  width: fit-content;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--n4-primary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
}

.n4-exam-heading h1 {
  margin: 0;
  color: var(--n4-text);
  font-size: clamp(30px, 3vw, 44px);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.035em;
}

.n4-exam-heading p {
  margin: 12px 0 0;
  color: var(--n4-primary);
  font-size: 18px;
  font-weight: 700;
}

/* ---------- Thanh tìm kiếm ---------- */

.n4-exam-toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 240px 108px;
  gap: 14px;
  margin-bottom: 14px;
}

.n4-search-box,
.n4-sort-box,
.n4-exam-count {
  min-height: 56px;
  border: 1px solid var(--n4-border);
  border-radius: 12px;
  background: var(--n4-surface);
  box-shadow: 0 4px 18px rgba(43, 31, 91, 0.035);
}

.n4-search-box,
.n4-sort-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
}

.n4-search-box svg,
.n4-sort-box svg {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  fill: none;
  stroke: #787ca0;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.n4-search-box input,
.n4-sort-box select {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--n4-text);
  font: inherit;
  font-size: 15px;
}

.n4-search-box input::placeholder {
  color: #a3a5bb;
}

.n4-sort-box select {
  cursor: pointer;
}

.n4-exam-count {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  color: var(--n4-primary);
  background: #fbf7ff;
  font-size: 14px;
}

.n4-exam-count strong {
  font-size: 16px;
}

/* ---------- Danh sách đề thi ---------- */

.n4-exam-list {
  display: grid;
  gap: 12px;
}

.n4-test-card {
  position: relative;
  min-height: 114px;
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) 150px;
  gap: 20px;
  align-items: center;
  padding: 17px 18px 17px 22px;

  border: 1px solid var(--n4-border);
  border-radius: 16px;
  background: var(--n4-surface);
  box-shadow: var(--n4-shadow);
  transition:
    transform 0.22s ease,
    box-shadow 0.22s ease,
    border-color 0.22s ease;
}

.n4-test-card:hover {
  transform: translateY(-3px);
  border-color: #bfdbfe;
  box-shadow: 0 18px 38px rgba(37, 99, 235, 0.12);
}

.n4-test-number {
  width: 84px;
  height: 78px;
  display: grid;
  place-items: center;

  border: 1px solid #dbeafe;
  border-radius: 14px;
  background: linear-gradient(145deg, #f8fbff, #eaf2ff);
  color: var(--n4-primary);
  font-size: 36px;
  font-weight: 600;
  letter-spacing: -0.05em;
}

.n4-test-main {
  min-width: 0;
}

.n4-test-title {
  margin: 0 0 12px;
  overflow: hidden;
  color: var(--n4-text);
  font-size: 20px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.n4-test-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.n4-test-meta span {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;

  border: 1px solid var(--n4-border);
  border-radius: 8px;
  background: #fdfcff;
  color: #767b9b;
  font-size: 13px;
  font-weight: 500;
}

.n4-meta-icon {
  color: #3b82f6;
  font-size: 15px;
  line-height: 1;
}

.n4-test-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

.n4-start-button,
.n4-detail-button {
  border: 0;
  font-family: inherit;
  cursor: pointer;
}

.n4-start-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;

  border-radius: 9px;
  background: linear-gradient(135deg, var(--n4-primary-2), var(--n4-primary));
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.22);
  font-size: 14px;
  font-weight: 700;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.n4-start-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.28);
}

.n4-detail-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 2px 0;
  background: transparent;
  color: var(--n4-primary);
  font-size: 13px;
  font-weight: 600;
}

.n4-detail-button span {
  transition: transform 0.2s ease;
}

.n4-detail-button[aria-expanded="true"] span {
  transform: rotate(90deg);
}

.n4-test-detail {
  grid-column: 2 / -1;
  margin-top: -2px;
  padding: 14px 16px;

  border-radius: 10px;
  background: var(--n4-primary-soft);
  color: #676b88;
  font-size: 13px;
  line-height: 1.7;
}

.n4-empty-state {
  margin: 32px 0 0;
  padding: 28px;
  border: 1px dashed #d8ccf8;
  border-radius: 16px;
  background: var(--n4-surface);
  color: var(--n4-muted);
  text-align: center;
}

/* ---------- Card tổng quan tiến độ ---------- */

.n4-progress-card {
  position: sticky;
  top: 24px;
  overflow: hidden;
  padding: 30px 32px 28px;

  border: 1px solid #dbeafe;
  border-radius: 18px;
  background:
    radial-gradient(circle at 100% 0%, rgba(244, 114, 182, 0.11), transparent 34%),
    linear-gradient(145deg, #f8fbff 0%, #ffffff 62%, #f4f8ff 100%);
  box-shadow: 0 14px 36px rgba(84, 46, 155, 0.07);
}

.n4-progress-card h2 {
  position: relative;
  z-index: 2;
  margin: 0;
  color: var(--n4-primary);
  font-size: 20px;
  font-weight: 700;
}

.n4-progress-decoration {
  position: absolute;
  top: 4px;
  right: 8px;
  width: 130px;
  height: 72px;
  color: #f5b6d2;
  pointer-events: none;
}

.n4-progress-decoration span {
  position: absolute;
  font-size: 25px;
  opacity: 0.62;
}

.n4-progress-decoration span:nth-child(1) {
  top: 5px;
  right: 8px;
  font-size: 34px;
}

.n4-progress-decoration span:nth-child(2) {
  top: 28px;
  right: 47px;
}

.n4-progress-decoration span:nth-child(3) {
  top: 16px;
  right: 88px;
  font-size: 17px;
}

.n4-progress-summary {
  display: grid;
  grid-template-columns: 175px minmax(0, 1fr);
  gap: 28px;
  align-items: center;
  margin-top: 28px;
}

.n4-progress-ring {
  --progress: 0;
  width: 170px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    conic-gradient(
      from -85deg,
      var(--n4-primary) calc(var(--progress) * 1%),
      #e5edff 0
    );
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.05);
}

.n4-progress-ring-inner {
  width: 126px;
  aspect-ratio: 1;
  display: grid;
  place-content: center;
  border-radius: 50%;
  background: var(--n4-surface);
  text-align: center;
}

.n4-progress-ring-inner strong {
  color: #1d4ed8;
  font-size: 38px;
  line-height: 1;
}

.n4-progress-ring-inner span {
  margin-top: 8px;
  color: #8587a2;
  font-size: 12px;
}

.n4-progress-stats {
  display: grid;
  gap: 18px;
  margin: 0;
}

.n4-progress-stats div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.n4-progress-stats dt {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #676b88;
  font-size: 13px;
}

.n4-progress-stats dd {
  margin: 0;
  color: var(--n4-text);
  font-size: 13px;
  font-weight: 600;
}

.n4-stat-icon {
  width: 25px;
  height: 25px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;

  border: 2px solid #60a5fa;
  border-radius: 50%;
  color: var(--n4-primary);
  font-size: 13px;
  font-weight: 800;
}

.n4-progress-divider {
  height: 1px;
  margin: 30px 0 24px;
  background: #eee7f8;
}

.n4-skill-progress h3 {
  margin: 0 0 20px;
  color: var(--n4-primary);
  font-size: 16px;
  font-weight: 700;
}

.n4-skill-progress {
  display: grid;
  gap: 18px;
}

.n4-skill-row {
  display: grid;
  grid-template-columns: 138px minmax(90px, 1fr) 42px;
  gap: 14px;
  align-items: center;
}

.n4-skill-label {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #565b78;
  font-size: 13px;
}

.n4-skill-label span {
  width: 26px;
  color: #3b82f6;
  font-size: 23px;
  text-align: center;
}

.n4-skill-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--n4-track);
}

.n4-skill-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #3b82f6, #2563eb);
}

.n4-skill-row > strong {
  color: var(--n4-text);
  font-size: 13px;
  text-align: right;
}

.n4-progress-message {
  position: relative;
  min-height: 94px;
  display: flex;
  align-items: center;
  gap: 16px;
  overflow: hidden;
  margin-top: 28px;
  padding: 20px 24px;

  border: 1px solid #dbeafe;
  border-radius: 14px;
  background: linear-gradient(135deg, #fff7fc, #fbf5ff);
}

.n4-message-flower {
  font-size: 34px;
}

.n4-progress-message strong {
  color: var(--n4-primary);
  font-size: 13px;
}

.n4-progress-message p {
  margin: 5px 0 0;
  color: #8b8da5;
  font-size: 12px;
}

.n4-message-petals {
  position: absolute;
  right: 24px;
  color: #f1abc9;
  font-size: 26px;
  opacity: 0.7;
}

/* ---------- Dark mode ---------- */

html.dark body.n4-exam-page,
body.dark.n4-exam-page,
body.dark .n4-exam-page {
  --n4-page-bg: #081120;
  --n4-surface: #111c30;
  --n4-surface-soft: #17233a;
  --n4-text: #f8fafc;
  --n4-muted: #a7b2c8;
  --n4-border: #2b3951;
  --n4-primary-soft: #13213a;
  --n4-track: #26344a;
  --n4-shadow: 0 12px 32px rgba(0, 0, 0, 0.24);

  background: var(--n4-page-bg) !important;
  background-image: none !important;
}

html.dark .n4-search-box,
body.dark .n4-search-box,
body.dark .n4-sort-box,
body.dark .n4-exam-count,
body.dark .n4-test-card,
body.dark .n4-empty-state {
  background: var(--n4-surface);
  border-color: var(--n4-border);
}

html.dark .n4-exam-count,
body.dark .n4-exam-count {
  color: #93c5fd;
}

html.dark .n4-test-number,
body.dark .n4-test-number {
  border-color: #3a3154;
  background: #1c263b;
  color: #60a5fa;
}

html.dark .n4-test-meta span,
body.dark .n4-test-meta span {
  border-color: var(--n4-border);
  background: #0d1729;
  color: #b8c1d3;
}

html.dark .n4-progress-card,
body.dark .n4-progress-card {
  border-color: var(--n4-border);
  background:
    radial-gradient(circle at 100% 0%, rgba(59, 130, 246, 0.12), transparent 34%),
    #111c30;
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.24);
}

html.dark .n4-progress-ring,
body.dark .n4-progress-ring {
  background:
    conic-gradient(
      from -85deg,
      #3b82f6 calc(var(--progress) * 1%),
      #27344a 0
    );
}

html.dark .n4-progress-divider,
body.dark .n4-progress-divider {
  background: var(--n4-border);
}

html.dark .n4-progress-message,
body.dark .n4-progress-message {
  border-color: var(--n4-border);
  background: #17233a;
}

html.dark .n4-search-box input::placeholder,
body.dark .n4-search-box input::placeholder,
body.dark .n4-progress-ring-inner span,
body.dark .n4-progress-stats dt,
body.dark .n4-skill-label,
body.dark .n4-progress-message p {
  color: #a7b2c8;
}

html.dark .n4-search-box svg,
body.dark .n4-search-box svg,
body.dark .n4-sort-box svg {
  stroke: #cbd5e1;
}

html.dark .n4-search-box input,
body.dark .n4-search-box input,
body.dark .n4-sort-box select {
  color: #ffffff;
}

/* ---------- Responsive ---------- */

@media (max-width: 1180px) {
  .n4-exam-shell {
    grid-template-columns: 1fr;
  }

  .n4-progress-card {
    position: static;
    grid-row: 1;
  }

  .n4-back-link {
    display: inline-flex;
  }
}

@media (max-width: 760px) {
  .n4-exam-shell {
    width: min(100% - 28px, 680px);
    padding-top: 20px;
  }

  .n4-exam-toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .n4-search-box {
    grid-column: 1 / -1;
  }

  .n4-exam-count {
    min-height: 52px;
  }

  .n4-test-card {
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 14px;
    padding: 15px;
  }

  .n4-test-number {
    width: 68px;
    height: 68px;
    font-size: 29px;
  }

  .n4-test-actions {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .n4-test-detail {
    grid-column: 1 / -1;
  }

  .n4-progress-summary {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .n4-progress-stats {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .n4-exam-heading h1 {
    font-size: 30px;
  }

  .n4-exam-heading p {
    font-size: 16px;
  }

  .n4-exam-toolbar {
    grid-template-columns: 1fr;
  }

  .n4-search-box {
    grid-column: auto;
  }

  .n4-test-card {
    grid-template-columns: 60px minmax(0, 1fr);
  }

  .n4-test-number {
    width: 58px;
    height: 58px;
    font-size: 25px;
  }

  .n4-test-title {
    font-size: 17px;
  }

  .n4-test-meta span {
    padding: 5px 9px;
    font-size: 11px;
  }

  .n4-test-actions {
    grid-template-columns: 1fr;
  }

  .n4-progress-card {
    padding: 26px 20px 22px;
  }

  .n4-skill-row {
    grid-template-columns: 112px minmax(70px, 1fr) 38px;
    gap: 9px;
  }

  .n4-skill-label {
    gap: 8px;
    font-size: 12px;
  }
}


@media (max-width: 720px) {
  .n4-page-header {
    grid-template-columns: auto 1fr auto;
    gap: 12px;
    padding: 10px 14px;
  }

  .n4-header-back {
    min-width: 46px;
    width: 46px;
    padding: 0;
  }

  .n4-header-back span {
    display: none;
  }

  .n4-header-brand {
    justify-self: center;
    gap: 7px;
  }

  .n4-brand-flower {
    font-size: 23px;
  }

  .n4-header-brand strong {
    font-size: 18px;
  }

  .n4-brand-level {
    min-width: 39px;
    min-height: 30px;
    padding: 0 10px;
    font-size: 13px;
  }

  .n4-header-icon-button {
    width: 42px;
    height: 42px;
  }
}

@media (max-width: 480px) {
  .n4-header-actions {
    gap: 6px;
  }

  .n4-header-brand strong {
    display: none;
  }
}


/* =========================================================
   CUSTOM SORT DROPDOWN — BO TRÒN, HIỆU ỨNG 3D
   ========================================================= */

.n4-sort-dropdown {
  position: relative;
  min-width: 250px;
}

.n4-sort-trigger {
  width: 100%;
  min-height: 52px;
  display: grid;
  grid-template-columns: 23px 1fr 18px;
  align-items: center;
  gap: 11px;
  padding: 0 16px;
  border: 1px solid #dbe3ef;
  border-radius: 16px;
  background:
    linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  color: var(--n4-text);
  box-shadow:
    0 2px 0 rgba(255, 255, 255, 0.95) inset,
    0 -2px 0 rgba(148, 163, 184, 0.08) inset,
    0 8px 18px rgba(15, 23, 42, 0.08);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  transition:
    border-color 0.2s ease,
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.n4-sort-trigger:hover {
  transform: translateY(-2px);
  border-color: #93c5fd;
  box-shadow:
    0 2px 0 rgba(255, 255, 255, 0.95) inset,
    0 -2px 0 rgba(148, 163, 184, 0.08) inset,
    0 13px 25px rgba(37, 99, 235, 0.13);
}

.n4-sort-dropdown.is-open .n4-sort-trigger {
  border-color: #60a5fa;
  box-shadow:
    0 0 0 4px rgba(59, 130, 246, 0.12),
    0 12px 26px rgba(37, 99, 235, 0.14);
}

.n4-sort-trigger svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: var(--n4-primary);
}

.n4-sort-trigger .n4-sort-chevron {
  width: 18px;
  height: 18px;
  color: #64748b;
  transition: transform 0.22s ease;
}

.n4-sort-dropdown.is-open .n4-sort-chevron {
  transform: rotate(180deg);
}

.n4-sort-menu {
  position: absolute;
  top: calc(100% + 12px);
  left: 0;
  z-index: 1200;
  width: min(330px, calc(100vw - 28px));
  padding: 9px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow:
    0 4px 8px rgba(15, 23, 42, 0.08),
    0 18px 45px rgba(15, 23, 42, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(16px);
  transform-origin: top;
  animation: n4SortMenuIn 0.18s ease-out;
}

.n4-sort-menu[hidden] {
  display: none !important;
}

@keyframes n4SortMenuIn {
  from {
    opacity: 0;
    transform: translateY(-8px) perspective(700px) rotateX(-5deg);
  }

  to {
    opacity: 1;
    transform: translateY(0) perspective(700px) rotateX(0);
  }
}

.n4-sort-option {
  width: 100%;
  display: grid;
  grid-template-columns: 54px 1fr 24px;
  align-items: center;
  gap: 12px;
  padding: 13px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  color: #334155;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    transform 0.18s ease;
}

.n4-sort-option:hover,
.n4-sort-option:focus-visible {
  outline: none;
  transform: translateX(3px);
  border-color: #bfdbfe;
  background: #eff6ff;
}

.n4-sort-option.is-selected {
  border-color: #93c5fd;
  background:
    linear-gradient(135deg, #eff6ff, #dbeafe);
  color: #1d4ed8;
}

.n4-sort-option-icon {
  min-height: 38px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: #ffffff;
  box-shadow:
    0 5px 12px rgba(37, 99, 235, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  color: #2563eb;
  font-size: 12px;
  font-weight: 900;
}

.n4-sort-option strong,
.n4-sort-option small {
  display: block;
}

.n4-sort-option strong {
  font-size: 14px;
}

.n4-sort-option small {
  margin-top: 3px;
  color: #7c879a;
  font-size: 11px;
  font-weight: 500;
}

.n4-sort-check {
  opacity: 0;
  color: #2563eb;
  font-size: 18px;
  font-weight: 900;
}

.n4-sort-option.is-selected .n4-sort-check {
  opacity: 1;
}


/* =========================================================
   TRẠNG THÁI ĐỀ THI
   ========================================================= */

.n4-test-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.n4-availability-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}

.n4-availability-badge.is-ready {
  border: 1px solid #bbf7d0;
  background: #f0fdf4;
  color: #15803d;
}

.n4-availability-badge.is-updating {
  border: 1px solid #fde68a;
  background: #fffbeb;
  color: #b45309;
}

.n4-test-card.is-coming-soon .n4-test-number {
  filter: grayscale(0.15);
  opacity: 0.78;
}


/* =========================================================
   POPUP ĐỀ CHƯA CÓ
   ========================================================= */

body.n4-modal-open {
  overflow: hidden;
}

.n4-unavailable-modal {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: grid;
  place-items: center;
  padding: 22px;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.2s ease,
    visibility 0.2s ease;
}

.n4-unavailable-modal.is-open {
  opacity: 1;
  visibility: visible;
}

.n4-modal-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: rgba(15, 23, 42, 0.62);
  backdrop-filter: blur(7px);
  cursor: default;
}

.n4-unavailable-card {
  position: relative;
  z-index: 1;
  width: min(470px, 100%);
  padding: 31px 30px 28px;
  overflow: hidden;
  border: 1px solid rgba(191, 219, 254, 0.9);
  border-radius: 28px;
  background:
    radial-gradient(circle at 12% 10%, #eff6ff 0 13%, transparent 14%),
    radial-gradient(circle at 90% 3%, #fdf2f8 0 12%, transparent 13%),
    #ffffff;
  box-shadow:
    0 4px 8px rgba(15, 23, 42, 0.08),
    0 30px 90px rgba(15, 23, 42, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
  text-align: center;
  transform: translateY(18px) scale(0.96);
  transition: transform 0.24s ease;
}

.n4-unavailable-modal.is-open .n4-unavailable-card {
  transform: translateY(0) scale(1);
}

.n4-modal-close {
  position: absolute;
  top: 13px;
  right: 14px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 11px;
  background: rgba(241, 245, 249, 0.88);
  color: #64748b;
  font-size: 25px;
  line-height: 1;
  cursor: pointer;
}

.n4-unavailable-illustration {
  position: relative;
  width: 165px;
  height: 145px;
  margin: 0 auto 16px;
}

.n4-illustration-paper {
  position: absolute;
  left: 50%;
  bottom: 8px;
  width: 116px;
  height: 128px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px solid #bfdbfe;
  border-radius: 18px;
  background:
    linear-gradient(#ffffff, #f8fbff);
  box-shadow:
    0 18px 30px rgba(37, 99, 235, 0.16),
    inset 0 2px 0 #ffffff;
  transform: translateX(-50%) rotate(-3deg);
}

.n4-illustration-paper::before {
  content: "";
  position: absolute;
  top: 18px;
  left: 17px;
  right: 17px;
  height: 4px;
  border-radius: 999px;
  background: #dbeafe;
  box-shadow:
    0 10px 0 #e0e7ff,
    0 20px 0 #dbeafe;
}

.n4-illustration-paper span {
  margin-top: 28px;
  color: #64748b;
  font-family: "Noto Sans JP", sans-serif;
  font-size: 12px;
  font-weight: 700;
}

.n4-illustration-paper strong {
  color: #2563eb;
  font-size: 32px;
  line-height: 1.15;
}

.n4-illustration-paper i {
  position: absolute;
  right: -15px;
  bottom: -9px;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 4px solid #ffffff;
  border-radius: 50%;
  background: linear-gradient(145deg, #60a5fa, #2563eb);
  color: #ffffff;
  box-shadow: 0 9px 19px rgba(37, 99, 235, 0.28);
  font-size: 24px;
  font-style: normal;
  font-weight: 900;
}

.n4-illustration-spark {
  position: absolute;
  color: #60a5fa;
  font-size: 24px;
}

.spark-one {
  top: 10px;
  left: 6px;
}

.spark-two {
  top: 40px;
  right: 2px;
  color: #fb7185;
  font-size: 20px;
}

.spark-three {
  bottom: 12px;
  left: 6px;
  color: #fbbf24;
  font-size: 18px;
}

.n4-unavailable-badge {
  display: inline-flex;
  padding: 7px 13px;
  border-radius: 999px;
  background: #eff6ff;
  color: #2563eb;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.n4-unavailable-card h2 {
  margin: 14px 0 9px;
  color: #172033;
  font-size: 24px;
  line-height: 1.3;
}

.n4-unavailable-card p {
  max-width: 380px;
  margin: 0 auto;
  color: #64748b;
  font-size: 14px;
  line-height: 1.75;
}

.n4-modal-confirm {
  min-width: 145px;
  min-height: 48px;
  margin-top: 23px;
  padding: 0 22px;
  border: 0;
  border-radius: 14px;
  background:
    linear-gradient(135deg, #3b82f6, #2563eb);
  color: #ffffff;
  box-shadow:
    0 11px 23px rgba(37, 99, 235, 0.26),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
  font-family: inherit;
  font-weight: 800;
  cursor: pointer;
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease;
}

.n4-modal-confirm:hover {
  transform: translateY(-2px);
  box-shadow:
    0 15px 28px rgba(37, 99, 235, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}


/* Dark mode cho dropdown và popup */

html.dark .n4-sort-trigger,
body.dark .n4-sort-trigger {
  border-color: #334155;
  background:
    linear-gradient(180deg, #1b2535, #111827);
  color: #f8fafc;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 10px 25px rgba(0, 0, 0, 0.28);
}

html.dark .n4-sort-menu,
body.dark .n4-sort-menu {
  border-color: #334155;
  background: rgba(17, 24, 39, 0.98);
  box-shadow:
    0 25px 60px rgba(0, 0, 0, 0.48),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

html.dark .n4-sort-option,
body.dark .n4-sort-option {
  color: #e5e7eb;
}

html.dark .n4-sort-option:hover,
html.dark .n4-sort-option:focus-visible,
body.dark .n4-sort-option:hover,
body.dark .n4-sort-option:focus-visible {
  border-color: #3b82f6;
  background: #172554;
}

html.dark .n4-sort-option.is-selected,
body.dark .n4-sort-option.is-selected {
  border-color: #3b82f6;
  background: #172554;
  color: #bfdbfe;
}

html.dark .n4-sort-option-icon,
body.dark .n4-sort-option-icon {
  background: #111827;
  color: #93c5fd;
  box-shadow: none;
}

html.dark .n4-sort-option small,
body.dark .n4-sort-option small {
  color: #94a3b8;
}

html.dark .n4-unavailable-card,
body.dark .n4-unavailable-card {
  border-color: #334155;
  background:
    radial-gradient(circle at 12% 10%, #172554 0 13%, transparent 14%),
    radial-gradient(circle at 90% 3%, #3b172d 0 12%, transparent 13%),
    #17191d;
  box-shadow:
    0 30px 90px rgba(0, 0, 0, 0.58),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

html.dark .n4-unavailable-card h2,
body.dark .n4-unavailable-card h2 {
  color: #f8fafc;
}

html.dark .n4-unavailable-card p,
body.dark .n4-unavailable-card p {
  color: #a8abb2;
}

html.dark .n4-modal-close,
body.dark .n4-modal-close {
  background: #25282d;
  color: #cbd5e1;
}

html.dark .n4-illustration-paper,
body.dark .n4-illustration-paper {
  border-color: #3b82f6;
  background: linear-gradient(#22252b, #17191d);
  box-shadow:
    0 18px 30px rgba(0, 0, 0, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

html.dark .n4-availability-badge.is-ready,
body.dark .n4-availability-badge.is-ready {
  border-color: #166534;
  background: #14291c;
  color: #86efac;
}

html.dark .n4-availability-badge.is-updating,
body.dark .n4-availability-badge.is-updating {
  border-color: #854d0e;
  background: #2d210e;
  color: #fde68a;
}


@media (max-width: 760px) {
  .n4-sort-dropdown {
    min-width: 100%;
  }

  .n4-sort-menu {
    width: 100%;
  }

  .n4-unavailable-card {
    padding: 28px 20px 24px;
    border-radius: 22px;
  }
}
/* =========================================================
   UNIFIED DARK THEME — PAGE DANH SÁCH ĐỀ N4
   ========================================================= */

html.dark body.n4-exam-page,
body.dark.n4-exam-page {
  --n4-page-bg: #34383f;
  --n4-surface: #3f444c;
  --n4-surface-soft: #484e57;
  --n4-text: #f4f6f8;
  --n4-muted: #c5cad1;
  --n4-border: #5c6470;
  --n4-primary: #8ab4ff;
  --n4-primary-soft: #3d5274;
  --n4-track: #555d68;
  --n4-shadow:
    0 14px 34px rgba(19, 23, 29, 0.20);

  background: var(--n4-page-bg) !important;
  background-image: none !important;
  color: var(--n4-text) !important;
}

html.dark .n4-page-header,
body.dark .n4-page-header {
  border-color: var(--n4-border) !important;
  background: #3b4048 !important;
  color: var(--n4-text) !important;
  box-shadow: var(--n4-shadow) !important;
}

html.dark .n4-header-back,
body.dark .n4-header-back,
html.dark .n4-header-icon-button,
body.dark .n4-header-icon-button {
  border-color: var(--n4-border) !important;
  background: var(--n4-surface-soft) !important;
  color: var(--n4-text) !important;
}

html.dark .n4-exam-heading h1,
body.dark .n4-exam-heading h1,
html.dark .n4-test-title,
body.dark .n4-test-title {
  color: var(--n4-text) !important;
}

html.dark .n4-exam-heading p,
body.dark .n4-exam-heading p,
html.dark .n4-test-detail,
body.dark .n4-test-detail {
  color: var(--n4-muted) !important;
}

html.dark .n4-search-box,
body.dark .n4-search-box,
html.dark .n4-sort-trigger,
body.dark .n4-sort-trigger,
html.dark .n4-sort-menu,
body.dark .n4-sort-menu,
html.dark .n4-exam-count,
body.dark .n4-exam-count,
html.dark .n4-test-card,
body.dark .n4-test-card,
html.dark .n4-empty-state,
body.dark .n4-empty-state,
html.dark .n4-progress-card,
body.dark .n4-progress-card,
html.dark .n4-unavailable-card,
body.dark .n4-unavailable-card {
  border-color: var(--n4-border) !important;
  background: var(--n4-surface) !important;
  background-image: none !important;
  color: var(--n4-text) !important;
  box-shadow: var(--n4-shadow) !important;
}

html.dark .n4-search-box input,
body.dark .n4-search-box input {
  background: transparent !important;
  color: var(--n4-text) !important;
}

html.dark .n4-sort-menu::before,
body.dark .n4-sort-menu::before {
  border-color: var(--n4-border) !important;
  background: var(--n4-surface) !important;
}

html.dark .n4-sort-option,
body.dark .n4-sort-option {
  color: var(--n4-text) !important;
}

html.dark .n4-sort-option:hover,
body.dark .n4-sort-option:hover {
  background: var(--n4-surface-hover, #525965) !important;
}

html.dark .n4-sort-option.is-selected,
body.dark .n4-sort-option.is-selected {
  background: var(--n4-primary-soft) !important;
  box-shadow:
    inset 0 0 0 1px #7ca8f2 !important;
}

html.dark .n4-test-number,
body.dark .n4-test-number {
  border-color: #6d7785 !important;
  background: #4a5260 !important;
  color: #a9c7ff !important;
}

html.dark .n4-test-meta span,
body.dark .n4-test-meta span {
  border-color: var(--n4-border) !important;
  background: var(--n4-surface-soft) !important;
  color: #d5dae1 !important;
}

html.dark .n4-detail-button,
body.dark .n4-detail-button {
  color: #a9c7ff !important;
}

html.dark .n4-availability-badge.is-ready,
body.dark .n4-availability-badge.is-ready {
  border-color: #4d8a68 !important;
  background: #395e4a !important;
  color: #c9f5d9 !important;
}

html.dark .n4-availability-badge.is-updating,
body.dark .n4-availability-badge.is-updating {
  border-color: #8b7747 !important;
  background: #65583c !important;
  color: #f7e4ad !important;
}

html.dark .n4-progress-message,
body.dark .n4-progress-message,
html.dark .n4-translation-box,
body.dark .n4-translation-box {
  border-color: var(--n4-border) !important;
  background: var(--n4-surface-soft) !important;
  color: var(--n4-text) !important;
}

html.dark .n4-progress-divider,
body.dark .n4-progress-divider,
html.dark .n4-skill-track,
body.dark .n4-skill-track {
  background: var(--n4-track) !important;
}

.n4-header-actions .jlpt-auth-slot { margin-left: 2px; }

/* FIX 2026-07-06 — N4 EXAMS: 3D BACK + CONDITIONAL NOTIFICATION DOT */
body.n4-exam-page .n4-header-back {
  min-width: 126px !important;
  min-height: 46px !important;
  padding: 0 18px !important;
  border: 1px solid #d8e1ee !important;
  border-radius: 14px !important;
  background: linear-gradient(145deg, #ffffff, #e7edf6) !important;
  color: #31507f !important;
  box-shadow:
    0 9px 18px rgba(49, 65, 95, 0.14),
    inset 1px 1px 0 rgba(255, 255, 255, 0.96),
    inset -1px -1px 0 rgba(87, 104, 135, 0.10) !important;
  font-weight: 800 !important;
  transform: translateZ(0);
}

body.n4-exam-page .n4-header-back:hover {
  border-color: #b7c7dc !important;
  background: linear-gradient(145deg, #ffffff, #dce6f2) !important;
  color: var(--n4-primary, #2563eb) !important;
  transform: translateX(-3px) translateY(-1px) !important;
  box-shadow:
    0 14px 26px rgba(49, 65, 95, 0.19),
    inset 1px 1px 0 rgba(255, 255, 255, 0.98),
    inset -1px -1px 0 rgba(87, 104, 135, 0.08) !important;
}

body.n4-exam-page .n4-header-back:active {
  transform: translateX(-2px) translateY(1px) !important;
  box-shadow:
    0 4px 9px rgba(49, 65, 95, 0.13),
    inset 1px 1px 0 rgba(255, 255, 255, 0.86) !important;
}

html.dark body.n4-exam-page .n4-header-back,
body.dark.n4-exam-page .n4-header-back {
  border-color: #626b77 !important;
  background: linear-gradient(145deg, #59616c, #41474f) !important;
  color: #f3f6fb !important;
  box-shadow:
    0 10px 20px rgba(0, 0, 0, 0.22),
    inset 1px 1px 0 rgba(255, 255, 255, 0.10),
    inset -1px -1px 0 rgba(0, 0, 0, 0.12) !important;
}

html.dark body.n4-exam-page .n4-header-back:hover,
body.dark.n4-exam-page .n4-header-back:hover {
  border-color: #7a8593 !important;
  background: linear-gradient(145deg, #666f7a, #4b525b) !important;
  color: #ffffff !important;
  box-shadow:
    0 14px 27px rgba(0, 0, 0, 0.28),
    inset 1px 1px 0 rgba(255, 255, 255, 0.12) !important;
}

/* Không hiển thị chấm khi không có thông báo chưa đọc. */
body.n4-exam-page .n4-notification-dot {
  display: none !important;
}

body.n4-exam-page .n4-notification-button.has-unread .n4-notification-dot {
  display: block !important;
}
