/* ── Admin layout ─────────────────────────────────────────────────────────── */

.admin-layout {
  display: flex;
  min-height: 100vh;
  background: var(--bg-1);
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 50;
  transition: transform 0.25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-1);
  text-decoration: none;
}

.sidebar-brand span { color: var(--text-2); font-weight: 400; font-size: 0.75rem; }

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.sidebar-section-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-3);
  font-weight: 700;
  padding: 12px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  color: var(--text-2);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: var(--transition);
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: var(--bg-4);
  color: var(--text-1);
}

.nav-item.active {
  background: var(--accent-bg);
  color: var(--accent);
  border: 1px solid rgba(240,90,34,0.15);
}

.nav-item svg { flex-shrink: 0; opacity: 0.7; }
.nav-item.active svg { opacity: 1; }

.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid var(--border);
}

.admin-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 10px;
  background: var(--bg-3);
  margin-bottom: 8px;
}

.admin-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: #fff;
  flex-shrink: 0;
}

.admin-name { font-size: 0.85rem; font-weight: 600; line-height: 1.3; }
.admin-role { font-size: 0.7rem; color: var(--text-3); }

/* ── Main content area ────────────────────────────────────────────────────── */

.admin-main {
  flex: 1;
  margin-left: 240px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.admin-topbar {
  height: 60px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-1);
}

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.admin-content {
  flex: 1;
  padding: 28px;
  max-width: 1200px;
  width: 100%;
}

/* ── Page header ─────────────────────────────────────────────────────────── */

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.page-header h1 { font-size: 1.5rem; margin-bottom: 4px; }
.page-header p { color: var(--text-2); font-size: 0.9rem; }

/* ── Stat cards ──────────────────────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  cursor: default;
  transition: var(--transition);
}

.stat-card:hover { border-color: var(--border-md); }

.stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
  font-weight: 700;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
}

.stat-card.s-total .stat-value { color: var(--text-1); }
.stat-card.s-new .stat-value { color: var(--blue-light); }
.stat-card.s-progress .stat-value { color: var(--amber); }
.stat-card.s-resolved .stat-value { color: var(--green); }

/* ── Table panel ─────────────────────────────────────────────────────────── */

.table-panel {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}

.table-toolbar-title { font-weight: 600; font-size: 0.95rem; }

.toolbar-right { display: flex; align-items: center; gap: 8px; }

.search-input {
  background: var(--bg-2);
  border: 1px solid var(--border-md);
  border-radius: 8px;
  padding: 7px 12px;
  color: var(--text-1);
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
  width: 200px;
  transition: var(--transition);
}

.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.search-input::placeholder { color: var(--text-3); }

.filter-select {
  background: var(--bg-2);
  border: 1px solid var(--border-md);
  border-radius: 8px;
  padding: 7px 30px 7px 10px;
  color: var(--text-2);
  font-size: 0.8rem;
  font-family: inherit;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%234B5E7A' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
  transition: var(--transition);
}

.filter-select:focus { border-color: var(--accent); color: var(--text-1); }

.data-table { width: 100%; border-collapse: collapse; }

.data-table th {
  text-align: left;
  padding: 10px 16px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
}

.data-table td {
  padding: 13px 16px;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-4); }
.data-table tr { cursor: pointer; transition: var(--transition); }

.td-ref {
  font-family: var(--mono);
  font-weight: 700;
  color: var(--accent);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
}

.td-muted { color: var(--text-3); font-size: 0.8rem; }

.empty-state {
  text-align: center;
  padding: 56px 24px;
  color: var(--text-3);
}
.empty-state svg { margin-bottom: 16px; opacity: 0.4; }
.empty-state p { font-size: 0.9rem; }

/* ── Login page ──────────────────────────────────────────────────────────── */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg-0);
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  top: -200px;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(240,90,34,0.06) 0%, transparent 70%);
  pointer-events: none;
}

.login-card {
  background: var(--bg-3);
  border: 1px solid var(--border-md);
  border-radius: var(--radius-lg);
  padding: 40px 40px 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 28px;
}

.login-card h1 { font-size: 1.4rem; margin-bottom: 6px; }
.login-card .login-sub { color: var(--text-2); font-size: 0.9rem; margin-bottom: 28px; }

/* ── Case detail page ────────────────────────────────────────────────────── */

.case-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  align-items: start;
}

.case-panel {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-title { font-size: 0.85rem; font-weight: 700; letter-spacing: 0.02em; }

.panel-body { padding: 20px; }

.detail-row {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
}

.detail-label {
  min-width: 110px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-3);
  padding-top: 1px;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.detail-value { font-size: 0.9rem; color: var(--text-1); line-height: 1.5; }

.details-text {
  background: var(--bg-2);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text-1);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Thread (admin) ──────────────────────────────────────────────────────── */

.admin-thread { padding: 16px 20px; max-height: 400px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }

.admin-msg { display: flex; flex-direction: column; }
.admin-msg.from-reporter { align-items: flex-start; }
.admin-msg.from-handler { align-items: flex-end; }

.admin-msg .msg-bubble { max-width: 80%; font-size: 0.875rem; line-height: 1.5; }

.from-reporter .msg-bubble {
  background: var(--bg-4);
  border: 1px solid var(--border);
  border-radius: 4px 12px 12px 12px;
}

.from-handler .msg-bubble {
  background: var(--accent-bg);
  border: 1px solid rgba(240,90,34,0.18);
  border-radius: 12px 4px 12px 12px;
}

.admin-msg-meta { font-size: 0.7rem; color: var(--text-3); padding: 4px 4px 0; }

/* ── Internal notes ──────────────────────────────────────────────────────── */

.note-item {
  background: var(--amber-glow);
  border: 1px solid rgba(245,158,11,0.15);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 10px;
}

.note-author { font-size: 0.75rem; font-weight: 700; color: var(--amber); margin-bottom: 4px; }
.note-text { font-size: 0.875rem; color: var(--text-1); line-height: 1.5; }
.note-time { font-size: 0.7rem; color: var(--text-3); margin-top: 4px; }

/* ── Audit log ───────────────────────────────────────────────────────────── */

.audit-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.audit-item:last-child { border-bottom: none; }

.audit-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-3);
  margin-top: 6px;
  flex-shrink: 0;
}

.audit-action { font-size: 0.85rem; font-weight: 600; }
.audit-actor { font-size: 0.8rem; color: var(--text-2); }
.audit-time { font-size: 0.75rem; color: var(--text-3); margin-top: 2px; }

/* ── Status select ───────────────────────────────────────────────────────── */

.status-select-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}

.status-select-row select {
  flex: 1;
  background: var(--bg-2);
  border: 1px solid var(--border-md);
  border-radius: 8px;
  padding: 8px 32px 8px 12px;
  color: var(--text-1);
  font-family: inherit;
  font-size: 0.875rem;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%234B5E7A' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.status-select-row select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

/* ── Team table ──────────────────────────────────────────────────────────── */

.team-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--accent);
  border: 1px solid var(--border-md);
  flex-shrink: 0;
}

.role-badge {
  display: inline-flex;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}

.role-super { background: rgba(124,58,237,0.1); color: var(--purple); }
.role-handler { background: var(--accent-bg); color: var(--accent); }

/* ── Settings ────────────────────────────────────────────────────────────── */

.settings-section { margin-bottom: 28px; }

.settings-section-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.color-preview {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border-md);
  flex-shrink: 0;
  transition: var(--transition);
}

.color-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.color-row input[type="color"] {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 8px;
  padding: 2px;
  background: var(--bg-2);
  cursor: pointer;
}

/* ── Modals ──────────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5,8,15,0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal {
  background: var(--bg-3);
  border: 1px solid var(--border-md);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 460px;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-title { font-size: 1rem; font-weight: 700; }

.modal-body { padding: 20px 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* ── Hamburger (mobile) ──────────────────────────────────────────────────── */

.sidebar-toggle {
  display: none;
  padding: 8px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-2);
}

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-toggle { display: flex; }
  .admin-main { margin-left: 0; }
  .case-grid { grid-template-columns: 1fr; }
  .admin-content { padding: 16px; }
}
