/* BrightGuard - Design System */
/* Inspired by Proton: clean, trustworthy, modern */

:root {
  --bg: #F4F3FF;
  --bg2: #FFFFFF;
  --bg3: #F0EFF8;
  --surface: #FFFFFF;
  --surface2: #F7F6FE;
  --border: #E4E2F4;
  --border2: #D4D1EE;
  --text: #1C1B2E;
  --text2: #6B6892;
  --text3: #9B98BC;
  --purple: #6D28D9;
  --purple2: #7C3AED;
  --purple-light: #EDE9FE;
  --purple-mid: #8B5CF6;
  --danger: #DC2626;
  --danger-light: #FEE2E2;
  --warn: #D97706;
  --warn-light: #FEF3C7;
  --success: #059669;
  --success-light: #D1FAE5;
  --font: 'DM Sans', sans-serif;
  --mono: 'DM Mono', monospace;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(109,40,217,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(109,40,217,0.12), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 20px 60px rgba(109,40,217,0.15), 0 4px 16px rgba(0,0,0,0.08);
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ===== LOGIN ===== */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #EDE9FE 0%, #F4F3FF 50%, #E0E7FF 100%);
}

.login-bg { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }

.login-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.4;
}
.login-orb-1 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, #8B5CF6, #6D28D9);
  top: -100px; right: -100px;
}
.login-orb-2 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, #A78BFA, #7C3AED);
  bottom: -80px; left: -80px;
}

.login-card {
  position: relative;
  background: white;
  border-radius: 16px;
  padding: 40px;
  width: 380px;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(109,40,217,0.08);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}

.logo-mark {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
}

.logo-name {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.3px;
}

.login-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.4px;
  margin-bottom: 4px;
}

.login-sub {
  color: var(--text2);
  font-size: 13px;
  margin-bottom: 28px;
}

.field { margin-bottom: 16px; }
.field-row { display: flex; gap: 12px; }

.field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text2);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.field input, .field select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg2);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus, .field select:focus {
  border-color: var(--purple-mid);
  box-shadow: 0 0 0 3px rgba(139,92,246,0.12);
}

.login-error {
  background: var(--danger-light);
  color: var(--danger);
  font-size: 13px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}

.btn-login {
  width: 100%;
  background: linear-gradient(135deg, var(--purple2), var(--purple));
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  padding: 12px;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  margin-top: 4px;
  box-shadow: 0 4px 12px rgba(109,40,217,0.3);
}
.btn-login:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-login:active { transform: translateY(0); }

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

/* ===== SIDEBAR ===== */
.sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-top { padding: 20px 16px 16px; border-bottom: 1px solid var(--border); }

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand-mark { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; }
.brand-name { font-size: 16px; font-weight: 600; letter-spacing: -0.3px; }

.nav { padding: 12px 8px; }

.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
  margin-bottom: 2px;
}
.nav-btn:hover { background: var(--surface2); color: var(--text); }
.nav-btn.active {
  background: var(--purple-light);
  color: var(--purple);
}
.nav-btn.active svg { stroke: var(--purple); }

.sidebar-accounts {
  padding: 8px 8px;
  border-top: 1px solid var(--border);
  flex: 1;
  overflow-y: auto;
}

.sidebar-section-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text3);
  padding: 8px 12px 6px;
}

.account-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}
.account-chip:hover { background: var(--surface2); }

.account-chip-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--purple-mid);
  flex-shrink: 0;
}
.account-chip-dot.gmail { background: #EA4335; }
.account-chip-dot.custom { background: var(--purple-mid); }

.account-chip-info { overflow: hidden; }
.account-chip-name { font-size: 12.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-chip-email { font-size: 11px; color: var(--text3); font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-bottom { padding: 12px 8px; border-top: 1px solid var(--border); }

.logout-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text3);
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.logout-btn:hover { background: var(--danger-light); color: var(--danger); }

/* ===== CONTENT ===== */
.content {
  flex: 1;
  overflow-y: auto;
  background: var(--bg);
}

.view { padding: 32px; }
.view.hidden { display: none !important; }
.view.active { display: block; }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.4px;
}

.page-sub { font-size: 13px; color: var(--text2); margin-top: 2px; }

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

/* ===== CARD ===== */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

.card-header h2 { font-size: 15px; font-weight: 600; }

/* ===== STATS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: var(--shadow);
}
.stat-card:hover { border-color: var(--purple-mid); box-shadow: var(--shadow-md); transform: translateY(-1px); }

.stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text3); margin-bottom: 10px; }
.stat-value { font-size: 36px; font-weight: 600; color: var(--purple); letter-spacing: -1px; line-height: 1; }
.stat-detail { font-size: 12px; color: var(--text2); margin-top: 6px; }
.stat-email { font-size: 11px; color: var(--text3); font-family: var(--mono); }

/* ===== BUTTONS ===== */
.btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  background: linear-gradient(135deg, var(--purple2), var(--purple));
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 600;
  padding: 9px 18px;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  box-shadow: 0 2px 8px rgba(109,40,217,0.25);
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }

.btn-secondary {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg2);
  color: var(--text);
  border: 1.5px solid var(--border2);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 500;
  padding: 9px 18px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-secondary:hover { border-color: var(--purple-mid); color: var(--purple); }

.btn-sm {
  display: inline-flex; align-items: center; gap: 5px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 12.5px;
  font-weight: 500;
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.15s;
  border: 1.5px solid transparent;
}

.btn-ghost {
  background: var(--surface2);
  color: var(--text2);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--purple-light); color: var(--purple); border-color: var(--purple-mid); }

.btn-ghost-danger {
  background: var(--danger-light);
  color: var(--danger);
  border-color: transparent;
}
.btn-ghost-danger:hover { background: var(--danger); color: white; }

.btn-ghost-warn {
  background: var(--warn-light);
  color: var(--warn);
  border-color: transparent;
}
.btn-ghost-warn:hover { background: var(--warn); color: white; }

.btn-page {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text2);
  transition: all 0.15s;
}
.btn-page:hover:not(:disabled) { border-color: var(--purple-mid); color: var(--purple); }
.btn-page:disabled { opacity: 0.35; cursor: not-allowed; }

/* ===== SELECT ===== */
.select {
  padding: 9px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13.5px;
  color: var(--text);
  background: var(--bg2);
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s;
}
.select:focus { border-color: var(--purple-mid); }

/* ===== TOOLBAR ===== */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  margin-bottom: 0;
  flex-wrap: wrap;
}

.check-all {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text2); cursor: pointer;
}
.check-all input { accent-color: var(--purple); width: 15px; height: 15px; }

.toolbar-pills { display: flex; gap: 4px; }

.pill {
  padding: 4px 10px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  background: none;
  font-family: var(--font);
  font-size: 12px;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
}
.pill:hover { border-color: var(--purple-mid); color: var(--purple); background: var(--purple-light); }

.toolbar-right { display: flex; gap: 6px; align-items: center; margin-left: auto; }

.sel-count { font-size: 12px; color: var(--purple); font-weight: 500; font-family: var(--mono); }

/* ===== EMAIL LIST ===== */
.email-list {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
}

.email-row {
  display: grid;
  grid-template-columns: 36px 1fr 130px 72px;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
  position: relative;
}
.email-row:last-child { border-bottom: none; }
.email-row:hover { background: var(--surface2); }
.email-row.selected { background: var(--purple-light); }
.email-row.unread .email-subject { font-weight: 600; }

.email-check input { accent-color: var(--purple); width: 15px; height: 15px; cursor: pointer; }

.email-info { overflow: hidden; }
.email-from { font-size: 12px; color: var(--text2); font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 2px; }
.email-subject { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.email-preview { font-size: 12px; color: var(--text3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }

.email-date { font-size: 11.5px; color: var(--text3); text-align: right; font-family: var(--mono); }

/* ===== AI BADGES ===== */
.ai-pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  white-space: nowrap;
}
.ai-pill.spam { background: #FEE2E2; color: #DC2626; }
.ai-pill.phishing { background: #FFE4E6; color: #BE123C; }
.ai-pill.newsletter { background: #FEF3C7; color: #D97706; }
.ai-pill.promotional { background: #FFEDD5; color: #EA580C; }
.ai-pill.suspicious { background: #FEF9C3; color: #CA8A04; }
.ai-pill.legitimate { background: #D1FAE5; color: #059669; }
.ai-pill.unknown { background: var(--bg3); color: var(--text3); }

.score-bar { width: 56px; height: 4px; background: var(--border); border-radius: 4px; overflow: hidden; margin-top: 3px; }
.score-fill { height: 100%; border-radius: 4px; }

/* ===== PAGINATION ===== */
.pagination {
  display: flex; align-items: center; gap: 12px;
  justify-content: center;
  padding: 16px 0;
}
#page-info { font-size: 12.5px; color: var(--text2); font-family: var(--mono); }

/* ===== SCANNER ===== */
.scanner-accounts { display: flex; flex-wrap: wrap; gap: 8px; padding: 16px 20px; }

.scanner-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--bg2);
}
.scanner-chip:hover { border-color: var(--purple-mid); }
.scanner-chip input { accent-color: var(--purple); }
.scanner-chip span { font-size: 13px; font-weight: 500; }

.scan-running {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px 12px;
}

.scan-pulse {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--purple);
  animation: pulse 1.2s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

#scan-status-text { font-size: 13px; font-weight: 500; color: var(--purple); }

.scan-log {
  padding: 0 20px 16px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text2);
  max-height: 140px;
  overflow-y: auto;
  line-height: 2;
}

/* ===== ACCOUNTS GRID ===== */
.accounts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

.account-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: all 0.15s;
}
.account-card:hover { border-color: var(--purple-mid); box-shadow: var(--shadow-md); }

.account-card-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 12px; }
.account-card-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--purple-light);
  display: flex; align-items: center; justify-content: center;
  color: var(--purple);
}
.account-card-name { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.account-card-email { font-size: 12px; color: var(--text2); font-family: var(--mono); }
.account-card-type { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--purple); background: var(--purple-light); padding: 2px 8px; border-radius: 20px; }

.account-card-actions { display: flex; gap: 6px; margin-top: 14px; }

.account-delete-btn {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text3);
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.15s;
}
.account-delete-btn:hover { background: var(--danger-light); color: var(--danger); border-color: transparent; }

/* ===== MODAL ===== */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal.hidden { display: none !important; }

.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(28, 27, 46, 0.5);
  backdrop-filter: blur(4px);
}

.modal-panel {
  position: relative;
  width: 92%;
  max-width: 660px;
  max-height: 88vh;
  background: var(--bg2);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalIn 0.2s ease;
}

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

.modal-head {
  display: flex; align-items: flex-start; gap: 16px;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-head-info { flex: 1; overflow: hidden; }
.modal-head h2 { font-size: 16px; font-weight: 600; line-height: 1.3; }

.modal-meta { display: flex; gap: 16px; margin-top: 4px; font-size: 12px; color: var(--text2); font-family: var(--mono); }

.modal-close {
  background: none; border: none; color: var(--text3);
  cursor: pointer; padding: 2px; border-radius: 6px;
  transition: all 0.15s; flex-shrink: 0;
}
.modal-close:hover { background: var(--surface2); color: var(--text); }

.modal-ai-row { padding: 10px 24px; display: flex; align-items: center; gap: 8px; }

.modal-advice {
  margin: 0 24px 8px;
  background: var(--purple-light);
  border-left: 3px solid var(--purple);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text);
}

.modal-body {
  flex: 1; overflow-y: auto;
  padding: 14px 24px;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--text2);
  white-space: pre-wrap;
  word-break: break-word;
}

.modal-foot {
  display: flex; gap: 8px;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

/* ===== HINT ===== */
.hint {
  display: flex; align-items: flex-start; gap: 8px;
  background: var(--purple-light);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 12.5px;
  color: var(--purple);
  margin-top: 4px;
}

/* ===== TOAST ===== */
.toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 200; display: flex; flex-direction: column; gap: 8px;
}

.toast {
  background: var(--text);
  color: white;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  min-width: 220px;
  max-width: 320px;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.2s ease;
}
.toast.error { background: var(--danger); }
.toast.warn { background: var(--warn); }
.toast.success { background: var(--success); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ===== MISC ===== */
.hidden { display: none !important; }

.empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--text3);
  font-size: 13.5px;
}

.loading-state {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 48px; color: var(--text3); font-size: 13px;
}

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

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }
