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

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

:root {
  --bg-root: #000000;
  --bg-sidebar: #000000;
  --bg-surface: #000000;
  --bg-card: #000000;
  --bg-card-hover: #0a0a0a;
  --bg-input: #000000;
  --border: #1a1a1a;
  --border-light: #252525;
  --border-focus: #6366f1;
  --text-primary: #fafafa;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --accent: #ff9f1c;
  --accent-hover: #ffb347;
  --accent-glow: rgba(255, 159, 28, 0.15);
  --green: #22c55e;
  --green-hover: #16a34a;
  --green-glow: rgba(34, 197, 94, 0.15);
  --red: #ef4444;
  --red-hover: #dc2626;
  --red-glow: rgba(239, 68, 68, 0.1);
  --blue: #ff9f1c;
  --blue-hover: #ffb347;
  --blue-glow: rgba(255, 159, 28, 0.15);
  --radius: 10px;
  --radius-lg: 14px;
  --sidebar-width: 260px;
  --sidebar-collapsed: 64px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --sidebar-transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-root);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  animation: fadeIn 0.15s ease;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ─── Layout Shell ─── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ─── */
.sidebar {
  width: var(--sidebar-collapsed);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 50;
  transition: width var(--sidebar-transition);
  overflow: hidden;
}
.sidebar.expanded { width: var(--sidebar-width); }

.sidebar-nav {
  flex: 1;
  padding: 18px 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Grip handle on right edge (toggles collapse/expand) */
.sidebar-grip {
  position: fixed;
  top: 50%;
  left: calc(var(--sidebar-collapsed) - 8px);
  transform: translateY(-50%);
  width: 16px;
  height: 56px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 55;
  padding: 0;
  transition: left var(--sidebar-transition), color var(--transition), background var(--transition), height 0.2s;
}
.sidebar.expanded ~ .sidebar-grip {
  left: calc(var(--sidebar-width) - 8px);
}
.sidebar-grip:hover {
  color: var(--accent);
  background: var(--bg-card);
  height: 72px;
}
.sidebar-grip svg {
  width: 14px;
  height: 14px;
  transition: transform var(--sidebar-transition);
}
.sidebar.expanded ~ .sidebar-grip svg {
  transform: rotate(180deg);
}

.nav-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  white-space: nowrap;
  overflow: hidden;
  opacity: 0;
  height: 0;
  margin: 0;
  transition: all var(--sidebar-transition);
}
.sidebar.expanded .nav-label {
  opacity: 1;
  height: auto;
  padding: 8px 4px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0;
  height: 42px;
  padding: 0;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid transparent;
  background: none;
  width: 100%;
  text-align: left;
  text-decoration: none;
  justify-content: center;
}
.sidebar.expanded .nav-item {
  gap: 12px;
  padding: 0 14px;
  justify-content: flex-start;
}
.nav-item:hover { color: var(--text-primary); background: var(--bg-card); }
.nav-item.active {
  color: var(--text-primary);
  background: transparent;
  border: 2px solid #555555;
}
.nav-item svg { width: 18px; min-width: 18px; height: 18px; flex-shrink: 0; opacity: 0.7; }
.nav-item.active svg { opacity: 1; }
.nav-item .nav-text {
  display: none;
  white-space: nowrap;
}
.sidebar.expanded .nav-item .nav-text {
  display: inline;
}

.sidebar-footer {
  padding: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.sidebar.expanded .sidebar-footer {
  align-items: stretch;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  width: auto;
}
.sidebar.expanded .sidebar-user {
  justify-content: flex-start;
  width: 100%;
  padding: 0 4px;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #e8890c);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.footer-nav {
  width: 34px !important;
  height: 34px;
  padding: 0 !important;
  border-radius: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  justify-content: center !important;
  gap: 0 !important;
}
.footer-nav:hover { background: var(--bg-card-hover); }
.footer-nav.active { border-color: #555555 !important; }
.user-meta {
  flex: 1;
  min-width: 0;
  display: none;
}
.sidebar.expanded .user-meta { display: block; }
.user-meta .name { font-size: 13px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta .email { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Logout button — icon-only when collapsed, icon+text when expanded (matches nav-item style) */
.sidebar-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
  flex-shrink: 0;
}
.sidebar-logout:hover {
  color: var(--red);
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.08);
}
.sidebar-logout svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.85;
}
.sidebar-logout .logout-text {
  display: none;
}
.sidebar.expanded .sidebar-logout {
  width: 100%;
  height: 42px;
  gap: 10px;
  padding: 0 14px;
  justify-content: flex-start;
}
.sidebar.expanded .sidebar-logout .logout-text {
  display: inline;
}

/* ─── Main Content ─── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-collapsed);
  padding: 32px 40px;
  max-width: 100%;
  overflow-x: hidden;
  transition: margin-left var(--sidebar-transition);
}
.sidebar.expanded ~ .main-content { margin-left: var(--sidebar-width); }

.page-header {
  margin-bottom: 36px;
}
.page-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}
.page-header p {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ─── Cards ─── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  transition: border-color var(--transition);
}
.card:hover { border-color: var(--border-light); }
.card h3 { font-size: 15px; font-weight: 600; margin-bottom: 16px; color: var(--text-primary); }

/* ─── Forms ─── */
label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.2px;
}
input, select, textarea {
  width: 100%;
  padding: 10px 13px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: all var(--transition);
}
textarea {
  resize: vertical;
  min-height: 90px;
  line-height: 1.5;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }
.form-group { margin-bottom: 16px; }

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: 0.1px;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.1);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-green {
  background: var(--green);
  color: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.1);
}
.btn-green:hover:not(:disabled) { background: var(--green-hover); }

.btn-secondary {
  background: var(--bg-card);
  border-color: var(--border);
  color: var(--text-secondary);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg-card-hover); color: var(--text-primary); border-color: var(--border-light); }

.btn-danger {
  background: transparent;
  border-color: var(--border);
  color: var(--red);
}
.btn-danger:hover:not(:disabled) { background: var(--red-glow); border-color: rgba(239,68,68,0.3); }

.btn-blue {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.1);
}
.btn-blue:hover:not(:disabled) { background: var(--blue-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 8px;
}
.btn-ghost:hover:not(:disabled) { color: var(--text-primary); background: var(--bg-card); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; }

/* ─── Tables ─── */
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 14px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }

/* ─── Server Cards (User Dashboard) ─── */
.server-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 300px);
  gap: 16px;
}
.server-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}
.server-card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
}

.server-card-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}
.server-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent-glow);
  border: 1px solid rgba(99, 102, 241, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-hover);
}
.server-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--green);
  margin-left: auto;
}
.server-status.status-offline { color: var(--red); }
.server-status.status-backup { color: var(--accent); }
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green-glow);
}
.server-status.status-offline .status-dot { background: var(--red); box-shadow: 0 0 6px var(--red-glow); }
.server-status.status-backup .status-dot { background: var(--accent); box-shadow: 0 0 6px var(--accent-glow); }

.server-name-group { flex: 1; }
.server-card .server-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.2px;
}
.server-card .server-nickname {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.server-card-image {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 14px;
  position: relative;
}
.server-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.server-card-image::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 8px;
  box-shadow: inset 0 0 30px 15px #000000;
  pointer-events: none;
}

.server-tier-tag {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  background: rgba(161, 161, 170, 0.1);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  margin-bottom: 12px;
}

.server-card-actions {
  display: flex;
  gap: 10px;
}
.server-card-actions.stacked {
  flex-direction: column;
  gap: 6px;
}
.server-card-actions .btn {
  flex: 1;
  padding: 10px 14px;
  justify-content: center;
}

.btn-filled {
  background: #151515;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.btn-filled:hover:not(:disabled) {
  background: #1a1a1a;
  color: var(--text-primary);
  border-color: var(--border-light);
}
.server-card-actions .btn.copied {
  border-color: var(--green);
  color: var(--green);
}

/* ─── Auth Pages ─── */
.auth-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background: var(--bg-root);
}
.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.3);
}
.auth-card h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}
.auth-card p.subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 28px;
  margin-top: 6px;
}

/* ─── Alerts ─── */
.alert {
  padding: 11px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 16px;
}
.alert-error { background: var(--red-glow); border: 1px solid rgba(239,68,68,0.25); color: #fca5a5; }
.alert-success { background: var(--green-glow); border: 1px solid rgba(34,197,94,0.25); color: #86efac; }

/* ─── Modals ─── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  margin: 24px;
  box-shadow: 0 16px 64px rgba(0,0,0,0.5);
}
.modal.modal-wide {
  max-width: 760px;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}
.form-grid .form-group.full { grid-column: 1 / -1; }
.modal h2 {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 24px; }

/* ─── Tabs ─── */
.tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  width: fit-content;
}
.tab {
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 7px;
  transition: all var(--transition);
  background: none;
  border: none;
}
.tab:hover { color: var(--text-secondary); }
.tab.active {
  color: var(--text-primary);
  background: var(--accent-glow);
  box-shadow: 0 0 0 1px rgba(99,102,241,0.2);
}

/* ─── Badges ─── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.badge-admin { background: var(--accent-glow); color: var(--accent-hover); }
.badge-user { background: rgba(161,161,170,0.1); color: var(--text-muted); }
.badge-count {
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  min-width: 24px;
  text-align: center;
}

/* ─── Misc ─── */
.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty p:first-child { font-size: 15px; font-weight: 500; color: var(--text-secondary); }
.text-muted { color: var(--text-muted); font-size: 13px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }

.copied-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--green);
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  z-index: 200;
  box-shadow: 0 4px 16px rgba(34,197,94,0.3);
  animation: toastIn 1.8s ease forwards;
}
@keyframes toastIn {
  0% { opacity: 0; transform: translateX(-50%) translateY(8px); }
  12% { opacity: 1; transform: translateX(-50%) translateY(0); }
  80% { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-4px); }
}

/* ─── Stat cards ─── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.stat-card .stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 4px;
  letter-spacing: -1px;
}

/* ─── Toggle Switch ─── */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-slider {
  position: absolute;
  inset: 0;
  background: #0d0d0d;
  border: 1px solid var(--border);
  border-radius: 22px;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  height: 14px;
  width: 14px;
  left: 3px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform var(--transition), background var(--transition);
}
.toggle-switch input:checked + .toggle-slider {
  background: var(--accent);
  border-color: var(--accent);
}
.toggle-switch input:checked + .toggle-slider::before {
  transform: translate(18px, -50%);
  background: #000;
}
.toggle-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0 0;
}
.toggle-field .toggle-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.toggle-field .toggle-label .title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}
.toggle-field .toggle-label .desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ─── Embed Overlay ─── */
.embed-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  z-index: 200;
  padding: 24px;
  animation: fadeIn 0.15s ease;
}
.embed-overlay.active { display: flex; }
.embed-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  position: relative;
}
.embed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.embed-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}
.embed-actions {
  display: flex;
  gap: 8px;
}
.embed-container iframe {
  flex: 1;
  width: 100%;
  border: none;
  background: #000;
}
.embed-container iframe.loaded {
  background: #fff;
}
.embed-loading {
  position: absolute;
  inset: 0;
  top: 45px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: #000;
  z-index: 2;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}
.embed-loading.hidden { display: none; }
.spinner {
  width: 28px;
  height: 28px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ─── FAQ Cards (shared) ─── */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.faq-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  transition: border-color var(--transition);
}
.faq-item:hover { border-color: var(--border-light); }
.faq-item .q {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
  line-height: 1.4;
}
.faq-item .a {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.65;
  white-space: pre-wrap;
}
.faq-item .actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  margin-top: 12px;
}

/* ─── Back Link ─── */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 20px;
  transition: color var(--transition);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}
.back-link:hover { color: var(--text-primary); }

/* ─── Search Input ─── */
.search-input {
  padding: 10px 14px 10px 40px !important;
  font-size: 13px !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: 14px center !important;
}

/* ─── Nav Badge (unread count) ─── */
.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: auto;
  margin-right: 8px;
  background: var(--accent);
  color: #000;
  font-size: 11px;
  font-weight: 700;
  border-radius: 9px;
  flex-shrink: 0;
}
.sidebar:not(.expanded) .nav-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  margin: 0;
  min-width: 14px;
  height: 14px;
  padding: 0 4px;
  font-size: 9px;
}
.sidebar:not(.expanded) .nav-item { position: relative; }

/* ─── Support / Chat ─── */
.support-layout {
  display: grid;
  grid-template-columns: 320px 16px 1fr;
  gap: 0;
  min-height: 0;
}
.support-layout.user-view {
  grid-template-columns: 1fr;
}
.conv-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
.resize-handle {
  width: 16px;
  height: 100%;
  cursor: col-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  opacity: 0.55;
  transition: opacity 0.2s, color 0.2s;
}
.resize-handle svg {
  width: 10px;
  height: 32px;
  transition: height 0.2s;
}
.resize-handle:hover,
.resize-handle.dragging {
  opacity: 1;
  color: var(--accent);
}
.resize-handle:hover svg,
.resize-handle.dragging svg {
  height: 48px;
}
.conv-filters {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.conv-search {
  padding: 8px 12px !important;
  font-size: 12px !important;
  height: auto !important;
  min-height: 0 !important;
}
.filter-pills {
  display: flex;
  gap: 6px;
  align-items: stretch;
}
.filter-pill {
  height: 28px;
  padding: 0 12px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  gap: 6px;
  align-items: center;
  transition: all var(--transition);
  font-family: inherit;
  letter-spacing: 0.3px;
  white-space: nowrap;
  box-sizing: border-box;
}
.filter-pill:hover { border-color: var(--border-light); color: var(--text-primary); }
.filter-pill.active {
  background: var(--text-primary);
  border-color: var(--text-primary);
  color: #000;
}
.filter-pill .count {
  background: rgba(255, 255, 255, 0.07);
  color: inherit;
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 10px;
  min-width: 18px;
  text-align: center;
  font-weight: 700;
  line-height: 1.4;
}
.filter-pill.active .count {
  background: rgba(0, 0, 0, 0.18);
  color: #000;
}

.filter-dropdown {
  position: relative;
  flex: 1;
  display: flex;
  min-width: 0;
}
.filter-toggle {
  width: 100%;
  justify-content: flex-start;
}
.filter-toggle svg {
  width: 12px;
  height: 12px;
  opacity: 0.8;
  flex-shrink: 0;
}
.filter-toggle .chevron {
  transition: transform var(--transition);
  margin-left: auto;
}
.filter-dropdown.open .chevron { transform: rotate(180deg); }
.filter-menu {
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 220px;
  padding: 4px;
  z-index: 20;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  display: none;
  animation: fadeIn 0.1s ease;
}
.filter-dropdown.open .filter-menu { display: block; }
.filter-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-primary);
  font-weight: 500;
  transition: background var(--transition);
  user-select: none;
}
.filter-option:hover { background: var(--bg-card-hover); }
.filter-option input[type=checkbox] {
  width: 14px;
  height: 14px;
  padding: 0;
  margin: 0;
  accent-color: var(--accent);
  flex-shrink: 0;
}
.filter-option .count {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  text-align: center;
}
.conv-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.conv-list .empty-state {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
.conv-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.conv-item:last-child { border-bottom: none; }
.conv-item:hover { background: var(--bg-card-hover); }
.conv-item.active { background: var(--bg-card-hover); border-left: 2px solid var(--accent); padding-left: 14px; }
.conv-item .conv-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.conv-item .conv-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.conv-item .conv-time {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.conv-item .conv-email {
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv-item .conv-preview {
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 2px;
}
.conv-item .conv-badges {
  display: flex;
  gap: 5px;
  margin-top: 4px;
  flex-wrap: wrap;
}
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border-radius: 10px;
  line-height: 1.6;
}
.status-pill.new {
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid rgba(255, 159, 28, 0.3);
}
.status-pill.unanswered {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.status-pill.answered {
  background: var(--green-glow);
  color: var(--green);
  border: 1px solid rgba(34, 197, 94, 0.25);
}
.status-pill.resolved {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.chat-pane {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}
.chat-header-info .name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}
.chat-header-info .email {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-body .load-older {
  align-self: center;
  margin-bottom: 4px;
}
.chat-body .empty-chat {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  margin: auto;
}
.msg {
  max-width: 60%;
  width: fit-content;
  padding: 7px 11px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.45;
}
.msg-text {
  white-space: pre-wrap;
  word-wrap: break-word;
}
.msg.from-user {
  align-self: flex-end;
  background: var(--accent);
  color: #000;
  border-bottom-right-radius: 3px;
}
.msg.from-admin {
  align-self: flex-start;
  background: #111111;
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-bottom-left-radius: 3px;
}
.msg-time {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 3px;
  opacity: 0.7;
}
.msg.from-user .msg-time { text-align: right; color: rgba(0, 0, 0, 0.55); }

.chat-input {
  border-top: 1px solid var(--border);
  padding: 12px 16px 10px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-shrink: 0;
  position: relative;
}
.chat-input textarea {
  flex: 1;
  min-height: 40px;
  max-height: 150px;
  height: 40px;
  resize: none;
  padding: 10px 13px;
  font-size: 13px;
  line-height: 1.4;
  overflow-y: hidden;
}
.chat-input textarea.overflowing {
  overflow-y: auto;
}
.chat-input .send-btn {
  height: 40px;
  padding: 0 20px;
  flex-shrink: 0;
}
.send-group {
  position: relative;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.send-group .send-primary {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
.send-group .send-caret {
  height: 40px;
  min-width: 30px;
  padding: 0 6px;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  border-left: 1px solid rgba(0, 0, 0, 0.25);
}
.send-group .send-caret svg {
  width: 14px;
  height: 14px;
  transition: transform var(--transition);
}
.send-group.open .send-caret svg { transform: rotate(180deg); }
.send-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 200px;
  padding: 5px;
  z-index: 10;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  display: none;
  animation: fadeIn 0.1s ease;
}
.send-group.open .send-menu { display: block; }
.send-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
  transition: background var(--transition);
  font-family: inherit;
}
.send-menu button:hover { background: var(--bg-card-hover); }
.send-menu button .sub {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  font-weight: 400;
}
.chat-input .char-count {
  position: absolute;
  right: 16px;
  bottom: -16px;
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  pointer-events: none;
}
.chat-input .char-count.warn { color: var(--accent); }
.chat-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  color: var(--text-muted);
  font-size: 13px;
  gap: 8px;
}

/* ─── Tutorials ─── */
.tutorial-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.tutorial-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition);
  display: flex;
  flex-direction: column;
}
.tutorial-card:hover { border-color: var(--border-light); }
.tutorial-thumb {
  aspect-ratio: 16 / 9;
  background: #0a0a0a;
  position: relative;
  overflow: hidden;
}
.tutorial-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.tutorial-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}
.tutorial-thumb .play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.25);
  transition: background 0.2s;
}
.tutorial-card:hover .play-overlay { background: rgba(0, 0, 0, 0.1); }
.tutorial-thumb .play-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.75);
  border: 2px solid rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  transition: transform 0.2s, background 0.2s;
}
.tutorial-card:hover .play-icon {
  transform: scale(1.1);
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
}
.tutorial-thumb .type-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 3px 8px;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border-radius: 4px;
  backdrop-filter: blur(4px);
}
.tutorial-body {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.tutorial-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tutorial-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tutorial-card .actions {
  display: flex;
  gap: 6px;
  padding: 0 16px 14px;
}

/* Player overlay */
.player-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 200;
  padding: 24px;
  animation: fadeIn 0.15s ease;
  align-items: center;
  justify-content: center;
}
.player-overlay.active { display: flex; }
.player-container {
  width: 100%;
  max-width: 1100px;
  max-height: 90vh;
  background: #000;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.player-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 12px;
}
.player-header .title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.player-body {
  aspect-ratio: 16 / 9;
  background: #000;
  position: relative;
  min-height: 0;
  flex-shrink: 1;
}
.player-body iframe,
.player-body video {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
  object-fit: contain;
}
.player-resize {
  flex-shrink: 0;
  height: 10px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  cursor: row-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  opacity: 0.7;
  transition: opacity 0.2s, background 0.2s, color 0.2s;
}
.player-resize:hover,
.player-resize.dragging {
  opacity: 1;
  background: var(--bg-card-hover);
  color: var(--accent);
}
.player-resize svg {
  width: 36px;
  height: 4px;
}
.player-description {
  padding: 16px 20px;
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  height: 180px;
  overflow-y: auto;
  flex-shrink: 0;
  flex-grow: 0;
}

/* Segmented control for Youtube/Upload toggle */
.segmented {
  display: flex;
  gap: 0;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
}
.segmented label {
  flex: 1;
  margin: 0;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  cursor: pointer;
  border-radius: 6px;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.segmented label:has(input:checked) {
  background: var(--accent);
  color: #000;
}
.segmented input {
  display: none;
}

/* ─── Status Webhook URLs (admin) ─── */
.status-urls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.status-url-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.status-url-row .url-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 78px;
  height: 28px;
  padding: 0 10px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  flex-shrink: 0;
}
.status-url-row .url-label.available {
  background: var(--green-glow);
  color: var(--green);
  border: 1px solid rgba(34, 197, 94, 0.25);
}
.status-url-row .url-label.offline {
  background: var(--red-glow);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.status-url-row .url-label.backup {
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid rgba(255, 159, 28, 0.3);
}
.status-url-row input {
  flex: 1;
  font-size: 11px !important;
  padding: 7px 10px !important;
  height: auto !important;
  font-family: 'Fira Code', 'Courier New', monospace;
  color: var(--text-secondary) !important;
}
.status-url-row button {
  flex-shrink: 0;
  height: 28px;
  padding: 0 12px;
}
.status-url-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.5;
}
.status-url-hint code {
  background: var(--bg-root);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

/* ─── Audit log pills ─── */
.log-pill {
  display: inline-block;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}
.log-pill-success { background: var(--green-glow); color: var(--green); border: 1px solid rgba(34, 197, 94, 0.25); }
.log-pill-danger  { background: var(--red-glow); color: var(--red); border: 1px solid rgba(239, 68, 68, 0.25); }
.log-pill-warn    { background: var(--accent-glow); color: var(--accent); border: 1px solid rgba(255, 159, 28, 0.25); }
.log-pill-info    { background: rgba(255, 255, 255, 0.04); color: var(--text-secondary); border: 1px solid var(--border); }
.log-pill-muted   { background: rgba(255, 255, 255, 0.03); color: var(--text-muted); border: 1px solid var(--border); }

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }
