/* ──────────────────────────────────────────────────────────────────────
   TicketDesk Dashboard — Phase 1 Foundation
   Clean, professional, dark, no emojis
   ──────────────────────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

* { box-sizing: border-box; margin: 0; padding: 0; }

/* Critical: [hidden] must beat any class with display:flex/grid/block.
   Without this, .full-loader[hidden] would still show because
   `.full-loader { display: flex }` wins specificity over UA `[hidden]`. */
[hidden] { display: none !important; }

:root {
  --bg-0: #07080d;
  --bg-1: #0c0e15;
  --bg-2: #11141d;
  --bg-3: #161a25;
  --bg-4: #1d2230;

  --border:    rgba(255,255,255,.06);
  --border-h:  rgba(255,255,255,.10);
  --border-s:  rgba(255,255,255,.14);

  --acc:       #7c5cfc;
  --acc-l:     #9d82fd;
  --acc-d:     #5b3de8;
  --acc-dim:   rgba(124,92,252,.10);
  --acc-glow:  rgba(124,92,252,.20);

  --green:     #22d3a0;
  --green-dim: rgba(34,211,160,.10);
  --amber:     #f6a32e;
  --amber-dim: rgba(246,163,46,.10);
  --red:       #f25c5c;
  --red-dim:   rgba(242,92,92,.10);
  --blue:      #4ea8de;

  --t:         #e8eaf0;
  --t-m:       #8b8fa8;
  --t-d:       #5a5e75;
  --t-dd:      #3a3e51;

  --sans: 'Inter', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', monospace;

  --topbar-h:  52px;
  --sidebar-w: 220px;
}

html, body {
  height: 100%;
  background: var(--bg-0);
  color: var(--t);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -.005em;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img { max-width: 100%; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-4); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--acc-d); }

/* ── Loaders ────────────────────────────────────────────────────────── */
.full-loader {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-0);
  z-index: 100;
}
.page-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px 0;
}
.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border-h);
  border-top-color: var(--acc);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Error screen ───────────────────────────────────────────────────── */
.full-error {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}
.error-card { text-align: center; max-width: 380px; }
.error-icon {
  width: 56px; height: 56px;
  border-radius: 14px;
  background: var(--red-dim);
  color: var(--red);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}
.error-card h1 { font-size: 18px; font-weight: 600; margin-bottom: 6px; }
.error-card p { color: var(--t-m); font-size: 13px; margin-bottom: 20px; }
.error-actions { display: flex; gap: 8px; justify-content: center; }

/* ── Top Bar ─────────────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-h);
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 50;
  backdrop-filter: blur(16px);
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}

.brand { display: flex; align-items: center; gap: 8px; }
.brand-mark {
  width: 26px; height: 26px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--acc), var(--acc-d));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 0 12px var(--acc-glow);
}
.brand-name { font-weight: 700; font-size: 14px; letter-spacing: -.01em; }

.topbar-divider { width: 1px; height: 20px; background: var(--border-h); }

.server-switcher,
.user-menu-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-2);
  border: 1px solid var(--border-h);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--t);
  font-weight: 500;
  transition: all .12s;
}
.server-switcher:hover,
.user-menu-btn:hover {
  border-color: var(--border-s);
  background: var(--bg-3);
}

.server-icon {
  width: 18px; height: 18px;
  border-radius: 4px;
  background: var(--bg-3);
  flex-shrink: 0;
  background-size: cover;
  background-position: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--t-m);
}

.caret { color: var(--t-m); }

.user-avatar {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--bg-3);
  object-fit: cover;
}

/* ── Dropdowns ──────────────────────────────────────────────────────── */
.server-dropdown,
.user-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  background: var(--bg-2);
  border: 1px solid var(--border-h);
  border-radius: 10px;
  min-width: 240px;
  max-height: 60vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
  z-index: 51;
  padding: 6px;
}
.server-dropdown { left: calc(120px + 24px); }
.user-dropdown   { right: 0; min-width: 220px; }

.server-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: background .12s;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: inherit;
}
.server-dropdown-item:hover { background: var(--bg-3); }
.server-dropdown-item.active { background: var(--acc-dim); color: var(--acc-l); }
.server-dropdown-item .server-icon {
  width: 24px; height: 24px;
  border-radius: 6px;
  font-size: 12px;
}
.server-dropdown-item .info { flex: 1; min-width: 0; }
.server-dropdown-item .role {
  font-size: 10px;
  font-family: var(--mono);
  color: var(--t-d);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-top: 2px;
}

.user-dropdown-info { padding: 12px 12px 10px; }
.user-dropdown-name { font-size: 13px; font-weight: 600; }
.user-dropdown-id {
  font-size: 11px;
  color: var(--t-d);
  font-family: var(--mono);
  margin-top: 2px;
}
.user-dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }
.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--t);
  cursor: pointer;
  transition: background .12s;
}
.user-dropdown-item:hover { background: var(--bg-3); }
.user-dropdown-item svg { color: var(--t-m); }

/* ── Layout ──────────────────────────────────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: calc(100vh - var(--topbar-h));
}

/* ── Sidebar ─────────────────────────────────────────────────────────── */
.sidebar {
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
}
.nav-section { margin-bottom: 18px; }
.nav-section-bottom { margin-top: auto; padding-top: 18px; border-top: 1px solid var(--border); }

.nav-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--t-d);
  padding: 0 10px 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--t-m);
  cursor: pointer;
  transition: all .12s;
  margin-bottom: 1px;
}
.nav-item:hover { background: var(--bg-3); color: var(--t); }
.nav-item.active { background: var(--acc-dim); color: var(--acc-l); }
.nav-item.active .nav-ic { color: var(--acc-l); }
.nav-ic { color: var(--t-d); flex-shrink: 0; }
.nav-item:hover .nav-ic { color: var(--t); }

/* ── Content area ────────────────────────────────────────────────────── */
.content { padding: 28px 32px; overflow-x: hidden; }

/* ── Page header ─────────────────────────────────────────────────────── */
.page-header { margin-bottom: 24px; }
.page-title { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.page-desc { color: var(--t-m); font-size: 13.5px; margin-top: 4px; }

/* ── Empty state ─────────────────────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 64px 24px;
  background: var(--bg-1);
  border: 1px dashed var(--border-h);
  border-radius: 12px;
}
.empty-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  background: var(--bg-3);
  color: var(--t-d);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}
.empty-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.empty-desc {
  color: var(--t-m);
  font-size: 13px;
  max-width: 340px;
  margin: 0 auto;
}

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all .12s;
  white-space: nowrap;
}
.btn-primary {
  background: var(--acc);
  color: #fff;
  box-shadow: 0 1px 6px var(--acc-glow);
}
.btn-primary:hover {
  background: var(--acc-l);
  box-shadow: 0 2px 14px var(--acc-glow);
}
.btn-ghost {
  background: transparent;
  border-color: var(--border-h);
  color: var(--t-m);
}
.btn-ghost:hover {
  background: var(--bg-3);
  color: var(--t);
  border-color: var(--border-s);
}

/* ── Toasts ──────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}
.toast {
  background: var(--bg-2);
  border: 1px solid var(--border-h);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 240px;
  pointer-events: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
  animation: toastIn .2s ease-out;
}
.toast.success { border-color: rgba(34,211,160,.4); color: var(--green); }
.toast.error   { border-color: rgba(242,92,92,.4); color: var(--red); }
.toast.warn    { border-color: rgba(246,163,46,.4); color: var(--amber); }
@keyframes toastIn {
  from { transform: translateY(8px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* ── Page stub ───────────────────────────────────────────────────────── */
.page-stub {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 48px 32px;
  text-align: center;
}
.page-stub-icon {
  width: 56px; height: 56px;
  border-radius: 14px;
  background: var(--acc-dim);
  color: var(--acc-l);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
}
.page-stub h2 { font-size: 17px; font-weight: 600; margin-bottom: 6px; }
.page-stub p {
  color: var(--t-m);
  font-size: 13.5px;
  max-width: 460px;
  margin: 0 auto 20px;
}

/* ── Forbidden ──────────────────────────────────────────────────────── */
.forbidden { text-align: center; padding: 80px 24px; }
.forbidden h1 { font-size: 18px; font-weight: 600; margin-bottom: 6px; }
.forbidden p { color: var(--t-m); font-size: 13.5px; }

/* ── Server Picker page (when /dashboard without guild_id) ──────────── */
.picker-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 60px 24px;
}
.picker-header { text-align: center; margin-bottom: 36px; }
.picker-header h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -.01em;
  margin-bottom: 6px;
}
.picker-header p { color: var(--t-m); font-size: 14px; }

.picker-section-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--t-d);
  margin-bottom: 8px;
  padding: 0 4px;
}

.picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin-bottom: 24px;
}

.picker-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  transition: all .15s;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-family: inherit;
  color: inherit;
  font-size: inherit;
  min-height: 110px;
}
.picker-card:hover {
  border-color: var(--acc);
  background: var(--bg-2);
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(0,0,0,.3);
}
.picker-card.disabled {
  opacity: .4;
  cursor: not-allowed;
}
.picker-card.disabled:hover {
  border-color: var(--border);
  background: var(--bg-1);
  transform: none;
  box-shadow: none;
}

.picker-card-top {
  display: flex;
  align-items: center;
  gap: 12px;
}
.picker-card-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--bg-3);
  background-size: cover;
  background-position: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  color: var(--t-m);
  flex-shrink: 0;
}
.picker-card-name {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -.005em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.picker-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
}
.picker-badge {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 100px;
}
.picker-badge.admin   { background: var(--acc-dim); color: var(--acc-l); }
.picker-badge.owner   { background: var(--acc-dim); color: var(--acc-l); }
.picker-badge.support { background: var(--green-dim); color: var(--green); }
.picker-badge.unavailable { background: var(--bg-3); color: var(--t-d); }

.picker-card-go {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--t-m);
}
.picker-card:hover .picker-card-go { color: var(--acc-l); }

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 880px) {
  :root { --sidebar-w: 60px; }
  .sidebar { padding: 16px 6px; }
  .nav-label { display: none; }
  .nav-item {
    justify-content: center;
    padding: 10px;
  }
  .nav-item span:not(.nav-ic),
  .nav-item:not(:has(.nav-ic)) { display: none; }
  .content { padding: 20px 16px; }
  .server-name { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .user-name { display: none; }
  .picker-grid { grid-template-columns: 1fr; }
}
