:root {
  --bg: #0b1020;
  --bg-card: #111827;
  --bg-panel: #141b2e;
  --border: rgba(255,255,255,.08);
  --border-strong: rgba(124,58,237,.22);
  --text: #f8fafc;
  --text-muted: rgba(248,250,252,.6);
  --purple: #7c3aed;
  --purple-light: #a78bfa;
  --cyan: #06b6d4;
  --green: #22c55e;
  --danger: #ef4444;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 24px 60px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
body {
  margin: 0; min-height: 100vh;
  font-family: Inter, system-ui, sans-serif;
  color: var(--text); background: radial-gradient(circle at top, rgba(124,58,237,.18), transparent 28%), linear-gradient(180deg, #09101f 0%, #06090f 100%);
}

button, input, textarea, select {
  font: inherit; color: inherit;
}

a { color: inherit; text-decoration: none; }

.container { width: min(1180px, calc(100% - 32px)); margin: 0 auto; }

.navbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(8,13,26,.95);
  border-bottom: 1px solid rgba(255,255,255,.06);
  padding: 18px 0;
}
.navbar .container { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.navbar-logo { font-weight: 800; letter-spacing: -.03em; }
.navbar-links { display: flex; gap: 14px; flex-wrap: wrap; }
.navbar-links a { padding: 10px 14px; border-radius: 12px; color: var(--text-muted); transition: background .2s, color .2s; }
.navbar-links a:hover, .navbar-links a.active { color: var(--text); background: rgba(124,58,237,.14); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; border: none; border-radius: 999px; padding: 12px 20px; font-weight: 700; cursor: pointer; }
.btn-primary { background: linear-gradient(135deg, #7c3aed, #06b6d4); color: #fff; }
.btn-secondary { background: rgba(255,255,255,.05); color: var(--text); border: 1px solid rgba(255,255,255,.08); }
.btn-outline { background: transparent; border: 1px solid rgba(255,255,255,.08); color: var(--text); }

.page-header { padding: 80px 0 24px; }
.page-title { font-size: clamp(2.2rem, 4vw, 3.6rem); line-height: 1.05; margin-bottom: 12px; }
.page-sub { max-width: 680px; color: var(--text-muted); line-height: 1.8; }

.card {
  background: rgba(12,17,33,.86);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-body { padding: 28px; }
.card-sm { padding: 20px; }

.grid { display: grid; gap: 22px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }

.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: .95rem; margin-bottom: 8px; color: var(--text-muted); }
.form-input, .form-textarea, .form-select { width: 100%; border-radius: 14px; border: 1px solid rgba(255,255,255,.08); background: rgba(255,255,255,.04); color: var(--text); padding: 14px 16px; }
.form-textarea { min-height: 140px; resize: vertical; }

.ticket-row { display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center; padding: 16px; border-bottom: 1px solid rgba(255,255,255,.06); cursor: pointer; }
.ticket-row:hover { background: rgba(124,58,237,.08); }
.ticket-title { font-weight: 700; margin-bottom: 6px; }
.ticket-meta { color: var(--text-muted); font-size: .92rem; }
.ticket-status { white-space: nowrap; padding: 8px 14px; border-radius: 999px; font-size: .82rem; }
.ticket-open { background: rgba(34,197,94,.12); color: #86efac; }
.ticket-closed { background: rgba(6,182,212,.12); color: #7dd3fc; }
.ticket-wait { background: rgba(251,191,36,.12); color: #fde68a; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.65); z-index: 60; display: none; }
.modal-backdrop.open { display: block; }
.modal { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(960px, calc(100% - 32px)); background: rgba(12,17,33,.98); border: 1px solid rgba(255,255,255,.08); border-radius: 24px; box-shadow: var(--shadow); z-index: 70; overflow: hidden; max-height: 90vh; display: none; }
.modal.open { display: block; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 22px 28px; border-bottom: 1px solid rgba(255,255,255,.08); }
.modal-body { padding: 24px 28px; overflow: auto; }

.notification-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 24px; border-radius: 999px; background: #ef4444; color: #fff; font-size: .75rem; }

.hidden { display: none !important; }
.btn-sm { padding: 8px 16px; font-size: .875rem; }
.btn-danger { background: rgba(239,68,68,.15); color: #fca5a5; border: 1px solid rgba(239,68,68,.3); }
.btn-danger:hover { background: rgba(239,68,68,.3); }

.navbar-actions { display: flex; align-items: center; gap: 12px; }
.nav-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--purple), var(--cyan));
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: .9rem; cursor: pointer; text-decoration: none;
  color: #fff;
}

.badge {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 4px 12px; border-radius: 999px; font-size: .78rem; font-weight: 700;
}
.badge-open   { background: rgba(34,197,94,.12); color: #86efac; }
.badge-closed { background: rgba(6,182,212,.12); color: #7dd3fc; }
.badge-wait   { background: rgba(251,191,36,.12); color: #fde68a; }
.badge-inprogress { background: rgba(168,85,247,.12); color: #d8b4fe; }

.ticket-status-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.ticket-cat { font-size: .78rem; color: var(--text-muted); background: rgba(255,255,255,.05); padding: 6px 12px; border-radius: 999px; white-space: nowrap; }

/* Ticket detail slide-up drawer */
.ticket-detail {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0); pointer-events: none;
  transition: background .25s;
  display: flex; align-items: flex-end; justify-content: center;
}
.ticket-detail.open { background: rgba(0,0,0,.65); pointer-events: auto; }
.ticket-detail-box {
  width: min(960px, 100%); height: 82vh;
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 24px 24px 0 0;
  display: flex; flex-direction: column;
  transform: translateY(100%);
  transition: transform .32s cubic-bezier(.4,0,.2,1);
}
.ticket-detail.open .ticket-detail-box { transform: translateY(0); }
.ticket-detail-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 20px 28px; border-bottom: 1px solid rgba(255,255,255,.08); flex-shrink: 0;
  gap: 16px;
}
.ticket-detail-body { flex: 1; overflow-y: auto; padding: 24px 28px; display: flex; flex-direction: column; gap: 12px; }

/* Chat messages */
.ticket-msg { padding: 14px 18px; border-radius: 18px; max-width: 78%; line-height: 1.6; }
.ticket-msg.user { background: rgba(124,58,237,.12); margin-left: auto; }
.ticket-msg.staff { background: rgba(6,182,212,.1); }
.ticket-msg-meta { font-size: .78rem; color: var(--text-muted); margin-bottom: 6px; }
.ticket-msg-text { white-space: pre-wrap; word-break: break-word; }
.ticket-msg-row { display: flex; flex-direction: column; }
.ticket-msg-row.user { align-items: flex-end; }
.ticket-msg-row.staff { align-items: flex-start; }

/* Reply bar */
.reply-bar {
  border-top: 1px solid rgba(255,255,255,.08);
  padding: 16px 28px; flex-shrink: 0;
  display: flex; gap: 12px; align-items: flex-end;
}
.reply-bar textarea {
  flex: 1; border-radius: 14px; border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.04); color: var(--text); padding: 12px 14px;
  resize: none; min-height: 60px; max-height: 160px;
}

.form-error { color: var(--danger); font-size: .9rem; margin-top: 6px; }

/* Page wrapper */
.page-wrapper { padding: 80px 0 60px; min-height: calc(100vh - 65px); }

/* Stats grid */
.stat-card { padding: 22px; border-radius: 18px; background: rgba(255,255,255,.03); border: 1px solid rgba(255,255,255,.07); }
.stat-num { font-size: 2rem; font-weight: 800; }
.stat-label { color: var(--text-muted); font-size: .88rem; margin-top: 4px; }

/* Light mode */
[data-theme="light"] {
  --bg: #f4f6fb;
  --bg-card: #ffffff;
  --bg-panel: #eef1f7;
  --border: rgba(0,0,0,.09);
  --text: #1a1f2e;
  --text-muted: rgba(26,31,46,.55);
}
[data-theme="light"] body {
  background: linear-gradient(180deg, #eef1fb 0%, #f4f6fb 100%);
}
[data-theme="light"] .navbar { background: rgba(255,255,255,.95); }
[data-theme="light"] .card { background: #fff; }
[data-theme="light"] .stat-card { background: rgba(0,0,0,.02); border-color: rgba(0,0,0,.07); }
[data-theme="light"] .form-input, [data-theme="light"] .form-textarea { background: rgba(0,0,0,.03); border-color: rgba(0,0,0,.1); color:#1a1f2e; }
[data-theme="light"] .ticket-detail-box { background: #fff; }
[data-theme="light"] .reply-bar textarea { background: rgba(0,0,0,.03); border-color: rgba(0,0,0,.1); }

/* FAQ accordion */
.faq-item {
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color .2s;
}
.faq-item:hover { border-color: rgba(124,58,237,.25); }
.faq-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; font-weight: 600; font-size: .95rem;
  background: rgba(255,255,255,.03);
  user-select: none;
}
.faq-arrow { font-size: 1.2rem; color: var(--text-muted); transition: transform .2s; }
.faq-item.open .faq-arrow { transform: rotate(90deg); }
.faq-body {
  max-height: 0; overflow: hidden; transition: max-height .3s ease, padding .3s;
  padding: 0 20px; font-size: .9rem;
}
.faq-item.open .faq-body { max-height: 500px; padding: 6px 20px 20px; }
.faq-body code { background: rgba(124,58,237,.15); padding: 2px 8px; border-radius: 6px; font-family: monospace; font-size: .88rem; }

/* Ticket row active state */
.ticket-row-active { background: rgba(124,58,237,.1) !important; }

/* btn-ghost */
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid transparent; }
.btn-ghost:hover { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.08); color: var(--text); }

/* Theme toggle no padding issue */
.btn-ghost.btn-sm { padding: 8px 10px; }

/* Filter buttons */
.filter-btn-sm { font-family: inherit; }

@media (max-width: 960px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .navbar .container { flex-wrap: wrap; }
  .navbar-links { width: 100%; justify-content: center; }
  .ticket-msg { max-width: 90%; }
  .cat-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .cat-grid { grid-template-columns: 1fr; }
}
