/* ==========================================================
   Email Forensic Platform — Global Stylesheet
   Design tokens: Inter (UI), JetBrains Mono (code/data)
   Dark/light theme via [data-theme="dark"] on <html>
   ========================================================== */

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

:root {
  --bg-base:        #0f1117;
  --bg-surface:     #1a1d27;
  --bg-elevated:    #22263a;
  --bg-card:        #1e2235;
  --border:         #2e3452;
  --border-subtle:  #252944;
  --accent:         #4f8ef7;
  --accent-hover:   #6ba3ff;
  --accent-dim:     rgba(79,142,247,.15);
  --success:        #2dd4aa;
  --success-dim:    rgba(45,212,170,.12);
  --warning:        #f5a623;
  --warning-dim:    rgba(245,166,35,.12);
  --danger:         #f45c5c;
  --danger-dim:     rgba(244,92,92,.12);
  --text-primary:   #e8eaf6;
  --text-secondary: #8b93b8;
  --text-muted:     #525b80;
  --radius-sm:      6px;
  --radius-md:      10px;
  --radius-lg:      16px;
  --shadow-card:    0 4px 24px rgba(0,0,0,.45);
  --shadow-float:   0 8px 40px rgba(0,0,0,.6);
  --font-ui:        'Inter', system-ui, sans-serif;
  --font-mono:      'JetBrains Mono', 'Cascadia Code', monospace;
  --transition:     .18s ease;
}

[data-theme="light"] {
  --bg-base:        #f0f2f8;
  --bg-surface:     #ffffff;
  --bg-elevated:    #f8f9fd;
  --bg-card:        #ffffff;
  --border:         #d4d9ee;
  --border-subtle:  #e5e9f5;
  --accent:         #2d6be4;
  --accent-hover:   #1a56cc;
  --accent-dim:     rgba(45,107,228,.1);
  --success:        #0a9b7d;
  --success-dim:    rgba(10,155,125,.1);
  --warning:        #d4820a;
  --warning-dim:    rgba(212,130,10,.1);
  --danger:         #d63333;
  --danger-dim:     rgba(214,51,51,.1);
  --text-primary:   #1a1d2e;
  --text-secondary: #4a5170;
  --text-muted:     #8890ac;
  --shadow-card:    0 2px 12px rgba(0,0,0,.08);
  --shadow-float:   0 6px 24px rgba(0,0,0,.12);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-ui);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  font-size: 14px;
  transition: background var(--transition), color var(--transition);
}

/* ─── Layout ─────────────────────────────────────────────── */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 58px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 200;
  gap: 16px;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
  color: var(--text-primary);
  text-decoration: none;
  letter-spacing: -.3px;
}

.topbar-brand svg { color: var(--accent); flex-shrink: 0; }

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.main-content {
  flex: 1;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

/* ─── Wizard Progress ─────────────────────────────────────── */
.wizard-progress {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 32px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.wizard-step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  cursor: default;
  user-select: none;
  flex-shrink: 0;
  transition: all var(--transition);
  position: relative;
}

.wizard-step.active {
  background: var(--accent-dim);
  color: var(--accent);
}

.wizard-step.done {
  color: var(--success);
  cursor: pointer;
}

.wizard-step.done:hover { background: var(--success-dim); }

.wizard-step.locked { color: var(--text-muted); }

.step-num {
  width: 24px; height: 24px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  background: var(--bg-elevated);
  border: 1.5px solid currentColor;
  flex-shrink: 0;
}

.wizard-step.done .step-num {
  background: var(--success);
  color: var(--bg-base);
  border-color: var(--success);
}

.wizard-step.active .step-num {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.step-connector {
  height: 1px;
  width: 28px;
  background: var(--border);
  flex-shrink: 0;
}

.step-label { font-size: 12px; font-weight: 500; white-space: nowrap; }

/* ─── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
}

.card + .card { margin-top: 20px; }

.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.card-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 20px;
}

.badge-accent { background: var(--accent-dim); color: var(--accent); }
.badge-success { background: var(--success-dim); color: var(--success); }
.badge-warning { background: var(--warning-dim); color: var(--warning); }
.badge-danger { background: var(--danger-dim); color: var(--danger); }

/* ─── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-md);
  border: none;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
}

.btn:disabled {
  opacity: .4;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }

.btn-success { background: var(--success); color: var(--bg-base); }
.btn-success:hover { filter: brightness(1.1); transform: translateY(-1px); }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text-secondary);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-elevated); color: var(--text-primary); }

.btn-danger-outline {
  background: transparent;
  border: 1.5px solid var(--danger);
  color: var(--danger);
}
.btn-danger-outline:hover { background: var(--danger-dim); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 28px; font-size: 15px; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); }

/* ─── Forms ───────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; }

label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .5px;
}

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], select, textarea {
  background: var(--bg-base);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 14px;
  padding: 10px 14px;
  width: 100%;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

textarea {
  font-family: var(--font-mono);
  font-size: 12px;
  resize: vertical;
  min-height: 160px;
}

/* ─── Drop Zone ───────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg-base);
}

.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.drop-zone-icon { font-size: 36px; margin-bottom: 12px; opacity: .5; }
.drop-zone-title { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.drop-zone-sub { font-size: 13px; color: var(--text-muted); }

/* ─── IP Status Cards ─────────────────────────────────────── */
.ip-delivery-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: center;
  margin: 20px 0;
}

.ip-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
}

.ip-card.origin      { border-left: 3px solid var(--warning); }
.ip-card.destination { border-left: 3px solid var(--success); }

.ip-card-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.ip-card-value {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
  word-break: break-all;
}

.ip-card-sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

.delivery-arrow {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.delivery-arrow svg { color: var(--success); }

.delivery-confirmed {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--success-dim);
  border: 1px solid var(--success);
  color: var(--success);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  margin-top: 8px;
}

/* ─── Hop Table ───────────────────────────────────────────── */
.hop-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-top: 12px;
}

.hop-table th {
  background: var(--bg-elevated);
  padding: 8px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .4px;
  border-bottom: 1px solid var(--border);
}

.hop-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  color: var(--text-primary);
  vertical-align: top;
}

.hop-table tr:last-child td { border-bottom: none; }
.hop-table tr:hover td { background: var(--bg-elevated); }

.hop-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
}

/* ─── Report View ─────────────────────────────────────────── */
.report-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 48px 56px;
  font-size: 14px;
  line-height: 1.7;
}

.report-header {
  text-align: center;
  margin-bottom: 36px;
  padding-bottom: 28px;
  border-bottom: 2px solid var(--border);
}

.report-title {
  font-size: 20px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.report-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  justify-content: center;
  gap: 24px;
  flex-wrap: wrap;
}

.report-section { margin-bottom: 28px; }

.report-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--accent);
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 6px;
  margin-bottom: 14px;
}

.report-field {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 8px 16px;
  margin-bottom: 8px;
  align-items: start;
}

.report-field-label {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 12px;
}

.report-field-value {
  font-family: var(--font-mono);
  font-size: 12px;
  word-break: break-all;
}

.hash-display {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  word-break: break-all;
  color: var(--success);
}

/* ─── Metrics Grid (Admin) ────────────────────────────────── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-card);
}

.metric-value {
  font-size: 30px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 6px;
}

.metric-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
}

.metric-sub {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ─── Data Table ──────────────────────────────────────────── */
.data-table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  background: var(--bg-elevated);
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--bg-elevated); }

.user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  flex-shrink: 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.pill-green { background: var(--success-dim); color: var(--success); }
.pill-red   { background: var(--danger-dim);  color: var(--danger);  }
.pill-blue  { background: var(--accent-dim);  color: var(--accent);  }
.pill-gray  { background: var(--bg-elevated); color: var(--text-muted); }

/* ─── Alerts ──────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 16px;
}

.alert-danger  { background: var(--danger-dim);  border: 1px solid var(--danger);  color: var(--danger);  }
.alert-success { background: var(--success-dim); border: 1px solid var(--success); color: var(--success); }
.alert-warning { background: var(--warning-dim); border: 1px solid var(--warning); color: var(--warning); }
.alert-info    { background: var(--accent-dim);  border: 1px solid var(--accent);  color: var(--accent);  }

/* ─── Login Page ──────────────────────────────────────────── */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-base);
  padding: 24px;
}

.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 44px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-float);
}

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

.login-logo-text { font-size: 18px; font-weight: 700; letter-spacing: -.3px; }

.login-title { font-size: 22px; font-weight: 700; margin-bottom: 6px; text-align: center; }
.login-sub   { font-size: 13px; color: var(--text-muted); text-align: center; margin-bottom: 28px; }

/* ─── Unauth Notice ───────────────────────────────────────── */
.unauth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-base);
  padding: 24px;
}

.unauth-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 48px 44px;
  max-width: 480px;
  text-align: center;
  box-shadow: var(--shadow-float);
}

.unauth-icon  { font-size: 48px; margin-bottom: 18px; opacity: .5; }
.unauth-title { font-size: 20px; font-weight: 700; margin-bottom: 10px; }
.unauth-desc  { font-size: 14px; color: var(--text-secondary); line-height: 1.6; }

/* ─── Miscellaneous ───────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 24px 0; }

.mono         { font-family: var(--font-mono); }
.text-muted   { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-accent  { color: var(--accent); }

.flex            { display: flex; }
.flex-col        { flex-direction: column; }
.items-center    { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8   { gap: 8px;  }
.gap-12  { gap: 12px; }
.gap-16  { gap: 16px; }
.gap-20  { gap: 20px; }
.mt-8    { margin-top: 8px;    }
.mt-12   { margin-top: 12px;   }
.mt-16   { margin-top: 16px;   }
.mt-20   { margin-top: 20px;   }
.mb-8    { margin-bottom: 8px;  }
.mb-12   { margin-bottom: 12px; }
.mb-16   { margin-bottom: 16px; }
.mb-20   { margin-bottom: 20px; }

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border-subtle);
}

.spinner {
  width: 18px; height: 18px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

.step-panel        { display: none; }
.step-panel.active { display: block; }

/* ─── Modal ───────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 500;
  padding: 24px;
}

.modal-backdrop.hidden { display: none; }

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-float);
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 20px;
}

/* ─── Print / PDF Export ──────────────────────────────────── */
@media print {
  .topbar,
  .wizard-progress,
  .action-row,
  .no-print {
    display: none !important;
  }

  body {
    background: #fff !important;
    color: #000 !important;
    font-size: 12pt;
  }

  .report-wrap {
    border: none !important;
    padding: 0 !important;
    box-shadow: none !important;
  }

  .report-title        { color: #000 !important; }
  .report-section-title { color: #1a1d2e !important; }
  .report-field-label,
  .report-field-value  { color: #000 !important; }
  .hash-display {
    background: #f0f0f0 !important;
    color: #000 !important;
    border: 1px solid #ccc !important;
  }

  .hop-table th { background: #e0e0e0 !important; color: #000 !important; }
  .hop-table td { color: #000 !important; }
  .ip-card {
    background: #f5f5f5 !important;
    border: 1px solid #ccc !important;
  }
  .ip-card-value, .ip-card-label, .ip-card-sub { color: #000 !important; }

  a { text-decoration: none !important; color: #000 !important; }

  @page { margin: 1.5cm 2cm; }
}

@media (max-width: 768px) {
  .main-content { padding: 20px 16px 48px; }
  .topbar       { padding: 0 16px; }
  .login-card   { padding: 28px 20px; }
  .report-wrap  { padding: 24px 20px; }
  .ip-delivery-grid { grid-template-columns: 1fr; }
  .delivery-arrow   { flex-direction: row; }
  .report-field     { grid-template-columns: 1fr; }
  .metrics-grid     { grid-template-columns: 1fr 1fr; }
}
