/* ============================================
   GMAIL CLEANER DASHBOARD — style.css
   Aesthetic: Dark terminal ops / mission control
   ============================================ */

:root {
  --bg:        #060609;
  --bg2:       #0b0b12;
  --bg3:       #0f0f18;
  --border:    #15151f;
  --border2:   #1e1e2e;
  --text:      #c8cce8;
  --text-dim:  #555575;
  --text-faint:#2a2a40;
  --accent:    #00e5b0;
  --accent2:   #0088ff;
  --danger:    #ff4458;
  --warn:      #ffaa00;
  --mono:      'Space Mono', monospace;
  --display:   'Syne', sans-serif;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  overflow-x: hidden;
}

/* ── Scanlines ── */
.scanlines {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: repeating-linear-gradient(
    to bottom,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.08) 2px,
    rgba(0,0,0,0.08) 4px
  );
}

/* ── Corner decorations ── */
.corner {
  position: fixed;
  width: 20px;
  height: 20px;
  z-index: 500;
  opacity: 0.4;
}
.corner-tl { top: 12px; left: 12px; border-top: 1px solid var(--accent); border-left: 1px solid var(--accent); }
.corner-tr { top: 12px; right: 12px; border-top: 1px solid var(--accent); border-right: 1px solid var(--accent); }
.corner-bl { bottom: 12px; left: 12px; border-bottom: 1px solid var(--accent); border-left: 1px solid var(--accent); }
.corner-br { bottom: 12px; right: 12px; border-bottom: 1px solid var(--accent); border-right: 1px solid var(--accent); }

/* ── Header ── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.logo-mark {
  width: 36px; height: 36px;
  background: var(--accent);
  color: #000;
  font-family: var(--display);
  font-size: 13px;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px;
  letter-spacing: -1px;
  box-shadow: 0 0 20px rgba(0,229,176,0.3);
}

.title-main {
  font-family: var(--display);
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  letter-spacing: 1px;
  display: block;
}
.title-sub {
  font-size: 9px;
  color: var(--accent);
  letter-spacing: 2px;
  display: block;
  margin-top: 1px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: all 0.3s;
}
.status-dot.connected { background: var(--accent); box-shadow: 0 0 8px var(--accent); animation: pulse 2s infinite; }
.status-dot.error { background: var(--danger); box-shadow: 0 0 8px var(--danger); }
.status-dot.warn { background: var(--warn); box-shadow: 0 0 8px var(--warn); }

.status-label {
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 1.5px;
}

/* ── ACCOUNT SWITCHER ── */
.header-divider {
  width: 1px; height: 24px;
  background: var(--border);
  margin: 0 8px;
}

.account-switcher {
  position: relative;
}

.account-trigger {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 5px;
  cursor: pointer;
  transition: all .15s;
  user-select: none;
}
.account-trigger:hover { border-color: var(--accent); background: var(--bg4); }

.account-avatar {
  width: 28px; height: 28px; border-radius: 7px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #060609; line-height: 1;
}
.account-avatar-sm { width: 20px; height: 20px; border-radius: 5px; font-size: 11px; }
/* Fixed palette (inline styles are blocked by the CSP, so colors are classes) */
.av-0 { background: #00e5b0; }
.av-1 { background: #0088ff; }
.av-2 { background: #ffaa00; }
.av-3 { background: #c084fc; }
.av-4 { background: #ff6b9d; }
.av-5 { background: #fb923c; }
.av-6 { background: #38bdf8; }
.av-7 { background: #a3e635; }
.av-none { background: var(--border2); color: var(--text-dim); }
.account-active-label {
  font-size: 11px; color: var(--text);
  letter-spacing: .5px; max-width: 140px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.account-chevron { font-size: 10px; color: var(--text-dim); transition: transform .2s; }
.account-switcher.open .account-chevron { transform: rotate(180deg); }

.account-menu {
  display: none;
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 290px;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
  z-index: 200;
  overflow: hidden;
}
.account-switcher.open .account-menu { display: block; }

.account-menu-header {
  font-size: 9px; color: var(--text-faint);
  letter-spacing: 2px; padding: 10px 14px 8px;
  border-bottom: 1px solid var(--border);
}
.account-menu-list { padding: 6px; }
.account-menu-loading { font-size: 11px; color: var(--text-dim); padding: 10px 8px; }

.account-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 5px;
  cursor: pointer; transition: background .12s;
}
.account-item:hover { background: rgba(255,255,255,.04); }
.account-item.active { background: rgba(0,229,176,.07); }

.account-item .account-avatar { opacity: .7; transition: opacity .15s; }
.account-item:hover .account-avatar { opacity: 1; }
.account-item.active .account-avatar {
  opacity: 1;
  box-shadow: 0 0 0 2px var(--bg2), 0 0 0 3px var(--accent);
}
.account-item-info { flex: 1; min-width: 0; }
.account-item-label {
  font-size: 12px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.account-item.active .account-item-label { color: var(--accent); }
.account-item-id {
  font-size: 10px; color: var(--text-dim); margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.account-item.stale .account-item-id { color: var(--warn); }
.account-item-badge {
  font-size: 9px; padding: 2px 6px;
  background: rgba(0,229,176,.1); color: var(--accent);
  border: 1px solid rgba(0,229,176,.2); border-radius: 3px;
  letter-spacing: 1px;
}
.account-item-badge.warn {
  background: rgba(255,170,0,.1); color: var(--warn);
  border-color: rgba(255,170,0,.25); text-decoration: none;
}
.account-item-badge.warn:hover { background: rgba(255,170,0,.2); }
.account-switching {
  font-size: 10px; color: var(--text-dim);
  padding: 8px 10px; text-align: center;
  border-top: 1px solid var(--border);
}

.time-display {
  font-size: 11px;
  color: var(--text-dim);
  border-left: 1px solid var(--border2);
  padding-left: 10px;
  font-variant-numeric: tabular-nums;
}

/* ── Main grid ── */
.main-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 16px;
  padding: 20px 24px;
  min-height: calc(100vh - 60px);
  max-width: 1400px;
  margin: 0 auto;
}

.left-col, .right-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Stats row ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  position: relative;
  overflow: hidden;
  animation: slideUp 0.4s ease both;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.3;
}

.stat-value {
  font-family: var(--display);
  font-size: 26px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 6px;
  transition: all 0.3s;
}

.stat-label {
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 1.5px;
  margin-bottom: 10px;
}

.stat-bar {
  height: 2px;
  background: var(--border2);
  border-radius: 1px;
  overflow: hidden;
}
.stat-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 1px;
  width: 0%;
  transition: width 1s ease;
  box-shadow: 0 0 6px var(--accent);
}

/* ── Panels ── */
.panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  animation: slideUp 0.4s ease both;
}

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

.panel-title {
  font-size: 10px;
  color: var(--accent);
  letter-spacing: 2px;
  font-weight: 700;
}

.panel-hint {
  font-size: 10px;
  color: var(--text-faint);
  letter-spacing: 1px;
}

.panel-action {
  background: transparent;
  border: 1px solid var(--border2);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 10px;
  padding: 4px 10px;
  border-radius: 3px;
  cursor: pointer;
  letter-spacing: 1px;
  transition: all 0.15s;
}
.panel-action:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Controls ── */
.controls-grid {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.control-group {}

.ctrl-label {
  display: block;
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 2px;
  margin-bottom: 8px;
}

.checkbox-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cb-item {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 11px;
  color: var(--text);
  padding: 5px 10px;
  border: 1px solid var(--border2);
  border-radius: 4px;
  transition: all 0.12s;
  user-select: none;
}
.cb-item:hover { border-color: var(--accent); }
.cb-item input[type="checkbox"] {
  appearance: none;
  width: 12px; height: 12px;
  border: 1px solid var(--border2);
  border-radius: 2px;
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.12s;
}
.cb-item input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.cb-item input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  top: 1px; left: 3px;
  width: 4px; height: 7px;
  border: 2px solid #000;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

.range-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

input[type="range"] {
  flex: 1;
  appearance: none;
  height: 2px;
  background: var(--border2);
  border-radius: 1px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(0,229,176,0.5);
}

.range-val {
  font-family: var(--display);
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  min-width: 36px;
  text-align: right;
}

/* ── Action row ── */
.action-row {
  display: flex;
  gap: 10px;
  padding: 0 16px 16px;
}

.btn {
  flex: 1;
  padding: 10px 16px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1.5px;
  cursor: pointer;
  font-weight: 700;
  transition: all 0.15s;
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  box-shadow: 0 0 20px rgba(0,229,176,0.2);
}
.btn-primary:hover {
  background: #00ffca;
  box-shadow: 0 0 30px rgba(0,229,176,0.4);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled {
  background: var(--border2);
  color: var(--text-dim);
  border-color: transparent;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border2);
}
.btn-ghost:hover { border-color: var(--text-dim); }

/* ── Preview result ── */
.preview-result {
  margin: 0 16px 16px;
  padding: 0;
  max-height: 0;
  overflow: hidden;
  transition: all 0.3s ease;
}
.preview-result.visible {
  padding: 12px;
  max-height: 420px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 4px;
}

.preview-line {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  font-size: 11px;
  border-bottom: 1px solid var(--border);
}
.preview-line:last-child { border-bottom: none; }
.preview-line .pl-label { color: var(--text-dim); }
.preview-line .pl-val { color: var(--accent); font-weight: 700; }
.preview-total {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border2);
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
}
.preview-total .pt-label { color: var(--text); }
.preview-total .pt-val { color: var(--accent); }

/* ── History list ── */
.history-list {
  max-height: 280px;
  overflow-y: auto;
}

.history-empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--text-faint);
  font-size: 11px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.history-item:last-child { border-bottom: none; }
.history-item:hover { background: rgba(255,255,255,0.02); }

.hi-icon { font-size: 14px; flex-shrink: 0; }
.hi-info { flex: 1; min-width: 0; }
.hi-date { font-size: 10px; color: var(--text-dim); margin-bottom: 2px; }
.hi-stats { font-size: 11px; color: var(--text); }
.hi-trigger {
  font-size: 9px;
  color: var(--text-faint);
  background: var(--bg3);
  padding: 2px 6px;
  border-radius: 2px;
  letter-spacing: 1px;
  flex-shrink: 0;
}

/* ── Last run detail ── */
.last-run-detail { padding: 16px; }

.detail-empty {
  text-align: center;
  padding: 28px 0;
  color: var(--text-faint);
  font-size: 11px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
}
.detail-row:last-child { border-bottom: none; }
.dr-label { color: var(--text-dim); }
.dr-val { color: var(--text); font-weight: 700; }
.dr-val.green { color: var(--accent); }
.dr-val.red { color: var(--danger); }

.detail-categories {
  margin-top: 14px;
}
.dc-title {
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 2px;
  margin-bottom: 8px;
}
.dc-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  font-size: 11px;
  border-bottom: 1px solid var(--border);
}
.dc-item:last-child { border-bottom: none; }
.dc-cat { color: var(--text-dim); }
.dc-count { color: var(--accent); }

/* ── Log ── */
.log-panel { flex: 1; display: flex; flex-direction: column; }
.log-body {
  flex: 1;
  padding: 8px 0;
  overflow-y: auto;
  max-height: 260px;
  min-height: 120px;
}

.log-entry {
  display: flex;
  gap: 10px;
  padding: 4px 16px;
  font-size: 10px;
  line-height: 1.5;
  animation: fadeIn 0.2s ease;
}
.log-time { color: var(--text-faint); flex-shrink: 0; font-variant-numeric: tabular-nums; }
.log-msg { color: var(--text-dim); }
.log-msg.info { color: var(--text); }
.log-msg.success { color: var(--accent); }
.log-msg.error { color: var(--danger); }
.log-msg.warn { color: var(--warn); }

/* ── Schedule ── */
.schedule-list { padding: 4px 0; }

.schedule-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.schedule-item:last-child { border-bottom: none; }

.sched-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.sched-active { background: var(--accent); box-shadow: 0 0 6px var(--accent); animation: pulse 2s infinite; }

.sched-info { flex: 1; }
.sched-name { font-size: 11px; color: var(--text); margin-bottom: 2px; }
.sched-time { font-size: 10px; color: var(--text-dim); }
.sched-next { font-size: 10px; color: var(--text-faint); text-align: right; white-space: nowrap; }

/* ── Run overlay ── */
.run-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6,6,9,0.92);
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  backdrop-filter: blur(4px);
}
.run-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

.run-modal {
  text-align: center;
  padding: 40px;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 10px;
  min-width: 300px;
  box-shadow: 0 0 60px rgba(0,229,176,0.08);
}

.run-spinner {
  width: 44px; height: 44px;
  border: 2px solid var(--border2);
  border-top: 2px solid var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 20px;
  box-shadow: 0 0 20px rgba(0,229,176,0.2);
}

.run-title {
  font-family: var(--display);
  font-size: 18px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 2px;
  margin-bottom: 8px;
}

.run-sub {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 24px;
  letter-spacing: 1px;
}

.run-progress {
  height: 2px;
  background: var(--border2);
  border-radius: 1px;
  overflow: hidden;
}
.run-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 1px;
  width: 35%;
  box-shadow: 0 0 8px var(--accent);
  /* Indeterminate: the backend reports no progress, so don't fake it */
  animation: run-indeterminate 1.4s ease-in-out infinite;
}
@keyframes run-indeterminate {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(300%); }
}

/* ── Scrollbars ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

/* ── Animations ── */
@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Stagger delays for panels */
[data-delay="0"] { animation-delay: 0ms; }
[data-delay="1"] { animation-delay: 60ms; }
[data-delay="2"] { animation-delay: 120ms; }
[data-delay="3"] { animation-delay: 180ms; }
[data-delay="4"] { animation-delay: 240ms; }
[data-delay="5"] { animation-delay: 300ms; }
[data-delay="6"] { animation-delay: 360ms; }

/* ── Responsive ── */
@media (max-width: 1100px) {
  .main-grid { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .stats-row { grid-template-columns: 1fr 1fr; }
  .main-grid { padding: 12px; }
}

.preview-note {
  font-size: 10px; color: var(--text-dim);
  line-height: 1.5; padding: 10px 2px 2px;
}

.sched-accounts {
  font-size: 10px; color: var(--text-dim);
  padding: 10px 16px 12px; border-top: 1px solid var(--border);
  line-height: 1.5;
}
.sched-accounts:empty { display: none; }
.sched-next.paused { color: var(--warn); }
.hi-untracked {
  font-size: 9px; color: var(--text-dim);
  border: 1px solid var(--border2); border-radius: 3px;
  padding: 1px 5px; margin-left: 6px; letter-spacing: 1px;
}
