/* ============================================
   AI Chat - Modern Dark Theme
   ============================================ */

/* Reset & Base */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #0f0f13;
  --bg-secondary: #19191f;
  --bg-tertiary: #22222b;
  --bg-hover: #2a2a35;
  --bg-active: #32324a;

  --text-primary: #e8e8ed;
  --text-secondary: #9b9baf;
  --text-tertiary: #6b6b80;
  --text-inverse: #ffffff;

  --accent: #DD3333;
  --accent-hover: #e55555;
  --accent-muted: rgba(221, 51, 51, 0.15);
  --accent-glow: rgba(221, 51, 51, 0.5);

  --success: #22c55e;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --warning: #f59e0b;

  --border: #2a2a35;
  --border-light: #1e1e28;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 20px rgba(124, 58, 237, 0.3);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --sidebar-width: 320px;
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

input, button, textarea, select {
  font-family: inherit;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* ============================================
   Auth Pages
   ============================================ */

.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-primary);
  background-image:
    radial-gradient(ellipse at 50% 0%, rgba(221, 51, 51, 0.08) 0%, transparent 60%);
}

.auth-container {
  width: 100%;
  max-width: 420px;
  padding: 20px;
}

.auth-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px 32px;
  box-shadow: var(--shadow-lg);
}

.auth-header {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo {
  margin-bottom: 20px;
  display: flex;
  justify-content: center;
}

.auth-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.auth-header p {
  color: var(--text-secondary);
  font-size: 14px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"] {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 14px;
  transition: all 0.2s;
  outline: none;
}

.form-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

.form-group input::placeholder {
  color: var(--text-tertiary);
}

.hint {
  font-size: 12px;
  color: var(--text-tertiary);
}

.auth-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 14px;
  color: var(--text-secondary);
}

/* ============================================
   Buttons
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: var(--shadow-glow);
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-secondary {
  background: var(--surface-hover);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
  border-color: var(--text-tertiary);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: var(--danger);
  color: white;
}

.btn-icon {
  padding: 8px;
  background: transparent;
  color: var(--text-secondary);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-full {
  width: 100%;
}

.btn-send {
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ============================================
   Alerts
   ============================================ */

.alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  margin-bottom: 20px;
}

.alert-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

/* ============================================
   App Layout
   ============================================ */

#app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  width: 100dvw;
}

/* ============================================
   Sidebar
   ============================================ */

#sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.sidebar-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  object-fit: cover;
}

.auth-logo-img {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  object-fit: cover;
}

.profile-avatar-preview {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

.profile-avatar-img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--accent);
}

.sidebar-search {
  position: relative;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
}

.sidebar-search svg {
  position: absolute;
  left: 22px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  pointer-events: none;
}

.sidebar-search input {
  width: 100%;
  padding: 10px 14px 10px 36px;
  background: var(--bg-tertiary);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: all 0.2s;
}

.sidebar-search input:focus {
  border-color: var(--accent);
  background: var(--bg-hover);
}

.sidebar-search input::placeholder {
  color: var(--text-tertiary);
}

/* Chat List */
#chatList {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

#chatList::-webkit-scrollbar {
  width: 4px;
}

#chatList::-webkit-scrollbar-track {
  background: transparent;
}

#chatList::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: 2px;
}

.chat-item:hover {
  background: var(--bg-hover);
}

.chat-item.active {
  background: var(--accent-muted);
  border-left: 3px solid var(--accent);
}

.chat-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.chat-item.active .chat-icon {
  background: var(--accent);
  color: white;
}

.chat-item-info {
  flex: 1;
  min-width: 0;
}

.chat-item-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item-preview {
  font-size: 12px;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.chat-item-meta {
  font-size: 11px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--radius-md);
  transition: background 0.2s;
}

.user-info:hover {
  background: var(--bg-hover);
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #aa2222);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  color: white;
  flex-shrink: 0;
  overflow: hidden;
}

.user-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-details {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-email {
  font-size: 11px;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-actions {
  display: flex;
  gap: 2px;
}

/* ============================================
   Main Area
   ============================================ */

#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Empty State */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px;
  color: var(--text-tertiary);
}

.empty-icon {
  opacity: 0.4;
  margin-bottom: 8px;
}

.empty-state h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-secondary);
}

.empty-state p {
  font-size: 14px;
  color: var(--text-tertiary);
  text-align: center;
  max-width: 280px;
}

/* Chat View */
.chat-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.chat-header-info h2 {
  font-size: 16px;
  font-weight: 600;
}

.chat-meta {
  font-size: 12px;
  color: var(--text-tertiary);
}

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

/* Messages Container */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scroll-behavior: smooth;
}

.messages-container::-webkit-scrollbar {
  width: 6px;
}

.messages-container::-webkit-scrollbar-track {
  background: transparent;
}

.messages-container::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.message {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  max-width: 85%;
  animation: messageIn 0.2s ease-out;
}

@keyframes messageIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.message.ai {
  align-self: flex-start;
}

.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
  margin-top: 4px;
  overflow: hidden;
}

.msg-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.message.ai .message-avatar {
  background: linear-gradient(135deg, var(--accent), #aa2222);
}

.message.user .message-avatar {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
}

.message-bubble {
  padding: 10px 16px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.6;
  word-wrap: break-word;
  position: relative;
}

.message.ai .message-bubble {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-top-left-radius: 4px;
  color: var(--text-primary);
}

.message.user .message-bubble {
  background: var(--accent);
  border-top-right-radius: 4px;
  color: white;
}

.message-sender {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 4px;
}

.message-time {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 4px;
  text-align: right;
}

.message.user .message-time {
  color: rgba(255,255,255,0.6);
}

/* Typing / Loading indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  border-top-left-radius: 4px;
  align-self: flex-start;
  margin-top: 4px;
}

.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-tertiary);
  animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Input Area */
.input-area {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}

.message-form {
  display: flex;
  align-items: center;
  gap: 12px;
}

.message-form input {
  flex: 1;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: all 0.2s;
}

.message-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

.message-form input::placeholder {
  color: var(--text-tertiary);
}

/* ============================================
   Modal
   ============================================ */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.15s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 460px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.2s ease-out;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}

.modal-header h2,
.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

.modal-body {
  padding: 20px 24px 16px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  width: 32px;
  height: 32px;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.modal-close:hover {
  color: var(--text-primary);
  background: var(--surface-hover);
}

.modal-footer {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 0 24px 24px;
}

.modal-footer .btn {
  flex: 1;
  max-width: 200px;
}

/* Toggle Switch */
.toggle-group {
  margin-bottom: 8px;
}

.toggle-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.toggle-label span {
  font-size: 14px;
  font-weight: 500;
}

.toggle-row {
  display: flex;
  align-items: center;
  flex-direction: row-reverse;
  justify-content: flex-end;
  gap: 12px;
  padding: 12px 0;
}

.toggle-row-label {
  font-size: 14px;
  font-weight: 500;
  display: block;
  margin-bottom: 2px;
}

.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 24px;
  transition: 0.3s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background: var(--text-secondary);
  border-radius: 50%;
  transition: 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--accent);
  border-color: var(--accent);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
  background: white;
}

/* Invite */
.invite-link-container {
  display: flex;
  gap: 8px;
  margin: 12px 0;
}

.invite-link-container input {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

.add-user-row {
  display: flex;
  gap: 8px;
}

.add-user-row input {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
}

/* Members List */
.members-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.member-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
}

.member-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
}

.member-info {
  flex: 1;
}

.member-name {
  font-size: 14px;
  font-weight: 500;
}

.member-email {
  font-size: 12px;
  color: var(--text-tertiary);
}

/* ============================================
   Admin Panel
   ============================================ */

.admin-layout {
  display: flex;
  height: 100vh;
}

.admin-sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.admin-nav {
  padding: 12px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 14px;
  transition: all 0.2s;
  text-decoration: none;
}

.nav-link:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  text-decoration: none;
}

.nav-link.active {
  background: var(--surface-hover);
  color: var(--text-primary);
  font-weight: 600;
}

.admin-main {
  flex: 1;
  overflow-y: auto;
  padding: 32px 40px;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.admin-header h1 {
  font-size: 24px;
  font-weight: 700;
}

.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 24px;
  margin-bottom: 24px;
}

.card h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.checkbox-group {
  display: flex;
  align-items: flex-end;
  padding-bottom: 4px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
}

.checkbox-label input[type="checkbox"] {
  display: none;
}

.checkbox-custom {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.checkbox-label input:checked + .checkbox-custom {
  background: var(--accent);
  border-color: var(--accent);
}

.checkbox-label input:checked + .checkbox-custom::after {
  content: '✓';
  color: white;
  font-size: 14px;
  font-weight: 700;
}

/* Table */
.table-wrapper {
  overflow-x: auto;
}

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

.users-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}

.users-table td {
  padding: 12px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--border-light);
}

.users-table tr:last-child td {
  border-bottom: none;
}

.users-table tr:hover td {
  background: var(--bg-hover);
}

.actions-cell {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
}

.badge-admin {
  background: var(--accent-muted);
  color: var(--accent);
}

.badge-user {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

/* ============================================
   Utilities
   ============================================ */

.hidden {
  display: none !important;
}

/* ============================================
   Responsive
   ============================================ */

.btn-mobile-only {
  display: none;
}

.btn-desktop-only {
  display: flex;
}

@media (max-width: 768px) {
  .btn-desktop-only {
    display: none;
  }
}

.mobile-top-bar {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-primary);
}

.mobile-top-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.mobile-breadcrumb {
  font-size: 14px;
  color: var(--text-muted);
  display: none;
  align-items: center;
  gap: 4px;
}

.mobile-breadcrumb::before {
  content: '›';
  font-size: 18px;
  color: var(--text-muted);
  margin-right: 2px;
}

.mobile-breadcrumb.visible {
  display: inline-flex;
}

@media (max-width: 768px) {
  .btn-mobile-only {
    display: flex;
  }

  #main {
    position: relative;
  }

  #app {
    position: relative;
    overflow: hidden;
  }

  #sidebar {
    width: 100%;
    min-width: 100%;
    position: absolute;
    z-index: 20;
    height: 100vh;
    height: 100dvh;
    transition: transform 0.25s ease;
  }

  #sidebar.hidden-mobile {
    transform: translateX(-100%);
    display: flex; /* keep display flex so transform works */
  }

  #main {
    width: 100%;
  }

  .message {
    max-width: 92%;
  }

  .chat-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .empty-state {
    height: calc(100dvh - 50px);
  }

  .admin-layout {
    flex-direction: column;
  }

  .admin-sidebar {
    width: 100%;
    min-width: 100%;
    flex-direction: row;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .admin-main {
    padding: 20px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }
}

/* Context Menu */
.context-menu-container {
  position: relative;
  display: inline-block;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.btn-icon:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.context-menu {
  position: fixed;
  z-index: 1000;
  background: #1a1a2e;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  min-width: 200px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.6);
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s;
  font-family: inherit;
  text-align: left;
}

.context-menu-item svg {
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.context-menu-item:hover {
  background: var(--surface-hover);
}

.context-menu-item.delete-user-btn:hover {
  color: var(--danger);
}

.context-menu-item.delete-user-btn:hover svg {
  color: var(--danger);
}

.context-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 8px;
}

.context-menu.hidden {
  display: none;
}

/* Email Settings */
.settings-form {
  max-width: 640px;
}

.help-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.help-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}

.help-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-secondary);
}

.help-table tr:last-child td {
  border-bottom: none;
}

/* Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--surface-hover);
  transition: 0.2s;
  border-radius: 24px;
}

.slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: var(--text-tertiary);
  transition: 0.2s;
  border-radius: 50%;
}

.switch input:checked + .slider {
  background: var(--accent);
}

.switch input:checked + .slider::before {
  transform: translateX(20px);
  background: white;
}

/* Alerts */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
}

.alert-error {
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.alert-success {
  background: rgba(34, 197, 94, 0.1);
  color: var(--accent);
  border: 1px solid rgba(34, 197, 94, 0.2);
}
