/* ============================================================
 *  DBO Galaxy Support Portal-Custom Styles
 *  Light-first theme with dark mode toggle
 * ============================================================ */

/* ---- CSS Variables ---- */
:root,
[data-bs-theme="light"] {
  --sp-primary:     #269eff;
  --sp-primary-rgb: 38,158,255;
  --sp-accent:      #f4a623;
  --sp-bg:          #f8fafc;
  --sp-surface:     #ffffff;
  --sp-surface-alt: #f1f5f9;
  --sp-border:      #e2e8f0;
  --sp-text:        #1e293b;
  --sp-text-muted:  #64748b;
  --sp-text-light:  #94a3b8;
  --sp-nav-bg:      #ffffff;
  --sp-nav-shadow:  0 1px 3px rgba(0,0,0,0.08);
  --sp-card-shadow: 0 1px 3px rgba(0,0,0,0.06);
  --sp-input-bg:    #ffffff;
  --sp-input-border:#d1d5db;
  --sp-footer-bg:   #1e293b;
  --sp-footer-text: #94a3b8;
  --sp-badge-bg:    rgba(38,158,255,0.1);
  --sp-badge-text:  #269eff;
  --sp-warning-bg:  rgba(245,158,11,0.08);
  --sp-warning-border: rgba(245,158,11,0.25);
  --sp-success:     #10b981;
  --sp-danger:      #ef4444;
}

[data-bs-theme="dark"] {
  --sp-bg:          #0f172a;
  --sp-surface:     #1e293b;
  --sp-surface-alt: #162032;
  --sp-border:      #334155;
  --sp-text:        #e2e8f0;
  --sp-text-muted:  #94a3b8;
  --sp-text-light:  #64748b;
  --sp-nav-bg:      #1e293b;
  --sp-nav-shadow:  0 1px 3px rgba(0,0,0,0.3);
  --sp-card-shadow: 0 1px 3px rgba(0,0,0,0.2);
  --sp-input-bg:    #0f172a;
  --sp-input-border:#334155;
  --sp-footer-bg:   #0c1322;
  --sp-footer-text: #64748b;
  --sp-badge-bg:    rgba(38,158,255,0.15);
  --sp-warning-bg:  rgba(245,158,11,0.1);
}

/* ---- Base ---- */
/* Skip to content link (accessibility) */
.skip-to-content {
  position: absolute;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--sp-primary);
  color: #fff;
  padding: 0.5rem 1.5rem;
  border-radius: 0 0 8px 8px;
  z-index: 10000;
  font-weight: 600;
  text-decoration: none;
  transition: top 0.2s ease;
}
.skip-to-content:focus {
  top: 0;
  color: #fff;
}

body {
  background: var(--sp-bg);
  color: var(--sp-text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--sp-primary); text-decoration: none; }
a:hover { color: var(--sp-primary); text-decoration: underline; }

/* ---- Navbar ---- */
.sp-navbar {
  background: var(--sp-nav-bg);
  box-shadow: var(--sp-nav-shadow);
  border-bottom: 2px solid var(--sp-primary);
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 1030;
}
.sp-navbar .navbar-brand {
  color: var(--sp-text);
  font-weight: 700;
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sp-navbar .navbar-brand img {
  width: 32px;
  height: 32px;
  border-radius: 6px;
}
.sp-navbar .nav-link {
  color: var(--sp-text-muted);
  font-weight: 500;
  font-size: 0.88rem;
  padding: 0.65rem 0.7rem !important;
  transition: color 0.2s;
  white-space: nowrap;
}
.sp-navbar .nav-link:hover,
.sp-navbar .nav-link.active {
  color: var(--sp-primary);
}
.sp-navbar .nav-link i { margin-right: 4px; }

/* ---- Main Content ---- */
.sp-main {
  flex: 1;
  padding: 2rem 0;
}

/* ---- Cards ---- */
.sp-card {
  background: var(--sp-surface);
  border: 1px solid var(--sp-border);
  border-radius: 12px;
  box-shadow: var(--sp-card-shadow);
  transition: box-shadow 0.2s, transform 0.2s;
}
.sp-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.sp-card .card-header {
  background: var(--sp-surface-alt);
  border-bottom: 1px solid var(--sp-border);
  border-radius: 12px 12px 0 0 !important;
  padding: 1rem 1.25rem;
  font-weight: 600;
}
.sp-card .card-body { padding: 1.25rem; }

/* ---- Category Cards (clickable grid) ---- */
.category-card {
  background: var(--sp-surface);
  border: 2px solid var(--sp-border);
  border-radius: 12px;
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}
.category-card:hover {
  border-color: var(--sp-primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(38,158,255,0.12);
}
.category-card.selected {
  border-color: var(--sp-primary);
  background: rgba(var(--sp-primary-rgb), 0.06);
}
.category-card i {
  font-size: 2rem;
  color: var(--sp-primary);
  display: block;
  margin-bottom: 0.75rem;
}
.category-card .cat-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--sp-text);
}
.category-card .cat-count {
  font-size: 0.8rem;
  color: var(--sp-text-muted);
  margin-top: 4px;
}

/* ---- Ticket Thread ---- */
.msg-bubble {
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  position: relative;
}
.msg-bubble.msg-player {
  background: var(--sp-surface-alt);
  border-left: 4px solid var(--sp-success);
}
.msg-bubble.msg-staff {
  background: rgba(var(--sp-primary-rgb), 0.06);
  border-left: 4px solid var(--sp-primary);
}
.msg-bubble.msg-system {
  background: var(--sp-surface-alt);
  border-left: 4px solid var(--sp-text-light);
  font-style: italic;
  color: var(--sp-text-muted);
}
.msg-bubble.msg-internal {
  background: var(--sp-warning-bg);
  border-left: 4px solid var(--sp-accent);
}
.msg-sender {
  font-weight: 600;
  font-size: 0.9rem;
}
.msg-time {
  font-size: 0.78rem;
  color: var(--sp-text-light);
}

/* ---- Status Badges ---- */
.badge-open        { background: rgba(16,185,129,0.12); color: #10b981; font-weight: 600; }
.badge-waiting     { background: rgba(245,158,11,0.12); color: #f59e0b; font-weight: 600; }
.badge-waiting_reply { background: rgba(245,158,11,0.12); color: #f59e0b; font-weight: 600; }
.badge-replied     { background: rgba(38,158,255,0.12); color: #269eff; font-weight: 600; }
.badge-closed      { background: rgba(100,116,139,0.12); color: #64748b; font-weight: 600; }

.badge-tier1       { background: rgba(16,185,129,0.12); color: #10b981; }
.badge-tier2       { background: rgba(245,158,11,0.12); color: #f59e0b; }
.badge-tier3       { background: rgba(239,68,68,0.12);  color: #ef4444; }

.badge-lang {
  background: var(--sp-badge-bg);
  color: var(--sp-badge-text);
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
}

/* ---- Buttons ---- */
.btn-sp {
  background: var(--sp-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.5rem 1.5rem;
  font-weight: 600;
  transition: all 0.2s;
}
.btn-sp:hover { background: #1a85e0; color: #fff; transform: translateY(-1px); }

.btn-sp-outline {
  background: transparent;
  color: var(--sp-primary);
  border: 2px solid var(--sp-primary);
  border-radius: 8px;
  padding: 0.45rem 1.4rem;
  font-weight: 600;
  transition: all 0.2s;
}
.btn-sp-outline:hover { background: var(--sp-primary); color: #fff; }

/* ---- Forms ---- */
.sp-input {
  background: var(--sp-input-bg);
  border: 1px solid var(--sp-input-border);
  border-radius: 8px;
  color: var(--sp-text);
  padding: 0.6rem 0.9rem;
  transition: border-color 0.2s;
}
.sp-input:focus {
  border-color: var(--sp-primary);
  box-shadow: 0 0 0 3px rgba(var(--sp-primary-rgb), 0.15);
  outline: none;
}

/* ---- Form Steps ---- */
.form-step { display: none; }
.form-step.active { display: block; }

/* ---- Step Indicator ---- */
.step-indicator {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0;
  margin-bottom: 2rem;
}
.step-item {
  display: flex;
  align-items: center;
  gap: 0;
}
.step-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  background: var(--sp-surface-alt);
  color: var(--sp-text-muted);
  border: 2px solid var(--sp-border);
  transition: all 0.3s;
}
.step-circle.active {
  background: var(--sp-primary);
  color: #fff;
  border-color: var(--sp-primary);
}
.step-circle.done {
  background: var(--sp-success);
  color: #fff;
  border-color: var(--sp-success);
}
.step-line {
  width: 40px;
  height: 2px;
  background: var(--sp-border);
  margin: 0 4px;
  transition: background 0.3s;
}
.step-line.done { background: var(--sp-success); }

/* ---- Hero Section ---- */
.sp-hero {
  text-align: center;
  padding: 3rem 1rem;
  background: linear-gradient(135deg, rgba(var(--sp-primary-rgb),0.08), rgba(var(--sp-primary-rgb),0.02));
  border-radius: 16px;
  margin-bottom: 2rem;
}
.sp-hero h1 {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}
.sp-hero p { color: var(--sp-text-muted); font-size: 1.1rem; }
.sp-hero .search-box {
  max-width: 500px;
  margin: 1.5rem auto 0;
}

/* ---- Warning Box ---- */
.sp-warning {
  background: var(--sp-warning-bg);
  border: 1px solid var(--sp-warning-border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  color: var(--sp-accent);
  font-size: 0.88rem;
  margin-bottom: 1rem;
}

/* ---- Footer ---- */
.sp-footer {
  background: var(--sp-footer-bg);
  color: var(--sp-footer-text);
  padding: 2rem 0;
  margin-top: auto;
  font-size: 0.85rem;
}
.sp-footer a { color: var(--sp-text-light); }
.sp-footer a:hover { color: var(--sp-primary); text-decoration: none; }

/* Footer social icons */
.footer-social {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  color: var(--sp-text-muted);
  text-decoration: none;
  font-size: 1rem;
  transition: background 0.2s, color 0.2s, transform 0.2s;
}
.footer-social:hover {
  background: var(--sp-primary);
  color: #fff;
  transform: translateY(-2px);
}

/* ---- Cookie Banner ---- */
.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--sp-surface);
  border-top: 1px solid var(--sp-border);
  box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
  padding: 1rem 2rem;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}
.cookie-banner.hidden { display: none; }

/* ---- Priority badges ---- */
.priority-low    { color: var(--sp-text-muted); }
.priority-normal { color: var(--sp-primary); }
.priority-high   { color: var(--sp-accent); }
.priority-urgent { color: var(--sp-danger); }

/* ---- Stat Cards (Staff Dashboard) ---- */
.stat-card {
  background: var(--sp-surface);
  border: 1px solid var(--sp-border);
  border-radius: 12px;
  padding: 1.25rem;
  text-align: center;
  transition: transform 0.2s;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-number { font-size: 1.75rem; font-weight: 800; color: var(--sp-primary); }
.stat-label  { font-size: 0.82rem; color: var(--sp-text-muted); margin-top: 4px; }

/* ============================================================
 *  Staff Dashboard-Zendesk-inspired Rework
 * ============================================================ */

/* ---- Dashboard Stat Cards ---- */
.dash-stat-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--sp-surface);
  border: 1px solid var(--sp-border);
  border-radius: 12px;
  padding: 1.25rem;
  text-decoration: none;
  color: var(--sp-text);
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}
.dash-stat-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  border-radius: 12px 0 0 12px;
}
.dash-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  text-decoration: none;
  color: var(--sp-text);
}
.dash-stat-card.active { border-color: var(--sp-primary); box-shadow: 0 0 0 2px rgba(var(--sp-primary-rgb),0.15); }
.dash-stat-danger::before  { background: #ef4444; }
.dash-stat-warning::before { background: #f59e0b; }
.dash-stat-info::before    { background: #269eff; }
.dash-stat-primary::before { background: #8b5cf6; }
.dash-stat-icon {
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
  font-size: 1.25rem;
  flex-shrink: 0;
}
.dash-stat-danger .dash-stat-icon  { background: rgba(239,68,68,0.1); color: #ef4444; }
.dash-stat-warning .dash-stat-icon { background: rgba(245,158,11,0.1); color: #f59e0b; }
.dash-stat-info .dash-stat-icon    { background: rgba(38,158,255,0.1); color: #269eff; }
.dash-stat-primary .dash-stat-icon { background: rgba(139,92,246,0.1); color: #8b5cf6; }
.dash-stat-number { font-size: 1.5rem; font-weight: 800; line-height: 1; }
.dash-stat-label  { font-size: 0.78rem; color: var(--sp-text-muted); margin-top: 2px; }

/* ---- Dashboard Toolbar ---- */
.dash-toolbar {
  background: var(--sp-surface);
  border: 1px solid var(--sp-border);
  border-radius: 12px;
  padding: 0.75rem 1rem;
}
.dash-filter-pills {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.dash-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--sp-text-muted);
  background: transparent;
  border: 1px solid transparent;
  text-decoration: none;
  transition: all 0.2s;
}
.dash-pill:hover {
  background: var(--sp-surface-alt);
  color: var(--sp-text);
  text-decoration: none;
}
.dash-pill.active {
  background: rgba(var(--sp-primary-rgb),0.1);
  color: var(--sp-primary);
  border-color: rgba(var(--sp-primary-rgb),0.2);
}
.dash-pill-count {
  background: var(--sp-surface-alt);
  color: var(--sp-text-muted);
  font-size: 0.72rem;
  padding: 1px 7px;
  border-radius: 10px;
  font-weight: 700;
}
.dash-pill.active .dash-pill-count {
  background: rgba(var(--sp-primary-rgb),0.15);
  color: var(--sp-primary);
}
.dash-search-form { max-width: 280px; }
.dash-search-form .input-group-text {
  background: var(--sp-input-bg);
  border-color: var(--sp-input-border);
  color: var(--sp-text-muted);
}

/* ---- Dashboard Queue Card ---- */
.dash-queue-card {
  background: var(--sp-surface);
  border: 1px solid var(--sp-border);
  border-radius: 12px;
  overflow: hidden;
}
.dash-queue-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--sp-border);
  background: var(--sp-surface-alt);
}
.dash-empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--sp-text-muted);
}
.dash-empty-state i { font-size: 3rem; display: block; margin-bottom: 0.75rem; opacity: 0.4; }
.dash-empty-state p { margin: 0; font-size: 0.95rem; }

.dash-table-wrap { overflow-x: auto; }
.dash-table { margin: 0; }
.dash-table thead th {
  background: transparent;
  border-bottom: 1px solid var(--sp-border);
  color: var(--sp-text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.65rem 0.75rem;
  white-space: nowrap;
}
.dash-table tbody tr {
  border-bottom: 1px solid var(--sp-border);
  transition: background 0.15s;
}
.dash-table tbody tr:last-child { border-bottom: none; }
.dash-table tbody tr:hover { background: var(--sp-surface-alt); }
.dash-table td { padding: 0.75rem; vertical-align: middle; font-size: 0.88rem; }

/* Row priority indicators */
.dash-ticket-row { cursor: pointer; }
.priority-row-high { border-left: 3px solid #ef4444; }
.priority-row-medium { border-left: 3px solid #f59e0b; }
.priority-row-low { border-left: 3px solid transparent; }

.ticket-id-badge {
  font-family: 'SF Mono', 'Cascadia Code', monospace;
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--sp-primary);
  background: rgba(var(--sp-primary-rgb),0.08);
  padding: 3px 8px;
  border-radius: 6px;
}
.ticket-subject { font-weight: 600; font-size: 0.88rem; line-height: 1.3; }
.ticket-player { font-size: 0.78rem; color: var(--sp-text-muted); margin-top: 2px; }
.ticket-cat-badge {
  font-size: 0.78rem;
  color: var(--sp-text-muted);
  background: var(--sp-surface-alt);
  padding: 2px 8px;
  border-radius: 4px;
}
.assigned-badge {
  font-size: 0.82rem;
  color: var(--sp-success);
}
.unassigned-badge {
  font-size: 0.82rem;
  color: var(--sp-accent);
}
.time-ago { font-size: 0.8rem; color: var(--sp-text-muted); }

/* Priority dots */
.priority-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
}
.priority-dot.priority-high { background: #ef4444; }
.priority-dot.priority-medium { background: #f59e0b; }
.priority-dot.priority-low { background: #94a3b8; }

/* Pagination */
.dash-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border-top: 1px solid var(--sp-border);
}

/* ---- Mobile Cards ---- */
.dash-mobile-card {
  display: block;
  background: var(--sp-surface);
  border: 1px solid var(--sp-border);
  border-radius: 10px;
  padding: 0.875rem;
  margin: 0.5rem 0.75rem;
  text-decoration: none;
  color: var(--sp-text);
  transition: all 0.15s;
}
.dash-mobile-card:hover { text-decoration: none; color: var(--sp-text); border-color: var(--sp-primary); }
.priority-border-high { border-left: 3px solid #ef4444; }
.priority-border-medium { border-left: 3px solid #f59e0b; }
.priority-border-low { border-left: 3px solid transparent; }

/* ============================================================
 *  Staff Ticket View-Reworked Thread + Sidebar
 * ============================================================ */

/* ---- Ticket Header Card ---- */
.ticket-header-card {
  background: var(--sp-surface);
  border: 1px solid var(--sp-border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  box-shadow: var(--sp-card-shadow);
}
.ticket-meta-row {
  font-size: 0.85rem;
  color: var(--sp-text-muted);
  margin-top: 4px;
}

/* ---- Thread Messages ---- */
.ticket-thread-container {
  position: relative;
  padding-left: 28px;
  margin-bottom: 1.5rem;
}
.ticket-thread-container::before {
  content: '';
  position: absolute;
  left: 20px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--sp-border);
}
.thread-msg {
  display: flex;
  gap: 1rem;
  margin-bottom: 0;
  padding: 1rem 0;
  position: relative;
}
.thread-msg + .thread-msg {
  border-top: 1px solid var(--sp-border);
}
.thread-msg-avatar {
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}
.avatar-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  border: 2px solid var(--sp-surface);
}
.avatar-player { background: rgba(16,185,129,0.15); color: #10b981; }
.avatar-staff  { background: rgba(38,158,255,0.15); color: #269eff; }
.avatar-system { background: var(--sp-surface-alt); color: var(--sp-text-light); }

.thread-msg-content {
  flex: 1;
  min-width: 0;
}
.thread-msg-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  flex-wrap: wrap;
  gap: 4px;
}
.thread-msg-sender { font-size: 0.88rem; }
.thread-msg-body {
  font-size: 0.9rem;
  line-height: 1.65;
  color: var(--sp-text);
  word-wrap: break-word;
}
.thread-msg-body p:last-child { margin-bottom: 0; }

/* Internal note highlight */
.thread-msg-internal .thread-msg-content {
  background: var(--sp-warning-bg);
  border: 1px solid var(--sp-warning-border);
  border-radius: 10px;
  padding: 0.75rem 1rem;
}

/* ---- Attachments ---- */
.thread-msg-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.att-file-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: 6px;
  background: var(--sp-surface-alt);
  color: var(--sp-text-muted);
  font-size: 0.8rem;
  text-decoration: none;
  border: 1px solid var(--sp-border);
  transition: all 0.15s;
}
.att-file-badge:hover { border-color: var(--sp-primary); color: var(--sp-primary); text-decoration: none; }
.att-image-preview {
  display: inline-block;
  text-decoration: none;
}
.att-image-preview img {
  max-height: 150px;
  max-width: 250px;
  border-radius: 8px;
  border: 1px solid var(--sp-border);
  object-fit: cover;
}
.att-image-preview .att-filename {
  display: block;
  font-size: 0.75rem;
  color: var(--sp-text-muted);
  margin-top: 2px;
}
.att-video-preview .att-filename {
  font-size: 0.78rem;
  color: var(--sp-text-muted);
  margin-top: 4px;
}

/* ---- Reply Card ---- */
.ticket-reply-card {
  background: var(--sp-surface);
  border: 1px solid var(--sp-border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--sp-card-shadow);
}
.ticket-reply-header {
  background: var(--sp-surface-alt);
  border-bottom: 1px solid var(--sp-border);
  padding: 0.75rem 1.25rem;
}
.ticket-reply-body { padding: 0; }
.ticket-reply-body textarea {
  border: none;
  border-radius: 0;
  resize: vertical;
  min-height: 120px;
}
.ticket-reply-body textarea:focus {
  box-shadow: none;
  border-color: transparent;
}
.ticket-reply-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--sp-border);
  background: var(--sp-surface-alt);
  gap: 1rem;
  flex-wrap: wrap;
}

/* Closed banner */
.ticket-closed-banner {
  background: var(--sp-surface);
  border: 1px solid var(--sp-border);
  border-radius: 12px;
  text-align: center;
  padding: 2rem;
  color: var(--sp-text-muted);
}

/* ---- Sidebar Cards ---- */
.sidebar-card {
  background: var(--sp-surface);
  border: 1px solid var(--sp-border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--sp-card-shadow);
}
.sidebar-card-header {
  background: var(--sp-surface-alt);
  border-bottom: 1px solid var(--sp-border);
  padding: 0.65rem 1rem;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--sp-text);
}
.sidebar-card-body {
  padding: 0.875rem 1rem;
}
.sidebar-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--sp-border);
  font-size: 0.85rem;
}
.sidebar-detail-row:last-child { border-bottom: none; }
.sidebar-detail-label {
  color: var(--sp-text-muted);
  font-weight: 600;
  font-size: 0.8rem;
}

/* ---- TinyMCE Dark Theme Adjustments ---- */
[data-bs-theme="dark"] .tox-tinymce {
  border-color: var(--sp-border) !important;
  border-radius: 0 !important;
}
[data-bs-theme="dark"] .tox .tox-toolbar,
[data-bs-theme="dark"] .tox .tox-toolbar__overflow,
[data-bs-theme="dark"] .tox .tox-toolbar__primary {
  background: var(--sp-surface-alt) !important;
}

/* Font-size helper */
.fs-7 { font-size: 0.82rem; }

/* ---- KB Article ---- */
.kb-article { line-height: 1.8; }
.kb-article h2 { margin-top: 2rem; font-size: 1.4rem; }
.kb-article h3 { margin-top: 1.5rem; font-size: 1.15rem; }
.kb-article img { max-width: 100%; height: auto; border-radius: 8px; margin: 1rem 0; }
.kb-article pre { background: var(--sp-surface-alt); border-radius: 8px; padding: 1rem; overflow-x: auto; }
.kb-article blockquote { border-left: 4px solid var(--sp-primary); padding: 0.5rem 1rem; margin: 1rem 0; background: var(--sp-surface-alt); border-radius: 0 8px 8px 0; }

/* ---- Language Switcher ---- */
.lang-switch-btn {
  background: var(--sp-surface-alt);
  border: 1px solid var(--sp-border);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  color: var(--sp-text-muted);
  font-size: 0.85rem;
  transition: all 0.2s;
}
.lang-switch-btn:hover { border-color: var(--sp-primary); color: var(--sp-primary); }

/* ---- Responsive ---- */
@media (max-width: 991px) {
  .sp-main .container { max-width: 100%; padding: 0 0.75rem; }
  .dash-toolbar .d-flex { flex-direction: column; }
  .dash-search-form { max-width: 100% !important; }
  .dash-filter-pills { justify-content: center; }
  .ticket-thread-container { padding-left: 16px; }
  .ticket-thread-container::before { left: 12px; }
  .ticket-reply-footer { flex-direction: column; }
  .ticket-reply-footer .d-flex { width: 100%; }
  .sidebar-card { margin-bottom: 1rem; }
}

@media (max-width: 768px) {
  .sp-hero h1 { font-size: 1.5rem; }
  .sp-hero { padding: 2rem 0.75rem; }
  .sp-main { padding: 1rem 0; }
  .step-line { width: 20px; }
  .step-circle { width: 30px; height: 30px; font-size: 0.75rem; }
  .cookie-banner { flex-direction: column; text-align: center; gap: 0.75rem; }

  /* Ticket form full-width */
  .sp-card { border-radius: 8px; }
  .sp-card[style*="max-width"] { max-width: 100% !important; }
  .category-card { padding: 0.875rem !important; }
  .category-card i { font-size: 1.5rem !important; }

  /* Stat cards 2x2 grid */
  .dash-stat-card { padding: 0.875rem; gap: 0.75rem; }
  .dash-stat-icon { width: 40px; height: 40px; font-size: 1rem; }
  .dash-stat-number { font-size: 1.25rem; }
  .dash-stat-label { font-size: 0.72rem; }

  /* Footer stacked */
  .sp-footer .row > div { text-align: center; }
  .sp-footer .d-flex { justify-content: center; }

  /* Buttons full-width in ticket views */
  .btn-sp, .btn-sp-outline { width: 100%; text-align: center; }
  .d-flex.justify-content-between:has(.btn-step-prev) { gap: 0.5rem; }
  .d-flex.justify-content-between:has(.btn-step-prev) > * { flex: 1; }

  /* Navbar compact */
  .sp-navbar .navbar-brand img { width: 28px; height: 28px; }
  .sp-navbar .nav-link { padding: 0.5rem 0.75rem !important; font-size: 0.85rem; }

  /* Queue header */
  .dash-queue-header { flex-direction: column; gap: 0.5rem; text-align: center; }

  /* Sidebar details on ticket view */
  .sidebar-detail-row { font-size: 0.8rem; }
}

@media (max-width: 480px) {
  .sp-hero h1 { font-size: 1.25rem; }
  .sp-hero p { font-size: 0.9rem; }
  .step-line { width: 12px; }
  .step-circle { width: 26px; height: 26px; font-size: 0.7rem; }

  /* Mobile card improvements */
  .dash-mobile-card { padding: 0.75rem; margin: 0.375rem 0.5rem; }
  .ticket-id-badge { font-size: 0.75rem; padding: 2px 6px; }

  /* Thread messages compact */
  .thread-msg { gap: 0.5rem; }
  .avatar-circle { width: 28px; height: 28px; font-size: 0.75rem; }
  .thread-msg-body { font-size: 0.85rem; }

  /* Attachment previews */
  .att-image-preview img { max-height: 100px; max-width: 160px; }
}

/* ===== M17: Animations ===== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* Stat cards */
.dash-stat-card {
  animation: fadeInUp 0.4s ease both;
}
.dash-stat-card:nth-child(1) { animation-delay: 0.05s; }
.dash-stat-card:nth-child(2) { animation-delay: 0.1s; }
.dash-stat-card:nth-child(3) { animation-delay: 0.15s; }
.dash-stat-card:nth-child(4) { animation-delay: 0.2s; }

/* Sidebar cards */
.sidebar-card {
  animation: slideInRight 0.35s ease both;
}
.sidebar-card:nth-child(1) { animation-delay: 0.05s; }
.sidebar-card:nth-child(2) { animation-delay: 0.1s; }
.sidebar-card:nth-child(3) { animation-delay: 0.15s; }
.sidebar-card:nth-child(4) { animation-delay: 0.2s; }
.sidebar-card:nth-child(5) { animation-delay: 0.25s; }
.sidebar-card:nth-child(6) { animation-delay: 0.3s; }

/* Thread messages */
.thread-msg {
  animation: fadeInUp 0.3s ease both;
}
.thread-msg:nth-child(n+2) { animation-delay: 0.08s; }
.thread-msg:nth-child(n+3) { animation-delay: 0.12s; }

/* Ticket header card */
.ticket-header-card { animation: fadeIn 0.35s ease both; }

/* Ticket reply card */
.ticket-reply-card { animation: fadeInUp 0.4s ease 0.15s both; }

/* Breadcrumbs */
nav[aria-label="breadcrumb"] { animation: fadeIn 0.3s ease both; }

/* Flash messages */
.alert {
  animation: fadeInUp 0.35s ease both;
}

/* Badge/pill hover */
.dash-pill { transition: all 0.2s ease; }
.dash-pill:hover { transform: translateY(-1px); }

/* Button hover */
.btn { transition: all 0.2s ease; }

/* Table rows */
.dash-ticket-row {
  animation: fadeIn 0.25s ease both;
  transition: background-color 0.15s ease;
}

/* Smooth modal */
.modal.fade .modal-dialog {
  transition: transform 0.25s ease;
}

/* ============================================================
 *  Live Chat Widget
 * ============================================================ */
.chat-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--sp-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(38,158,255,0.35);
  z-index: 10000;
  transition: transform 0.2s, box-shadow 0.2s;
}
.chat-bubble:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 24px rgba(38,158,255,0.5);
}
.chat-bubble-active {
  transform: scale(0.9);
}
.chat-bubble-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ef4444;
  color: #fff;
  font-size: 0.7rem;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
.chat-window {
  position: fixed;
  bottom: 90px;
  right: 24px;
  width: 380px;
  max-height: 560px;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(0,0,0,0.2);
  z-index: 10001;
  display: flex;
  flex-direction: column;
  background: var(--sp-surface);
  border: 1px solid var(--sp-border);
  animation: chatSlideUp 0.3s ease;
}
@keyframes chatSlideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chat-header {
  background: linear-gradient(135deg, #1e3a5f 0%, #269eff 100%);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.chat-header-title { font-weight: 600; font-size: 0.95rem; }
.chat-header-status { font-size: 0.75rem; opacity: 0.85; }
.chat-header-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.8rem;
  transition: background 0.2s;
}
.chat-header-btn:hover { background: rgba(255,255,255,0.3); }
.chat-prebody {
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.chat-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 300px;
  max-height: 380px;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-msg {
  display: flex;
  gap: 8px;
  max-width: 88%;
  animation: chatMsgIn 0.2s ease;
}
@keyframes chatMsgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chat-msg-player { align-self: flex-end; flex-direction: row-reverse; }
.chat-msg-bot, .chat-msg-staff { align-self: flex-start; }
.chat-msg-system { align-self: center; max-width: 100%; }
.chat-msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.chat-msg-avatar.bot { background: rgba(38,158,255,0.15); color: var(--sp-primary); }
.chat-msg-avatar.staff { background: rgba(16,185,129,0.15); color: #10b981; }
.chat-msg-avatar.player { background: rgba(148,163,184,0.15); color: var(--sp-text-muted); }
.chat-msg-avatar.system { background: rgba(245,158,11,0.15); color: #f59e0b; }
.chat-msg-content { min-width: 0; }
.chat-msg-name { font-size: 0.7rem; font-weight: 600; color: var(--sp-text-muted); margin-bottom: 2px; }
.chat-msg-text {
  background: var(--sp-surface-alt);
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 0.85rem;
  line-height: 1.45;
  word-wrap: break-word;
}
.chat-msg-player .chat-msg-text {
  background: var(--sp-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-msg-bot .chat-msg-text, .chat-msg-staff .chat-msg-text {
  border-bottom-left-radius: 4px;
}
.chat-msg-system .chat-msg-text {
  background: rgba(245,158,11,0.08);
  color: var(--sp-text-muted);
  text-align: center;
  font-size: 0.8rem;
  font-style: italic;
}
.chat-msg-time { font-size: 0.65rem; color: var(--sp-text-light); margin-top: 2px; }
.chat-link { color: #60a5fa !important; text-decoration: underline; }
.chat-actions {
  padding: 8px 14px;
  display: flex;
  gap: 8px;
  justify-content: center;
  border-top: 1px solid var(--sp-border);
}
.chat-input-bar {
  padding: 10px 14px;
  border-top: 1px solid var(--sp-border);
  background: var(--sp-surface);
}
.chat-input-wrap {
  display: flex;
  gap: 6px;
}

/* ---- Redesign polish ---- */
.chat-header-avatar { position: relative; display: inline-flex; }
.chat-header-online {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid #1e3a5f;
  box-shadow: 0 0 0 0 rgba(34,197,94,0.6);
  animation: chatOnlinePulse 2.4s infinite;
}
@keyframes chatOnlinePulse {
  0%   { box-shadow: 0 0 0 0 rgba(34,197,94,0.55); }
  70%  { box-shadow: 0 0 0 6px rgba(34,197,94,0); }
  100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}
.chat-header-title { letter-spacing: 0.2px; }

/* Subtle attention pulse on the closed bubble */
.chat-bubble:not(.chat-bubble-active)::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(38,158,255,0.5);
  animation: chatBubblePulse 2.8s infinite;
  pointer-events: none;
}
@keyframes chatBubblePulse {
  0%   { box-shadow: 0 0 0 0 rgba(38,158,255,0.45); }
  70%  { box-shadow: 0 0 0 14px rgba(38,158,255,0); }
  100% { box-shadow: 0 0 0 0 rgba(38,158,255,0); }
}

/* Polished message bubbles */
.chat-msg-text {
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.chat-msg-bot .chat-msg-text, .chat-msg-staff .chat-msg-text {
  border: 1px solid var(--sp-border);
}
.chat-msg-text a.chat-link { font-weight: 600; }
.chat-msg-player .chat-msg-text a.chat-link { color: #e0f2fe !important; }

/* Custom scrollbar inside the message list */
.chat-messages::-webkit-scrollbar { width: 7px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--sp-border); border-radius: 8px; }
.chat-messages::-webkit-scrollbar-thumb:hover { background: var(--sp-text-light); }

/* Quick-reply suggestion chips */
.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 14px 4px;
}
.chat-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--sp-primary);
  color: var(--sp-primary);
  background: rgba(38,158,255,0.06);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, color 0.15s;
  white-space: nowrap;
  text-decoration: none;
}
.chat-chip:hover { background: var(--sp-primary); color: #fff; transform: translateY(-1px); }
.chat-chip i { font-size: 0.85rem; }

/* ============================================================
 *  Staff Chat Panel
 * ============================================================ */
.chat-session-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--sp-border);
  cursor: pointer;
  transition: background 0.15s;
}
.chat-session-item:hover, .chat-session-item.active {
  background: rgba(38,158,255,0.06);
}
.chat-session-item.chat-session-urgent {
  background: rgba(245,158,11,0.08);
  border-left: 3px solid #f59e0b;
}
.badge-chat-bot     { background: rgba(38,158,255,0.15); color: var(--sp-primary); }
.badge-chat-waiting { background: rgba(245,158,11,0.15); color: #f59e0b; }
.badge-chat-live    { background: rgba(16,185,129,0.15); color: #10b981; }
.badge-chat-closed  { background: rgba(148,163,184,0.15); color: var(--sp-text-muted); }

.staff-chat-msg {
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.staff-chat-msg-bot .staff-chat-icon { color: var(--sp-primary); }
.staff-chat-msg-staff .staff-chat-icon { color: #10b981; }
.staff-chat-msg-player .staff-chat-icon { color: var(--sp-text-muted); }
.staff-chat-msg-system .staff-chat-icon { color: #f59e0b; }
.staff-chat-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sp-surface-alt);
  flex-shrink: 0;
}
.staff-chat-text {
  font-size: 0.88rem;
  line-height: 1.5;
  word-wrap: break-word;
}
.staff-chat-msg-system .staff-chat-text {
  font-style: italic;
  color: var(--sp-text-muted);
}

/* Chat widget mobile */
@media (max-width: 480px) {
  .chat-window {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-height: 100vh;
    border-radius: 16px 16px 0 0;
  }
  .chat-bubble {
    bottom: 16px;
    right: 16px;
    width: 50px;
    height: 50px;
    font-size: 1.3rem;
  }
}

/* ============================================================
 *  Typing Indicator
 * ============================================================ */
.chat-typing-indicator {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 4px 12px;
  font-size: 0.75rem;
  color: var(--sp-text-muted);
}
.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--sp-text-muted);
  animation: typingBounce 1.2s infinite ease-in-out;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
.typing-name {
  margin-left: 6px;
  font-style: italic;
  font-size: 0.72rem;
}
@keyframes typingBounce {
  0%, 100% { transform: translateY(0); opacity: 0.3; }
  50% { transform: translateY(-2px); opacity: 1; }
}

/* ---- DeepL Translate ---- */
.translate-msg-btn {
  font-size: 0.72rem;
  padding: 2px 8px !important;
  border-radius: 12px;
  opacity: 0.6;
  transition: opacity 0.2s;
}
.translate-msg-btn:hover { opacity: 1; }
.translated-text {
  margin-top: 8px;
  padding: 8px 12px;
  background: rgba(38,158,255,0.07);
  border-left: 3px solid var(--sp-primary);
  border-radius: 0 8px 8px 0;
  font-size: 0.9rem;
}
.translated-header {
  font-size: 0.7rem;
  color: var(--sp-muted);
  margin-bottom: 4px;
  font-style: italic;
}
.chat-translate-btn {
  opacity: 0.5;
  transition: opacity 0.2s;
  text-decoration: none !important;
}
.chat-translate-btn:hover { opacity: 1; }

/* ============================================================
 *  UI Polish-Enhanced spacing, typography, hover states
 * ============================================================ */

/* Better card hover states */
.sp-card {
  transition: box-shadow 0.2s ease, transform 0.15s ease;
}
.sp-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* Dashboard stat cards hover */
.dash-stat-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.dash-stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.12) !important;
}

/* Better button transitions */
.btn-sp, .btn-outline-secondary, .btn-outline-primary, .btn-outline-danger, .btn-outline-success, .btn-outline-warning, .btn-outline-info {
  transition: all 0.2s ease;
}

/* Ticket row hover enhancement */
.dash-ticket-row:hover {
  background: rgba(38,158,255,0.04) !important;
  transform: translateX(2px);
  transition: all 0.15s ease;
}

/* Badge enhancements */
.badge {
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* Better input focus states */
.sp-input:focus {
  border-color: var(--sp-primary) !important;
  box-shadow: 0 0 0 3px rgba(38,158,255,0.15) !important;
  transition: all 0.2s ease;
}

/* Chat file upload button styling */
.chat-file-btn {
  border-radius: 8px !important;
  font-size: 0.9rem;
}
.chat-file-btn:hover {
  background: var(--sp-primary);
  color: #fff;
  border-color: var(--sp-primary);
}

/* Analytics cards */
.sp-card canvas {
  max-width: 100%;
}

/* Audit log table */
.table-sm td, .table-sm th {
  padding: 0.4rem 0.6rem;
}

/* Toast animations */
.toast-container .toast {
  animation: slideInRight 0.3s ease;
}
@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Smooth page transitions */
.sp-main {
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Chat images in messages */
.chat-msg-text img,
.staff-chat-text img {
  max-width: 200px;
  max-height: 200px;
  border-radius: 8px;
  margin-top: 4px;
  cursor: pointer;
  transition: transform 0.2s ease;
}
.chat-msg-text img:hover,
.staff-chat-text img:hover {
  transform: scale(1.05);
}

/* 2FA page styling */
.font-monospace {
  font-family: 'Courier New', monospace !important;
}

/* Staff tier badges (consistent across views) */
.badge-tier1 { background: #6b7280; color: #fff; }
.badge-tier2 { background: #3b82f6; color: #fff; }
.badge-tier3 { background: #f59e0b; color: #1e293b; }

/* ============================================================
 *  Mobile Polish
 * ============================================================ */
@media (max-width: 768px) {
  /* Better spacing on mobile */
  .container-fluid { padding-left: 12px !important; padding-right: 12px !important; }
  
  /* Dashboard stat cards: 2-column grid */
  .dash-stat-card .dash-stat-number { font-size: 1.5rem; }
  .dash-stat-card .dash-stat-label { font-size: 0.7rem; }
  
  /* Quick actions wrap better */
  .dash-toolbar { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .dash-filter-pills { flex-wrap: nowrap; overflow-x: auto; }
  
  /* Staff chat panel: stack vertically */
  .staff-chat-msg { padding: 6px 0; }
  
  /* Better mobile ticket cards */
  .dash-mobile-card { margin-bottom: 8px !important; padding: 12px !important; }
  
  /* Table font size adjustments */
  .dash-table { font-size: 0.82rem; }
  
  /* Nav improvements */
  .sp-navbar .nav-link { font-size: 0.85rem; padding: 0.6rem 0.75rem !important; }
  
  /* Analytics charts responsive */
  .sp-card canvas { min-height: 180px; }
  
  /* Footer compact */
  .sp-footer { padding: 1.5rem 0 !important; font-size: 0.78rem; }
}

@media (max-width: 576px) {
  /* Very small screens */
  h3 { font-size: 1.2rem; }
  .btn-sm { font-size: 0.75rem; padding: 0.25rem 0.5rem; }
  
  /* Stack action buttons */
  .d-flex.gap-2.flex-wrap { gap: 4px !important; }
  
  /* Live chat panel: full width */
  #chatConversationCard { margin-top: 12px; }
  
  /* Pagination compact */
  .dash-pagination { flex-wrap: wrap; gap: 4px; }
}

/* Prefers reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================
 *  Skeleton Loaders
 * ============================================================ */
.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--sp-card-bg, #1a2332);
  border-radius: 8px;
}
.skeleton::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.04) 50%, transparent 100%);
  animation: skeleton-shimmer 1.5s infinite;
}
@keyframes skeleton-shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
.skeleton-line {
  height: 14px;
  background: rgba(255,255,255,0.06);
  border-radius: 4px;
  margin-bottom: 10px;
}
.skeleton-line.w-75 { width: 75%; }
.skeleton-line.w-50 { width: 50%; }
.skeleton-line.w-100 { width: 100%; }
.skeleton-circle {
  width: 40px; height: 40px;
  background: rgba(255,255,255,0.06);
  border-radius: 50%;
}
.skeleton-card {
  padding: 20px;
  margin-bottom: 12px;
}
.page-skeleton { display: block; }
.page-content { display: none; }
.page-loaded .page-skeleton { display: none; }
.page-loaded .page-content { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- Announcement Carousel ---- */
.announcement-carousel {
  background: var(--sp-surface);
  border: 1px solid var(--sp-border);
  border-radius: 12px;
  padding: 1rem 1.5rem;
  position: relative;
  overflow: hidden;
}
.announcement-slide {
  display: none;
  animation: annFade 0.4s ease;
}
.announcement-slide.active {
  display: block;
}
@keyframes annFade {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: translateX(0); }
}
.announcement-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.announcement-btn {
  background: none;
  border: none;
  color: var(--sp-text-muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.2s;
}
.announcement-btn:hover { color: var(--sp-primary); }
.announcement-dots {
  display: flex;
  gap: 6px;
}
.ann-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: none;
  background: var(--sp-border);
  cursor: pointer;
  padding: 0;
  transition: background 0.2s, transform 0.2s;
}
.ann-dot.active {
  background: var(--sp-primary);
  transform: scale(1.3);
}

/* --- KB Table of Contents --- */
.kb-toc {
  background: rgba(38, 158, 255, 0.04);
  border: 1px solid var(--sp-border);
  border-left: 3px solid var(--sp-primary);
  border-radius: 8px;
}
.kb-toc a:hover {
  text-decoration: underline !important;
}

/* --- Navbar Search --- */
.navbar-search .sp-input {
  background: rgba(255,255,255,0.06) !important;
  border-color: var(--sp-border) !important;
  font-size: 0.85rem;
}
.navbar-search .sp-input:focus {
  background: rgba(255,255,255,0.1) !important;
}
@media (max-width: 991.98px) {
  .navbar-search {
    margin: 0.5rem 0;
    width: 100%;
  }
  .navbar-search .sp-input {
    max-width: 100% !important;
  }
}

/* ================================================================
 *  Reputation Name Colors (Level-Based)
 * ================================================================ */
/* Levels 1-3: default color (inherit) */
.rep-name { font-weight: 600; transition: color 0.3s, text-shadow 0.3s; }

/* Negative-dominant: strip all color perks, plain white */
.rep-name.rep-neg-dominant { color: rgba(255,255,255,0.6) !important; text-shadow: none !important; background: none !important; -webkit-text-fill-color: unset !important; animation: none !important; filter: none !important; font-weight: 500 !important; }

/* Level 4-Single custom color (--nc1) with blue fallback */
.rep-name.rep-lvl-4 { color: var(--nc1, #42A5F5); }

/* Level 5-Dual-tone glow: primary + glow color */
.rep-name.rep-lvl-5 {
  color: var(--nc1, #AB47BC);
  text-shadow: 0 0 8px var(--nc2, rgba(171, 71, 188, 0.4));
}

/* Level 6-Tri-tone warm glow */
.rep-name.rep-lvl-6 {
  color: var(--nc1, #FFA726);
  text-shadow: 0 0 10px var(--nc2, rgba(255, 167, 38, 0.5)), 0 0 20px var(--nc3, rgba(255, 167, 38, 0.2));
}

/* Level 7-RADIANT animated flowing gradient */
.rep-name.rep-lvl-7 {
  display: inline-block;
  background: linear-gradient(
    90deg,
    var(--rc1, #ff6b35),
    var(--rc2, #ffc107),
    var(--rc3, #ff1744),
    var(--rc1, #ff6b35),
    var(--rc2, #ffc107),
    var(--rc3, #ff1744),
    var(--rc1, #ff6b35)
  );
  background-size: 400% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* ================================================================
 *  Custom Color Picker Component
 * ================================================================ */
.cp-wrap { position: relative; display: inline-block; width: 100%; }
.cp-swatch {
  width: 100%; height: 42px; border-radius: 8px; cursor: pointer;
  border: 2px solid rgba(255,255,255,0.15);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.cp-swatch:hover { border-color: var(--sp-primary); box-shadow: 0 0 8px rgba(26,115,232,0.3); }
.cp-dropdown {
  position: absolute; top: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  width: 248px; padding: 14px; border-radius: 12px;
  background: var(--sp-card-bg, #1e2029); border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5); z-index: 1000;
  display: none;
}
.cp-dropdown.open { display: block; }
.cp-preview-bar {
  height: 28px; border-radius: 6px; margin-bottom: 10px;
  border: 1px solid rgba(255,255,255,0.1);
}
.cp-slider-row { margin-bottom: 8px; }
.cp-slider-row label { font-size: 0.7rem; color: rgba(255,255,255,0.5); margin-bottom: 2px; display: block; }
.cp-slider-row input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 14px;
  border-radius: 7px; outline: none; cursor: pointer; border: 1px solid rgba(255,255,255,0.08);
}
.cp-slider-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; border: 2px solid rgba(0,0,0,0.3); cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.cp-slider-row input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; border: 2px solid rgba(0,0,0,0.3); cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.cp-hue { background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00) !important; }
.cp-hex-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.cp-hex-input {
  flex: 1; background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px; color: #fff; padding: 5px 8px; font-size: 0.85rem;
  font-family: monospace; text-transform: uppercase;
}
.cp-hex-input:focus { border-color: var(--sp-primary); outline: none; }
.cp-presets { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.cp-preset {
  width: 22px; height: 22px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; transition: border-color 0.2s, transform 0.15s;
}
.cp-preset:hover { border-color: #fff; transform: scale(1.15); }
@media (max-width: 576px) {
  .cp-dropdown { width: 220px; left: 0; transform: none; }
}

/* Staff badge name-subtle blue */
.rep-name.rep-staff {
  color: var(--sp-primary);
  font-weight: 700;
}

/* ================================================================
 *  Achievement Badges-Stage 8
 * ================================================================ */
.achievement-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--sp-card-bg);
  border: 1px solid var(--sp-border);
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
}
.achievement-badge:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.2); }
.achievement-locked { opacity: 0.55; filter: grayscale(0.6); }
.achievement-locked:hover { opacity: 0.75; filter: grayscale(0.3); }
.achievement-emoji { font-size: 1.8rem; flex-shrink: 0; }
.achievement-info { flex: 1; min-width: 0; }
.achievement-title { font-weight: 700; font-size: 0.9rem; }
.achievement-desc { font-size: 0.75rem; color: var(--sp-text-muted); margin-top: 1px; }
.achievement-date { font-size: 0.7rem; margin-top: 3px; }
.achievement-progress { margin-top: 4px; }
.achievement-progress .progress { background: rgba(255,255,255,0.08); }
.achievement-progress small { font-size: 0.7rem; }

/* Tier colors */
.achievement-tier-bronze { border-left: 3px solid #cd7f32; }
.achievement-tier-bronze .achievement-title { color: #cd7f32; }
.achievement-tier-silver { border-left: 3px solid #c0c0c0; }
.achievement-tier-silver .achievement-title { color: #c0c0c0; }
.achievement-tier-gold { border-left: 3px solid #ffd700; }
.achievement-tier-gold .achievement-title { color: #ffd700; }
.achievement-tier-diamond { border-left: 3px solid #b9f2ff; }
.achievement-tier-diamond .achievement-title { color: #b9f2ff; text-shadow: 0 0 6px rgba(185,242,255,0.4); }
.achievement-tier-legendary {
  border-left: 3px solid #ff6b35;
  background: linear-gradient(135deg, rgba(255,107,53,0.08), rgba(255,193,7,0.05));
}
.achievement-tier-legendary .achievement-title {
  background: linear-gradient(90deg, #ff6b35, #ffc107, #ff1744);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 800;
}

/* @Mention links */
.mention-link {
  color: var(--sp-primary);
  font-weight: 600;
  text-decoration: none;
  background: rgba(26,115,232,0.1);
  padding: 0 3px;
  border-radius: 3px;
}
.mention-link:hover { text-decoration: underline; background: rgba(26,115,232,0.2); }

/* Subscription bell */
.subscribe-btn { border: none; background: transparent; cursor: pointer; font-size: 1.1rem; padding: 4px 8px; border-radius: 6px; transition: background 0.2s; }
.subscribe-btn:hover { background: rgba(255,255,255,0.08); }
.subscribe-btn.active { color: #ffc107; }

/* ============================================
   Profile Banner & Avatar
   ============================================ */
.profile-banner {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  position: relative;
  overflow: hidden;
}
.profile-banner-default {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 40%, #0f3460 70%, #1a1a2e 100%);
}
.profile-banner .banner-edit-btn {
  position: absolute;
  bottom: 12px;
  right: 12px;
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(255,255,255,0.15);
  color: #fff;
  padding: 4px 12px;
  border-radius: 8px;
  font-size: 0.8rem;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: background 0.2s;
}
.profile-banner .banner-edit-btn:hover {
  background: rgba(0,0,0,0.75);
}
.profile-banner .banner-lock-text {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.5);
  color: rgba(255,255,255,0.6);
  padding: 4px 14px;
  border-radius: 8px;
  font-size: 0.75rem;
  backdrop-filter: blur(4px);
}

/* Avatar overlay edit button */
.avatar-edit-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(transparent, rgba(0,0,0,0.6));
  border-radius: 0 0 50% 50%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 4px;
  opacity: 0;
  transition: opacity 0.2s;
  cursor: pointer;
}
.avatar-wrapper:hover .avatar-edit-overlay {
  opacity: 1;
}
.avatar-edit-overlay i {
  font-size: 1rem;
  color: #fff;
}

/* Profile appearance section */
.appearance-section .avatar-preview-box {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
}
.appearance-section .avatar-preview-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.appearance-section .banner-preview-box {
  width: 100px;
  height: 56px;
  border-radius: 6px;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
  background-size: cover;
  background-position: center;
}
.appearance-section .perk-lock {
  color: rgba(255,255,255,0.4);
  font-size: 0.78rem;
}
.appearance-section .perk-lock i {
  margin-right: 3px;
}

/* ============================================
   Forum Post Avatars
   ============================================ */
.forum-post-avatar {
  border: 2px solid rgba(255,255,255,0.08);
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
  flex-shrink: 0;
}

/* Avatar initials in forum (smaller text) */
.forum-post-avatar span {
  font-size: 0.85rem !important;
}

/* ============================================
   Image Cropper Modal
   ============================================ */
.cropper-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1060;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(3px);
}
.cropper-modal-content {
  background: var(--sp-card-bg, #1a1a2e);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 24px;
  max-width: 600px;
  width: 95%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.cropper-modal-content .cropper-preview-area {
  max-height: 400px;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
}
.cropper-modal-content .cropper-preview-area img {
  max-width: 100%;
  display: block;
}
.cropper-toolbar {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
}
.cropper-toolbar button {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: #fff;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  transition: background 0.2s;
}
.cropper-toolbar button:hover {
  background: rgba(255,255,255,0.12);
}
.cropper-upload-progress {
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}
.cropper-upload-progress .bar {
  height: 100%;
  background: var(--sp-primary, #1a73e8);
  border-radius: 2px;
  transition: width 0.3s;
}

/* Circle crop overlay for avatar mode */
.cropper-circle-overlay .cropper-view-box,
.cropper-circle-overlay .cropper-face {
  border-radius: 50%;
}

/* ============================================
   Public profile banner overrides
   ============================================ */
.public-profile-card {
  overflow: hidden;
  border-radius: 16px;
}

/* ============================================
   Ticket Tag Pills (queue + ticket view)
   ============================================ */
.ticket-tag-pill {
  display: inline-flex;
  align-items: center;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 12px;
  border: 1px solid;
  letter-spacing: 0.02em;
  text-decoration: none;
  transition: opacity .15s;
  white-space: nowrap;
}
a.ticket-tag-pill:hover { opacity: 0.8; }

/* ============================================
   Giveaway — Public Page
   ============================================ */
.giveaway-hero {
  background: linear-gradient(135deg, #1a2332 0%, #0f1923 100%);
  border: 1px solid #2d3748;
  border-radius: 16px;
  padding: 40px 32px;
}
.giveaway-badge-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid;
}
.giveaway-prize-card {
  background: rgba(38,158,255,0.04);
  border: 1px solid #2d3748;
  border-radius: 12px;
  padding: 18px 20px;
}
.giveaway-prize-card .prize-count-badge {
  background: rgba(38,158,255,0.12);
  color: #269eff;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 0.78rem;
  font-weight: 700;
}
.giveaway-timer {
  font-size: 2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #269eff;
  letter-spacing: 0.04em;
}
.giveaway-enter-form {
  background: rgba(26,35,50,0.8);
  border: 1px solid rgba(38,158,255,0.2);
  border-radius: 12px;
  padding: 24px;
}

/* ============================================
   Giveaway — Staff Panel
   ============================================ */
.giveaway-batch-row {
  background: #1a2332;
  border: 1px solid #2d3748;
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 12px;
  transition: border-color .15s;
}
.giveaway-batch-row:hover { border-color: #4a5568; }
.giveaway-batch-row .gw-status-active { color: #10b981; }
.giveaway-batch-row .gw-status-ended  { color: #6b7280; }
.giveaway-winner-row { font-size: 0.88rem; }
.giveaway-winner-row.delivered td { opacity: 0.55; }
.giveaway-checklist-check {
  width: 18px; height: 18px;
  accent-color: #10b981;
}
.giveaway-prize-form-section {
  padding: 0.75rem 1rem;
  border: 1px solid var(--sp-border, #374151);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.15);
}
.giveaway-mail-command {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid #374151;
  color: #93c5fd;
  word-break: break-all;
  max-width: 100%;
}
.giveaway-copy-btn {
  font-size: 0.72rem;
  white-space: nowrap;
}
