/* ============================================================
   Support Desk — app.css
   Aesthetic: refined industrial / deep navy + amber accents
   ============================================================ */

:root {
  --bg:          #0f1117;
  --bg2:         #161b27;
  --bg3:         #1e2536;
  --border:      #2a3248;
  --text:        #e2e8f0;
  --text2:       #94a3b8;
  --text3:       #64748b;
  --accent:      #2563eb;
  --accent-h:    #1d4ed8;
  --amber:       #f59e0b;
  --green:       #10b981;
  --red:         #ef4444;
  --purple:      #8b5cf6;
  --sidebar-w:   260px;
  --radius:      10px;
  --shadow:      0 4px 24px rgba(0,0,0,.4);
  --font-head:   'Syne', sans-serif;
  --font-body:   'DM Sans', sans-serif;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.6;
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .25s ease;
}
.sidebar-header {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-head);
  font-weight: 700; font-size: 17px; color: var(--text);
  text-decoration: none;
}
.sidebar-toggle { display: none; background: none; border: none; color: var(--text2); font-size: 18px; cursor: pointer; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 8px; }
.nav-section {
  font-size: 10px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--text3);
  padding: 14px 10px 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px;
  color: var(--text2); text-decoration: none;
  font-size: 13.5px; font-weight: 500;
  transition: background .15s, color .15s;
  position: relative; margin-bottom: 2px;
}
.nav-item svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: rgba(37,99,235,.15); color: var(--accent); }
.nav-item.active svg { stroke: var(--accent); }
.nav-item.nav-highlight { background: var(--accent); color: #fff; margin-bottom: 6px; }
.nav-item.nav-highlight:hover { background: var(--accent-h); }
.nav-item.nav-highlight svg { stroke: #fff; }
.nav-item.nav-danger:hover { background: rgba(239,68,68,.1); color: var(--red); }
.badge-count {
  background: var(--accent); color: #fff; font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 20px; margin-left: auto;
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg2);
}
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-head); font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.user-name { font-weight: 600; font-size: 13px; color: var(--text); }
.user-role { font-size: 11px; color: var(--text3); }

/* ---- Main Content ---- */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
}
.topbar {
  height: 58px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px; gap: 16px;
  position: sticky; top: 0; z-index: 50;
}
.topbar-toggle { display: none; background: none; border: none; color: var(--text2); font-size: 20px; cursor: pointer; }
.topbar-title { font-family: var(--font-head); font-weight: 700; font-size: 16px; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-icon {
  position: relative; color: var(--text2); text-decoration: none;
  display: flex; align-items: center; padding: 6px;
}
.topbar-icon:hover { color: var(--text); }
.notif-dot {
  position: absolute; top: 2px; right: 2px;
  background: var(--red); color: #fff; font-size: 9px; font-weight: 700;
  min-width: 16px; height: 16px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; padding: 0 3px;
}
.content-wrapper { padding: 28px; max-width: 1300px; width: 100%; margin: 0 auto; }

/* ---- Cards ---- */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.card-title { font-family: var(--font-head); font-weight: 700; font-size: 16px; }

/* ---- Stats Grid ---- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(200px,1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; display: flex; flex-direction: column; gap: 8px;
}
.stat-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text3); }
.stat-value { font-family: var(--font-head); font-size: 32px; font-weight: 800; color: var(--text); }
.stat-sub { font-size: 12px; color: var(--text3); }
.stat-card.accent { border-left: 3px solid var(--accent); }
.stat-card.amber  { border-left: 3px solid var(--amber); }
.stat-card.green  { border-left: 3px solid var(--green); }
.stat-card.red    { border-left: 3px solid var(--red); }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--text3); padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.02); }
.ticket-subject { font-weight: 600; color: var(--text); text-decoration: none; }
.ticket-subject:hover { color: var(--accent); }
.ticket-meta { font-size: 12px; color: var(--text3); margin-top: 2px; }

/* ---- Badges ---- */
.badge {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 20px;
  text-transform: uppercase; letter-spacing: .04em; white-space: nowrap;
}
.badge-open     { background: rgba(37,99,235,.2);  color: #60a5fa; }
.badge-pending  { background: rgba(245,158,11,.2); color: #fbbf24; }
.badge-progress { background: rgba(139,92,246,.2); color: #a78bfa; }
.badge-resolved { background: rgba(16,185,129,.2); color: #34d399; }
.badge-closed   { background: rgba(100,116,139,.2);color: #94a3b8; }
.badge-low      { background: rgba(16,185,129,.15);color: #34d399; }
.badge-medium   { background: rgba(245,158,11,.15);color: #fbbf24; }
.badge-high     { background: rgba(239,68,68,.15); color: #f87171; }
.badge-urgent   { background: rgba(239,68,68,.3);  color: #fca5a5; animation: pulse 1.5s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.6} }

/* ---- Forms ---- */
.form-group { margin-bottom: 18px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
label { display: block; font-size: 12px; font-weight: 600; color: var(--text2); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .04em; }
input[type=text], input[type=email], input[type=password], input[type=date],
textarea, select {
  width: 100%; background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); padding: 10px 14px; border-radius: 8px;
  font-family: var(--font-body); font-size: 14px;
  transition: border-color .15s, box-shadow .15s; outline: none;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
textarea { resize: vertical; min-height: 100px; }
select option { background: var(--bg3); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; border-radius: 8px; font-family: var(--font-body);
  font-size: 13.5px; font-weight: 600; cursor: pointer;
  border: none; text-decoration: none; transition: all .15s; white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-h); }
.btn-secondary { background: var(--bg3); color: var(--text2); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); color: var(--text); }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { filter: brightness(1.1); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { filter: brightness(1.1); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- Ticket Thread ---- */
.ticket-header { margin-bottom: 24px; }
.ticket-title { font-family: var(--font-head); font-size: 22px; font-weight: 800; margin-bottom: 10px; }
.ticket-badges { display: flex; gap: 8px; flex-wrap: wrap; }
.thread { display: flex; flex-direction: column; gap: 16px; }
.reply-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.reply-card.private { border-left: 3px solid var(--amber); }
.reply-card.staff { border-left: 3px solid var(--accent); }
.reply-header {
  background: var(--bg3); padding: 12px 16px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--border);
}
.reply-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; font-family: var(--font-head); flex-shrink: 0;
}
.reply-avatar.agent { background: var(--green); }
.reply-avatar.admin { background: var(--purple); }
.reply-author { font-weight: 600; font-size: 13px; }
.reply-time { font-size: 12px; color: var(--text3); margin-left: auto; }
.reply-body { padding: 16px; line-height: 1.7; white-space: pre-wrap; word-break: break-word; }

/* ---- Ticket Meta Panel ---- */
.ticket-layout { display: grid; grid-template-columns: 1fr 300px; gap: 24px; align-items: start; }
.meta-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 0; overflow: hidden; }
.meta-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.meta-row:last-child { border-bottom: none; }
.meta-key { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text3); }
.meta-val { font-size: 13px; color: var(--text); font-weight: 500; text-align: right; }

/* ---- Filters bar ---- */
.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 20px; }
.filters input, .filters select { width: auto; padding: 8px 12px; }
.filter-badge {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--bg3); border: 1px solid var(--border);
  padding: 5px 12px; border-radius: 20px; font-size: 12px; font-weight: 600;
  color: var(--text2); cursor: pointer; text-decoration: none;
}
.filter-badge:hover, .filter-badge.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---- Alerts ---- */
.alert {
  padding: 12px 16px; border-radius: 8px; margin-bottom: 16px;
  font-weight: 500; font-size: 13.5px;
}
.alert-success { background: rgba(16,185,129,.15); border: 1px solid rgba(16,185,129,.3); color: #34d399; }
.alert-error   { background: rgba(239,68,68,.15);  border: 1px solid rgba(239,68,68,.3);  color: #f87171; }
.alert-info    { background: rgba(37,99,235,.15);  border: 1px solid rgba(37,99,235,.3);  color: #60a5fa; }
.alert-warning { background: rgba(245,158,11,.15); border: 1px solid rgba(245,158,11,.3); color: #fbbf24; }

/* ---- Auth pages ---- */
.auth-page {
  min-height: 100vh; display: flex; align-items: center;
  justify-content: center; background: var(--bg);
}
.auth-box {
  width: 400px; background: var(--bg2); border: 1px solid var(--border);
  border-radius: 14px; padding: 40px; box-shadow: var(--shadow);
}
.auth-logo { text-align: center; margin-bottom: 32px; }
.auth-logo .logo-icon { width: 48px; height: 48px; margin: 0 auto 12px; }
.auth-logo h1 { font-family: var(--font-head); font-size: 24px; font-weight: 800; }
.auth-logo p { color: var(--text3); font-size: 13px; margin-top: 4px; }
.auth-footer { text-align: center; margin-top: 24px; font-size: 13px; color: var(--text3); }
.auth-footer a { color: var(--accent); text-decoration: none; }

/* ---- Pagination ---- */
.pagination { display: flex; gap: 6px; margin-top: 20px; justify-content: center; flex-wrap: wrap; }
.page-btn {
  min-width: 36px; height: 36px; display: flex; align-items: center;
  justify-content: center; border-radius: 8px; font-size: 13px; font-weight: 600;
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text2); text-decoration: none; padding: 0 10px;
}
.page-btn:hover { border-color: var(--accent); color: var(--accent); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---- History log ---- */
.history-item {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 10px 0; border-bottom: 1px solid var(--border);
  font-size: 13px; color: var(--text2);
}
.history-item:last-child { border-bottom: none; }
.history-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); flex-shrink: 0; margin-top: 5px;
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .ticket-layout { grid-template-columns: 1fr; }
  .meta-card { order: -1; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-toggle, .topbar-toggle { display: block; }
  .main-content { margin-left: 0; }
  .form-row { grid-template-columns: 1fr; }
  .content-wrapper { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ---- Misc ---- */
.text-center { text-align: center; }
.text-muted { color: var(--text3); }
.mt-16 { margin-top: 16px; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text3); }
.empty-state svg { width: 48px; height: 48px; stroke: var(--text3); fill: none; stroke-width: 1.5; margin-bottom: 12px; }
.empty-state h3 { font-family: var(--font-head); font-size: 18px; color: var(--text2); margin-bottom: 8px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 24px 0; }
a { color: inherit; }
