/* ==========================================
   MDHub.dev - AI Prompt Blueprint System
   Design System & Core Styles
   ========================================== */

/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ==========================================
   CSS Custom Properties (Design Tokens)
   ========================================== */
:root {
  /* Colors - Dark Mode Theme */
  --color-bg-primary: #0a0a0f;
  --color-bg-secondary: #13131a;
  --color-bg-tertiary: #1a1a24;
  --color-bg-elevated: #20202e;

  /* Vibrant Accent Colors */
  --color-accent-purple: #8b5cf6;
  --color-accent-cyan: #06b6d4;
  --color-accent-pink: #ec4899;
  --color-accent-green: #10b981;
  --color-accent-orange: #f97316;
  --color-accent-blue: #3b82f6;

  /* Gradient Definitions */
  --gradient-primary: linear-gradient(135deg, #8b5cf6 0%, #06b6d4 100%);
  --gradient-secondary: linear-gradient(135deg, #ec4899 0%, #8b5cf6 100%);
  --gradient-success: linear-gradient(135deg, #10b981 0%, #06b6d4 100%);
  --gradient-warm: linear-gradient(135deg, #f97316 0%, #ec4899 100%);

  /* Text Colors */
  --color-text-primary: #f8f9fa;
  --color-text-secondary: #adb5bd;
  --color-text-tertiary: #6c757d;
  --color-text-muted: #495057;

  /* Border & Divider Colors */
  --color-border: rgba(255, 255, 255, 0.1);
  --color-border-hover: rgba(255, 255, 255, 0.2);
  --color-divider: rgba(255, 255, 255, 0.05);

  /* Shadow Definitions */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow-purple: 0 0 20px rgba(139, 92, 246, 0.3);
  --shadow-glow-cyan: 0 0 20px rgba(6, 182, 212, 0.3);

  /* Spacing Scale */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;

  /* Border Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;

  /* Font Sizes */
  --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;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Z-Index Scale */
  --z-base: 1;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-modal: 300;
  --z-tooltip: 400;
}

/* ==========================================
   Reset & Base Styles
   ========================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--color-bg-primary);
  color: var(--color-text-primary);
  line-height: 1.6;
  overflow: hidden;
  position: relative;
}

/* Animated Background */
body::before {
  content: '';
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 30% 50%, rgba(139, 92, 246, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 70% 50%, rgba(6, 182, 212, 0.1) 0%, transparent 50%);
  animation: gradientShift 20s ease infinite;
  z-index: -1;
  pointer-events: none;
}

@keyframes gradientShift {

  0%,
  100% {
    transform: translate(0, 0) rotate(0deg);
  }

  33% {
    transform: translate(10%, -10%) rotate(120deg);
  }

  66% {
    transform: translate(-10%, 10%) rotate(240deg);
  }
}

/* ==========================================
   Layout - Three Panel System
   ========================================== */
.app-container {
  display: grid !important;
  grid-template-columns: 280px 1fr 360px !important;
  grid-template-rows: 60px 1fr 22px !important;
  grid-template-areas:
    "header header header"
    "sidebar canvas output"
    "footer footer footer" !important;
  height: 100vh !important;
  width: 100vw !important;
  gap: 0 !important;
  background: #0a0a0f !important;
  overflow: hidden !important;
}

/* ==========================================
   Footer / Status Bar (Professional IDE Style)
   ========================================== */
.app-footer {
  grid-area: footer !important;
  background: #007acc !important;
  /* Professional IDE Blue */
  color: #ffffff !important;
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: space-between !important;
  padding: 0 10px !important;
  font-size: 11px !important;
  height: 22px !important;
  min-height: 22px !important;
  max-height: 22px !important;
  z-index: 1000 !important;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
  user-select: none !important;
  box-sizing: border-box !important;
}

.footer-left,
.footer-right {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  height: 100% !important;
  flex-wrap: nowrap !important;
}

.status-item {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 4px !important;
  padding: 0 10px !important;
  height: 100% !important;
  cursor: default !important;
  white-space: nowrap !important;
}

.status-item:hover {
  background: rgba(255, 255, 255, 0.15);
}

.status-indicator {
  width: 7px;
  height: 7px;
  background: #ffffff;
  /* White dot on blue bar */
  border-radius: 50%;
  box-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
}

.app-footer a,
.app-footer a:link,
.app-footer a:visited,
.footer-copyright a,
.footer-copyright a:link,
.footer-copyright a:visited {
  color: #ffffff !important;
  text-decoration: none !important;
  font-weight: 600 !important;
  transition: all 0.2s ease !important;
}

.app-footer a:hover,
.footer-copyright a:hover {
  text-decoration: underline !important;
  opacity: 0.8 !important;
  color: #ffffff !important;
}

.status-label {
  opacity: 0.8;
  font-weight: 400;
}

.status-value {
  color: #ffffff !important;
  font-weight: 600 !important;
}

/* ==========================================
   Header / Toolbar
   ========================================== */
.app-header {
  grid-area: header;
  background: var(--color-bg-secondary);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-lg);
  backdrop-filter: blur(10px);
  position: relative;
  z-index: var(--z-sticky);
}

.app-logo {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  font-size: var(--text-xl);
  font-weight: 700;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.app-logo::before {
  content: '⚡';
  font-size: var(--text-2xl);
  filter: drop-shadow(0 0 10px rgba(139, 92, 246, 0.5));
  -webkit-text-fill-color: initial;
}

.toolbar {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}

.toolbar-button {
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all var(--transition-base);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.toolbar-button:hover {
  background: var(--color-bg-elevated);
  border-color: var(--color-border-hover);
  color: var(--color-text-primary);
  transform: translateY(-1px);
}

.toolbar-button.primary {
  background: var(--gradient-primary);
  border-color: transparent;
  color: white;
  font-weight: 600;
}

.toolbar-button.primary:hover {
  box-shadow: var(--shadow-glow-purple);
  transform: translateY(-2px);
}

/* ==========================================
   Left Sidebar - Card Library
   ========================================== */
.sidebar {
  grid-area: sidebar;
  background: var(--color-bg-secondary);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-divider);
}

.sidebar-title {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.search-box {
  width: 100%;
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  color: var(--color-text-primary);
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-family: var(--font-sans);
  transition: all var(--transition-base);
}

.search-box:focus {
  outline: none;
  border-color: var(--color-accent-purple);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.card-categories {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.card-category {
  margin-bottom: var(--space-md);
}

.category-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-xs);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.card-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Library Card (Draggable) */
.library-card {
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 6px 8px;
  cursor: grab;
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.library-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--card-color, var(--gradient-primary));
  opacity: 0;
  transition: opacity var(--transition-base);
}

.library-card:hover {
  border-color: var(--color-border-hover);
  transform: translateX(4px);
  background: var(--color-bg-elevated);
}

.library-card:hover::before {
  opacity: 1;
}

.library-card:active {
  cursor: grabbing;
}

.library-card-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
}

.library-card-icon {
  font-size: 14px;
}

.library-card-title {
  font-size: 11px;
  font-weight: 600;
  line-height: 1.1;
  color: var(--color-text-primary);
}

.library-card-description {
  font-size: 10px;
  color: var(--color-text-secondary);
  line-height: 1.2;
  opacity: 0.7;
}

/* ==========================================
   Center Canvas - Blueprint Workspace
   ========================================== */
.canvas-container {
  grid-area: canvas;
  background: var(--color-bg-primary);
  position: relative;
  overflow: hidden;
}

/* Grid Pattern */
.canvas-grid {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image:
    linear-gradient(var(--color-divider) 1px, transparent 1px),
    linear-gradient(90deg, var(--color-divider) 1px, transparent 1px);
  background-size: 20px 20px;
  pointer-events: none;
}

.canvas-viewport {
  width: 100%;
  height: 100%;
  position: relative;
  cursor: grab;
}

.canvas-viewport.panning {
  cursor: grabbing;
}

/* SVG Connection Layer */
.connection-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: var(--z-base);
}

.connection-line {
  stroke: var(--color-accent-purple);
  stroke-width: 2;
  fill: none;
  filter: drop-shadow(0 0 8px rgba(139, 92, 246, 0.4));
  transition: stroke var(--transition-fast);
}

.connection-line:hover {
  stroke: var(--color-accent-cyan);
  stroke-width: 3;
}

/* Canvas Node (Dropped Card) */
.canvas-node {
  position: absolute;
  background: var(--color-bg-elevated);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  min-width: 220px;
  cursor: move;
  transition: all var(--transition-base);
  box-shadow: var(--shadow-md);
}

.canvas-node:hover {
  border-color: var(--color-border-hover);
  box-shadow: var(--shadow-lg);
  z-index: 10 !important;
}

.canvas-node.selected {
  border-color: var(--color-accent-purple);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2), var(--shadow-lg);
}

.canvas-node.dragging {
  opacity: 0.8;
  cursor: grabbing;
  z-index: 100 !important;
  user-select: none;
  -webkit-user-select: none;
}

.node-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--color-divider);
}

.node-title-group {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.node-icon {
  font-size: var(--text-lg);
  filter: drop-shadow(0 0 8px currentColor);
}

.node-title {
  font-size: var(--text-sm);
  font-weight: 600;
}

.node-actions {
  display: flex;
  gap: var(--space-xs);
}

.node-action-btn {
  background: transparent;
  border: none;
  color: var(--color-text-tertiary);
  cursor: pointer;
  padding: var(--space-xs);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  transition: all var(--transition-fast);
  line-height: 1;
}

.node-action-btn:hover {
  background: var(--color-bg-tertiary);
  color: var(--color-text-primary);
}

.node-content {
  margin-bottom: var(--space-md);
}

.node-field {
  margin-bottom: var(--space-sm);
}

.node-field-label {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.node-field-input,
.node-field-textarea {
  width: 100%;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  color: var(--color-text-primary);
  padding: var(--space-sm);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  transition: all var(--transition-base);
}

.node-field-textarea {
  font-family: var(--font-mono);
  resize: vertical;
  min-height: 60px;
}

.node-field-input:focus,
.node-field-textarea:focus {
  outline: none;
  border-color: var(--color-accent-purple);
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.1);
}

/* Connection Ports */
.node-ports {
  display: flex;
  justify-content: space-between;
  gap: var(--space-md);
}

.port {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.port-connector {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-bg-secondary);
  border: 2px solid var(--color-border);
  cursor: crosshair;
  transition: all var(--transition-fast);
  position: relative;
}

.port-connector:hover {
  border-color: var(--color-accent-purple);
  background: var(--color-accent-purple);
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.6);
  transform: scale(1.3);
}

.port-connector.active {
  border-color: var(--color-accent-cyan);
  background: var(--color-accent-cyan);
  box-shadow: 0 0 16px rgba(6, 182, 212, 0.8);
  animation: pulse 1s infinite;
}

@keyframes pulse {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.2);
  }
}

.port-label {
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
}

/* ==========================================
   Right Panel - Output Display
   ========================================== */
.output-panel {
  grid-area: output;
  background: var(--color-bg-secondary);
  border-left: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.output-header {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--color-divider);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.output-title {
  font-size: var(--text-lg);
  font-weight: 600;
}

.copy-button {
  background: var(--gradient-primary);
  border: none;
  color: white;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-base);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.copy-button:hover {
  box-shadow: var(--shadow-glow-purple);
  transform: translateY(-2px);
}

.copy-button:active {
  transform: translateY(0);
}

.output-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-lg);
}

.prompt-output {
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.8;
  color: var(--color-text-primary);
  white-space: pre-wrap;
  word-wrap: break-word;
  min-height: 200px;
}

.prompt-output.empty {
  color: var(--color-text-tertiary);
  font-style: italic;
  text-align: center;
  padding: var(--space-3xl);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: var(--space-md);
}

.prompt-output.empty::before {
  content: '📝';
  font-size: var(--text-4xl);
  filter: grayscale(1) opacity(0.3);
}

/* ==========================================
   Utility Classes
   ========================================== */
.gradient-text {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.glassmorphism {
  background: rgba(32, 32, 46, 0.7);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ==========================================
   Scrollbar Styling
   ========================================== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--color-bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--color-bg-elevated);
  border-radius: var(--radius-full);
  border: 2px solid var(--color-bg-secondary);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-border-hover);
}

/* ==========================================
   Responsive Design
   ========================================== */
@media (max-width: 1280px) {
  .app-container {
    grid-template-columns: 260px 1fr 320px;
  }
}

@media (max-width: 1024px) {
  .app-container {
    grid-template-columns: 240px 1fr 300px;
  }

  .sidebar-header,
  .output-header {
    padding: var(--space-md);
  }
}

/* ==========================================
   Animations
   ========================================== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn var(--transition-base) ease-out;
}

@keyframes slideIn {
  from {
    transform: translateX(-100%);
  }

  to {
    transform: translateX(0);
  }
}

/* ==========================================
   Toast Notifications
   ========================================== */
.toast {
  position: fixed;
  bottom: var(--space-xl);
  right: var(--space-xl);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-md) var(--space-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  z-index: var(--z-tooltip);
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    transform: translateY(100px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.toast.success {
  border-left: 4px solid var(--color-accent-green);
}

.toast.error {
  border-left: 4px solid var(--color-accent-pink);
}