/* Self-hosted fonts - Must be first */
@import './fonts.css';

@tailwind base;
@tailwind components;
@tailwind utilities;

/* ============================================
   SEQUENSY BRAND SYSTEM
   Brand Identity: "Orchestrated Simplicity"
   ============================================ */

/* Remove WordPress admin default margins/padding for full-width layout */
#sequensy-admin-root {
  margin-left: -20px;
  margin-right: -10px;
  margin-top: -10px;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* Remove default WordPress admin page margins */
#wpbody-content > #sequensy-admin-root {
  padding: 0;
}

@layer base {
  :root {
    /* ========================================
       SEQUENSY COLOR SYSTEM
       ======================================== */

    /* Sequensy Slate - Primary Neutrals (80% of UI) */
    --seq-slate-950: #0f1419;
    --seq-slate-900: #1a2332;
    --seq-slate-800: #2d3a4d;
    --seq-slate-700: #445368;
    --seq-slate-600: #5c6b82;
    --seq-slate-500: #778899;
    --seq-slate-400: #94a3b8;
    --seq-slate-300: #b4c0d0;
    --seq-slate-200: #d1dae6;
    --seq-slate-100: #e8edf4;
    --seq-slate-50: #f4f7fa;

    /* Sequensy Cyan - Accent/Action Color (5% of UI) */
    --seq-cyan-700: #0e7490;
    --seq-cyan-600: #0891b2;
    --seq-cyan-500: #06b6d4;
    --seq-cyan-400: #22d3ee;
    --seq-cyan-300: #67e8f9;
    --seq-cyan-100: #cffafe;
    --seq-cyan-50: #ecfeff;

    /* shadcn/ui Base Tokens (using Sequensy colors) */
    --background: 0 0% 100%;
    --foreground: 210 33% 8%;
    --card: 0 0% 100%;
    --card-foreground: 210 33% 8%;
    --popover: 0 0% 100%;
    --popover-foreground: 210 33% 8%;
    --primary: 210 33% 15%;
    --primary-foreground: 210 20% 98%;
    --secondary: 210 20% 96%;
    --secondary-foreground: 210 33% 15%;
    --muted: 210 20% 96%;
    --muted-foreground: 215 16% 47%;
    --accent: 187 85% 37%;
    --accent-foreground: 0 0% 100%;
    --destructive: 0 72% 51%;
    --destructive-foreground: 210 20% 98%;
    --border: 214 32% 91%;
    --input: 214 32% 91%;
    --ring: 187 85% 37%;
    --radius: 0.5rem;

    /* ========================================
       WORKFLOW NODE TYPES (15% of UI)
       ======================================== */

    /* Triggers - Warm Amber (initiates action) */
    --seq-trigger: #d97706;
    --seq-trigger-muted: #fef3c7;
    --seq-trigger-text: #92400e;
    --seq-trigger-glow: rgba(217, 119, 6, 0.15);

    /* Actions - Ocean Blue (executes tasks) */
    --seq-action: #0284c7;
    --seq-action-muted: #e0f2fe;
    --seq-action-text: #075985;
    --seq-action-glow: rgba(2, 132, 199, 0.15);

    /* Operators - Deep Violet (logic/branching) */
    --seq-operator: #7c3aed;
    --seq-operator-muted: #ede9fe;
    --seq-operator-text: #5b21b6;
    --seq-operator-glow: rgba(124, 58, 237, 0.15);

    /* Connections - Neutral Gray (data flow) */
    --seq-connection: #64748b;
    --seq-connection-active: #0891b2;

    /* ========================================
       STATUS COLORS (Semantic)
       ======================================== */

    /* Success - Verdant Green */
    --seq-success: #059669;
    --seq-success-muted: #d1fae5;
    --seq-success-text: #065f46;

    /* Warning - Warm Amber */
    --seq-warning: #d97706;
    --seq-warning-muted: #fef3c7;
    --seq-warning-text: #92400e;

    /* Error - Warm Red */
    --seq-error: #dc2626;
    --seq-error-muted: #fee2e2;
    --seq-error-text: #991b1b;

    /* Info - Brand Cyan */
    --seq-info: #0891b2;
    --seq-info-muted: #cffafe;
    --seq-info-text: #155e75;

    /* Legacy compatibility aliases */
    --color-success: var(--seq-success);
    --color-warning: var(--seq-warning);
    --color-error: var(--seq-error);
    --color-info: var(--seq-info);
    --bg-success-subtle: var(--seq-success-muted);
    --bg-warning-subtle: var(--seq-warning-muted);
    --bg-error-subtle: var(--seq-error-muted);
    --bg-info-subtle: var(--seq-info-muted);

    /* ========================================
       TYPOGRAPHY
       ======================================== */

    --font-display: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    --font-body: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    /* Type Scale */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;
    --text-4xl: 2.25rem;

    /* Line Heights */
    --leading-tight: 1.25;
    --leading-snug: 1.375;
    --leading-normal: 1.5;
    --leading-relaxed: 1.625;

    /* Letter Spacing */
    --tracking-tight: -0.025em;
    --tracking-normal: 0;
    --tracking-wide: 0.025em;
    --tracking-wider: 0.05em;

    /* ========================================
       SPACING SYSTEM (4px base)
       ======================================== */

    --space-0: 0;
    --space-px: 1px;
    --space-0-5: 0.125rem;
    --space-1: 0.25rem;
    --space-1-5: 0.375rem;
    --space-2: 0.5rem;
    --space-2-5: 0.625rem;
    --space-3: 0.75rem;
    --space-3-5: 0.875rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-7: 1.75rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;
    --space-20: 5rem;
    --space-24: 6rem;

    /* Semantic Spacing */
    --spacing-component-xs: var(--space-2);
    --spacing-component-sm: var(--space-3);
    --spacing-component-md: var(--space-4);
    --spacing-component-lg: var(--space-6);
    --spacing-section: var(--space-8);
    --spacing-group: var(--space-6);
    --spacing-item: var(--space-4);
    --spacing-inline: var(--space-2);

    /* Legacy compatibility */
    --spacing-card: 1.5rem;
    --spacing-compact: 1rem;
    --spacing-tight: 0.75rem;

    /* Workflow Builder Spacing */
    --spacing-node-gap: 120px;
    --spacing-node-padding: var(--space-4);

    /* ========================================
       SHADOW & ELEVATION
       ======================================== */

    --shadow-xs: 0 1px 2px 0 rgb(15 20 25 / 0.05);
    --shadow-sm: 0 1px 3px 0 rgb(15 20 25 / 0.1), 0 1px 2px -1px rgb(15 20 25 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(15 20 25 / 0.1), 0 2px 4px -2px rgb(15 20 25 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(15 20 25 / 0.1), 0 4px 6px -4px rgb(15 20 25 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(15 20 25 / 0.1), 0 8px 10px -6px rgb(15 20 25 / 0.1);

    /* Interactive Shadows */
    --shadow-focus: 0 0 0 3px rgb(8 145 178 / 0.25);
    --shadow-error: 0 0 0 3px rgb(220 38 38 / 0.25);

    /* Glow Effects for Workflow Nodes */
    --glow-trigger: 0 0 20px rgb(217 119 6 / 0.3);
    --glow-action: 0 0 20px rgb(2 132 199 / 0.3);
    --glow-operator: 0 0 20px rgb(124 58 237 / 0.3);
    --glow-cyan: 0 0 20px rgb(8 145 178 / 0.3);

    /* Legacy workflow builder shadows */
    --wf-shadow-xs: var(--shadow-xs);
    --wf-shadow-sm: var(--shadow-sm);
    --wf-shadow-md: var(--shadow-md);
    --wf-shadow-lg: var(--shadow-lg);

    /* Legacy workflow neutral aliases */
    --wf-neutral-50: var(--seq-slate-50);
    --wf-neutral-100: var(--seq-slate-100);
    --wf-neutral-200: var(--seq-slate-200);
    --wf-neutral-300: var(--seq-slate-300);
    --wf-neutral-400: var(--seq-slate-400);
    --wf-neutral-500: var(--seq-slate-500);
    --wf-neutral-600: var(--seq-slate-600);
    --wf-neutral-700: var(--seq-slate-700);
    --wf-neutral-800: var(--seq-slate-800);
    --wf-neutral-900: var(--seq-slate-900);

    /* Legacy workflow type aliases */
    --wf-trigger: var(--seq-trigger);
    --wf-trigger-muted: var(--seq-trigger-muted);
    --wf-trigger-glow: var(--seq-trigger-glow);
    --wf-action: var(--seq-action);
    --wf-action-muted: var(--seq-action-muted);
    --wf-action-glow: var(--seq-action-glow);
    --wf-operator: var(--seq-operator);
    --wf-operator-muted: var(--seq-operator-muted);
    --wf-operator-glow: var(--seq-operator-glow);

    /* ========================================
       ANIMATION SYSTEM
       ======================================== */

    /* Duration Scale */
    --duration-instant: 50ms;
    --duration-fast: 150ms;
    --duration-normal: 200ms;
    --duration-slow: 300ms;
    --duration-slower: 500ms;

    /* Easing Functions */
    --ease-default: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-in: cubic-bezier(0.4, 0, 1, 1);
    --ease-out: cubic-bezier(0, 0, 0.2, 1);
    --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);

    /* ========================================
       BORDER RADIUS
       ======================================== */

    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;
    --radius-full: 9999px;

    /* ========================================
       ICON SIZES
       ======================================== */

    --icon-xs: 14px;
    --icon-sm: 16px;
    --icon-md: 20px;
    --icon-lg: 24px;
    --icon-xl: 32px;
  }
}

/* ============================================
   BASE STYLES
   ============================================ */

@layer base {
  * {
    @apply border-border;
  }

  body {
    @apply bg-background text-foreground;
  }

  /* Typography Base Classes */
  .text-display {
    font-family: var(--font-display);
  }

  .text-body {
    font-family: var(--font-body);
  }

  .text-mono {
    font-family: var(--font-mono);
  }
}

/* ============================================
   TYPOGRAPHY UTILITY CLASSES
   ============================================ */

/* Page Title - Plus Jakarta Sans */
.seq-page-title {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 700;
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
  color: var(--seq-slate-950);
}

/* Section Header */
.seq-section-header {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-snug);
  color: var(--seq-slate-900);
}

/* Card Title */
.seq-card-title {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 600;
  line-height: var(--leading-snug);
  color: var(--seq-slate-900);
}

/* Body Text */
.seq-body {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 400;
  line-height: var(--leading-relaxed);
  color: var(--seq-slate-600);
}

/* Label Text */
.seq-label {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--seq-slate-500);
}

/* Code/Mono Text */
.seq-code {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  background: var(--seq-slate-100);
  padding: 0.125em 0.375em;
  border-radius: var(--radius-sm);
  color: var(--seq-slate-700);
}

/* ============================================
   ANIMATION KEYFRAMES
   ============================================ */

/* Slide-in animation for sidebar panels */
@keyframes slide-in-right {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.animate-slide-in-right {
  animation: slide-in-right var(--duration-slow) var(--ease-out) forwards;
}

/* Fade in with slide up */
@keyframes fadeSlideUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-fade-in {
  animation: fadeSlideUp var(--duration-slow) var(--ease-out) forwards;
}

/* Skeleton shimmer animation */
@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

.skeleton-shimmer {
  background: linear-gradient(90deg, var(--seq-slate-100) 25%, var(--seq-slate-50) 50%, var(--seq-slate-100) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

/* Subtle pulse for unconfigured nodes */
@keyframes subtle-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Workflow connection flow animation */
@keyframes flowPulse {
  0%, 100% { stroke-dashoffset: 0; }
  50% { stroke-dashoffset: 8; }
}

.connection-active {
  animation: flowPulse 2s linear infinite;
}

/* ============================================
   STAGGERED ANIMATION DELAYS
   ============================================ */

.stagger-1 { animation-delay: 50ms; }
.stagger-2 { animation-delay: 100ms; }
.stagger-3 { animation-delay: 150ms; }
.stagger-4 { animation-delay: 200ms; }
.stagger-5 { animation-delay: 250ms; }
.stagger-6 { animation-delay: 300ms; }

/* ============================================
   INTERACTIVE UTILITIES
   ============================================ */

/* Card hover animation utility */
.card-hover {
  transition: transform var(--duration-normal) var(--ease-default),
              box-shadow var(--duration-normal) var(--ease-default),
              border-color var(--duration-normal) var(--ease-default);
}

.card-hover:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--seq-slate-300);
}

/* Button press effect */
.btn-press:active {
  transform: scale(0.98);
}

/* Smooth focus ring animation */
.focus-ring-animated {
  transition: box-shadow var(--duration-fast) var(--ease-default);
}

.focus-ring-animated:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

/* Interactive element base */
.seq-interactive {
  transition: all var(--duration-normal) var(--ease-default);
}

.seq-interactive:hover {
  background-color: var(--seq-slate-50);
}

.seq-interactive:active {
  transform: scale(0.98);
}

/* ============================================
   STATUS ROW HIGHLIGHTS
   ============================================ */

.row-success {
  background-color: var(--seq-success-muted);
}

.row-warning {
  background-color: var(--seq-warning-muted);
}

.row-error {
  background-color: var(--seq-error-muted);
}

.row-info {
  background-color: var(--seq-info-muted);
}

/* ============================================
   STATS CARD
   ============================================ */

.stats-card {
  @apply relative overflow-hidden;
}

.stats-card::before {
  content: '';
  @apply absolute -right-4 -bottom-4 w-24 h-24 opacity-5;
}

/* ============================================
   WORKFLOW BUILDER STYLES
   ============================================ */

/* Node base transition */
.workflow-node {
  transition: transform var(--duration-normal) var(--ease-default),
              box-shadow var(--duration-normal) var(--ease-default),
              border-color var(--duration-normal) var(--ease-default);
}

/* Unconfigured node pulse */
.node-unconfigured .status-icon {
  animation: subtle-pulse 2s ease-in-out infinite;
}

/* ReactFlow Handle styling - subtle visibility */
.react-flow__handle {
  opacity: 0 !important;
  transition: opacity var(--duration-fast) var(--ease-default) !important;
}

.react-flow__node:hover .react-flow__handle {
  opacity: 0.4 !important;
}

/* Edge hover effect */
.react-flow__edge:hover path {
  stroke: var(--seq-slate-400) !important;
}

/* Canvas background opacity */
.react-flow__background {
  opacity: 0.5;
}

/* ReactFlow Controls refinement */
.react-flow__controls {
  box-shadow: var(--shadow-sm) !important;
  border: 1px solid var(--seq-slate-200) !important;
  border-radius: var(--radius-lg) !important;
  overflow: hidden;
}

.react-flow__controls-button {
  background: white !important;
  border: none !important;
  border-bottom: 1px solid var(--seq-slate-100) !important;
}

.react-flow__controls-button:last-child {
  border-bottom: none !important;
}

.react-flow__controls-button:hover {
  background: var(--seq-slate-50) !important;
}

/* MiniMap refinement */
.react-flow__minimap {
  box-shadow: var(--shadow-sm) !important;
  border: 1px solid var(--seq-slate-200) !important;
  border-radius: var(--radius-lg) !important;
  overflow: hidden;
}

/* ============================================
   ACCENT BUTTON STYLES
   ============================================ */

.btn-accent {
  background-color: var(--seq-cyan-600);
  color: white;
  font-weight: 500;
  transition: all var(--duration-fast) var(--ease-default);
}

.btn-accent:hover {
  background-color: var(--seq-cyan-700);
}

.btn-accent:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

.btn-accent:active {
  transform: scale(0.98);
}

/* ============================================
   REACT FLOW NODE ANIMATIONS
   ============================================ */

/**
 * Smooth position transitions for React Flow nodes
 * Applied when nodes reposition after deletion
 * Uses GPU-accelerated CSS transforms for optimal performance
 */
.react-flow__node {
  transition-property: transform;
  transition-duration: var(--duration-slower); /* 500ms */
  transition-timing-function: var(--ease-out);
}

/**
 * Faster transitions for non-layout changes
 * (interactions, hover states, etc.)
 */
.react-flow__node.workflow-node:not([data-animating="true"]) {
  transition-duration: var(--duration-normal); /* 200ms */
}

/* ============================================
   REDUCED MOTION SUPPORT
   ============================================ */

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

