/* ----------------------------------------------------
   n8n Webhook Launchpad - Premium Stylesheet
   ---------------------------------------------------- */

/* Google Fonts Import */
@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500&family=Inter:wght@300;400;500;600;700&display=swap');

/* CSS Variables */
:root {
  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'Fira Code', monospace;

  /* Colors */
  --bg-primary: #0a0b10;
  --bg-secondary: rgba(18, 20, 29, 0.7);
  --bg-tertiary: rgba(30, 32, 45, 0.5);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(139, 92, 246, 0.5); /* Violet */
  
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;

  --accent-purple: #8b5cf6;
  --accent-purple-glow: rgba(139, 92, 246, 0.3);
  --accent-pink: #ec4899;
  --accent-indigo: #6366f1;

  --status-success: #10b981;
  --status-success-bg: rgba(16, 185, 129, 0.1);
  --status-success-border: rgba(16, 185, 129, 0.2);

  --status-error: #ef4444;
  --status-error-bg: rgba(239, 68, 68, 0.1);
  --status-error-border: rgba(239, 68, 68, 0.2);

  --status-warning: #f59e0b;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-glow: 0 0 20px 0 rgba(139, 92, 246, 0.15);

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  position: relative;
}

/* Ambient Background Light Spots */
body::before, body::after {
  content: "";
  position: absolute;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  z-index: -1;
  filter: blur(120px);
  opacity: 0.12;
  pointer-events: none;
}

body::before {
  top: -100px;
  left: -100px;
  background: radial-gradient(circle, var(--accent-purple) 0%, transparent 70%);
}

body::after {
  bottom: -100px;
  right: -100px;
  background: radial-gradient(circle, var(--accent-indigo) 0%, transparent 70%);
}

/* Layout Wrapper */
.app-container {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  flex-grow: 1;
}

/* Header */
header {
  text-align: center;
  margin-bottom: 0.5rem;
}

.logo-area {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.logo-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 15px rgba(139, 92, 246, 0.4);
  font-weight: 700;
  font-size: 1.25rem;
  color: white;
}

h1 {
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  background: linear-gradient(to right, #ffffff, #d8b4fe, #818cf8);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
  font-weight: 400;
  margin-top: 0.25rem;
}

/* Main Grid Layout */
.main-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 2rem;
}

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

/* Glassmorphism Panel card */
.panel {
  background-color: var(--bg-secondary);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  transition: border-color var(--transition-normal);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1rem;
}

.panel-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.panel-title svg {
  color: var(--accent-purple);
}

/* Forms & Inputs */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.input-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* URL Input field with HTTP Method badge */
.url-input-container {
  display: flex;
  border: 1px solid var(--border-color);
  background-color: var(--bg-tertiary);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.url-input-container:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-purple-glow);
}

.method-select {
  background: rgba(255, 255, 255, 0.03);
  border: none;
  border-right: 1px solid var(--border-color);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0 1rem;
  outline: none;
  cursor: pointer;
  height: 48px;
  min-height: 48px;
}

.method-select option {
  background-color: #0f1016;
  color: var(--text-primary);
}

.url-input {
  flex-grow: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  padding: 0 1rem;
  outline: none;
  min-height: 48px;
}

.url-input::placeholder {
  color: var(--text-muted);
}

/* Standard Inputs & Textareas */
input[type="text"], textarea, select {
  font-size: 1rem; /* iOS zoom prevention */
  padding: 0.75rem 1rem;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-sans);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  min-height: 48px;
}

input[type="text"]:focus, textarea:focus, select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-purple-glow);
}

textarea {
  min-height: 120px;
  resize: vertical;
}

/* Monospace text fields for Code */
.code-editor {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  tab-size: 2;
  line-height: 1.5;
}

.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.25rem;
}

.json-status {
  font-size: 0.75rem;
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
}

.json-status.valid {
  background-color: rgba(16, 185, 129, 0.1);
  color: var(--status-success);
}

.json-status.invalid {
  background-color: rgba(239, 68, 68, 0.1);
  color: var(--status-error);
}

/* Headers Builder */
.headers-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.header-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  animation: slideIn 0.2s ease;
}

.header-row input {
  flex: 1;
  min-height: 40px;
  height: 40px;
}

.btn-icon-danger {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: rgba(239, 68, 68, 0.05);
  color: var(--status-error);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-icon-danger:hover {
  background: var(--status-error);
  color: white;
}

.btn-secondary {
  padding: 0.5rem 1rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all var(--transition-fast);
  align-self: flex-start;
  min-height: 38px;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--text-secondary);
}

/* ----------------------------------------------------
   Right Column: Trigger, Console, History
   ---------------------------------------------------- */
.sidebar-panel {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Trigger Webhook Button */
.trigger-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem 0;
  position: relative;
}

.btn-trigger {
  width: 100%;
  min-height: 64px;
  border-radius: var(--radius-lg);
  border: none;
  background: linear-gradient(135deg, var(--accent-purple) 0%, var(--accent-indigo) 100%);
  color: white;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  position: relative;
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(139, 92, 246, 0.4);
  transition: all var(--transition-normal);
}

.btn-trigger:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 12px 35px rgba(139, 92, 246, 0.6);
  filter: brightness(1.1);
}

.btn-trigger:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
}

.btn-trigger:disabled {
  background: var(--text-muted);
  cursor: not-allowed;
  box-shadow: none;
}

/* Trigger Button Animations states */
.btn-trigger .spinner {
  display: none;
  width: 24px;
  height: 24px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 0.8s linear infinite;
}

.btn-trigger.sending {
  background: linear-gradient(135deg, #4b5563, #374151);
  box-shadow: none;
  pointer-events: none;
}

.btn-trigger.sending .spinner {
  display: block;
}

.btn-trigger.sending .btn-text,
.btn-trigger.sending svg {
  display: none;
}

/* Error Shake */
.btn-trigger.shake {
  animation: shake 0.5s ease-in-out;
  background: linear-gradient(135deg, #dc2626, #ef4444);
  box-shadow: 0 8px 30px rgba(239, 68, 68, 0.4);
}

/* Success Burst */
.btn-trigger.success {
  background: linear-gradient(135deg, #059669, #10b981);
  box-shadow: 0 8px 30px rgba(16, 185, 129, 0.4);
}

/* Console Display */
.console-panel {
  flex-grow: 1;
}

.console-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background-color: #05060b;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  min-height: 220px;
  max-height: 400px;
  overflow: hidden;
}

.console-header-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 0.5rem;
}

.status-badge {
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
}

.status-badge.empty {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
}

.status-badge.success {
  background-color: var(--status-success-bg);
  border: 1px solid var(--status-success-border);
  color: var(--status-success);
}

.status-badge.error {
  background-color: var(--status-error-bg);
  border: 1px solid var(--status-error-border);
  color: var(--status-error);
}

.time-elapsed {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.console-content {
  flex-grow: 1;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  color: #a7f3d0; /* Green terminal text default */
  scroll-behavior: smooth;
}

.console-content.error {
  color: #fca5a5; /* Red terminal text on error */
}

.console-content.empty {
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-style: italic;
}

.console-footer {
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 0.5rem;
}

/* History list */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.50rem;
  max-height: 250px;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  animation: slideIn 0.2s ease;
}

.history-item:hover {
  background-color: rgba(255, 255, 255, 0.05);
  border-color: var(--accent-purple);
  transform: translateX(2px);
}

.history-item-meta {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.history-url {
  font-weight: 500;
  color: var(--text-primary);
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-time {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.history-badge-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.history-method {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.7rem;
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius-sm);
  background-color: rgba(255, 255, 255, 0.05);
}

.history-status-badge {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.history-status-badge.success {
  background-color: var(--status-success);
  box-shadow: 0 0 6px var(--status-success);
}

.history-status-badge.error {
  background-color: var(--status-error);
  box-shadow: 0 0 6px var(--status-error);
}

.empty-history {
  color: var(--text-muted);
  font-size: 0.875rem;
  text-align: center;
  padding: 1.5rem;
  font-style: italic;
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
}

/* ----------------------------------------------------
   Confetti & Particle Effects (CSS Based)
   ---------------------------------------------------- */
.confetti-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
  z-index: 10;
}

.particle {
  position: absolute;
  width: 10px;
  height: 10px;
  opacity: 0;
  border-radius: 2px;
}

/* ----------------------------------------------------
   Custom Scrollbar
   ---------------------------------------------------- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ----------------------------------------------------
   Keyframes & Animations
   ---------------------------------------------------- */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-6px); }
  20%, 40%, 60%, 80% { transform: translateX(6px); }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 999;
}

.toast {
  background-color: #12141d;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  color: var(--text-primary);
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: 0 10px 25px rgba(0,0,0,0.3);
  animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  min-width: 280px;
}

.toast.success {
  border-left: 3px solid var(--status-success);
}

.toast.error {
  border-left: 3px solid var(--status-error);
}

.toast.info {
  border-left: 3px solid var(--accent-purple);
}

.toast-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.toast-icon.success { color: var(--status-success); }
.toast-icon.error { color: var(--status-error); }
.toast-icon.info { color: var(--accent-purple); }

.toast-message {
  flex-grow: 1;
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
}

.toast-close:hover {
  color: var(--text-primary);
}
