/* =============================================
   HelixAI - Modern AI Assistant Platform
   ============================================= */

:root {
  /* Dark theme (default) */
  --bg-primary: #0a0a12;
  --bg-secondary: #111827;
  --bg-tertiary: #1f2937;
  --bg-card: #1a1a2e;
  --bg-hover: #252545;
  --bg-input: #0f172a;
  --border-color: rgba(124, 58, 237, 0.15);
  --border-light: rgba(255, 255, 255, 0.06);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-purple: #7c3aed;
  --accent-cyan: #06b6d4;
  --accent-green: #10b981;
  --accent-orange: #f59e0b;
  --accent-red: #ef4444;
  --accent-gradient: linear-gradient(135deg, #7c3aed 0%, #06b6d4 100%);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 40px rgba(124, 58, 237, 0.15);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --sidebar-width: 300px;
  --topbar-height: 60px;
  --transition: all 0.2s ease;
}

.light-theme {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --bg-card: #ffffff;
  --bg-hover: #f1f5f9;
  --bg-input: #f1f5f9;
  --border-color: rgba(124, 58, 237, 0.15);
  --border-light: rgba(0, 0, 0, 0.08);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.15);
  --shadow-glow: 0 0 40px rgba(124, 58, 237, 0.08);
}

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

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

input, textarea, select, button { font-family: inherit; }
a { color: var(--accent-cyan); text-decoration: none; }

.hidden { display: none !important; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(124, 58, 237, 0.3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(124, 58, 237, 0.5); }

/* ============ LOGIN SCREEN ============ */
.login-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}

.login-bg {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 30% 20%, rgba(124, 58, 237, 0.15) 0%, transparent 50%),
              radial-gradient(ellipse at 70% 80%, rgba(6, 182, 212, 0.1) 0%, transparent 50%),
              var(--bg-primary);
  overflow: hidden;
}

.helix-animation {
  position: absolute; inset: 0;
  opacity: 0.15;
}

.helix-strand {
  position: absolute;
  width: 200%;
  height: 2px;
  background: var(--accent-gradient);
  animation: helixMove 20s linear infinite;
}
.strand-1 { top: 30%; left: -50%; transform: rotate(15deg); }
.strand-2 { top: 60%; left: -50%; transform: rotate(-10deg); animation-delay: -10s; }

@keyframes helixMove { 0% { transform: translateX(-25%) rotate(15deg); } 100% { transform: translateX(25%) rotate(15deg); } }

.login-card {
  position: relative; z-index: 1;
  background: rgba(26, 26, 46, 0.9);
  backdrop-filter: blur(30px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 48px 40px;
  width: 100%; max-width: 440px;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  animation: cardFloat 0.6s ease-out;
}

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

.login-logo { text-align: center; margin-bottom: 36px; }
.login-logo .logo-icon { width: 64px; height: 64px; margin: 0 auto 16px; }
.login-logo .logo-icon svg { width: 100%; height: 100%; }
.login-logo h1 { font-size: 36px; font-weight: 700; color: var(--text-primary); letter-spacing: -1px; }
.login-logo h1 span { background: var(--accent-gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.login-subtitle { color: var(--text-muted); margin-top: 6px; font-size: 14px; }

.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }

.input-wrapper {
  position: relative; display: flex; align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.input-wrapper:focus-within { border-color: var(--accent-purple); box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15); }
.input-icon { width: 18px; height: 18px; margin-left: 14px; color: var(--text-muted); flex-shrink: 0; }
.input-wrapper input {
  flex: 1; padding: 12px 14px; background: none; border: none; outline: none;
  color: var(--text-primary); font-size: 15px;
}
.input-wrapper input::placeholder { color: var(--text-muted); }

.error-msg { color: var(--accent-red); font-size: 13px; margin-bottom: 12px; padding: 8px 12px; background: rgba(239, 68, 68, 0.1); border-radius: var(--radius-sm); }

.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent-gradient);
  color: white; border: none; border-radius: var(--radius-sm);
  padding: 12px 24px; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: var(--transition);
  white-space: nowrap;
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: 0 4px 15px rgba(124, 58, 237, 0.4); }
.btn-primary:active { transform: translateY(0); }
.btn-primary svg { width: 18px; height: 18px; }

.btn-danger { background: var(--accent-red); color: white; border: none; border-radius: var(--radius-sm); padding: 12px 24px; font-size: 14px; font-weight: 500; cursor: pointer; width: 100%; }
.btn-danger:hover { opacity: 0.9; }

.btn-login { width: 100%; padding: 14px; font-size: 16px; }
.btn-arrow { width: 20px; height: 20px; }

.login-footer { text-align: center; margin-top: 24px; color: var(--text-muted); font-size: 12px; }

/* ============ APP LAYOUT ============ */
.app {
  display: flex; height: 100vh; overflow: hidden;
}

/* ============ SIDEBAR ============ */
.sidebar {
  width: var(--sidebar-width); height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-light);
  display: flex; flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.3s ease;
}

.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border-light);
}
.sidebar-logo { display: flex; align-items: center; gap: 10px; }
.sidebar-logo-icon { width: 32px; height: 32px; }
.sidebar-title { font-size: 20px; font-weight: 700; color: var(--text-primary); }
.sidebar-title em { font-style: normal; background: var(--accent-gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }

.new-chat-btn {
  display: flex; align-items: center; gap: 10px;
  margin: 12px 16px; padding: 12px 16px;
  background: var(--accent-gradient);
  color: white; border: none; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; cursor: pointer;
  transition: var(--transition);
}
.new-chat-btn:hover { opacity: 0.9; box-shadow: 0 4px 15px rgba(124, 58, 237, 0.3); }
.new-chat-btn svg { width: 18px; height: 18px; }

.sidebar-search {
  display: flex; align-items: center; gap: 8px;
  margin: 0 16px 12px; padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
}
.sidebar-search svg { width: 16px; height: 16px; color: var(--text-muted); flex-shrink: 0; }
.sidebar-search input { flex: 1; background: none; border: none; outline: none; color: var(--text-primary); font-size: 13px; }
.sidebar-search input::placeholder { color: var(--text-muted); }

/* Sidebar Nav Tabs */
.sidebar-nav {
  display: flex; gap: 2px; padding: 0 16px; margin-bottom: 12px;
  flex-wrap: wrap;
}
.nav-tab {
  display: flex; align-items: center; gap: 5px;
  padding: 8px 12px; border: none;
  background: transparent; color: var(--text-muted);
  border-radius: var(--radius-sm); cursor: pointer;
  font-size: 12px; font-weight: 500;
  transition: var(--transition);
}
.nav-tab svg { width: 14px; height: 14px; }
.nav-tab:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-tab.active { background: rgba(124, 58, 237, 0.15); color: var(--accent-purple); }

/* Conversation List */
.sidebar-conversations {
  flex: 1; overflow-y: auto; padding: 0 8px;
}

.conv-group-label {
  padding: 8px 12px 4px; font-size: 11px; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px;
}

.conv-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin: 2px 0;
  border-radius: var(--radius-sm);
  cursor: pointer; transition: var(--transition);
  border: none; background: transparent;
  width: 100%; text-align: left; color: var(--text-secondary);
  font-size: 13px;
}
.conv-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.conv-item.active { background: rgba(124, 58, 237, 0.12); color: var(--text-primary); }
.conv-item .conv-icon { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.6; }
.conv-item .conv-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-item .conv-delete {
  opacity: 0; width: 16px; height: 16px; color: var(--text-muted);
  background: none; border: none; cursor: pointer; flex-shrink: 0;
  padding: 0; transition: var(--transition);
}
.conv-item:hover .conv-delete { opacity: 1; }
.conv-item .conv-delete:hover { color: var(--accent-red); }
.conv-item .conv-pin { color: var(--accent-purple); width: 12px; height: 12px; flex-shrink: 0; }

/* Sidebar Footer */
.sidebar-footer { padding: 12px 16px; border-top: 1px solid var(--border-light); }
.sidebar-footer-btn {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 10px 12px; border: 1px solid var(--border-light);
  background: transparent; color: var(--text-secondary);
  border-radius: var(--radius-sm); cursor: pointer;
  font-size: 13px; margin-bottom: 10px;
  transition: var(--transition);
}
.sidebar-footer-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-footer-btn svg { width: 18px; height: 18px; }

.user-menu {
  display: flex; align-items: center; gap: 10px;
}
.user-avatar {
  width: 36px; height: 36px;
  background: var(--accent-gradient);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 14px; color: white;
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-info #user-name { display: block; font-size: 13px; font-weight: 500; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role-badge { font-size: 10px; font-weight: 600; text-transform: uppercase; color: var(--accent-purple); letter-spacing: 0.5px; }

.icon-btn {
  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;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.icon-btn svg { width: 20px; height: 20px; }

.icon-btn-label {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border-light); background: transparent;
  color: var(--text-secondary); border-radius: var(--radius-sm);
  padding: 6px 12px; font-size: 12px; cursor: pointer;
  transition: var(--transition);
}
.icon-btn-label:hover { background: var(--bg-hover); color: var(--text-primary); }
.icon-btn-label svg { width: 14px; height: 14px; }

/* ============ MAIN CONTENT ============ */
.main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* Top Bar */
.top-bar {
  height: var(--topbar-height);
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-secondary);
  flex-shrink: 0;
}
.top-bar-title { flex: 1; min-width: 0; }
.top-bar-title h2 { font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-bar-actions { display: flex; gap: 4px; }

.theme-icon-light { display: none; }
.light-theme .theme-icon-dark { display: none; }
.light-theme .theme-icon-light { display: inline; }

/* Content Views */
.content-view { display: none; flex: 1; flex-direction: column; min-height: 0; }
.content-view.active { display: flex; }

/* ============ MESSAGES ============ */
.messages-container {
  flex: 1; overflow-y: auto;
  padding: 0;
}

.welcome-screen {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; padding: 40px 20px; text-align: center;
}
.welcome-logo { margin-bottom: 24px; }
.welcome-logo-svg { width: 80px; height: 80px; animation: welcomePulse 3s ease-in-out infinite; }
@keyframes welcomePulse {
  0%, 100% { opacity: 0.8; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.05); }
}
.welcome-screen h1 { font-size: 36px; font-weight: 700; margin-bottom: 8px; }
.welcome-screen .accent { background: var(--accent-gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.welcome-subtitle { color: var(--text-muted); font-size: 16px; margin-bottom: 40px; }

.quick-actions {
  display: flex; flex-wrap: wrap; gap: 10px;
  justify-content: center; max-width: 600px;
}
.quick-action {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 999px; color: var(--text-secondary);
  font-size: 13px; cursor: pointer;
  transition: var(--transition);
}
.quick-action:hover { border-color: var(--accent-purple); color: var(--text-primary); background: var(--bg-hover); }
.quick-action svg { width: 16px; height: 16px; }

.messages { padding: 20px; }

.message {
  display: flex; gap: 14px;
  margin-bottom: 24px; max-width: 900px;
  margin-left: auto; margin-right: auto;
  animation: messageIn 0.3s ease-out;
}
@keyframes messageIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.message-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 13px; font-weight: 600;
}
.message.user .message-avatar { background: var(--accent-gradient); color: white; }
.message.assistant .message-avatar { background: linear-gradient(135deg, #06b6d4, #7c3aed); color: white; }

.message-content {
  flex: 1; min-width: 0;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  line-height: 1.6; font-size: 14px;
}
.message.user .message-content { background: var(--bg-card); border: 1px solid var(--border-light); }
.message.assistant .message-content { background: transparent; padding-left: 0; }

.message-content p { margin-bottom: 12px; }
.message-content p:last-child { margin-bottom: 0; }
.message-content ul, .message-content ol { margin: 8px 0 8px 20px; }
.message-content li { margin-bottom: 4px; }
.message-content h1, .message-content h2, .message-content h3 { margin: 16px 0 8px; font-weight: 600; }
.message-content h1 { font-size: 20px; }
.message-content h2 { font-size: 17px; }
.message-content h3 { font-size: 15px; }
.message-content strong { font-weight: 600; }
.message-content em { font-style: italic; }
.message-content a { color: var(--accent-cyan); }
.message-content blockquote { border-left: 3px solid var(--accent-purple); padding-left: 12px; margin: 8px 0; color: var(--text-secondary); }
.message-content hr { border: none; border-top: 1px solid var(--border-light); margin: 16px 0; }

/* Tables */
.message-content table {
  width: 100%; border-collapse: collapse; margin: 12px 0;
  font-size: 13px;
}
.message-content th, .message-content td {
  padding: 8px 12px; text-align: left;
  border: 1px solid var(--border-light);
}
.message-content th {
  background: var(--bg-tertiary); font-weight: 600;
}
.message-content tr:nth-child(even) {
  background: rgba(124, 58, 237, 0.03);
}

/* Code blocks */
.message-content pre {
  background: #0d1117; border-radius: var(--radius-sm);
  padding: 16px; margin: 12px 0; overflow-x: auto;
  font-size: 13px; line-height: 1.5;
  border: 1px solid rgba(255,255,255,0.06);
  position: relative;
}
.message-content code {
  font-family: 'JetBrains Mono', monospace;
}
.message-content :not(pre) > code {
  background: var(--bg-tertiary);
  padding: 2px 6px; border-radius: 4px;
  font-size: 0.9em;
}

.code-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 16px; background: #161b22;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  font-size: 12px; color: var(--text-muted);
  border: 1px solid rgba(255,255,255,0.06); border-bottom: none;
}
.code-header + pre { border-radius: 0 0 var(--radius-sm) var(--radius-sm); margin-top: 0; }

.copy-code-btn {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  font-size: 12px; display: flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 4px;
  transition: var(--transition);
}
.copy-code-btn:hover { color: var(--text-primary); background: rgba(255,255,255,0.1); }

.message-actions {
  display: flex; gap: 4px; margin-top: 8px; opacity: 0;
  transition: var(--transition);
}
.message:hover .message-actions { opacity: 1; }
.message-action-btn {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 10px; border: 1px solid var(--border-light);
  background: transparent; color: var(--text-muted); border-radius: 999px;
  font-size: 11px; cursor: pointer; transition: var(--transition);
}
.message-action-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.message-action-btn svg { width: 12px; height: 12px; }

/* File attachment preview */
.message-file {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; background: var(--bg-tertiary);
  border-radius: var(--radius-sm); font-size: 12px;
  color: var(--text-secondary); margin-bottom: 8px;
  border: 1px solid var(--border-light);
}
.message-file svg { width: 14px; height: 14px; color: var(--accent-cyan); }

/* ============ INPUT AREA ============ */
.input-area {
  padding: 12px 20px 16px;
  border-top: 1px solid var(--border-light);
  background: var(--bg-secondary);
}

.file-preview {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-bottom: 8px; max-width: 900px;
  margin-left: auto; margin-right: auto;
}
.file-preview-item {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; background: var(--bg-tertiary);
  border: 1px solid var(--border-light); border-radius: var(--radius-sm);
  font-size: 12px; color: var(--text-secondary);
}
.file-preview-item .remove-file {
  width: 16px; height: 16px; background: none; border: none;
  color: var(--text-muted); cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.file-preview-item .remove-file:hover { color: var(--accent-red); }

.input-container {
  display: flex; align-items: flex-end; gap: 8px;
  max-width: 900px; margin: 0 auto;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  transition: var(--transition);
}
.input-container:focus-within { border-color: var(--accent-purple); box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1); }

#message-input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text-primary); font-size: 14px;
  resize: none; max-height: 200px; min-height: 24px;
  line-height: 1.5; padding: 4px 0;
}
#message-input::placeholder { color: var(--text-muted); }

.send-btn {
  width: 36px; height: 36px;
  background: var(--accent-gradient);
  border: none; border-radius: var(--radius-sm);
  color: white; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition); flex-shrink: 0;
}
.send-btn:hover { opacity: 0.9; transform: scale(1.05); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.send-btn svg { width: 18px; height: 18px; }

.input-footer {
  display: flex; justify-content: space-between; align-items: center;
  max-width: 900px; margin: 6px auto 0;
  font-size: 11px; color: var(--text-muted);
}

.typing-indicator {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--accent-purple);
}
.typing-indicator .dot {
  width: 4px; height: 4px;
  background: var(--accent-purple);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite;
}
.typing-indicator .dot:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator .dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}

/* ============ EMAIL TOOL ============ */
.email-tool { flex: 1; overflow-y: auto; padding: 24px; }
.email-header-bar { margin-bottom: 24px; }
.email-header-bar h2 { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.email-header-bar p { color: var(--text-muted); font-size: 14px; }

.email-workspace {
  display: grid; grid-template-columns: 1fr 1fr; gap: 24px;
  max-width: 1200px;
}

.email-input-section label, .email-output-header label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--text-secondary); margin-bottom: 8px;
}

#email-input, .email-output-content {
  width: 100%; min-height: 250px;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 16px; color: var(--text-primary);
  font-size: 14px; line-height: 1.6;
  resize: vertical;
}
#email-input:focus { outline: none; border-color: var(--accent-purple); }

.email-output-content {
  overflow-y: auto; max-height: 500px;
}
.email-output-content .placeholder-text { color: var(--text-muted); font-style: italic; }

.email-actions {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin: 16px 0;
}
.email-action-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 999px; color: var(--text-secondary);
  font-size: 12px; font-weight: 500;
  cursor: pointer; transition: var(--transition);
}
.email-action-btn:hover { border-color: var(--accent-purple); color: var(--accent-purple); background: rgba(124, 58, 237, 0.08); }
.email-action-btn svg { width: 14px; height: 14px; }

.email-custom {
  display: flex; gap: 8px; margin-top: 12px;
}
.email-custom input {
  flex: 1; padding: 10px 14px;
  background: var(--bg-input); border: 1px solid var(--border-light);
  border-radius: var(--radius-sm); color: var(--text-primary); font-size: 13px;
  outline: none;
}
.email-custom input:focus { border-color: var(--accent-purple); }
.email-custom .btn-primary { padding: 10px 20px; font-size: 13px; }

.email-output-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}
.email-output-actions { display: flex; gap: 6px; }

.email-loading {
  display: flex; align-items: center; gap: 12px;
  padding: 20px; color: var(--text-muted);
}

.spinner {
  width: 24px; height: 24px;
  border: 3px solid var(--border-light);
  border-top-color: var(--accent-purple);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ ADMIN PANEL ============ */
.admin-panel { flex: 1; overflow-y: auto; padding: 24px; }
.admin-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.admin-header h2 { font-size: 24px; font-weight: 700; }

.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px; margin-bottom: 32px;
}
.stat-card {
  display: flex; align-items: center; gap: 16px;
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  transition: var(--transition);
}
.stat-card:hover { border-color: var(--border-color); box-shadow: var(--shadow-sm); }
.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
}
.stat-icon svg { width: 24px; height: 24px; color: white; }
.stat-icon.purple { background: rgba(124, 58, 237, 0.2); }
.stat-icon.purple svg { color: var(--accent-purple); }
.stat-icon.cyan { background: rgba(6, 182, 212, 0.2); }
.stat-icon.cyan svg { color: var(--accent-cyan); }
.stat-icon.green { background: rgba(16, 185, 129, 0.2); }
.stat-icon.green svg { color: var(--accent-green); }
.stat-icon.orange { background: rgba(245, 158, 11, 0.2); }
.stat-icon.orange svg { color: var(--accent-orange); }
.stat-info { display: flex; flex-direction: column; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.admin-section { margin-bottom: 32px; }
.admin-section h3 { font-size: 18px; font-weight: 600; margin-bottom: 16px; }

.table-container { overflow-x: auto; }
.admin-table {
  width: 100%; border-collapse: collapse;
  font-size: 13px;
}
.admin-table th {
  text-align: left; padding: 12px 16px;
  background: var(--bg-tertiary);
  color: var(--text-muted); font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-light);
}
.admin-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-secondary);
}
.admin-table tr:hover td { background: var(--bg-hover); }

.user-status { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.user-status.active { background: rgba(16, 185, 129, 0.15); color: var(--accent-green); }
.user-status.inactive { background: rgba(239, 68, 68, 0.15); color: var(--accent-red); }

.role-badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.role-badge.superadmin { background: rgba(124, 58, 237, 0.15); color: var(--accent-purple); }
.role-badge.admin { background: rgba(6, 182, 212, 0.15); color: var(--accent-cyan); }
.role-badge.user { background: rgba(148, 163, 184, 0.15); color: var(--text-muted); }

.table-actions { display: flex; gap: 4px; }
.table-action-btn {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border-light); background: transparent;
  color: var(--text-muted); border-radius: var(--radius-sm);
  cursor: pointer; transition: var(--transition);
}
.table-action-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.table-action-btn svg { width: 14px; height: 14px; }
.table-action-btn.danger:hover { color: var(--accent-red); border-color: rgba(239,68,68,0.3); }

/* ============ MODALS ============ */
.modal {
  position: fixed; inset: 0; z-index: 999;
  display: flex; align-items: center; justify-content: center;
}
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}
.modal-content {
  position: relative; z-index: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 0; width: 90%; max-width: 500px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s ease-out;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 24px; border-bottom: 1px solid var(--border-light);
}
.modal-header h3 { font-size: 18px; font-weight: 600; }
.modal-close { font-size: 24px; line-height: 1; }
.modal-body { padding: 24px; }
.modal-body .form-group { margin-bottom: 16px; }
.modal-body .form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
.modal-body input, .modal-body select {
  width: 100%; padding: 10px 14px;
  background: var(--bg-input); border: 1px solid var(--border-light);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-size: 14px; outline: none;
}
.modal-body input:focus, .modal-body select:focus { border-color: var(--accent-purple); }
.modal-body select { cursor: pointer; }

.settings-section { margin-bottom: 24px; padding-bottom: 24px; border-bottom: 1px solid var(--border-light); }
.settings-section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.settings-section h4 { font-size: 15px; font-weight: 600; margin-bottom: 16px; }

/* ============ TOAST NOTIFICATIONS ============ */
.toast-container {
  position: fixed; bottom: 20px; right: 20px;
  z-index: 10000; display: flex; flex-direction: column; gap: 8px;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  font-size: 13px; color: var(--text-primary);
  animation: toastIn 0.3s ease-out;
  max-width: 360px;
}
.toast.success { border-left: 3px solid var(--accent-green); }
.toast.error { border-left: 3px solid var(--accent-red); }
.toast.info { border-left: 3px solid var(--accent-cyan); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ============ SIDEBAR OVERLAY (Mobile) ============ */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.5); z-index: 99;
}
.sidebar-overlay.active { display: block; }

.mobile-only { display: none; }

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
  .mobile-only { display: flex; }

  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 100;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }

  .email-workspace { grid-template-columns: 1fr; }

  .quick-actions { gap: 6px; }
  .quick-action { padding: 8px 14px; font-size: 12px; }

  .messages { padding: 12px; }
  .input-area { padding: 8px 12px 12px; }

  .stats-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .login-card { padding: 32px 24px; margin: 16px; }
  .login-logo h1 { font-size: 28px; }
  .welcome-screen h1 { font-size: 24px; }
  .stats-grid { grid-template-columns: 1fr; }
}
