/* ========================================
   PromptCraft — Design System
   ======================================== */

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

/* ---- CSS Custom Properties ---- */
:root {
  /* Color Palette — Deep Space */
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.7);
  --bg-card-hover: rgba(23, 32, 52, 0.85);
  --bg-input: rgba(15, 20, 35, 0.8);
  --bg-glass: rgba(255, 255, 255, 0.03);

  /* Accent gradient */
  --accent-1: #6366f1;
  --accent-2: #8b5cf6;
  --accent-3: #a78bfa;
  --accent-4: #c084fc;
  --accent-glow: rgba(99, 102, 241, 0.25);

  /* Semantic Colors */
  --success: #34d399;
  --success-glow: rgba(52, 211, 153, 0.2);
  --warning: #fbbf24;
  --info: #60a5fa;

  /* Text */
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-accent: #a78bfa;

  /* Borders */
  --border-subtle: rgba(148, 163, 184, 0.08);
  --border-active: rgba(99, 102, 241, 0.4);

  /* Shadows */
  --shadow-sm: 0 1px 3px 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: 0 0 40px var(--accent-glow);

  /* Spacing */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* Transitions */
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* Animated background mesh */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(99, 102, 241, 0.12) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 80% 80%, rgba(139, 92, 246, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 50% 50%, rgba(192, 132, 252, 0.05) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
  animation: meshFloat 20s ease-in-out infinite alternate;
}

@keyframes meshFloat {
  0% { transform: scale(1) translate(0, 0); }
  50% { transform: scale(1.05) translate(-2%, 1%); }
  100% { transform: scale(1) translate(1%, -1%); }
}

/* ---- Layout ---- */
.app-container {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

/* ---- Header ---- */
.app-header {
  text-align: center;
  padding: 3rem 0 2.5rem;
  position: relative;
}

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

.logo-icon {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-4));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: var(--shadow-glow);
  animation: logoPulse 3s ease-in-out infinite;
}

@keyframes logoPulse {
  0%, 100% { box-shadow: 0 0 20px var(--accent-glow); }
  50% { box-shadow: 0 0 40px var(--accent-glow), 0 0 60px rgba(139, 92, 246, 0.15); }
}

.app-title {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent-3) 50%, var(--accent-4) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.app-subtitle {
  font-size: 1.1rem;
  color: var(--text-secondary);
  font-weight: 400;
  margin-top: 0.5rem;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

/* ---- Method Selector Section ---- */
.method-selector-section {
  margin-bottom: 2rem;
}

.section-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.section-label .icon {
  font-size: 1rem;
}

/* Custom Select */
.select-wrapper {
  position: relative;
}

.method-select {
  width: 100%;
  padding: 1rem 3rem 1rem 1.25rem;
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  appearance: none;
  transition: all 0.3s var(--ease-smooth);
  backdrop-filter: blur(20px);
}

.method-select:hover {
  border-color: var(--border-active);
  background: var(--bg-card-hover);
}

.method-select:focus {
  outline: none;
  border-color: var(--accent-1);
  box-shadow: 0 0 0 3px var(--accent-glow), var(--shadow-md);
}

.method-select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
  padding: 0.75rem;
}

.select-arrow {
  position: absolute;
  right: 1.25rem;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  transition: transform 0.3s var(--ease-smooth);
}

/* ---- Method Info Card ---- */
.method-info {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 2rem;
  backdrop-filter: blur(20px);
  animation: slideUp 0.4s var(--ease-smooth);
  position: relative;
  overflow: hidden;
}

.method-info::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent-1), var(--accent-2), var(--accent-4));
}

.method-info-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.method-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.85rem;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: white;
  white-space: nowrap;
  flex-shrink: 0;
}

.method-full-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
}

.method-description {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ---- Main Content Grid ---- */
.main-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  align-items: start;
}

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

/* ---- Form Panel ---- */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(20px);
  overflow: hidden;
}

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

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

.panel-body {
  padding: 1.5rem;
}

/* ---- Field Groups ---- */
.field-group {
  margin-bottom: 1.5rem;
  animation: slideUp 0.4s var(--ease-smooth);
  animation-fill-mode: both;
}

.field-group:last-child {
  margin-bottom: 0;
}

.field-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

.letter-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 800;
  color: white;
  flex-shrink: 0;
}

.field-label-text {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.field-help {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  padding-left: calc(28px + 0.6rem);
}

.field-input,
.field-textarea {
  width: 100%;
  padding: 0.85rem 1rem;
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  transition: all 0.3s var(--ease-smooth);
  line-height: 1.5;
}

.field-textarea {
  min-height: 100px;
  resize: vertical;
}

.field-input:hover,
.field-textarea:hover {
  border-color: rgba(148, 163, 184, 0.15);
}

.field-input:focus,
.field-textarea:focus {
  outline: none;
  border-color: var(--accent-1);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background: rgba(15, 20, 35, 0.95);
}

.field-input::placeholder,
.field-textarea::placeholder {
  color: var(--text-muted);
  font-size: 0.82rem;
}

/* ---- Action Buttons ---- */
.actions-bar {
  display: flex;
  gap: 0.75rem;
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--border-subtle);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.3s var(--ease-smooth);
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.1), transparent);
  opacity: 0;
  transition: opacity 0.3s;
}

.btn:hover::after {
  opacity: 1;
}

.btn-primary {
  flex: 1;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  color: white;
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px var(--accent-glow);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--bg-glass);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.btn-secondary:hover {
  color: var(--text-primary);
  border-color: var(--border-active);
  background: var(--bg-card-hover);
}

/* ---- Output Panel ---- */
.output-panel {
  position: sticky;
  top: 2rem;
}

.output-content {
  min-height: 300px;
  max-height: 600px;
  overflow-y: auto;
  padding: 1.5rem;
}

.output-content::-webkit-scrollbar {
  width: 6px;
}

.output-content::-webkit-scrollbar-track {
  background: transparent;
}

.output-content::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 3px;
}

.output-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  text-align: center;
  color: var(--text-muted);
  gap: 1rem;
}

.output-placeholder-icon {
  font-size: 3rem;
  opacity: 0.3;
}

.output-placeholder-text {
  font-size: 0.9rem;
  max-width: 250px;
  line-height: 1.6;
}

.prompt-output {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  line-height: 1.8;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}

.prompt-output h1 {
  font-family: 'Inter', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-3);
  margin-bottom: 0.25rem;
}

.prompt-output h2 {
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent-4);
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border-subtle);
}

.prompt-output h3 {
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.prompt-output hr {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: 1rem 0;
}

/* Output action bar */
.output-actions {
  display: flex;
  gap: 0.5rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-subtle);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem;
  font-weight: 500;
  background: var(--bg-glass);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.3s var(--ease-smooth);
}

.btn-icon:hover {
  color: var(--text-primary);
  border-color: var(--border-active);
  background: var(--bg-card-hover);
}

.btn-icon.copied {
  color: var(--success);
  border-color: var(--success);
  background: var(--success-glow);
}

/* ---- Tips Section ---- */
.tips-section {
  margin-top: 2rem;
  animation: slideUp 0.5s var(--ease-smooth) 0.2s both;
}

.tips-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 0.75rem;
}

.tip-card {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: all 0.3s var(--ease-smooth);
}

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

.tip-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.tip-text {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ---- Toast Notification ---- */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  padding: 0.85rem 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--success);
  border-radius: var(--radius-md);
  color: var(--success);
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 8px 32px rgba(52, 211, 153, 0.15);
  backdrop-filter: blur(20px);
  z-index: 1000;
  transform: translateY(120%);
  opacity: 0;
  transition: all 0.4s var(--ease-bounce);
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* ---- Animations ---- */
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Staggered field animation */
.field-group:nth-child(1) { animation-delay: 0.05s; }
.field-group:nth-child(2) { animation-delay: 0.1s; }
.field-group:nth-child(3) { animation-delay: 0.15s; }
.field-group:nth-child(4) { animation-delay: 0.2s; }
.field-group:nth-child(5) { animation-delay: 0.25s; }

/* ---- Responsive ---- */
@media (max-width: 640px) {
  .app-container {
    padding: 1rem 1rem 3rem;
  }

  .app-title {
    font-size: 1.8rem;
  }

  .app-subtitle {
    font-size: 0.95rem;
  }

  .panel-body {
    padding: 1rem;
  }

  .method-info {
    padding: 1.25rem;
  }

  .output-panel {
    position: static;
  }

  .tips-grid {
    grid-template-columns: 1fr;
  }
}

/* ---- Character counter ---- */
.char-counter {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: right;
  margin-top: 0.25rem;
  transition: color 0.3s;
}

.char-counter.near-limit {
  color: var(--warning);
}

/* ---- Loading spinner ---- */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---- Prompt raw text mode ---- */
.prompt-raw {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  line-height: 1.7;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}
