/* ================================================================
   你好 HSK - Enhancements & Modern UI Components
   ================================================================ */

/* Global & modal hidden rule */
.hanzi-modal-overlay[hidden],
.hanzi-modal-overlay.hidden,
.srs-modal-overlay[hidden],
.srs-modal-overlay.hidden,
[hidden] {
  display: none !important;
}

/* SRS Review Modal */
.srs-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(18, 20, 36, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: srsFadeIn 0.25s ease-out;
}
.srs-modal-card {
  width: min(560px, 100%);
  background: #ffffff;
  border-radius: 24px;
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: 90vh;
}
.srs-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 22px 24px 16px;
  border-bottom: 1px solid #eef0f8;
}
.srs-kicker {
  font-size: 11px;
  font-weight: 800;
  color: #6657d9;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.srs-header h2 {
  margin: 4px 0 0;
  font-size: 20px;
  color: #1a1e36;
}
.srs-close {
  background: #f1f3f9;
  border: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  color: #626880;
  transition: all 0.2s;
}
.srs-close:hover {
  background: #e2e5f1;
  color: #1a1e36;
}
.srs-progress-bar {
  height: 6px;
  background: #eef0f8;
  width: 100%;
}
.srs-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #6657d9, #00b4d8);
  width: 0%;
  transition: width 0.3s ease;
}
.srs-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
}
.srs-card-meta {
  width: 100%;
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 700;
  color: #7b809a;
  margin-bottom: 14px;
}
.srs-level-pill {
  background: #f0edff;
  color: #6657d9;
  padding: 3px 10px;
  border-radius: 999px;
}
.srs-flip-card {
  width: 100%;
  min-height: 250px;
  background: #fbfbfe;
  border: 2px solid #e7e9f8;
  border-radius: 20px;
  padding: 24px;
  cursor: pointer;
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  transition: all 0.25s ease;
  user-select: none;
}
.srs-flip-card:hover {
  border-color: #6657d9;
  box-shadow: 0 10px 30px rgba(102, 87, 217, 0.1);
}
.srs-hanzi {
  font-size: 64px;
  font-family: STKaiti, KaiTi, 'KaiTi SC', serif;
  color: #1a1e36;
  line-height: 1.1;
  margin-bottom: 12px;
}
.srs-hint {
  color: #8b90a6;
  font-size: 13px;
  margin-top: 10px;
}
.srs-pinyin {
  font-size: 24px;
  font-weight: 700;
  color: #6657d9;
  margin: 6px 0;
}
.srs-hv {
  font-size: 14px;
  color: #b5830e;
  font-weight: 600;
}
.srs-meaning {
  font-size: 18px;
  color: #2b304c;
  margin-top: 6px;
  font-weight: 600;
}
.srs-audio-slot {
  margin-top: 14px;
}
.srs-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
  margin-top: 20px;
}
.srs-btn {
  border: 0;
  border-radius: 14px;
  padding: 12px 10px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  text-align: center;
}
.srs-btn:hover {
  transform: translateY(-2px);
}
.srs-btn small {
  display: block;
  font-size: 11px;
  font-weight: 500;
  margin-top: 4px;
  opacity: 0.85;
}
.srs-bad {
  background: #ffe6e8;
  color: #bd2739;
}
.srs-medium {
  background: #fff4d5;
  color: #946900;
}
.srs-good {
  background: #ddfaed;
  color: #0d835f;
}
.srs-complete {
  text-align: center;
  padding: 20px 10px;
}
.srs-trophy {
  font-size: 64px;
  margin-bottom: 12px;
}
.srs-complete h3 {
  font-size: 22px;
  color: #1a1e36;
  margin: 0 0 10px;
}
.srs-complete p {
  color: #626880;
  margin: 6px 0;
}

/* Hanzi Canvas Pad Modal */
.hanzi-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(18, 20, 36, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: srsFadeIn 0.2s ease-out;
}
.hanzi-modal-card {
  width: min(440px, 100%);
  background: #fff;
  border-radius: 24px;
  box-shadow: 0 25px 60px rgba(0,0,0,0.3);
  padding: 24px;
  text-align: center;
}
.hanzi-grid-box {
  width: 260px;
  height: 260px;
  margin: 12px auto 10px;
  position: relative;
  border: 3px solid #6657d9;
  border-radius: 14px;
  background: #ffffff;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(102, 87, 217, 0.12);
  /* Rice grid background */
  background-image:
    linear-gradient(to right, rgba(220, 220, 235, 0.7) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(220, 220, 235, 0.7) 1px, transparent 1px),
    linear-gradient(45deg, transparent 49.5%, rgba(230, 230, 245, 0.9) 50%, transparent 50.5%),
    linear-gradient(-45deg, transparent 49.5%, rgba(230, 230, 245, 0.9) 50%, transparent 50.5%);
  background-size: 100% 100%;
}
.hanzi-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
  z-index: 6;
}
.hanzi-writer-layer {
  position: absolute;
  inset: 0;
  width: 260px;
  height: 260px;
  pointer-events: none;
  z-index: 2;
}
.hanzi-writer-layer svg {
  width: 100% !important;
  height: 100% !important;
}
.hanzi-guide {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 175px;
  font-family: STKaiti, KaiTi, 'KaiTi SC', SimKai, serif;
  font-weight: 700;
  color: #4f46e5;
  opacity: 0.50; /* Đậm nét rõ ràng - chuẩn hướng dẫn tập viết */
  pointer-events: none;
  line-height: 1;
  user-select: none;
  overflow: hidden;
  text-align: center;
  z-index: 1;
  transition: opacity 0.2s ease;
}
.hanzi-stroke-badges {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
}
.stroke-guide-marker {
  position: absolute;
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2.5px;
  background: #ef4444;
  color: #ffffff;
  padding: 1.5px 5.5px;
  border-radius: 999px;
  border: 1.5px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  font-size: 10.5px;
  font-weight: 800;
  line-height: 1;
  user-select: none;
  pointer-events: none;
  animation: strokeBadgePop 0.22s ease-out;
  z-index: 5;
}
.stroke-num-badge {
  font-size: 11px;
  font-weight: 900;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: #ffffff;
  letter-spacing: -0.2px;
}
.stroke-arrow-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 11px;
  height: 11px;
}
@keyframes strokeBadgePop {
  0% { transform: translate(-50%, -50%) scale(0.3); opacity: 0; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}
.hanzi-char-chip {
  background: #f1f5f9;
  color: #475569;
  border: 1.5px solid #cbd5e1;
  border-radius: 9px;
  padding: 5px 12px;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}
.hanzi-char-chip:hover {
  border-color: #6657d9;
  color: #6657d9;
}
.hanzi-char-chip.active {
  background: #6657d9;
  color: #ffffff;
  border-color: #6657d9;
  box-shadow: 0 2px 6px rgba(102, 87, 217, 0.3);
}
.hanzi-toolbar {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 14px;
}
.hanzi-btn {
  border: 1px solid #d9d5ff;
  background: #f5f3ff;
  color: #6657d9;
  border-radius: 10px;
  padding: 8px 14px;
  font-weight: 700;
  cursor: pointer;
}
.hanzi-btn:hover {
  background: #ece8ff;
}

/* Quick review banner on Home */
.home-review-cta {
  background: linear-gradient(135deg, #f7f5ff 0%, #edf8fc 100%);
  border: 1.5px solid #dcd4ff;
  border-radius: 18px;
  padding: 18px 22px;
  margin: 20px 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: 0 4px 18px rgba(102, 87, 217, 0.08);
}
.home-review-left {
  display: flex;
  align-items: center;
  gap: 14px;
}
.home-review-icon {
  font-size: 32px;
  background: #fff;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(102, 87, 217, 0.12);
}
.home-review-btn {
  background: #6657d9;
  color: #fff;
  border: 0;
  padding: 12px 20px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(102, 87, 217, 0.35);
  transition: all 0.2s;
}
.home-review-btn:hover {
  background: #5344c9;
  transform: translateY(-1px);
}

@keyframes srsFadeIn {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

/* ================================================================
   CLEAN & COMPACT MODERN HEADER SYSTEM
   ================================================================ */
.header-action-cluster {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Search Pill */
.header-search-pill,
.spotlight-header-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}
.header-search-pill:hover,
.spotlight-header-btn:hover {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #1e1b4b;
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}
.header-search-pill .search-kbd,
.spotlight-header-btn .search-kbd,
.header-search-pill .spotlight-shortcut-badge,
.spotlight-header-btn .spotlight-shortcut-badge {
  font-size: 10px;
  font-weight: 800;
  color: #94a3b8;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 2px 5px;
}

/* Ghost Circle Icon Buttons (Sound, Theme) */
.header-circle-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1.5px solid #e2e8f0;
  background: #ffffff;
  color: #475569;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14.5px;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  flex-shrink: 0;
  padding: 0;
}
.header-circle-btn:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  transform: scale(1.06);
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}

/* User Menu & Dropdown */
.user-menu-wrap {
  position: relative;
  display: inline-block;
}
.user-menu-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: 999px;
  padding: 3px 12px 3px 4px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: #1e1b4b;
  transition: all 0.15s ease;
}
.user-menu-trigger:hover,
.user-menu-wrap.active .user-menu-trigger {
  border-color: #cbd5e1;
  background: #f8fafc;
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}
.user-avatar-circle {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6657d9, #4f46e5);
  color: #ffffff;
  font-weight: 800;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.user-chevron {
  font-size: 10px;
  color: #94a3b8;
  transition: transform 0.15s ease;
}
.user-menu-wrap.active .user-chevron {
  transform: rotate(180deg);
}

.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 99999;
  width: 260px;
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: 18px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.16), 0 0 0 1px rgba(0,0,0,0.03);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: dropdownFadeIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}
.user-menu-dropdown.hidden,
.user-menu-dropdown[hidden] {
  display: none !important;
}

.user-dropdown-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 10px;
}
.user-dropdown-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #ede9fe;
  color: #6657d9;
  font-weight: 800;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.user-dropdown-info {
  display: flex;
  flex-direction: column;
}
.user-dropdown-name {
  font-size: 13.5px;
  font-weight: 800;
  color: #1e1b4b;
}
.user-dropdown-role {
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
}
.user-dropdown-role.admin {
  color: #dc2626;
}

.user-dropdown-rank {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 8px 12px;
  margin: 4px 0 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.user-dropdown-rank:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.user-dropdown-divider {
  height: 1px;
  background: #f1f5f9;
  margin: 4px 0;
}

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  text-decoration: none;
  cursor: pointer;
  border: 0;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: all 0.12s ease;
}
.user-dropdown-item:hover {
  background: #f1f5f9;
  color: #1e1b4b;
}
.user-dropdown-item.admin {
  color: #4f46e5;
  font-weight: 700;
}
.user-dropdown-item.logout {
  color: #e11d48;
}
.user-dropdown-item.logout:hover {
  background: #fff1f2;
  color: #be123c;
}

/* Login Header Button */
.btn-login-header {
  background: #6657d9;
  color: #ffffff;
  border: 0;
  border-radius: 10px;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 6px rgba(102,87,217,0.25);
  transition: all 0.15s ease;
}
.btn-login-header:hover {
  background: #5544d4;
  transform: translateY(-1px);
}

/* Nav Dropdown for Practice Tools */
.nav-dropdown {
  position: relative;
  display: inline-block;
}
.nav-dropdown-btn {
  border: 0;
  background: transparent;
  font-weight: 600;
  color: #726c83;
  padding: 11px 16px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}
.nav-dropdown-btn:hover,
.nav-dropdown.active .nav-dropdown-btn {
  background: #f5f3fb;
  color: #6657d9;
}
.nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 99998;
  width: 240px;
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.14);
  padding: 8px;
  display: none;
  flex-direction: column;
  gap: 2px;
  animation: dropdownFadeIn 0.15s ease-out;
}
.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown.open .nav-dropdown-menu {
  display: flex;
}
.nav-dropdown-menu a {
  display: flex !important;
  align-items: center;
  gap: 10px;
  padding: 8px 12px !important;
  border-radius: 10px;
  font-size: 13px !important;
  font-weight: 600 !important;
  color: #334155 !important;
  background: transparent !important;
  transition: all 0.12s ease;
}
.nav-dropdown-menu a:hover {
  background: #f8fafc !important;
  color: #6657d9 !important;
  transform: translateX(3px);
}

@media (max-width: 950px) {
  .header-search-pill .spotlight-btn-text,
  .header-search-pill .search-kbd,
  .header-search-pill .spotlight-shortcut-badge {
    display: none !important;
  }
  .header-search-pill {
    padding: 6px 9px !important;
  }
  .user-display-name {
    display: none !important;
  }
  .site-nav a {
    padding: 7px 9px !important;
    font-size: 13px !important;
  }
}

@media (max-width: 680px) {
  .top {
    flex-wrap: wrap !important;
    gap: 10px !important;
    padding: 10px 14px !important;
    min-height: auto !important;
  }
  .header-action-cluster {
    margin-left: auto;
    gap: 6px !important;
  }
  .site-nav {
    order: 3;
    width: 100%;
    overflow-x: auto;
    padding: 4px 0;
    gap: 2px !important;
    margin: 0 !important;
  }
}
