/* ============================================================
   Component Library v3 (Light Academy)
   Cards, buttons, forms, tables, badges, progress, notifications,
   modals. Legacy selectors preserved; values are light-professional.
   ============================================================ */

/* ---------- Icons (see tracker/templatetags/icons.py) ---------- */
.icon {
  display: inline-block;
  flex-shrink: 0;
  vertical-align: -3px;
}

/* ---------- Rank badge pills (gamification content — colors stay rich) ---------- */
.rank-badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.78em;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur-fast) var(--ease-out);
  border: 1px solid rgba(26, 34, 51, 0.06);
}

.rank-badge-pill:hover {
  transform: translateY(-1px);
}

/* Per-rank text colour for the four lower tiers. The templates that render a
   pill (dashboard, admin_activity_stats, performance_report) set
   `background`/`color` inline from tracker/ranks.py; an inline declaration
   beats a stylesheet one, so the tint background stays the inline
   rgba(...,0.15) wash and the text colour needs !important to win. ranks.py
   colours are mid-tones (#94a3b8 = 2.12:1) that fail AA on that wash — these
   are the same hues darkened to >= 4.5:1 on both surfaces the pill appears
   on (white card and the rgb(233,238,244) glass card). Ratios in the
   comments are white / glass-card. */
.rank-page,
.rank-master {
  color: #475569 !important;   /* slate — 6.70 / 5.86 */
}

.rank-iron-knight {
  color: #334155 !important;   /* steel — 8.60 / 7.49 */
}

.rank-hero {
  color: var(--gold-600) !important;   /* amber — 6.31 / 5.51 */
}

.rank-sword-saint {
  color: var(--primary-700) !important;   /* blue — 7.95 / 6.93 */
}

/* These three top tiers keep a rich gradient instead of the pale wash —
   escalating visual weight for the highest ranks. Every declaration needs
   !important for the same inline-vs-stylesheet reason as above. */
.rank-legend {
  background: linear-gradient(135deg, #b91c1c, #dc2626) !important;
  color: white !important;
  border-color: rgba(0, 0, 0, 0.12) !important;
}

.rank-celestial-venerable {
  background: linear-gradient(135deg, #6d28d9, #7c3aed) !important;
  color: white !important;
  border-color: rgba(0, 0, 0, 0.12) !important;
}

.rank-dao-ancestor {
  background: linear-gradient(135deg, #92400e, #b45309) !important;
  color: white !important;
  border-color: rgba(0, 0, 0, 0.12) !important;
}

@keyframes pulse-gold {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.25); }
  50% { box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); }
}

/* ---------- Tabs ---------- */
.tab-btn {
  color: var(--text-muted);
  transition: all var(--dur-med) var(--ease-out);
  position: relative;
  cursor: pointer;
}
.tab-btn:hover {
  color: var(--primary-600);
}
.tab-btn.active {
  color: var(--primary-700) !important;
  background: var(--primary-50);
  border: 1px solid var(--primary-100) !important;
}
.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 15%;
  width: 70%;
  height: 2px;
  background: var(--primary-600);
  border-radius: 2px;
}

/* ---------- Tabs (professional underline variant) ----------
   Markup contract: <div class="tabs" role="tablist"><button class="tab"
   role="tab" aria-selected="true|false" aria-controls="panel-id">…
   Driven off aria-selected (not a .active class) so visual state and a11y
   state can't diverge. .tab-btn/.sect-btn above are untouched aliases kept
   for templates not yet swept onto this component. */
.tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--glass-border);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar {
  display: none;
}
.tab {
  padding: 0.6rem 1rem;
  font-weight: 500;
  font-size: 0.92rem;
  font-family: var(--font-body);
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  white-space: nowrap;
  transition: color var(--dur-fast) ease;
}
.tab:hover {
  color: var(--text-color);
}
.tab[aria-selected="true"] {
  color: var(--primary-700);
  font-weight: 600;
}
.tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--primary-600);
  border-radius: 2px 2px 0 0;
}
.tab:focus-visible {
  outline: 2px solid var(--primary-500);
  outline-offset: -2px;
}

.wuxia-scroll::-webkit-scrollbar {
  display: none;
}
.wuxia-scroll {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

/* ---------- Cards ---------- */
.card {
  background: var(--card-bg);
  padding: 2.25rem;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--glass-border);
  position: relative;
  transition: box-shadow var(--dur-med) ease, transform var(--dur-med) var(--ease-out);
}

.card:hover {
  box-shadow: var(--shadow-lg);
}

.glass-panel {
  background: var(--card-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-md);
}

/* ---------- Buttons ---------- */
.btn {
  background: var(--primary-600);
  color: #fff;
  border: none;
  padding: 0.6rem 1.4rem;
  border-radius: 10px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: background var(--dur-fast) ease, transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  position: relative;
  box-shadow: var(--shadow-sm);
  font-size: 0.92rem;
  gap: 0.5rem;
  letter-spacing: 0.005em;
}

.btn:hover {
  background: var(--primary-700);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.btn-success {
  background: var(--success-color);
}
.btn-success:hover {
  background: #065f46;
}

.btn-danger {
  background: var(--danger-color);
}
.btn-danger:hover {
  background: #9f1239;
}

/* ---------- Forms ---------- */
input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
textarea,
select {
  background: #ffffff;
  border: 1px solid var(--glass-border);
  color: var(--text-color);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
  font-family: inherit;
  font-size: 0.94rem;
  transition: border-color var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="email"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px var(--primary-100);
}

::placeholder {
  color: var(--text-muted);
  opacity: 0.65;
}

/* ---------- Tables ---------- */
.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1.5rem;
}

.leaderboard-table th,
.leaderboard-table td {
  text-align: left;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border-soft);
}

.leaderboard-table th {
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

.leaderboard-table tbody tr {
  transition: background var(--dur-fast) ease;
}

.leaderboard-table tbody tr:hover {
  background: var(--primary-50);
}

.rank-badge {
  background: var(--ink-950);
  padding: 0.2rem 0.6rem;
  border-radius: 0.4rem;
  font-weight: 700;
  border: 1px solid var(--border-soft);
}

/* ---------- Progress ---------- */
.progress-track {
  background: var(--ink-600);
  border-radius: var(--radius-pill);
  height: 8px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--primary-600);
  transition: width 0.6s var(--ease-out);
}

/* ---------- Notification bell (sidebar-foot row) ---------- */
.notification-wrapper {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  position: relative;
  width: 100%;
  padding: 0.55rem 0.6rem;
  border-radius: 9px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background var(--dur-fast) ease, color var(--dur-fast) ease;
}
.notification-wrapper:hover {
  background: var(--primary-50);
  color: var(--primary-600);
}
.notification-bell {
  color: inherit;
  display: flex;
  align-items: center;
  transition: transform var(--dur-fast) var(--ease-spring);
}
.notification-wrapper:hover .notification-bell {
  transform: rotate(10deg);
}
.notification-badge {
  position: absolute;
  top: 2px;
  left: 22px;
  background: var(--crimson-500);
  color: white;
  font-size: 0.62rem;
  padding: 1px 5px;
  border-radius: 9px;
  font-weight: 700;
  display: none;
  border: 2px solid #ffffff;
}
.notification-dropdown {
  /* left/bottom/max-height are computed in app-shell.js. Positioned fixed so
     the panel escapes the sidebar's `overflow: hidden` (which used to clip
     this flyout to near-zero width) and stays inside the viewport on mobile. */
  position: fixed;
  width: 340px;
  background: #ffffff;
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  display: none;
  z-index: var(--z-dropdown);
  max-height: 480px;
  overflow-y: auto;
}
.notification-item {
  padding: 1rem;
  border-bottom: 1px solid var(--border-soft);
  transition: background var(--dur-fast) ease;
}
.notification-item:hover {
  background: var(--primary-50);
}
.notification-item.unread {
  border-left: 3px solid var(--primary-600);
  background: var(--primary-50);
}
.notification-item h4 {
  margin: 0 0 0.3rem 0;
  font-size: 0.94rem;
  color: var(--text-color);
  font-weight: 600;
}
.notification-item p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.45;
}
.notification-item .meta {
  font-size: 0.74rem;
  color: var(--text-muted);
  opacity: 0.8;
  margin-top: 0.45rem;
}

/* ---------- Urgent modal (urgency kept, palette light) ---------- */
#urgent-modal {
  position: fixed;
  inset: 0;
  background: rgba(26, 34, 51, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: var(--z-urgent);
  opacity: 0;
  transition: opacity 0.3s ease;
  padding: 1rem;
}

#urgent-modal[style*="display: flex"] {
  animation: modalFadeIn 0.3s forwards;
}

.premium-urgent-content {
  background: #ffffff;
  border: 1px solid #fecdd3;
  border-top: 4px solid var(--crimson-500);
  border-radius: 1rem;
  max-width: 500px;
  width: 95%;
  max-height: 92vh;
  padding: 0;
  box-shadow: var(--shadow-lg);
  animation: modalSlam 0.35s var(--ease-out) forwards;
  overflow: hidden;
  position: relative;
  text-align: left;
  display: flex;
  flex-direction: column;
}

.urgent-header {
  background: #fff1f2;
  border-bottom: 1px solid #fecdd3;
  padding: 1rem 1.2rem;
  text-align: center;
  flex-shrink: 0;
}

.urgent-body-container {
  padding: 1.5rem 1.2rem;
  color: var(--text-color);
  font-family: var(--font-body);
  line-height: 1.6;
  font-size: 0.95rem;
  overflow-y: auto;
  flex: 1;
}

.btn-threat {
  background: var(--crimson-500);
  color: #fff;
  border: none;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.65rem 1.2rem;
  border-radius: 0.6rem;
  width: 100%;
  transition: all var(--dur-med) ease;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

.btn-threat:hover {
  background: #9f1239;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

#urgent-body h3 { color: var(--crimson-500); font-weight: 700; margin-top: 0.8rem; margin-bottom: 0.3rem; text-transform: uppercase; font-size: 0.88rem; }
#urgent-body h3:first-child { margin-top: 0; }
#urgent-body p { margin-bottom: 0.8rem; }
#urgent-body ul { list-style-type: disc; margin-left: 1.5rem; margin-bottom: 0.8rem; color: var(--text-muted); }
#urgent-body strong { color: var(--crimson-500); font-weight: 600; }
#urgent-body em { color: var(--gold-500); font-style: italic; }

@keyframes modalSlam {
  0% { transform: scale(1.04) translateY(-14px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}
@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes threatPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(190, 18, 60, 0.18); }
  60% { box-shadow: 0 0 0 10px rgba(190, 18, 60, 0); }
}
@keyframes slashRed {
  0%, 100% { opacity: 0; }
}
