/* ===========================================================
   AI Prompt Chain Builder — Styles
   Theme: Dark mode · Premium · Glassmorphism
   =========================================================== */

*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}

:root {
  --primary: #6C5CE7;
  --primary-light: #A29BFE;
  --accent: #00CEC9;
  --bg: #0B0E11;
  --bg-card: rgba(20, 24, 32, 0.7);
  --bg-hover: rgba(108, 92, 231, 0.08);
  --border: rgba(108, 92, 231, 0.15);
  --glass-border: rgba(255, 255, 255, 0.06);
  --text: #E8E6F0;
  --text-muted: #8B8A9E;
  --text-dim: #5A5872;
  --success: #00B894;
  --danger: #FF6B6B;
  --warning: #FDCB6E;
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --transition: 220ms ease;
}

html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body { font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100vh; line-height: 1.5; }

.app-container { max-width: 1200px; margin: 0 auto; padding: 24px 20px 60px; }

/* Header */
.app-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 24px; }
.logo-group { display: flex; align-items: center; gap: 12px; }
.app-header h1 {
  font-size: 1.4rem; font-weight: 700;
  background: linear-gradient(135deg, var(--primary-light), var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.tagline { font-size: 0.82rem; color: var(--text-muted); margin-top: 2px; }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Buttons */
.btn { border: none; cursor: pointer; font-family: var(--font); font-weight: 600; border-radius: var(--radius-sm); transition: all var(--transition); }
.btn-sm { font-size: 0.78rem; padding: 6px 14px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #5B4BD5; }
.btn-secondary { background: rgba(108,92,231,0.15); color: var(--primary-light); }
.btn-secondary:hover { background: rgba(108,92,231,0.25); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-accent { background: var(--accent); color: #0B0E11; }
.btn-accent:hover { background: #00B5B0; }
.btn-danger { color: var(--danger); }
.btn-xs { font-size: 0.7rem; padding: 3px 8px; }

/* Main Layout */
.main-layout { display: grid; grid-template-columns: 1fr 380px; gap: 16px; }

/* Steps Container */
.chain-panel {
  background: var(--bg-card); border: 1px solid var(--glass-border);
  border-radius: var(--radius); padding: 20px; backdrop-filter: blur(12px); min-height: 400px;
}
.steps-container { display: flex; flex-direction: column; gap: 12px; }

.empty-state {
  display: flex; align-items: center; justify-content: center;
  min-height: 200px; color: var(--text-muted); font-size: 0.88rem; text-align: center;
}

/* Step Card */
.step-card {
  background: rgba(0,0,0,0.25); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; position: relative;
  transition: border-color var(--transition); animation: fadeIn 0.3s ease;
}
.step-card:hover { border-color: rgba(108,92,231,0.3); }

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

.step-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.step-number {
  width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; flex-shrink: 0;
}
.step-name {
  flex: 1; background: transparent; border: none; color: var(--text);
  font-size: 0.9rem; font-weight: 600; font-family: var(--font); outline: none;
}
.step-name::placeholder { color: var(--text-dim); }
.step-actions { display: flex; gap: 4px; }

.step-body { display: flex; flex-direction: column; gap: 10px; }
.step-label { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.step-textarea {
  background: rgba(0,0,0,0.3); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-family: 'SF Mono', 'Fira Code', monospace; font-size: 0.8rem;
  padding: 10px 12px; resize: vertical; min-height: 80px; outline: none; width: 100%;
  transition: border-color var(--transition);
}
.step-textarea:focus { border-color: var(--primary); }
.step-textarea::placeholder { color: var(--text-dim); }

.step-vars {
  display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px;
}
.var-tag {
  font-size: 0.68rem; padding: 2px 8px; border-radius: 999px;
  background: rgba(0,206,201,0.12); color: var(--accent); border: 1px solid rgba(0,206,201,0.2);
  font-family: 'SF Mono', monospace;
}

.step-connector {
  display: flex; justify-content: center; padding: 4px 0;
}
.step-connector svg { opacity: 0.3; }

/* Preview Panel */
.preview-panel {
  background: var(--bg-card); border: 1px solid var(--glass-border);
  border-radius: var(--radius); padding: 18px; backdrop-filter: blur(12px);
  position: sticky; top: 20px; max-height: calc(100vh - 40px); overflow-y: auto;
}
.preview-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.preview-header h2 { font-size: 0.95rem; font-weight: 600; }
.preview-output { font-size: 0.82rem; }
.preview-placeholder { color: var(--text-muted); font-size: 0.82rem; }

.preview-step {
  background: rgba(0,0,0,0.2); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 8px;
}
.preview-step-header { font-size: 0.75rem; font-weight: 600; color: var(--primary-light); margin-bottom: 6px; }
.preview-step-body {
  font-size: 0.78rem; color: var(--text-muted); white-space: pre-wrap;
  font-family: 'SF Mono', monospace; line-height: 1.6;
}
.preview-step-body .var-highlight { color: var(--accent); font-weight: 600; }

/* Modal */
.modal { border: none; background: transparent; padding: 0; max-width: 90vw; }
.modal::backdrop { background: rgba(0,0,0,0.6); }
.modal-content {
  background: #141820; border: 1px solid var(--glass-border);
  border-radius: var(--radius); padding: 24px; min-width: 400px;
}
.modal-content h2 { font-size: 1rem; font-weight: 600; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

.code-textarea {
  width: 100%; background: rgba(0,0,0,0.3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-family: 'SF Mono', monospace;
  font-size: 0.8rem; padding: 10px; resize: vertical; outline: none;
}

.templates-list { display: flex; flex-direction: column; gap: 8px; }
.template-item {
  background: rgba(0,0,0,0.2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px; cursor: pointer; transition: all var(--transition);
}
.template-item:hover { border-color: var(--primary); background: var(--bg-hover); }
.template-item h3 { font-size: 0.85rem; font-weight: 600; margin-bottom: 4px; }
.template-item p { font-size: 0.75rem; color: var(--text-muted); }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(108,92,231,0.2); border-radius: 3px; }

/* Responsive */
@media (max-width: 768px) {
  .main-layout { grid-template-columns: 1fr; }
  .app-header { flex-direction: column; align-items: flex-start; }
  .preview-panel { position: static; max-height: none; }
}
