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

:root {
  --purple: #7c3aed;
  --purple-light: #a78bfa;
  --purple-dark: #5b21b6;
  --indigo: #4f46e5;
  --pink: #ec4899;
  --bg: #0a0a0f;
  --surface: rgba(255,255,255,0.04);
  --surface-hover: rgba(255,255,255,0.08);
  --border: rgba(255,255,255,0.1);
  --text: #f1f0ff;
  --text-muted: #8b8ba8;
  --success: #10b981;
  --error: #ef4444;
  --warning: #f59e0b;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 8px 32px rgba(0,0,0,0.4);
  --transition: 0.25s cubic-bezier(0.4,0,0.2,1);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ─── Background Blobs ───────────────────────────────────────────────────────── */
.bg-blob {
  position: fixed;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.18;
  pointer-events: none;
  z-index: 0;
  animation: blobFloat 12s ease-in-out infinite alternate;
}
.blob-1 { width: 500px; height: 500px; background: var(--purple); top: -150px; left: -150px; animation-delay: 0s; }
.blob-2 { width: 400px; height: 400px; background: var(--pink); top: 40%; right: -120px; animation-delay: 3s; }
.blob-3 { width: 350px; height: 350px; background: var(--indigo); bottom: -100px; left: 40%; animation-delay: 6s; }

@keyframes blobFloat {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(30px, 20px) scale(1.08); }
}

/* ─── Header ─────────────────────────────────────────────────────────────────── */
.header {
  position: relative;
  z-index: 10;
  text-align: center;
  padding: 48px 20px 24px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -1px;
}

.logo-icon { font-size: 2rem; }
.accent { color: var(--purple-light); }

.header-sub {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 400;
  letter-spacing: 0.02em;
}

/* ─── Main Container ─────────────────────────────────────────────────────────── */
.main-container {
  position: relative;
  z-index: 10;
  max-width: 860px;
  margin: 0 auto;
  padding: 0 20px 80px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ─── Card ───────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 32px;
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition);
}
.card:hover { box-shadow: 0 12px 48px rgba(124,58,237,0.15); }

.card.hidden { display: none; }

.card-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
}

.step-badge {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--purple), var(--indigo));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(124,58,237,0.4);
}

.card-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 2px;
}

.card-sub {
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ─── Form ───────────────────────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.help-link {
  color: var(--purple-light);
  font-size: 0.75rem;
  text-decoration: none;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}
.help-link:hover { text-decoration: underline; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"] {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  color: var(--text);
  font-size: 0.93rem;
  font-family: inherit;
  transition: border-color var(--transition), background var(--transition);
  outline: none;
}
input:focus {
  border-color: var(--purple);
  background: rgba(124,58,237,0.08);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.18);
}

.password-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}
.password-wrapper input { flex: 1; padding-right: 44px; }
.toggle-pw {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  opacity: 0.6;
  transition: opacity var(--transition);
}
.toggle-pw:hover { opacity: 1; }

.field-hint {
  font-size: 0.73rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.section-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--purple-light);
  margin-bottom: 14px;
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 22px 0;
}

/* ─── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--purple), var(--indigo));
  color: #fff;
  box-shadow: 0 4px 18px rgba(124,58,237,0.4);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(124,58,237,0.55);
}

.btn-secondary {
  background: var(--surface-hover);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) {
  background: rgba(255,255,255,0.1);
  border-color: var(--purple-light);
}

.btn-outline {
  background: transparent;
  color: var(--purple-light);
  border: 1.5px solid var(--purple-light);
  padding: 8px 18px;
  font-size: 0.82rem;
}
.btn-outline:hover { background: rgba(167,139,250,0.1); }

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-icon { font-size: 1rem; }

.actions-row {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  justify-content: flex-end;
}

/* ─── Upload Zones ───────────────────────────────────────────────────────────── */
.upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
@media (max-width: 600px) { .upload-grid { grid-template-columns: 1fr; } }

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: border-color var(--transition), background var(--transition);
  cursor: default;
}
.upload-zone.has-file {
  border-color: var(--success);
  background: rgba(16,185,129,0.05);
}
.upload-zone:hover { border-color: var(--purple-light); background: rgba(124,58,237,0.04); }

.upload-icon { font-size: 2.2rem; }
.upload-title { font-weight: 700; font-size: 1rem; }
.upload-hint { color: var(--text-muted); font-size: 0.8rem; line-height: 1.5; }

.optional-tag {
  font-size: 0.68rem;
  background: rgba(245,158,11,0.15);
  color: var(--warning);
  border: 1px solid rgba(245,158,11,0.3);
  border-radius: 4px;
  padding: 1px 6px;
  vertical-align: middle;
  font-weight: 600;
}

.file-chosen {
  font-size: 0.78rem;
  color: var(--success);
  font-weight: 600;
  min-height: 16px;
  word-break: break-all;
}

/* ─── Table ──────────────────────────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead { background: rgba(124,58,237,0.15); }

th {
  padding: 12px 14px;
  text-align: left;
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--purple-light);
  white-space: nowrap;
}

td {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

tbody tr:hover { background: var(--surface-hover); }

/* Status badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
}
.badge-pending  { background: rgba(139,139,168,0.15); color: var(--text-muted); border: 1px solid rgba(139,139,168,0.25); }
.badge-sending  { background: rgba(79,70,229,0.2);   color: #818cf8; border: 1px solid rgba(79,70,229,0.35); }
.badge-sent     { background: rgba(16,185,129,0.15); color: var(--success); border: 1px solid rgba(16,185,129,0.3); }
.badge-failed   { background: rgba(239,68,68,0.15);  color: var(--error);   border: 1px solid rgba(239,68,68,0.3); }

/* ─── Progress ───────────────────────────────────────────────────────────────── */
.progress-bar-track {
  height: 10px;
  background: rgba(255,255,255,0.07);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 16px;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--purple), var(--pink));
  border-radius: 999px;
  width: 0%;
  transition: width 0.4s ease;
}

.progress-stats {
  display: flex;
  gap: 24px;
  font-size: 0.88rem;
  margin-bottom: 18px;
}
.stat strong { font-weight: 800; }
.stat.sent   { color: var(--success); }
.stat.failed { color: var(--error); }
.stat.total  { color: var(--text-muted); }

/* ─── Log Box ────────────────────────────────────────────────────────────────── */
.log-box {
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  height: 220px;
  overflow-y: auto;
  font-family: 'Consolas', monospace;
  font-size: 0.78rem;
  line-height: 1.6;
  scroll-behavior: smooth;
}

.log-entry {
  padding: 3px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.log-sent   { color: var(--success); }
.log-failed { color: var(--error); }
.log-info   { color: var(--purple-light); }
.log-warn   { color: var(--warning); }

/* ─── Email Preview ───────────────────────────────────────────────────────────── */
.email-preview-box {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.email-meta {
  background: rgba(124,58,237,0.12);
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.email-field { color: var(--text-muted); }
.email-field b { color: var(--text); }

.email-body {
  padding: 20px 24px;
  font-size: 0.88rem;
  line-height: 1.8;
  color: #d4d4e8;
  white-space: pre-line;
  font-family: 'Segoe UI', sans-serif;
}

/* ─── Toast ──────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9999;
  padding: 14px 22px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  color: #fff;
  max-width: 340px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  animation: slideUp 0.35s ease;
}
.toast.hidden { display: none; }
.toast.success { background: linear-gradient(135deg, #059669, #10b981); }
.toast.error   { background: linear-gradient(135deg, #dc2626, #ef4444); }
.toast.info    { background: linear-gradient(135deg, var(--purple-dark), var(--purple)); }

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

/* ─── Footer ─────────────────────────────────────────────────────────────────── */
.footer {
  position: relative;
  z-index: 10;
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
}

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

/* ─── Sending spinner on button ─────────────────────────────────────────────── */
@keyframes spin {
  to { transform: rotate(360deg); }
}
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
