/* ============================================================
   InstaFlow — Supabase Design System (Dark)
   Tokens + components modelled on supabase.com/design-system
   ============================================================ */

:root {
  /* ---- Backgrounds ---- */
  --background-default: #121212;
  --background-200: #1c1c1c;
  --background-alternative: #1c1c1c;
  --surface-100: #1c1c1c;
  --surface-200: #212121;
  --surface-300: #262626;
  --overlay: #212121;
  --control: #212121;
  --button: #262626;
  --dash-sidebar: #171717;

  /* ---- Borders ---- */
  --border-default: #2e2e2e;
  --border-secondary: #262626;
  --border-overlay: #2e2e2e;
  --border-control: #2e2e2e;
  --border-strong: #424242;
  --border-stronger: #595959;

  /* ---- Foreground ---- */
  --foreground-default: #ededed;
  --foreground-light: #cfcfcf;
  --foreground-lighter: #a1a1a1;
  --foreground-muted: #8b8b8b;
  --foreground-on-brand: #07140a;

  /* ---- Brand (Supabase #3FCF8E) ---- */
  --brand: #3fcf8e;
  --brand-200: #2f9e68;
  --brand-400: #3fcf8e;
  --brand-500: #3fcf8e;
  --brand-600: #16b674;
  --brand-hover: #16b674;

  /* ---- Status ---- */
  --destructive: #e5484d;
  --destructive-hover: #d94449;
  --warning: #f5a623;
  --info: #5ab9ff;
  --violet: #9f7bf7;
  --orange: #ff8b4c;

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
}

/* ============================================================
   Base
   ============================================================ */

html {
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Manrope', 'Inter', ui-sans-serif, system-ui, sans-serif;
}

body {
  background-color: var(--background-default) !important;
  color: var(--foreground-default) !important;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
  -webkit-font-smoothing: antialiased;
}

::selection {
  background-color: rgba(62, 207, 142, 0.28);
  color: var(--foreground-default);
}

/* Global scrollbar */
*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 99px;
}
*::-webkit-scrollbar-thumb:hover {
  background: var(--border-stronger);
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ============================================================
   Sidebar (Supabase studio style)
   ============================================================ */

.sidebar {
  background-color: var(--dash-sidebar) !important;
  border-right: 1px solid var(--border-default) !important;
}

.sidebar a.btn {
  border-radius: var(--radius-sm) !important;
  padding: 0.5rem 0.75rem !important;
  color: var(--foreground-lighter) !important;
  gap: 0.75rem !important;
  font-size: 0.8125rem !important;
  font-weight: 500 !important;
  transition: background-color 0.15s ease, color 0.15s ease !important;
  border-left: 2px solid transparent !important;
}

.sidebar a.btn:hover {
  background-color: var(--control) !important;
  color: var(--foreground-default) !important;
}

.sidebar a.btn.bg-accent {
  background-color: var(--surface-300) !important;
  color: var(--foreground-default) !important;
  border-left: 2px solid var(--brand) !important;
}

.sidebar a.btn.bg-accent i {
  color: var(--brand) !important;
}

/* ============================================================
   Header
   ============================================================ */

header {
  background-color: rgba(18, 18, 18, 0.85) !important;
  border-bottom: 1px solid var(--border-default) !important;
  backdrop-filter: blur(12px);
}

/* ============================================================
   Cards / Panels
   ============================================================ */

.card {
  background-color: var(--surface-100) !important;
  border: 1px solid var(--border-overlay) !important;
  border-radius: var(--radius-md) !important;
  padding: 1.25rem !important;
  transition: border-color 0.15s ease !important;
}

.card[data-size='sm'] {
  padding: 1rem !important;
}

/* ============================================================
   Buttons (Supabase)
   ============================================================ */

.btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 0.5rem !important;
  border-radius: 999px !important;
  font-size: 0.8125rem !important;
  font-weight: 500 !important;
  line-height: 1 !important;
  height: 2.25rem !important;
  padding: 0 1rem !important;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease !important;
}

.btn svg,
.btn i {
  flex-shrink: 0 !important;
}

.btn:disabled {
  opacity: 0.5 !important;
  pointer-events: none !important;
}

/* Primary */
.btn[data-variant='default'], .btn:not([data-variant]) {
  background-color: var(--brand) !important;
  color: var(--foreground-on-brand) !important;
  border: 1px solid var(--brand) !important;
}

.btn[data-variant='default']:hover, .btn:not([data-variant]):hover {
  background-color: var(--brand-hover) !important;
  border-color: var(--brand-hover) !important;
}

.btn[data-variant='default']:disabled, .btn:not([data-variant]):disabled {
  background-color: var(--brand-200) !important;
  border-color: var(--brand-200) !important;
}

/* Outline */
.btn[data-variant='outline'] {
  background-color: transparent !important;
  border: 1px solid var(--border-strong) !important;
  color: var(--foreground-light) !important;
}

.btn[data-variant='outline']:hover {
  background-color: var(--control) !important;
  border-color: var(--border-stronger) !important;
  color: var(--foreground-default) !important;
}

/* Ghost */
.btn[data-variant='ghost'] {
  background-color: transparent !important;
  border: 1px solid transparent !important;
  color: var(--foreground-lighter) !important;
}

.btn[data-variant='ghost']:hover {
  background-color: var(--control) !important;
  color: var(--foreground-default) !important;
}

/* Sizes */
.btn[data-size='sm'] {
  height: 2rem !important;
  padding: 0 0.75rem !important;
  font-size: 0.75rem !important;
}

.btn[data-size='xs'] {
  height: 1.625rem !important;
  padding: 0 0.5rem !important;
  font-size: 0.6875rem !important;
}

.btn[data-size='icon'] {
  width: 2.25rem !important;
  height: 2.25rem !important;
  padding: 0 !important;
}

/* ============================================================
   Badges (Supabase pills)
   ============================================================ */

.badge {
  display: inline-flex !important;
  align-items: center !important;
  gap: 0.25rem !important;
  border-radius: 4px !important;
  border: 1px solid var(--border-strong) !important;
  background-color: var(--surface-200) !important;
  color: var(--foreground-light) !important;
  font-family: 'Manrope', 'Inter', sans-serif !important;
  font-size: 0.6875rem !important;
  font-weight: 600 !important;
  line-height: 1 !important;
  padding: 0.25rem 0.5rem !important;
  white-space: nowrap;
}

.badge--sky     { background-color: rgba(90, 185, 255, 0.12) !important; color: var(--info) !important; border-color: rgba(90, 185, 255, 0.25) !important; }
.badge--amber   { background-color: rgba(245, 166, 35, 0.12) !important; color: var(--warning) !important; border-color: rgba(245, 166, 35, 0.25) !important; }
.badge--violet  { background-color: rgba(159, 123, 247, 0.12) !important; color: var(--violet) !important; border-color: rgba(159, 123, 247, 0.25) !important; }
.badge--orange  { background-color: rgba(255, 139, 76, 0.12) !important; color: var(--orange) !important; border-color: rgba(255, 139, 76, 0.25) !important; }
.badge--emerald { background-color: rgba(62, 207, 142, 0.12) !important; color: var(--brand) !important; border-color: rgba(62, 207, 142, 0.25) !important; }
.badge--red     { background-color: rgba(229, 72, 77, 0.12) !important; color: var(--destructive) !important; border-color: rgba(229, 72, 77, 0.25) !important; }
.badge--fuchsia { background-color: rgba(217, 70, 239, 0.12) !important; color: #e879f9 !important; border-color: rgba(217, 70, 239, 0.25) !important; }
.badge--gray    { background-color: rgba(139, 139, 139, 0.12) !important; color: var(--foreground-muted) !important; border-color: rgba(139, 139, 139, 0.25) !important; }

/* ============================================================
   Forms (Supabase inputs)
   ============================================================ */

input, textarea, select {
  background-color: var(--control) !important;
  border: 1px solid var(--border-control) !important;
  color: var(--foreground-default) !important;
  border-radius: var(--radius-sm) !important;
  padding: 0.5rem 0.75rem !important;
  font-size: 0.8125rem !important;
  width: 100% !important;
  transition: border-color 0.15s ease, box-shadow 0.15s ease !important;
}

input::placeholder, textarea::placeholder {
  color: var(--foreground-muted) !important;
}

input:hover, textarea:hover, select:hover {
  border-color: var(--border-strong) !important;
}

input:focus, textarea:focus, select:focus {
  border: 2px solid var(--brand) !important;
  box-shadow: none !important;
  outline: none !important;
}

select {
  appearance: none !important;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%238b8b8b' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e") !important;
  background-position: right 0.75rem center !important;
  background-repeat: no-repeat !important;
  background-size: 1.1rem 1.1rem !important;
  padding-right: 2.5rem !important;
}

.input-group {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  border: none !important;
  background: transparent !important;
}

.input-group input,
.input-group select,
.input-group textarea {
  padding-left: 2.5rem !important;
}

.input-group span[data-align='start'] {
  position: absolute;
  left: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--foreground-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 10;
}

.input-group button[data-align='end'] {
  position: absolute;
  right: 0.375rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
}

.field {
  margin-bottom: 0.25rem;
}

.label {
  display: block;
  font-size: 0.8125rem !important;
  font-weight: 500 !important;
  color: var(--foreground-light) !important;
  margin-bottom: 0.375rem !important;
}

.textarea {
  min-height: 7rem;
  resize: vertical !important;
}

/* ============================================================
   Timeline (activity log)
   ============================================================ */

.timeline {
  position: relative;
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
}

.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 2rem 1fr;
  column-gap: 1rem;
  padding-bottom: 1.25rem;
}

.timeline-item:not(:last-child) .timeline-line {
  position: absolute;
  left: calc(1rem - 1px);
  top: 1.75rem;
  bottom: 0;
  width: 2px;
  background: var(--border-secondary);
}

.timeline-dot {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background-color: var(--surface-200);
  z-index: 1;
}

.timeline-dot--sky     { background-color: rgba(90, 185, 255, 0.12); border-color: rgba(90, 185, 255, 0.3); color: var(--info); }
.timeline-dot--amber   { background-color: rgba(245, 166, 35, 0.12); border-color: rgba(245, 166, 35, 0.3); color: var(--warning); }
.timeline-dot--violet  { background-color: rgba(159, 123, 247, 0.12); border-color: rgba(159, 123, 247, 0.3); color: var(--violet); }
.timeline-dot--orange  { background-color: rgba(255, 139, 76, 0.12); border-color: rgba(255, 139, 76, 0.3); color: var(--orange); }
.timeline-dot--emerald { background-color: rgba(62, 207, 142, 0.12); border-color: rgba(62, 207, 142, 0.3); color: var(--brand); }
.timeline-dot--red     { background-color: rgba(229, 72, 77, 0.12); border-color: rgba(229, 72, 77, 0.3); color: var(--destructive); }
.timeline-dot--gray    { background-color: rgba(139, 139, 139, 0.12); border-color: rgba(139, 139, 139, 0.3); color: var(--foreground-muted); }

.timeline-content {
  min-width: 0;
}

/* ============================================================
   Code block / pre
   ============================================================ */

.code-block {
  background-color: var(--background-200) !important;
  border: 1px solid var(--border-overlay) !important;
  border-radius: var(--radius-sm) !important;
  padding: 0.75rem 1rem !important;
  font-size: 0.75rem !important;
  font-family: 'Source Code Pro', ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--foreground-lighter) !important;
  overflow-x: auto;
}

/* ============================================================
   Animations
   ============================================================ */

@keyframes pulse-active {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.6; }
}
.active-pulse-dot {
  animation: pulse-active 2s infinite ease-in-out;
}

/* ============================================================
   Live pipeline console
   ============================================================ */

.console-scroll {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.console-scroll::-webkit-scrollbar {
  width: 6px;
}
.console-scroll::-webkit-scrollbar-track {
  background: transparent;
}
.console-scroll::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
