/* Modern Design System Tokens */
:root {
  --bg-primary: #070b14;
  --bg-secondary: #0d1527;
  --card-bg: rgba(15, 23, 42, 0.7);
  --card-border: rgba(255, 255, 255, 0.08);
  --card-hover-border: rgba(99, 102, 241, 0.3);
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --accent-primary: #6366f1;
  --accent-primary-hover: #4f46e5;
  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  
  --glow-indigo: rgba(99, 102, 241, 0.25);
  --glow-emerald: rgba(16, 185, 129, 0.25);
  --glow-amber: rgba(245, 158, 11, 0.25);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Reset & Box Sizing */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Ambient Backdrops */
.ambient-glow {
  position: fixed;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.4;
}

.glow-top-left {
  top: -150px;
  left: -150px;
  background: radial-gradient(circle, #4f46e5 0%, transparent 70%);
}

.glow-bottom-right {
  bottom: -150px;
  right: -150px;
  background: radial-gradient(circle, #06b6d4 0%, transparent 70%);
}

/* Main Layout Container */
.app-layout {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

/* Header Section */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--card-border);
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

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

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #4f46e5, #06b6d4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: 0 4px 16px rgba(79, 70, 229, 0.4);
}

.brand-title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(180deg, #ffffff 30%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

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

.badge-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: #34d399;
  padding: 7px 14px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: var(--transition);
}

.badge-link:hover {
  background: rgba(16, 185, 129, 0.2);
  border-color: rgba(16, 185, 129, 0.5);
  transform: translateY(-1px);
}

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--card-border);
  padding: 7px 14px;
  border-radius: var(--radius-full);
  font-size: 13px;
  color: var(--text-muted);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 10px #10b981;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

/* Pipeline Switcher Tabs */
.pipeline-switcher {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

@media (max-width: 768px) {
  .pipeline-switcher {
    grid-template-columns: 1fr;
  }
}

.pipeline-tab {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  text-align: left;
  transition: var(--transition);
  position: relative;
}

.pipeline-tab:hover {
  background: rgba(30, 41, 59, 0.6);
  border-color: rgba(99, 102, 241, 0.3);
  transform: translateY(-1px);
}

.pipeline-tab.active {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(6, 182, 212, 0.1));
  border-color: rgba(99, 102, 241, 0.5);
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.2);
}

.tab-step {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.pipeline-tab.active .tab-step {
  background: var(--accent-primary);
  color: #ffffff;
  border-color: transparent;
}

.tab-content {
  flex: 1;
}

.tab-title {
  display: block;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: #ffffff;
}

.tab-desc {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.pill-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fbbf24;
}

/* Stats Cards Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: var(--transition);
}

.stat-card:hover {
  border-color: var(--card-hover-border);
  transform: translateY(-2px);
}

.stat-card.highlight-amber {
  border-color: rgba(245, 158, 11, 0.2);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.05), var(--card-bg));
}

.stat-card.highlight-emerald {
  border-color: rgba(16, 185, 129, 0.2);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.05), var(--card-bg));
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-cyan { background: rgba(6, 182, 212, 0.15); color: var(--accent-cyan); }
.icon-amber { background: rgba(245, 158, 11, 0.15); color: var(--accent-amber); }
.icon-emerald { background: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); }
.icon-indigo { background: rgba(99, 102, 241, 0.15); color: var(--accent-primary); }

.stat-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  display: block;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.stat-subtext {
  font-size: 13px;
  font-family: var(--font-mono);
  color: #cbd5e1;
  word-break: break-all;
}

/* Two-Column Grid */
.main-columns {
  display: grid;
  grid-template-columns: 460px 1fr;
  gap: 24px;
}

@media (max-width: 1024px) {
  .main-columns {
    grid-template-columns: 1fr;
  }
}

/* Card Common Styles */
.content-card {
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  transition: var(--transition);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  gap: 12px;
}

.card-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  color: var(--text-main);
}

.card-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* Action Trigger Box */
.trigger-box {
  margin-bottom: 20px;
}

.btn-primary {
  width: 100%;
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #4f46e5 0%, #6366f1 50%, #3b82f6 100%);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  padding: 16px 24px;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 4px 20px var(--glow-indigo);
  transition: var(--transition);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 26px rgba(99, 102, 241, 0.45);
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  filter: grayscale(0.4);
}

.btn-shine {
  position: absolute;
  top: 0;
  left: -100%;
  width: 50%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transform: skewX(-20deg);
  animation: shine 5s infinite;
}

@keyframes shine {
  0% { left: -100%; }
  20% { left: 200%; }
  100% { left: 200%; }
}

/* Progress Container */
.progress-container {
  margin-top: 16px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  transition: var(--transition);
}

.progress-container.hidden {
  display: none;
}

.progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text-muted);
}

.progress-track {
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #06b6d4);
  border-radius: var(--radius-full);
  transition: width 0.3s ease-out;
}

/* Test Email Box */
.test-email-box {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 16px;
}

.box-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.input-action-group {
  display: flex;
  gap: 10px;
}

.input-action-group input {
  flex: 1;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text-main);
  outline: none;
  transition: var(--transition);
}

.input-action-group input:focus {
  border-color: var(--accent-primary);
  background: rgba(30, 41, 59, 1);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.btn-secondary, .btn-outline {
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid var(--card-border);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

.btn-secondary:hover, .btn-outline:hover {
  background: rgba(51, 65, 85, 0.9);
  border-color: var(--accent-primary);
  transform: translateY(-1px);
}

.btn-text {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  transition: var(--transition);
}

.btn-text:hover {
  color: var(--text-muted);
}

/* Dynamic Template Card */
.badge-live-sync {
  background: rgba(6, 182, 212, 0.12);
  border: 1px solid rgba(6, 182, 212, 0.3);
  color: var(--accent-cyan);
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.template-field {
  margin-bottom: 16px;
}

.field-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.field-cell-tag {
  font-size: 11px;
  font-family: var(--font-mono);
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  color: #94a3b8;
}

.preview-subject-box {
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 600;
  color: #ffffff;
}

.preview-body-box {
  background: rgba(30, 41, 59, 0.4);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-size: 13px;
  line-height: 1.6;
  color: #cbd5e1;
  max-height: 240px;
  overflow-y: auto;
  white-space: pre-wrap;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.preview-body-box::-webkit-scrollbar {
  width: 6px;
}
.preview-body-box::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

.template-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 14px;
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.4;
}

.template-note svg {
  flex-shrink: 0;
  margin-top: 2px;
}

/* Attendees Table */
.search-input {
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-main);
  outline: none;
  min-width: 200px;
  transition: var(--transition);
}

.search-input:focus {
  border-color: var(--accent-primary);
}

.table-container {
  overflow-x: auto;
  max-height: 380px;
  overflow-y: auto;
}

.table-container::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.table-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

.attendees-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.attendees-table th {
  position: sticky;
  top: 0;
  background: #0f172a;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--card-border);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  z-index: 2;
}

.attendees-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: #cbd5e1;
}

.attendees-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.table-empty {
  text-align: center;
  padding: 40px !important;
  color: var(--text-dim);
}

/* Status Badges */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
}

.status-pending {
  background: rgba(245, 158, 11, 0.12);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.status-sent {
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-sending {
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

/* Single Send Row Button */
.btn-send-single {
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: #a5b4fc;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.btn-send-single:hover:not(:disabled) {
  background: rgba(99, 102, 241, 0.35);
  color: #ffffff;
}

.btn-send-single:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Live Activity Console */
.console-box {
  background: #040711;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  max-height: 200px;
  overflow-y: auto;
}

.console-box::-webkit-scrollbar {
  width: 6px;
}
.console-box::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

.log-entry {
  margin-bottom: 4px;
  word-break: break-all;
}

.log-entry.system { color: #64748b; }
.log-entry.info { color: #38bdf8; }
.log-entry.success { color: #4ade80; }
.log-entry.warning { color: #facc15; }
.log-entry.error { color: #f87171; }
