/* Trang Sổ tay thuật ngữ - chỉ tác động khi glossaryView đang hoạt động. */
body.glossary-page-active {
  background: #f5f7fa;
}

body.glossary-page-active .main-content {
  width: min(1380px, calc(100% - 40px));
  max-width: 1380px;
  margin: 28px auto 42px;
  padding: 0;
  display: block;
}

body.glossary-page-active .main-content > .sidebar {
  display: none !important;
}

body.glossary-page-active #mainView,
body.glossary-page-active #glossaryView {
  width: 100%;
  min-width: 0;
}

#glossaryView,
#glossaryView button,
#glossaryView input {
  font-family: 'Inter', 'Be Vietnam Pro', sans-serif;
}

#glossaryView h1,
#glossaryView h2,
#glossaryView h3,
#glossaryView h4 {
  font-family: 'Be Vietnam Pro', 'Inter', sans-serif;
}

#glossaryView .glossary-hero {
  min-height: 255px;
  margin: 0 0 18px;
  padding: 34px 46px;
  border: 1px solid #8d0000;
  border-radius: 14px;
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(320px, 0.7fr);
  align-items: center;
  gap: 34px;
  overflow: hidden;
  color: #fff;
  background:
    radial-gradient(circle at 84% 45%, rgba(255, 216, 77, 0.18), transparent 27%),
    linear-gradient(115deg, #8e0000 0%, #b40000 56%, #720000 100%);
  box-shadow: 0 10px 28px rgba(127, 0, 0, 0.16);
}

#glossaryView .glossary-hero::before {
  top: -120px;
  right: -60px;
  width: 430px;
  height: 430px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: repeating-linear-gradient(135deg, rgba(255,255,255,0.035) 0 1px, transparent 1px 13px);
}

#glossaryView .glossary-hero::after {
  right: 26%;
  bottom: -150px;
  width: 360px;
  height: 360px;
  border: 1px solid rgba(255, 216, 77, 0.12);
  background: transparent;
}

#glossaryView .glossary-hero-badge {
  margin-bottom: 8px;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: rgba(255,255,255,0.92);
  background: transparent;
  font-size: 0.84rem;
  letter-spacing: 0.8px;
}

#glossaryView .glossary-hero h1 {
  max-width: 640px;
  margin: 0 0 10px;
  color: #ffe16a;
  font-size: clamp(2rem, 3.2vw, 3rem);
  font-weight: 850;
  letter-spacing: -1px;
  text-transform: uppercase;
  text-shadow: none;
}

#glossaryView .glossary-hero-subtitle {
  max-width: 650px;
  color: rgba(255,255,255,0.92);
  font-size: 0.94rem;
  font-weight: 500;
  line-height: 1.65;
}

#glossaryView .glossary-hero-stats {
  margin-top: 22px;
  gap: 0;
}

#glossaryView .glossary-stat-pill {
  min-width: 142px;
  padding: 0 20px;
  border: 0;
  border-right: 1px solid rgba(255,255,255,0.22);
  border-radius: 0;
  background: transparent;
  color: #fff;
  font-size: 0.79rem;
}

#glossaryView .glossary-stat-pill:first-child {
  padding-left: 0;
}

#glossaryView .glossary-stat-pill:last-child {
  border-right: 0;
}

#glossaryView .glossary-stat-pill i,
#glossaryView .glossary-stat-pill strong {
  color: #ffe16a;
}

.glossary-hero-visual {
  position: relative;
  z-index: 2;
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.glossary-book-open {
  position: absolute;
  left: 4%;
  bottom: 3px;
  color: #fff4d4;
  font-size: 8.8rem;
  filter: drop-shadow(0 10px 12px rgba(0,0,0,0.28));
  transform: rotate(-5deg);
}

.glossary-book-cover {
  position: absolute;
  right: 5%;
  top: 5px;
  width: 132px;
  height: 174px;
  padding: 24px 14px;
  border: 4px double #ffd85a;
  display: grid;
  place-items: center;
  color: #ffe16a;
  background: linear-gradient(145deg, #a50000, #700000);
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 0.86rem;
  font-weight: 800;
  line-height: 1.5;
  text-align: center;
  text-transform: uppercase;
  transform: rotate(8deg);
  box-shadow: 0 13px 22px rgba(0,0,0,0.3);
}

.glossary-panel,
.glossary-widget,
.glossary-guide {
  border: 1px solid #e4e8ee;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.045);
}

#glossaryView .glossary-search-bar {
  margin: 0 0 14px;
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  border-radius: 10px;
}

#glossaryView .glossary-search-input-wrap {
  min-width: 0;
}

#glossaryView .glossary-search-input {
  height: 44px;
  border-radius: 7px;
  background: #fafbfc;
  font-size: 0.86rem;
}

.glossary-search-btn,
.glossary-guide-btn {
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid #d30000;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #fff;
  background: #d30000;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.glossary-guide-btn {
  border-color: #e2e8f0;
  color: #334155;
  background: #fff;
}

.glossary-search-btn:hover {
  background: #ad0000;
}

.glossary-guide-btn:hover {
  border-color: #d30000;
  color: #d30000;
}

.glossary-alphabet-panel {
  margin-bottom: 14px;
  padding: 15px 17px 17px;
}

.glossary-panel-heading {
  margin-bottom: 12px;
  color: #d30000;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.25px;
  text-transform: uppercase;
}

.glossary-alphabet {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.glossary-letter-btn {
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border: 1px solid #dfe4ea;
  border-radius: 6px;
  color: #334155;
  background: #fff;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
}

.glossary-letter-btn:hover,
.glossary-letter-btn.active {
  border-color: #d30000;
  color: #fff;
  background: #d30000;
}

.glossary-letter-btn.all {
  min-width: 62px;
}

.glossary-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: start;
}

.glossary-main-column,
.glossary-side-column {
  min-width: 0;
}

.glossary-results-panel {
  padding: 17px;
  display: flex;
  flex-direction: column;
}

.glossary-section-header {
  margin-bottom: 15px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e6e9ee;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.glossary-section-title {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #d30000;
  font-size: 0.94rem;
  font-weight: 800;
  text-transform: uppercase;
}

.glossary-section-title::before {
  content: '';
  width: 4px;
  height: 22px;
  border-radius: 3px;
  background: #d30000;
}

#glossaryView .glossary-result-info {
  margin: 0;
  padding: 0;
  justify-content: flex-end;
}

#glossaryView .glossary-sort-label {
  border-radius: 6px;
}

#glossaryView .glossary-grid {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

#glossaryView .glossary-card {
  min-height: 205px;
  padding: 19px;
  border-radius: 8px;
  outline: none;
  cursor: pointer;
}

#glossaryView .glossary-card:focus-visible {
  border-color: #d30000;
  box-shadow: 0 0 0 3px rgba(211,0,0,0.12);
}

#glossaryView .glossary-card::before {
  display: none;
}

#glossaryView .glossary-card:hover {
  transform: translateY(-2px);
}

#glossaryView .glossary-card-header {
  align-items: center;
  margin-bottom: 9px;
}

#glossaryView .glossary-card-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: #d30000;
  background: #fff1f2 !important;
  font-size: 0.92rem;
}

#glossaryView .glossary-card-title {
  color: #162033;
  font-size: 0.98rem;
}

#glossaryView .glossary-card-cat {
  margin-left: 48px;
  margin-bottom: 8px;
  font-size: 0.63rem;
}

#glossaryView .glossary-card-desc {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  color: #4b5563;
  font-size: 0.78rem;
  line-height: 1.65;
}

.glossary-card-more {
  margin-top: 11px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #d30000;
  font-size: 0.72rem;
  font-weight: 700;
}

.glossary-page-active .glossary-pagination {
  position: static !important;
  inset: auto !important;
  top: auto !important;
  right: auto !important;
  bottom: auto !important;
  left: auto !important;
  z-index: auto !important;
  width: 100% !important;
  height: auto !important;
  min-height: 0 !important;
  margin: 20px 0 0 !important;
  padding: 16px 0 0 !important;
  border-top: 1px solid #e6e9ee;
  border-bottom: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  transform: none !important;
}

.glossary-page-btn {
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid #dfe4ea;
  border-radius: 6px;
  color: #334155;
  background: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.glossary-page-btn:hover,
.glossary-page-btn.active {
  border-color: #d30000;
  color: #fff;
  background: #d30000;
}

.glossary-page-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.glossary-side-column {
  display: grid;
  gap: 14px;
}

.glossary-widget {
  padding: 17px;
}

.glossary-widget-title {
  margin-bottom: 12px;
  padding-bottom: 11px;
  border-bottom: 1px solid #e6e9ee;
  color: #d30000;
  font-size: 0.9rem;
  font-weight: 800;
  text-transform: uppercase;
}

.glossary-category-list,
.glossary-recent-list,
.glossary-reference-list {
  list-style: none;
}

.glossary-category-btn {
  width: 100%;
  min-height: 43px;
  padding: 8px 4px;
  border: 0;
  border-bottom: 1px solid #edf0f3;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  color: #334155;
  background: transparent;
  font-size: 0.74rem;
  text-align: left;
  cursor: pointer;
}

.glossary-category-btn i {
  color: #d30000;
  text-align: center;
}

.glossary-category-btn .count {
  min-width: 31px;
  padding: 3px 7px;
  border-radius: 999px;
  color: #64748b;
  background: #f1f3f5;
  font-size: 0.68rem;
  text-align: center;
}

.glossary-category-btn:hover,
.glossary-category-btn.active {
  color: #d30000;
  font-weight: 700;
}

.glossary-recent-item,
.glossary-reference-item {
  padding: 10px 0;
  border-bottom: 1px solid #edf0f3;
}

.glossary-recent-item:last-child,
.glossary-reference-item:last-child {
  border-bottom: 0;
}

.glossary-recent-btn {
  width: 100%;
  border: 0;
  display: grid;
  grid-template-columns: 21px minmax(0, 1fr);
  gap: 8px;
  color: #334155;
  background: transparent;
  font-size: 0.72rem;
  line-height: 1.45;
  text-align: left;
  cursor: pointer;
}

.glossary-recent-btn i,
.glossary-reference-item i {
  color: #d30000;
}

.glossary-reference-item {
  display: grid;
  grid-template-columns: 21px minmax(0, 1fr);
  gap: 8px;
  color: #4b5563;
  font-size: 0.69rem;
  line-height: 1.5;
}

.glossary-download-link {
  margin-top: 12px;
  min-height: 38px;
  border: 1px solid #f2c9c9;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: #d30000;
  font-size: 0.72rem;
  font-weight: 700;
}

.glossary-download-link:hover {
  color: #fff;
  background: #d30000;
}

.glossary-guide {
  margin-top: 16px;
  padding: 17px;
}

.glossary-guide-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.glossary-guide-item {
  padding: 8px 16px;
  border-right: 1px solid #e6e9ee;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.glossary-guide-item:last-child {
  border-right: 0;
}

.glossary-guide-icon {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #d30000;
  background: #fff1f2;
}

.glossary-guide-item h4 {
  margin-bottom: 3px;
  color: #253047;
  font-size: 0.76rem;
}

.glossary-guide-item p {
  color: #64748b;
  font-size: 0.68rem;
  line-height: 1.45;
}

.glossary-modal {
  position: fixed;
  inset: 0;
  z-index: 12000;
  padding: 24px;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.64);
  backdrop-filter: blur(3px);
}

.glossary-modal.open {
  display: flex;
}

.glossary-modal-dialog {
  width: min(760px, 100%);
  max-height: min(700px, calc(100vh - 48px));
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 24px 70px rgba(0,0,0,0.28);
}

.glossary-modal-header {
  padding: 20px 22px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  color: #fff;
  background: linear-gradient(120deg, #9b0000, #d30000);
}

.glossary-modal-kicker {
  margin-bottom: 5px;
  color: #ffe16a;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
}

.glossary-modal-title {
  color: #fff;
  font-size: 1.28rem;
  line-height: 1.35;
}

.glossary-modal-close {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border: 1px solid rgba(255,255,255,0.32);
  border-radius: 50%;
  color: #fff;
  background: rgba(255,255,255,0.12);
  cursor: pointer;
}

.glossary-modal-body {
  max-height: calc(min(700px, 100vh - 48px) - 94px);
  padding: 22px;
  overflow-y: auto;
}

.glossary-modal-body p {
  margin-bottom: 13px;
  color: #334155;
  font-size: 0.91rem;
  line-height: 1.78;
}

.glossary-modal-body p:first-child {
  color: #172033;
  font-weight: 600;
}

#glossaryView .glossary-empty {
  min-height: 260px;
  border: 1px dashed #d9dee5;
  border-radius: 8px;
  display: grid;
  place-items: center;
}

@media (max-width: 1050px) {
  #glossaryView .glossary-hero {
    grid-template-columns: minmax(0, 1fr) 300px;
    padding: 30px;
  }

  .glossary-layout {
    grid-template-columns: minmax(0, 1fr) 285px;
  }

  .glossary-book-open {
    font-size: 7.2rem;
  }

  .glossary-book-cover {
    width: 112px;
    height: 150px;
  }
}

@media (max-width: 900px) {
  #glossaryView .glossary-hero {
    grid-template-columns: 1fr;
  }

  .glossary-hero-visual {
    display: none;
  }

  .glossary-layout {
    grid-template-columns: 1fr;
  }

  .glossary-side-column {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .glossary-side-column .glossary-widget:last-child {
    grid-column: 1 / -1;
  }

  .glossary-guide-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    row-gap: 16px;
  }

  .glossary-guide-item:nth-child(2) {
    border-right: 0;
  }
}

@media (max-width: 768px) {
  body.glossary-page-active .main-content {
    width: 100% !important;
    margin: 14px auto 28px !important;
    padding: 0 12px !important;
  }

  #glossaryView .glossary-hero {
    min-height: auto;
    padding: 24px 20px;
    border-radius: 10px;
  }

  #glossaryView .glossary-hero h1 {
    font-size: 1.65rem;
    letter-spacing: -0.4px;
  }

  #glossaryView .glossary-hero-subtitle {
    font-size: 0.83rem;
  }

  #glossaryView .glossary-hero-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  #glossaryView .glossary-stat-pill {
    min-width: 0;
    padding: 0;
    border: 0;
    font-size: 0.72rem;
  }

  #glossaryView .glossary-search-bar {
    grid-template-columns: 1fr 48px;
  }

  .glossary-search-btn {
    width: 48px;
    padding: 0;
  }

  .glossary-search-btn span {
    display: none;
  }

  .glossary-guide-btn {
    grid-column: 1 / -1;
  }

  .glossary-alphabet {
    flex-wrap: nowrap;
    padding-bottom: 7px;
    overflow-x: auto;
    scrollbar-width: thin;
  }

  .glossary-letter-btn {
    flex: 0 0 auto;
  }

  .glossary-section-header {
    align-items: flex-start;
    flex-direction: column;
  }

  #glossaryView .glossary-result-info {
    width: 100%;
    justify-content: space-between;
  }

  #glossaryView .glossary-grid {
    grid-template-columns: 1fr;
  }

  #glossaryView .glossary-card {
    min-height: 190px;
  }

  .glossary-side-column {
    grid-template-columns: 1fr;
  }

  .glossary-side-column .glossary-widget:last-child {
    grid-column: auto;
  }

  .glossary-guide-grid {
    grid-template-columns: 1fr;
  }

  .glossary-guide-item,
  .glossary-guide-item:nth-child(2) {
    padding: 10px 4px;
    border-right: 0;
    border-bottom: 1px solid #e6e9ee;
  }

  .glossary-guide-item:last-child {
    border-bottom: 0;
  }

  .glossary-modal {
    padding: 12px;
  }

  .glossary-modal-dialog {
    max-height: calc(100vh - 24px);
  }

  .glossary-modal-header,
  .glossary-modal-body {
    padding: 17px;
  }

  .glossary-modal-title {
    font-size: 1.08rem;
  }
}
