/* ═══════════════════════════════════════════════════════════════
   UNIFIED TOOLS — Design Tokens & Shared Styles
   ═══════════════════════════════════════════════════════════════ */

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

:root {
  /* Color Palette */
  --bg-base:      #060b14;
  --bg-surface:   #0d1829;
  --bg-elevated:  #111f35;
  --bg-hover:     #172540;

  --glass-bg:     rgba(13, 24, 41, 0.75);
  --glass-border: rgba(255, 255, 255, 0.07);
  --glass-glow:   rgba(79, 172, 254, 0.08);

  --accent:       #4facfe;
  --accent-2:     #00f2fe;
  --accent-grad:  linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);

  --green:        #22c55e;
  --amber:        #f59e0b;
  --red:          #ef4444;
  --purple:       #a855f7;
  --cyan:         #06b6d4;

  --text-primary: #f0f6ff;
  --text-muted:   #7190b4;
  --text-dim:     #3d5a80;

  /* Fonts */
  --font-sans:  'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:  'JetBrains Mono', 'Fira Code', monospace;

  /* Spacing */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.4);
  --shadow-lg: 0 20px 60px rgba(0,0,0,0.6);
  --shadow-glow: 0 0 24px rgba(79, 172, 254, 0.25);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  overflow: hidden;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Background Mesh ───────────────────────────────────────────── */
.bg-mesh {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 80% 60% at 10% 10%, rgba(79,172,254,0.06) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 90% 80%, rgba(168,85,247,0.05) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 50% 50%, rgba(0,242,254,0.03) 0%, transparent 60%);
  pointer-events: none;
}

/* ── Shared Card ───────────────────────────────────────────────── */
.glass-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--radius-lg);
}

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent-grad);
  color: #fff;
  box-shadow: 0 4px 14px rgba(79,172,254,0.3);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(79,172,254,0.45); }

.btn-secondary {
  background: rgba(255,255,255,0.06);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
}
.btn-secondary:hover { background: rgba(255,255,255,0.1); transform: translateY(-1px); }

.btn-danger {
  background: rgba(239,68,68,0.15);
  color: #fca5a5;
  border: 1px solid rgba(239,68,68,0.3);
}
.btn-danger:hover { background: rgba(239,68,68,0.3); }

.btn-success {
  background: rgba(34,197,94,0.15);
  color: #86efac;
  border: 1px solid rgba(34,197,94,0.3);
}
.btn-success:hover { background: rgba(34,197,94,0.25); }

.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
.btn-lg { padding: 0.8rem 1.8rem; font-size: 1rem; }
.btn-full { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 6px;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text-primary);
  transform: scale(1.1);
}
.btn-icon-danger:hover {
  background: rgba(239,68,68,0.15);
  color: #fca5a5;
}

/* ── Form Controls ─────────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }
.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  transition: all 0.2s;
  outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent);
  background: rgba(79,172,254,0.05);
  box-shadow: 0 0 0 3px rgba(79,172,254,0.12);
}
.form-select option { background: var(--bg-surface); color: var(--text-primary); }
.form-textarea { resize: vertical; min-height: 100px; font-family: var(--font-mono); font-size: 0.85rem; }

/* ── Badge ─────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.badge-green  { background: rgba(34,197,94,0.15); color: #86efac; border: 1px solid rgba(34,197,94,0.3); }
.badge-red    { background: rgba(239,68,68,0.15);  color: #fca5a5; border: 1px solid rgba(239,68,68,0.3); }
.badge-amber  { background: rgba(245,158,11,0.15); color: #fcd34d; border: 1px solid rgba(245,158,11,0.3); }
.badge-blue   { background: rgba(79,172,254,0.15); color: #93c5fd; border: 1px solid rgba(79,172,254,0.3); }
.badge-purple { background: rgba(168,85,247,0.15); color: #d8b4fe; border: 1px solid rgba(168,85,247,0.3); }

/* ── Modal ─────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1rem;
  animation: fadeIn 0.2s ease;
}

.modal-box {
  background: var(--bg-elevated);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: 2rem;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.modal-box.modal-lg { max-width: 640px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.modal-header h3 { font-size: 1.2rem; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 1.5rem; cursor: pointer; line-height: 1; padding: 0.25rem; border-radius: 6px; }
.modal-close:hover { color: var(--text-primary); background: rgba(255,255,255,0.08); }
.modal-footer { display: flex; gap: 0.75rem; justify-content: flex-end; margin-top: 1.5rem; border-top: 1px solid var(--glass-border); padding-top: 1.25rem; }

/* ── Toast ─────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.toast {
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  animation: slideInRight 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  max-width: 320px;
}
.toast-success { background: #14532d; border: 1px solid rgba(34,197,94,0.4); color: #86efac; }
.toast-error   { background: #7f1d1d; border: 1px solid rgba(239,68,68,0.4);   color: #fca5a5; }
.toast-info    { background: #1e3a5f; border: 1px solid rgba(79,172,254,0.4);   color: #93c5fd; }

/* ── Table ─────────────────────────────────────────────────────── */
.table-container { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  padding: 0.6rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  border-bottom: 1px solid var(--glass-border);
}
.data-table td {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 0.875rem;
  color: var(--text-primary);
}
.data-table tr:hover td { background: rgba(255,255,255,0.02); }
.data-table tr:last-child td { border-bottom: none; }

/* ── Toggle Switch ─────────────────────────────────────────────── */
.toggle-switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: rgba(255,255,255,0.1);
  border-radius: 24px;
  transition: 0.3s;
  border: 1px solid rgba(255,255,255,0.15);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 2px; top: 2px;
  background: #fff;
  border-radius: 50%;
  transition: 0.3s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--accent); border-color: var(--accent); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ── Terminal Log ──────────────────────────────────────────────── */
.log-terminal {
  background: #020810;
  border: 1px solid rgba(79,172,254,0.15);
  border-radius: var(--radius-md);
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.75;
  height: 320px;
  overflow-y: auto;
  color: #94c7f7;
}
.log-terminal::-webkit-scrollbar { width: 5px; }
.log-terminal::-webkit-scrollbar-thumb { background: rgba(79,172,254,0.2); border-radius: 8px; }
.log-entry.sent    { color: #4ade80; }
.log-entry.ingested { color: #60a5fa; }
.log-entry.error   { color: #f87171; }
.log-entry.info    { color: #a3a3a3; }

/* ── Divider ───────────────────────────────────────────────────── */
.divider { height: 1px; background: var(--glass-border); margin: 1.5rem 0; }

/* ── Loading Spinner ───────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ── Animations ────────────────────────────────────────────────── */
@keyframes fadeIn       { from { opacity: 0 } to { opacity: 1 } }
@keyframes fadeOut      { from { opacity: 1 } to { opacity: 0 } }
@keyframes slideUp      { from { opacity: 0; transform: translateY(30px) } to { opacity: 1; transform: translateY(0) } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(40px) } to { opacity: 1; transform: translateX(0) } }
@keyframes slideInDown  { from { opacity: 0; transform: translateY(-20px) } to { opacity: 1; transform: translateY(0) } }
@keyframes spin         { to { transform: rotate(360deg) } }
@keyframes pulse        { 0%,100% { opacity: 1 } 50% { opacity: 0.5 } }
