/* ═══ Jengal AI — Professional Dark Theme ═══ */

:root {
  --bg-primary: #09090b;
  --bg-secondary: #0f0f14;
  --bg-tertiary: #16161e;
  --bg-card: rgba(22, 22, 30, 0.7);
  --bg-glass: rgba(15, 15, 20, 0.85);
  --bg-input: rgba(22, 22, 30, 0.6);
  --border: rgba(139, 92, 246, 0.12);
  --border-hover: rgba(139, 92, 246, 0.25);
  --border-subtle: rgba(255,255,255,0.06);
  --text-primary: #e8e8ed;
  --text-secondary: #8b8ba0;
  --text-muted: #4a4a60;
  --purple-400: #a78bfa;
  --purple-500: #8b5cf6;
  --purple-600: #7c3aed;
  --gradient: linear-gradient(135deg, #a78bfa, #7c3aed);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 20px rgba(139, 92, 246, 0.08);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --transition: 0.2s ease;
  --sidebar-width: 260px;
  /* Safe area for iOS notch */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  /* Prevent pull-to-refresh on mobile */
  overscroll-behavior: none;
}

.hidden { display: none !important; }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(139,92,246,0.2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(139,92,246,0.35); }

/* ═══ Auth Screen ═══ */
.auth-screen {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-primary);
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
}

.auth-bg { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }

.auth-orb {
  position: absolute; border-radius: 50%; filter: blur(100px); opacity: 0.3;
}
.auth-orb-1 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(124,58,237,0.3), transparent 70%);
  top: -150px; left: -100px;
}
.auth-orb-2 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(167,139,250,0.2), transparent 70%);
  bottom: -100px; right: -100px;
}

.auth-card {
  position: relative; z-index: 1;
  width: 380px; max-width: 90vw;
  background: var(--bg-glass);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  animation: authIn 0.5s ease;
}

@keyframes authIn {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-logo { text-align: center; margin-bottom: 32px; }

.auth-logo-img {
  width: 48px; height: 48px; margin-bottom: 16px;
  filter: brightness(0) invert(1) sepia(1) saturate(3) hue-rotate(240deg);
}

.auth-title {
  font-size: 22px; font-weight: 700; color: var(--text-primary);
  letter-spacing: -0.3px;
}

.auth-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.form-group { margin-bottom: 16px; }

.form-label {
  display: block; font-size: 12px; font-weight: 500;
  color: var(--text-secondary); margin-bottom: 6px; text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input {
  width: 100%; padding: 10px 14px;
  background: var(--bg-tertiary); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-family: inherit; font-size: 16px; outline: none;
  transition: var(--transition);
  /* Prevent zoom on iOS */
  -webkit-appearance: none;
}

.form-input:focus {
  border-color: var(--purple-500);
  box-shadow: 0 0 0 2px rgba(139,92,246,0.1);
}

.form-input::placeholder { color: var(--text-muted); }

.auth-error {
  font-size: 12px; color: #ef4444; min-height: 18px;
  margin-bottom: 4px;
}

.auth-btn {
  width: 100%; padding: 12px;
  background: var(--gradient); border: none;
  border-radius: var(--radius-sm); color: white;
  font-family: inherit; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: var(--transition);
  -webkit-appearance: none;
}

.auth-btn:hover { opacity: 0.9; transform: translateY(-1px); }
.auth-btn:active { transform: scale(0.98); }

.auth-switch {
  text-align: center; font-size: 13px;
  color: var(--text-muted); margin-top: 16px;
}

.auth-switch a {
  color: var(--purple-400); text-decoration: none;
  font-weight: 500;
}

.auth-switch a:hover { text-decoration: underline; }

/* ═══ App Layout ═══ */
.app {
  display: flex; height: 100vh;
  height: 100dvh; /* Dynamic viewport height for mobile */
  padding-top: var(--safe-top);
}

/* ═══ Sidebar ═══ */
.sidebar {
  width: var(--sidebar-width); min-width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-subtle);
  display: flex; flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 200;
}

.sidebar.collapsed {
  transform: translateX(-100%);
  position: absolute; height: 100%;
}

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 150;
  background: rgba(0,0,0,0.5);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
  display: block;
  animation: fadeIn 0.2s ease;
}

.sidebar-header {
  padding: 16px; display: flex;
  align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
}

.logo { display: flex; align-items: center; gap: 10px; }

.logo-icon {
  width: 28px; height: 28px;
  filter: brightness(0) invert(1) sepia(1) saturate(3) hue-rotate(240deg);
}

.logo-text {
  font-size: 16px; font-weight: 700;
  background: var(--gradient);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-close { display: none; }

.btn-icon {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: transparent;
  color: var(--text-secondary); border-radius: var(--radius-sm);
  cursor: pointer; transition: var(--transition); flex-shrink: 0;
  -webkit-appearance: none;
}

.btn-icon:hover { background: rgba(139,92,246,0.08); color: var(--purple-400); }
.btn-icon:active { transform: scale(0.92); }

.new-chat-btn {
  margin: 12px; padding: 10px 14px;
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--border-subtle); background: transparent;
  color: var(--text-secondary); border-radius: var(--radius-sm);
  cursor: pointer; font-size: 13px; font-family: inherit;
  transition: var(--transition);
  -webkit-appearance: none;
}

.new-chat-btn:hover {
  background: rgba(139,92,246,0.06);
  border-color: var(--border-hover); color: var(--purple-400);
}

.new-chat-btn:active { transform: scale(0.97); }

.chat-history { flex: 1; overflow-y: auto; padding: 0 8px; -webkit-overflow-scrolling: touch; }

.chat-history-item {
  padding: 10px 12px; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 13px; color: var(--text-secondary);
  transition: var(--transition); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 2px; display: flex; align-items: center;
  gap: 8px; position: relative;
}

.chat-history-item:hover { background: rgba(255,255,255,0.03); color: var(--text-primary); }
.chat-history-item.active { background: rgba(139,92,246,0.08); color: var(--text-primary); }

.chat-history-item .delete-chat {
  position: absolute; right: 6px; opacity: 0;
  transition: var(--transition);
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: rgba(239,68,68,0.1);
  color: #ef4444; border-radius: 4px;
  cursor: pointer; font-size: 11px;
}

.chat-history-item:hover .delete-chat { opacity: 1; }

.sidebar-footer {
  padding: 8px 12px; border-top: 1px solid var(--border-subtle);
  display: flex; flex-direction: column; gap: 2px;
  padding-bottom: calc(8px + var(--safe-bottom));
}

.sidebar-footer-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 10px; border: none; background: transparent;
  color: var(--text-secondary); border-radius: var(--radius-sm);
  cursor: pointer; font-size: 13px; font-family: inherit;
  transition: var(--transition); width: 100%; text-align: left;
  -webkit-appearance: none;
}

.sidebar-footer-btn:hover { background: rgba(255,255,255,0.03); color: var(--text-primary); }
.sidebar-footer-btn:active { transform: scale(0.97); }

/* ═══ Main ═══ */
.main {
  flex: 1; display: flex; flex-direction: column;
  min-width: 0; position: relative;
}

.topbar {
  height: 52px; display: flex; align-items: center;
  padding: 0 12px; gap: 8px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-secondary); flex-shrink: 0;
}

.topbar-title { flex: 1; min-width: 0; }

.topbar-title h1 {
  font-size: 14px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.topbar-actions { display: flex; gap: 2px; }

.chat-container {
  flex: 1; overflow-y: auto; position: relative;
  -webkit-overflow-scrolling: touch;
}

/* ═══ Welcome ═══ */
.welcome {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 100%; padding: 40px 20px;
  text-align: center;
  animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.welcome-icon { margin-bottom: 20px; }

.welcome-logo {
  width: 56px; height: 56px;
  filter: brightness(0) invert(1) sepia(1) saturate(3) hue-rotate(240deg);
  opacity: 0.7;
}

.welcome-title {
  font-size: 24px; font-weight: 700;
  background: var(--gradient);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; margin-bottom: 8px;
}

.welcome-subtitle {
  font-size: 14px; color: var(--text-muted);
  max-width: 400px; margin-bottom: 36px;
}

.welcome-features {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 10px; max-width: 480px; width: 100%;
}

.feature-card {
  display: flex; align-items: center; gap: 10px;
  padding: 14px; background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md); cursor: pointer;
  transition: var(--transition); text-align: left;
  -webkit-appearance: none;
}

.feature-card:hover {
  border-color: var(--border-hover);
  background: rgba(139,92,246,0.04);
}

.feature-card:active { transform: scale(0.97); }

.feature-icon {
  flex-shrink: 0; color: var(--purple-400); opacity: 0.7;
}

.feature-text strong {
  display: block; font-size: 12px; font-weight: 600; margin-bottom: 2px;
}

.feature-text span { font-size: 11px; color: var(--text-muted); }

/* ═══ Messages ═══ */
.messages {
  padding: 16px; max-width: 760px;
  margin: 0 auto; width: 100%;
}

.message {
  display: flex; margin-bottom: 16px;
  animation: msgIn 0.3s ease;
  padding: 12px 16px;
  border-radius: var(--radius-md);
}

.message.user {
  background: rgba(139, 92, 246, 0.04);
  border: 1px solid rgba(139, 92, 246, 0.08);
}

.message.assistant {
  background: transparent;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.message-content { flex: 1; min-width: 0; }

.message-header {
  display: flex; align-items: center; gap: 8px; margin-bottom: 6px;
}

.message-name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.message.assistant .message-name { color: var(--purple-400); }
.message-time { font-size: 11px; color: var(--text-muted); }

.message-body {
  font-size: 14px; line-height: 1.7; color: var(--text-secondary);
  word-wrap: break-word; overflow-wrap: break-word;
}

.message.user .message-body { color: var(--text-primary); }

.message-body p { margin-bottom: 8px; }
.message-body p:last-child { margin-bottom: 0; }
.message-body strong { color: var(--text-primary); font-weight: 600; }
.message-body em { color: var(--purple-400); font-style: italic; }

.message-body h1, .message-body h2, .message-body h3 {
  color: var(--text-primary); margin: 16px 0 8px; font-weight: 700;
}
.message-body h1 { font-size: 18px; }
.message-body h2 { font-size: 16px; }
.message-body h3 { font-size: 15px; }

.message-body ul, .message-body ol { margin: 8px 0; padding-left: 20px; }
.message-body li { margin-bottom: 4px; }

.message-body a {
  color: var(--purple-400); text-decoration: none;
  border-bottom: 1px solid rgba(167,139,250,0.3);
}
.message-body a:hover { border-bottom-color: var(--purple-400); }

.message-body blockquote {
  border-left: 3px solid var(--purple-500);
  padding: 8px 16px; margin: 12px 0;
  background: rgba(139,92,246,0.04);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-secondary);
}

.message-body hr { border: none; border-top: 1px solid var(--border-subtle); margin: 16px 0; }

.message-body code {
  background: rgba(139,92,246,0.1); color: var(--purple-400);
  padding: 2px 6px; border-radius: 4px;
  font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', monospace; font-size: 13px;
}

.message-body pre {
  background: #0d0d12; border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md); margin: 12px 0; overflow: hidden;
}

.message-body pre code {
  display: block; padding: 16px; overflow-x: auto;
  background: transparent; color: #d4d4d8;
  font-size: 13px; line-height: 1.6;
  -webkit-overflow-scrolling: touch;
}

.code-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px; background: rgba(255,255,255,0.03);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 11px; color: var(--text-muted);
}

.copy-btn {
  padding: 4px 10px; background: rgba(139,92,246,0.08);
  border: 1px solid var(--border-subtle); color: var(--text-secondary);
  border-radius: 4px; cursor: pointer; font-size: 11px;
  font-family: inherit; transition: var(--transition);
  -webkit-appearance: none;
}
.copy-btn:hover { background: rgba(139,92,246,0.15); color: var(--purple-400); }
.copy-btn:active { transform: scale(0.95); }

.message-files { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }

.message-file {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; background: var(--bg-card);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-sm);
  font-size: 12px; color: var(--text-secondary); text-decoration: none;
  transition: var(--transition);
}
.message-file:hover { border-color: var(--border-hover); }

.message-file-icon {
  width: 28px; height: 28px; display: flex;
  align-items: center; justify-content: center;
  background: rgba(139,92,246,0.08); border-radius: 6px;
}

.message-file-icon svg {
  width: 14px; height: 14px; stroke: var(--purple-400);
}

.message-file-name {
  max-width: 140px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}

.message-image {
  max-width: 280px; max-height: 280px;
  border-radius: var(--radius-md); border: 1px solid var(--border-subtle);
  margin-bottom: 6px; cursor: pointer; transition: var(--transition);
}
.message-image:hover { border-color: var(--border-hover); }

.typing-indicator { display: flex; gap: 4px; padding: 4px 0; }

.typing-indicator span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--purple-500);
  animation: typeDot 1.2s ease-in-out infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.3s; }

@keyframes typeDot {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

/* ═══ Input Area ═══ */
.input-area {
  padding: 0 12px 10px;
  padding-bottom: calc(10px + var(--safe-bottom));
  flex-shrink: 0;
}

.file-preview-area {
  display: flex; flex-wrap: wrap; gap: 6px;
  max-width: 760px; margin: 0 auto 6px;
}
.file-preview-area:empty { display: none; }

.file-preview-item {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; background: var(--bg-card);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-sm);
  font-size: 12px; color: var(--text-secondary);
  animation: fadeIn 0.2s ease;
}

.file-preview-item img {
  width: 32px; height: 32px; object-fit: cover; border-radius: 4px;
}

.file-preview-remove {
  width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: rgba(239,68,68,0.1);
  color: #ef4444; border-radius: 50%;
  cursor: pointer; font-size: 9px; transition: var(--transition);
  -webkit-appearance: none;
}
.file-preview-remove:hover { background: rgba(239,68,68,0.2); }

.input-wrapper { max-width: 760px; margin: 0 auto; }

.input-container {
  display: flex; align-items: flex-end; gap: 6px;
  padding: 8px 10px; background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md); transition: var(--transition);
}

.input-container:focus-within {
  border-color: var(--purple-500);
  box-shadow: 0 0 0 2px rgba(139,92,246,0.08);
}

.attach-btn { color: var(--text-muted); }
.attach-btn:hover { color: var(--purple-400); }

.chat-input {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--text-primary); font-family: inherit;
  font-size: 16px; line-height: 1.5; resize: none;
  max-height: 140px; padding: 4px 4px;
  -webkit-appearance: none;
}
.chat-input::placeholder { color: var(--text-muted); }

.send-btn {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: var(--gradient); color: white;
  border-radius: var(--radius-sm); cursor: pointer;
  transition: var(--transition); flex-shrink: 0;
  opacity: 0.4; pointer-events: none;
  -webkit-appearance: none;
}
.send-btn.active { opacity: 1; pointer-events: auto; }
.send-btn.active:hover { opacity: 0.85; }
.send-btn.active:active { transform: scale(0.9); }
.send-btn.loading { opacity: 1; pointer-events: auto; }

.input-hint {
  text-align: center; font-size: 11px;
  color: var(--text-muted); margin-top: 6px;
  max-width: 760px; margin-left: auto; margin-right: auto;
}

/* ═══ Modals ═══ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(0,0,0,0.6);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.2s ease;
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
}

.modal {
  width: 420px; max-width: 92vw; max-height: 85vh;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  display: flex; flex-direction: column;
  animation: authIn 0.3s ease;
}

.modal-lg { width: 600px; }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border-subtle);
}

.modal-header h2 { font-size: 16px; font-weight: 700; }

.modal-tabs {
  display: flex; padding: 0 20px;
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-tab {
  padding: 10px 16px; border: none; background: transparent;
  color: var(--text-muted); font-family: inherit; font-size: 13px;
  cursor: pointer; transition: var(--transition);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  white-space: nowrap;
  -webkit-appearance: none;
}

.modal-tab:hover { color: var(--text-secondary); }
.modal-tab.active {
  color: var(--purple-400);
  border-bottom-color: var(--purple-500);
}

.modal-body {
  padding: 20px; overflow-y: auto; flex: 1;
  -webkit-overflow-scrolling: touch;
}

/* Profile */
.profile-info {
  display: flex; flex-direction: column; gap: 12px;
}

.profile-row {
  display: flex; justify-content: space-between;
  align-items: center; padding: 12px 14px;
  background: var(--bg-tertiary); border-radius: var(--radius-sm);
}

.profile-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.profile-value { font-size: 14px; font-weight: 500; }

.admin-link {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px; margin-top: 8px;
  background: rgba(139,92,246,0.06);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--purple-400); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: var(--transition);
  font-family: inherit; width: 100%; text-align: left;
  -webkit-appearance: none;
}
.admin-link:hover { background: rgba(139,92,246,0.1); }

/* Admin */
.stat-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 10px; margin-bottom: 16px;
}

.stat-card {
  padding: 16px; background: var(--bg-tertiary);
  border-radius: var(--radius-md); text-align: center;
  border: 1px solid var(--border-subtle);
}

.stat-value {
  font-size: 24px; font-weight: 700;
  background: var(--gradient);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-label { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

.admin-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}

.admin-table th {
  text-align: left; padding: 8px 10px;
  font-size: 11px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-subtle);
}

.admin-table td {
  padding: 10px 10px; border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.admin-table tr:hover td { color: var(--text-primary); }

.badge {
  display: inline-block; padding: 3px 8px;
  border-radius: 4px; font-size: 11px; font-weight: 600;
}

.badge-admin { background: rgba(139,92,246,0.15); color: var(--purple-400); }
.badge-user { background: rgba(255,255,255,0.05); color: var(--text-muted); }
.badge-active { background: rgba(34,197,94,0.1); color: #22c55e; }
.badge-used { background: rgba(239,68,68,0.1); color: #ef4444; }

.gen-invite-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 16px; background: var(--gradient);
  border: none; border-radius: var(--radius-sm);
  color: white; font-family: inherit; font-size: 13px;
  font-weight: 600; cursor: pointer; transition: var(--transition);
  margin-bottom: 14px;
  -webkit-appearance: none;
}
.gen-invite-btn:hover { opacity: 0.9; }
.gen-invite-btn:active { transform: scale(0.97); }

.invite-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px; color: var(--purple-400);
  cursor: pointer;
}

.delete-user-btn {
  padding: 4px 10px; background: rgba(239,68,68,0.1);
  border: none; border-radius: 4px; color: #ef4444;
  font-size: 11px; cursor: pointer; font-family: inherit;
  transition: var(--transition);
  -webkit-appearance: none;
}
.delete-user-btn:hover { background: rgba(239,68,68,0.2); }

/* ═══ Lightbox ═══ */
.lightbox {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(0,0,0,0.9); display: flex;
  align-items: center; justify-content: center;
  cursor: pointer; animation: fadeIn 0.2s ease;
}

.lightbox img {
  max-width: 90%; max-height: 90%;
  border-radius: var(--radius-md);
}

/* ═══ Responsive — Mobile ═══ */
@media (max-width: 768px) {
  .sidebar {
    position: fixed; left: 0; top: 0;
    height: 100%; z-index: 1000;
    box-shadow: var(--shadow-md);
    padding-top: var(--safe-top);
  }
  .sidebar.collapsed { transform: translateX(-100%); }
  .sidebar-close { display: flex; }
  
  .welcome-features { grid-template-columns: 1fr; max-width: 320px; }
  .stat-grid { grid-template-columns: 1fr; }
  
  .messages { padding: 12px; }
  .message { padding: 10px 12px; margin-bottom: 12px; }
  
  .modal { max-width: 95vw; max-height: 90vh; }
  .modal-lg { width: 95vw; }
  
  .topbar { padding: 0 8px; }
  
  .input-area { padding: 0 8px 8px; padding-bottom: calc(8px + var(--safe-bottom)); }
  .input-hint { display: none; }
  
  .message-image { max-width: 220px; max-height: 220px; }
  
  /* Better touch targets */
  .chat-history-item { padding: 12px; }
  .chat-history-item .delete-chat { opacity: 0.7; }
}

@media (max-width: 480px) {
  .auth-card { padding: 32px 24px; }
  .welcome-title { font-size: 20px; }
  .welcome-subtitle { font-size: 13px; margin-bottom: 24px; }
  .feature-card { padding: 12px; }
  .feature-text strong { font-size: 11px; }
  .feature-text span { font-size: 10px; }
}

/* ═══ Standalone PWA mode ═══ */
@media (display-mode: standalone) {
  .topbar {
    padding-top: 0;
  }
}
