/* ═══════════════════════════════════════════════════════ */
/* Subhan's Team CRM — Design System v2 (Light Theme)    */
/* ═══════════════════════════════════════════════════════ */

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

/* ─── CSS Variables ──────────────────────────────────── */
:root {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-input: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --accent-blue: #4f46e5;
  --accent-blue-hover: #4338ca;
  --accent-blue-light: rgba(79, 70, 229, 0.08);
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-purple: #8b5cf6;
  --accent-cyan: #06b6d4;
  --border-color: #e2e8f0;
  --border-color-strong: #cbd5e1;
  --glass-bg: rgba(255, 255, 255, 0.85);
  --glass-border: #e2e8f0;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.08), 0 8px 10px -6px rgba(0,0,0,0.04);
  --shadow-glow: 0 0 0 3px rgba(79, 70, 229, 0.12);
  --shadow-glow-strong: 0 0 0 4px rgba(79, 70, 229, 0.18);
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 400ms ease;
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 72px;
  --topbar-height: 64px;
  --status-not-contacted: #64748b;
  --status-contacted: #3b82f6;
  --status-replied: #8b5cf6;
  --status-interested: #f59e0b;
  --status-converted: #10b981;
  --status-dead: #ef4444;
}

/* ─── Reset ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  font-family: var(--font-family);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: var(--accent-blue); text-decoration: none; }
a:hover { color: var(--accent-blue-hover); }
img { max-width: 100%; display: block; }
ul, ol { list-style: none; }
input, select, textarea, button { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
hr { border: none; border-top: 1px solid var(--border-color); margin: 1.5rem 0; }

/* ─── Selection ──────────────────────────────────────── */
::selection { background: rgba(79, 70, 229, 0.15); color: var(--text-primary); }

/* ─── Scrollbar ──────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ─── Typography ─────────────────────────────────────── */
h1 { font-size: 1.75rem; font-weight: 700; line-height: 1.2; }
h2 { font-size: 1.5rem; font-weight: 700; line-height: 1.3; }
h3 { font-size: 1.25rem; font-weight: 600; line-height: 1.4; }
h4 { font-size: 1.1rem; font-weight: 600; line-height: 1.4; }
h5 { font-size: 1rem; font-weight: 600; }
h6 { font-size: 0.875rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
p { color: var(--text-secondary); }
small, .text-sm { font-size: 0.8125rem; }
.text-xs { font-size: 0.75rem; }
.text-lg { font-size: 1.125rem; }
.text-muted { color: var(--text-muted) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-center { text-align: center; }

/* ─── Utility Classes ────────────────────────────────── */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-sm { gap: 0.5rem; }
.gap-md { gap: 1rem; }
.gap-lg { gap: 1.5rem; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }

/* ─── App Layout (FIXED SIDEBAR BUG) ────────────────── */
.app-container {
  display: block;
  min-height: 100vh;
}
.main-content {
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow: hidden;
  transition: margin-left var(--transition-normal);
}
.main-content.sidebar-collapsed {
  margin-left: var(--sidebar-collapsed-width);
}
.view-container {
  flex: 1;
  padding: 1.5rem 2rem;
  overflow-y: auto;
  animation: fadeIn 0.3s ease;
  transition: opacity var(--transition-fast);
}

/* ─── Sidebar ────────────────────────────────────────── */
.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: width var(--transition-normal), transform var(--transition-normal);
  overflow: hidden;
  box-shadow: 1px 0 4px rgba(0,0,0,0.03);
}
.sidebar.collapsed { width: var(--sidebar-collapsed-width); }
.sidebar.collapsed .sidebar-logo-text,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-badge,
.sidebar.collapsed .nav-group-label,
.sidebar.collapsed .user-info-text { display: none; }
.sidebar.collapsed .sidebar-header { justify-content: center; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 0.75rem; }
.sidebar.collapsed .nav-icon { margin-right: 0; }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1rem;
  border-bottom: 1px solid var(--border-color);
}
.sidebar-logo { display: flex; align-items: center; gap: 0.75rem; }
.sidebar-logo-icon { font-size: 1.5rem; }
.sidebar-logo-text { font-size: 1rem; font-weight: 800; white-space: nowrap; background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.sidebar-toggle { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); color: var(--text-muted); transition: all var(--transition-fast); }
.sidebar-toggle:hover { background: var(--accent-blue-light); color: var(--accent-blue); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 0.75rem 0; }
.nav-group { margin-bottom: 0.5rem; }
.nav-group-label { padding: 0.5rem 1.25rem 0.25rem; font-size: 0.6875rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); }
.nav-item {
  display: flex; align-items: center; padding: 0.6rem 1.25rem; margin: 1px 0.5rem;
  border-radius: var(--radius-md); color: var(--text-secondary);
  transition: all var(--transition-fast); position: relative;
}
.nav-item:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.nav-item.active { background: var(--accent-blue-light); color: var(--accent-blue); font-weight: 600; }
.nav-item.active::before { content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%); width: 3px; height: 60%; background: var(--accent-blue); border-radius: 0 3px 3px 0; }
.nav-icon { font-size: 1.1rem; margin-right: 0.75rem; flex-shrink: 0; width: 24px; text-align: center; }
.nav-label { white-space: nowrap; font-size: 0.875rem; }
.nav-badge { margin-left: auto; background: var(--accent-blue); color: #fff; font-size: 0.6875rem; font-weight: 600; padding: 2px 7px; border-radius: 10px; min-width: 20px; text-align: center; }

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-color);
  display: flex; align-items: center; justify-content: space-between;
}
.user-info { display: flex; align-items: center; gap: 0.75rem; flex: 1; min-width: 0; }
.user-info-text { min-width: 0; }
.user-display-name { font-size: 0.8125rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role-label { font-size: 0.6875rem; color: var(--text-muted); }
.btn-logout { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); color: var(--text-muted); transition: all var(--transition-fast); }
.btn-logout:hover { background: rgba(244, 63, 94, 0.08); color: var(--accent-rose); }

/* ─── Top Bar ────────────────────────────────────────── */
.top-bar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  height: var(--topbar-height); padding: 0 2rem;
  background: rgba(255, 255, 255, 0.85); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
}
.top-bar-left { display: flex; align-items: center; gap: 1rem; }
.page-title { font-size: 1.25rem; font-weight: 700; }
.top-bar-right { display: flex; align-items: center; gap: 1rem; }

/* Sync Status */
.sync-status { display: inline-flex; align-items: center; gap: 0.375rem; font-size: 0.75rem; color: var(--text-muted); padding: 4px 10px; border-radius: 20px; background: var(--bg-tertiary); }
.sync-dot { width: 7px; height: 7px; border-radius: 50%; }
.sync-status.synced .sync-dot { background: var(--accent-emerald); box-shadow: 0 0 6px var(--accent-emerald); }
.sync-status.syncing .sync-dot { background: var(--accent-amber); animation: pulse 1.5s infinite; }
.sync-status.offline .sync-dot { background: var(--text-muted); }

/* Search */
.search-bar { position: relative; }
.search-input {
  width: 240px; padding: 0.5rem 0.75rem 0.5rem 2.25rem;
  background: var(--bg-tertiary); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); color: var(--text-primary);
  font-size: 0.8125rem; transition: all var(--transition-fast);
}
.search-input:focus { outline: none; border-color: var(--accent-blue); box-shadow: var(--shadow-glow); width: 300px; background: var(--bg-secondary); }
.search-input::placeholder { color: var(--text-muted); }
.search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.search-results-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--bg-secondary); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
  display: none; max-height: 300px; overflow-y: auto; z-index: 200;
}
.search-results-dropdown.active { display: block; animation: fadeIn 0.15s ease; }
.search-result-item { padding: 0.625rem 1rem; cursor: pointer; transition: background var(--transition-fast); border-bottom: 1px solid var(--border-color); }
.search-result-item:hover { background: var(--accent-blue-light); }
.search-result-item:last-child { border-bottom: none; }
.search-result-name { font-size: 0.875rem; font-weight: 500; }
.search-result-detail { font-size: 0.75rem; color: var(--text-muted); }
.search-result-more { padding: 0.5rem 1rem; font-size: 0.75rem; color: var(--accent-blue); text-align: center; }
.search-empty { padding: 1rem; text-align: center; color: var(--text-muted); font-size: 0.8125rem; }

/* Notifications */
.notifications-bell { position: relative; }
.btn-icon-round {
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; color: var(--text-secondary); transition: all var(--transition-fast);
  background: var(--bg-tertiary);
}
.btn-icon-round:hover { background: var(--accent-blue-light); color: var(--accent-blue); }
.notification-dot {
  position: absolute; top: -2px; right: -2px;
  min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--accent-rose); color: #fff;
  font-size: 0.625rem; font-weight: 700;
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
}
.notif-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 320px; background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-xl);
  display: none; z-index: 200; overflow: hidden;
}
.notif-dropdown.active { display: block; animation: fadeIn 0.15s ease; }
.notif-header { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border-color); }
.notif-header h4 { font-size: 0.875rem; }
.notif-list { max-height: 300px; overflow-y: auto; }
.notif-item { display: flex; gap: 0.75rem; padding: 0.75rem 1rem; cursor: pointer; transition: background var(--transition-fast); border-bottom: 1px solid var(--border-color); }
.notif-item:hover { background: var(--accent-blue-light); }
.notif-icon { font-size: 1.25rem; flex-shrink: 0; }
.notif-message { font-size: 0.8125rem; }
.notif-time { font-size: 0.6875rem; color: var(--text-muted); }
.notif-empty { padding: 2rem; text-align: center; color: var(--text-muted); font-size: 0.8125rem; }

/* ─── Page Header ────────────────────────────────────── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; flex-wrap: wrap; gap: 0.75rem; }

/* ─── Loading ────────────────────────────────────────── */
.loading-screen { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 50vh; gap: 1rem; color: var(--text-muted); }

/* ─── Settings Page ──────────────────────────────────── */
.settings-sections { display: flex; flex-direction: column; gap: 1.5rem; max-width: 800px; }
.settings-card .card-header { display: flex; align-items: center; justify-content: space-between; padding-bottom: 0.75rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border-color); }
.settings-card .card-body { padding: 0; }
.settings-card h3 { font-size: 1rem; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.settings-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }

/* ─── Users Page ─────────────────────────────────────── */
.users-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1.5rem; }
.user-card { text-align: center; padding: 1.5rem; transition: all var(--transition-normal); }
.user-card.current-user { border-color: var(--accent-blue); box-shadow: var(--shadow-glow); }
.user-card-header { display: flex; flex-direction: column; align-items: center; gap: 0.75rem; margin-bottom: 1rem; }
.user-card-body { margin-bottom: 1rem; }
.user-card-name { font-size: 1.1rem; margin-bottom: 0.25rem; }
.user-card-username { font-size: 0.8125rem; color: var(--text-muted); }
.user-card-role { margin-top: 0.75rem; }
.user-card-email { font-size: 0.8125rem; color: var(--text-secondary); margin-top: 0.5rem; }
.user-card-footer { display: flex; gap: 0.5rem; justify-content: center; padding-top: 0.75rem; border-top: 1px solid var(--border-color); }

/* ─── Animations ─────────────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes shimmer { 0% { background-position: -200px 0; } 100% { background-position: 200px 0; } }
@keyframes spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }
@keyframes countUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(100%); } to { opacity: 1; transform: translateX(0); } }
@keyframes slideOutRight { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(100%); } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-20px); } }

/* ─── Responsive ─────────────────────────────────────── */
@media (max-width: 1024px) {
  .main-content { margin-left: 0; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-xl); }
  .view-container { padding: 1rem; }
  .search-input { width: 180px; }
  .search-input:focus { width: 220px; }
}
@media (max-width: 768px) {
  .top-bar { padding: 0 1rem; }
  .view-container { padding: 0.75rem; }
  .top-bar-right .search-bar { display: none; }
  .page-header h2 { font-size: 1.25rem; }
  .users-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .view-container { padding: 0.5rem; }
  .page-header { margin-bottom: 1rem; }
  .page-header h2 { font-size: 1.125rem; }
  .card { padding: 1rem; border-radius: var(--radius-md); }
  .card-header h4 { font-size: 0.875rem; }
  .modal-container { max-width: 100%; border-radius: var(--radius-lg); }
  .modal-header { padding: 1rem; }
  .modal-body { padding: 1rem; }
  .modal-footer { padding: 0.75rem 1rem; }
  .btn { padding: 0.5rem 0.75rem; font-size: 0.8125rem; }
  .top-bar { height: 52px; }
  h2 { font-size: 1.25rem; }
}

/* ─── Command Palette (Ctrl+K) ─── */
.command-palette {
  background: var(--bg-secondary);
  border-radius: var(--radius-xl);
  overflow: hidden;
}
.palette-search-wrapper {
  display: flex;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  gap: 0.75rem;
}
.palette-search-icon {
  font-size: 1.25rem;
  color: var(--text-muted);
}
#palette-search-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 1rem;
  outline: none;
}
#palette-search-input::placeholder {
  color: var(--text-muted);
}
.palette-esc-badge {
  font-size: 0.6875rem;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  font-weight: 600;
}
.palette-results {
  max-height: 320px;
  overflow-y: auto;
  padding: 0.5rem;
}
.palette-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.palette-item:hover, .palette-item.selected {
  background: var(--accent-blue-light);
}
.palette-item.selected .palette-enter-indicator {
  opacity: 1;
}
.palette-item-icon {
  font-size: 1.125rem;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  border-radius: 6px;
  flex-shrink: 0;
}
.palette-item-details {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.palette-item-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
}
.palette-item-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.125rem;
}
.palette-enter-indicator {
  font-size: 0.75rem;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity var(--transition-fast);
  font-weight: 600;
}
.palette-empty {
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ─── Floating Onboarding Checklist ─── */
.onboarding-widget {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 320px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.3s ease;
}
.onboarding-widget.collapsed {
  height: 48px;
  width: 240px;
  overflow: hidden;
}
.onboarding-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1rem;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  user-select: none;
}
.onboarding-header h4 {
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0;
}
.onboarding-header-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.onboarding-toggle-btn, .onboarding-dismiss-btn {
  font-size: 0.875rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
}
.onboarding-toggle-btn:hover, .onboarding-dismiss-btn:hover {
  color: var(--text-primary);
}
.onboarding-body {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.onboarding-progress-container {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}
.onboarding-progress-text {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.onboarding-steps {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.onboarding-step-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.8125rem;
  cursor: pointer;
  color: var(--text-secondary);
  transition: color var(--transition-fast);
}
.onboarding-step-item:hover {
  color: var(--text-primary);
}
.onboarding-step-item.completed {
  color: var(--text-muted);
  text-decoration: line-through;
}
.onboarding-step-checkbox {
  margin-top: 2px;
  cursor: pointer;
}
.onboarding-step-label {
  flex: 1;
  line-height: 1.4;
}

