@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800;900&display=swap');

:root {
  --bg:        #0d1117;
  --bg2:       #161b22;
  --bg3:       #21262d;
  --bg4:       #30363d;
  --border:    rgba(255,255,255,.08);
  --border2:   rgba(255,255,255,.14);
  --accent:    #5865f2;
  --accent2:   #4752c4;
  --cyan:      #00b0f4;
  --green:     #3ba55c;
  --green2:    #57f287;
  --yellow:    #faa61a;
  --red:       #ed4245;
  --text:      #e6edf3;
  --text2:     #8b949e;
  --text3:     #484f58;
  --sidebar-w: 240px;
  --topbar-h:  52px;
  --r:         8px;
  --r2:        12px;
}

*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Cairo', sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
.hidden { display: none !important; }

/* ── Auth ── */
.auth-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
}

.auth-bg {
  position: fixed; inset: 0; z-index: 0;
  background: radial-gradient(ellipse 80% 60% at 50% -10%, rgba(88,101,242,.25) 0%, transparent 70%),
              radial-gradient(ellipse 60% 40% at 80% 80%, rgba(0,176,244,.1) 0%, transparent 60%),
              var(--bg);
}

.auth-card {
  position: relative; z-index: 1;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 20px;
  padding: 48px 40px;
  text-align: center;
  width: 100%; max-width: 420px;
  margin: 16px;
  box-shadow: 0 24px 80px rgba(0,0,0,.6), 0 0 0 1px rgba(255,255,255,.04);
}

.auth-logo {
  width: 80px; height: 80px;
  border-radius: 20px;
  margin: 0 auto 24px;
  overflow: hidden;
  background: var(--bg3);
  display: flex; align-items: center; justify-content: center;
}

.auth-logo img { width: 100%; height: 100%; object-fit: cover; }
.auth-logo-fallback {
  display: none; width: 100%; height: 100%;
  align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--cyan));
  font-size: 32px; color: white;
}

.auth-card h1 {
  font-size: 24px; font-weight: 800; margin-bottom: 8px;
  color: var(--text);
}

.auth-card p { color: var(--text2); font-size: 14px; margin-bottom: 32px; line-height: 1.7; }

.login-error {
  background: rgba(237,66,69,.1); border: 1px solid rgba(237,66,69,.3);
  border-radius: var(--r); padding: 10px 14px;
  font-size: 13px; color: #f38ba8; margin-bottom: 16px;
}

.discord-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 13px 20px;
  background: #5865f2; color: white;
  border-radius: var(--r2); font-size: 15px; font-weight: 700;
  transition: background .15s, transform .1s;
  border: none; cursor: pointer;
}

.discord-btn:hover { background: #4752c4; transform: translateY(-1px); }
.discord-btn:active { transform: scale(.98); }

/* ── Layout ── */
#dashboard-page { display: flex; min-height: 100vh; flex-direction: row; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--bg2);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; right: 0; bottom: 0;
  z-index: 200; overflow-y: auto;
  transition: transform .25s ease;
}

.sidebar-brand {
  padding: 16px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--border);
}

.brand-logo {
  width: 40px; height: 40px; border-radius: 10px;
  object-fit: cover; flex-shrink: 0;
}

.brand-logo-fallback {
  display: none; width: 40px; height: 40px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--cyan));
  align-items: center; justify-content: center;
  color: white; font-size: 18px; flex-shrink: 0;
}

.brand-text { display: flex; flex-direction: column; }
.brand-name { font-size: 14px; font-weight: 800; color: var(--text); }
.brand-sub  { font-size: 11px; color: var(--text3); display: none; }

.sidebar-nav { flex: 1; padding: 8px; }

.nav-label {
  font-size: 10px; font-weight: 700; color: var(--text3);
  text-transform: uppercase; letter-spacing: 1.2px;
  padding: 12px 8px 6px;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--r);
  font-size: 14px; font-weight: 600; color: var(--text2);
  cursor: pointer; transition: all .12s;
  margin-bottom: 2px;
}

.nav-item:hover { background: var(--bg3); color: var(--text); }

.nav-item.active {
  background: rgba(88,101,242,.2);
  color: #c9cdfb;
}

.nav-icon {
  width: 32px; height: 32px; border-radius: var(--r);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0;
  background: var(--bg3);
}

.nav-item.active .nav-icon { background: rgba(88,101,242,.3); color: #c9cdfb; }

/* Sidebar User */
.sidebar-user {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
  background: rgba(0,0,0,.2);
}

.user-avatar-wrap {
  width: 32px; height: 32px; border-radius: 50%;
  position: relative; flex-shrink: 0;
}

.user-avatar-wrap img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }

#user-avatar-icon {
  width: 100%; height: 100%; border-radius: 50%;
  background: var(--bg3); border: 1px solid var(--border2);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: var(--text2);
}

.user-status {
  position: absolute; bottom: 0; left: 0;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--green2); border: 2px solid var(--bg2);
}

.user-info { flex: 1; min-width: 0; }
.user-name { display: block; font-size: 13px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-tag  { font-size: 11px; color: var(--text3); }

.logout-btn {
  width: 28px; height: 28px; border-radius: var(--r);
  background: none; border: none; cursor: pointer;
  color: var(--text3); font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  transition: all .12s;
}

.logout-btn:hover { background: rgba(237,66,69,.15); color: var(--red); }

/* ── Main ── */
.main-wrap {
  flex: 1;
  margin-right: var(--sidebar-w);
  margin-left: 0;
  display: flex; flex-direction: column; min-width: 0;
  min-height: 100vh;
}

/* ── Topbar ── */
.topbar {
  height: var(--topbar-h);
  background: rgba(13,17,23,.95);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  display: flex; align-items: center; gap: 12px;
  position: sticky; top: 0; z-index: 100;
  backdrop-filter: blur(12px);
}

.menu-btn {
  background: none; border: none; color: var(--text2);
  font-size: 16px; cursor: pointer; display: none;
  padding: 6px; border-radius: var(--r);
}

.menu-btn:hover { background: var(--bg3); color: var(--text); }

.topbar-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 15px; font-weight: 700; color: var(--text);
  flex: 1;
}

.topbar-title i { color: var(--text2); font-size: 14px; }

.topbar-right { display: flex; align-items: center; gap: 10px; }

.user-chip {
  display: flex; align-items: center; gap: 7px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 20px; padding: 4px 12px 4px 4px;
  font-size: 13px; font-weight: 600; color: var(--text2);
}

/* ── Page Content ── */
.page-content { padding: 24px; flex: 1; width: 100%; }

/* ── Stats ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px; margin-bottom: 20px;
  width: 100%;
}

.stat-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  padding: 18px 20px;
  display: flex; align-items: center; gap: 14px;
  flex-direction: row-reverse;
  transition: border-color .15s;
}

.stat-box:hover { border-color: var(--border2); }

.stat-icon-wrap {
  width: 44px; height: 44px; border-radius: var(--r2);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}

.stat-icon-wrap.blue   { background: rgba(88,101,242,.15); color: #c9cdfb; }
.stat-icon-wrap.green  { background: rgba(87,242,135,.1);  color: var(--green2); }
.stat-icon-wrap.red    { background: rgba(237,66,69,.1);   color: #f38ba8; }

.stat-info { display: flex; flex-direction: column; }
.stat-num   { font-size: 26px; font-weight: 900; line-height: 1; color: var(--text); }
.stat-label { font-size: 12px; color: var(--text2); margin-top: 3px; }

/* ── Content Card ── */
.content-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  overflow: hidden;
  width: 100%;
}

.card-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-direction: row-reverse;
}

.card-head-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 700; color: var(--text);
}

.card-head-title i { color: var(--text2); }

.filter-select {
  background: var(--bg3); border: 1px solid var(--border2);
  border-radius: var(--r); padding: 6px 12px;
  color: var(--text); font-size: 13px; font-weight: 600;
  outline: none; cursor: pointer; font-family: inherit;
  transition: border-color .12s;
}

.filter-select:focus { border-color: var(--accent); }

/* ── Tickets List ── */
.tickets-list { padding: 8px; }

.ticket-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: var(--r);
  transition: background .1s; cursor: default;
  border: 1px solid transparent;
  flex-direction: row-reverse;
}

.ticket-row:hover { background: var(--bg3); border-color: var(--border); }

.ticket-num {
  font-size: 12px; font-weight: 700; color: var(--accent);
  background: rgba(88,101,242,.1); border: 1px solid rgba(88,101,242,.2);
  border-radius: 6px; padding: 2px 8px; flex-shrink: 0;
  min-width: 48px; text-align: center;
}

.ticket-dept {
  flex: 1; font-size: 14px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-align: right;
}

.ticket-dates {
  display: flex; flex-direction: column; align-items: flex-start;
  gap: 2px; flex-shrink: 0;
}

.ticket-date { font-size: 11px; color: var(--text3); }

.badge {
  font-size: 11px; font-weight: 700; padding: 2px 10px;
  border-radius: 20px; flex-shrink: 0;
}

.badge-open    { background: rgba(87,242,135,.1);  color: var(--green2); border: 1px solid rgba(87,242,135,.2); }
.badge-claimed { background: rgba(250,166,26,.1);  color: #fde68a;       border: 1px solid rgba(250,166,26,.2); }
.badge-closed  { background: rgba(237,66,69,.1);   color: #f38ba8;       border: 1px solid rgba(237,66,69,.2); }

.transcript-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: var(--r);
  background: var(--bg3); border: 1px solid var(--border2);
  color: var(--text2); font-size: 12px; font-weight: 600;
  transition: all .12s; flex-shrink: 0; text-decoration: none;
  font-family: inherit;
}

.transcript-btn:hover { background: rgba(88,101,242,.15); border-color: rgba(88,101,242,.4); color: #c9cdfb; }
.transcript-btn i { font-size: 11px; }

.ticket-divider { height: 1px; background: var(--border); margin: 2px 14px; }

/* ── States ── */
.loading-state, .empty-state {
  text-align: center; padding: 52px 20px;
  color: var(--text2); font-size: 14px;
}

.loading-state i, .empty-state i {
  display: block; font-size: 36px; margin-bottom: 12px;
  opacity: .3;
}

/* ── Pagination ── */
.pagination {
  display: flex; gap: 4px; padding: 12px 16px;
  border-top: 1px solid var(--border); justify-content: center;
  flex-wrap: wrap;
}

.page-btn {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--r); padding: 5px 12px;
  color: var(--text2); cursor: pointer; font-size: 12px; font-weight: 700;
  transition: all .12s; font-family: inherit;
}

.page-btn:hover { background: var(--bg4); color: var(--text); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: white; }

/* ── Toast ── */
#toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: var(--r2);
  font-size: 13px; font-weight: 600;
  pointer-events: all; min-width: 260px;
  transform: translateY(20px) scale(.95); opacity: 0;
  transition: all .25s cubic-bezier(.34,1.56,.64,1);
  backdrop-filter: blur(12px);
}

.toast.show { transform: translateY(0) scale(1); opacity: 1; }
.toast.hide { transform: translateY(10px) scale(.95); opacity: 0; transition: all .2s ease; }

.toast-success { background: rgba(59,165,92,.15); border: 1px solid rgba(87,242,135,.25); color: var(--green2); }
.toast-error   { background: rgba(237,66,69,.15);  border: 1px solid rgba(237,66,69,.3);   color: #f38ba8; }
.toast-info    { background: rgba(88,101,242,.15); border: 1px solid rgba(88,101,242,.3);  color: #c9cdfb; }

/* ── Overlay ── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.6); z-index: 199;
  backdrop-filter: blur(2px);
}

.sidebar-overlay.show { display: block; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 4px; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrap { margin-right: 0; margin-left: 0; }
  .menu-btn { display: flex; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .page-content { padding: 16px; }
  .ticket-dates { display: none; }
}

@media (max-width: 480px) {
  .stats-row { grid-template-columns: 1fr; }
  .auth-card { padding: 32px 24px; }
}

/* ── Ticket Details ── */
.ticket-item { display: flex; flex-direction: column; }

.ticket-details {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 0 14px 10px;
  flex-direction: row-reverse;
}

.detail-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; color: var(--text2);
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 20px; padding: 3px 10px;
}

.detail-chip i { font-size: 10px; opacity: .7; }
.detail-chip.reason { color: var(--text2); max-width: 300px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Transcript Modal ── */
#transcript-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

#transcript-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(4px);
}

#transcript-panel {
  position: relative;
  z-index: 1;
  width: 92vw;
  max-width: 1100px;
  height: 88vh;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,.5);
}

#transcript-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
  color: var(--text1);
  flex-shrink: 0;
}

#transcript-close-btn {
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  font-size: 16px;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background .15s, color .15s;
}
#transcript-close-btn:hover { background: rgba(244,63,94,.15); color: #f43f5e; }

#transcript-body {
  flex: 1;
  overflow: auto;
  padding: 0;
}
