/* ============================================================
   PIR Content Pipeline — Styles
   ============================================================ */

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

:root {
  --bg: #0f1117;
  --bg-card: #1a1d27;
  --bg-input: #232733;
  --border: #2d3148;
  --text: #e2e8f0;
  --text-dim: #8892a8;
  --text-muted: #5a6480;
  --green: #276749;
  --green-light: #38a169;
  --green-bg: #f0fff4;
  --navy: #1a365d;
  --navy-light: #3182ce;
  --accent: #276749;
  --accent-hover: #22543d;
  --error: #e53e3e;
  --warning: #d69e2e;
  --purple: #6b46c1;
  --radius: 8px;
  --radius-lg: 12px;
}

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

/* --- Layout --- */

.app {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar --- */

.sidebar {
  width: 240px;
  min-height: 100vh;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 10;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--green) 0%, var(--green-light) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  color: #fff;
  letter-spacing: 0.5px;
}

.brand-name {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
}

.brand-sub {
  font-size: 11px;
  color: var(--text-dim);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 8px;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
  border-radius: var(--radius);
  transition: all 0.15s;
  text-align: left;
  width: 100%;
}

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

.nav-btn.active {
  background: rgba(39,103,73,0.15);
  color: var(--green-light);
}

.nav-icon {
  width: 20px;
  text-align: center;
  font-size: 12px;
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.stage-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.dot-pending { background: var(--text-muted); }
.dot-running { background: var(--warning); animation: pulse 1.5s infinite; }
.dot-done { background: var(--green-light); }
.dot-error { background: var(--error); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* --- Main --- */

.main {
  flex: 1;
  margin-left: 240px;
  padding: 32px 40px;
  max-width: 960px;
}

/* --- Views --- */

.view { display: none; }
.view.active { display: block; }

.view-header {
  margin-bottom: 32px;
}

.view-header h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
}

.view-desc {
  color: var(--text-dim);
  font-size: 14px;
}

/* --- Brief Form --- */

.brief-form {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.required { color: var(--error); }
.optional { color: var(--text-muted); font-weight: 400; font-size: 12px; }

.form-group input,
.form-group textarea,
.form-group select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--green-light);
}

.form-group textarea {
  resize: vertical;
}

.form-hint {
  font-size: 12px;
  color: var(--text-muted);
}

/* --- Buttons --- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  text-decoration: none;
}

.btn-primary {
  background: var(--green);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.btn-secondary:hover {
  background: var(--border);
}

.btn-ghost {
  background: none;
  color: var(--text-dim);
  padding: 8px 12px;
}

.btn-ghost:hover {
  color: var(--text);
}

.btn-lg {
  padding: 12px 24px;
  font-size: 15px;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-icon {
  font-size: 12px;
}

/* --- Stage Timeline --- */

.stage-timeline {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 24px;
  padding: 20px 0;
  overflow-x: auto;
}

.stage-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.node-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-input);
  border: 2px solid var(--border);
  transition: all 0.3s;
}

.node-label {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  font-weight: 500;
}

.stage-connector {
  flex: 1;
  height: 2px;
  background: var(--border);
  min-width: 24px;
  margin-bottom: 22px;
}

/* Stage states */
.stage-node.running .node-dot {
  border-color: var(--warning);
  background: rgba(214,158,46,0.2);
  animation: pulse 1.5s infinite;
}

.stage-node.running .node-label {
  color: var(--warning);
}

.stage-node.complete .node-dot {
  border-color: var(--green-light);
  background: var(--green);
}

.stage-node.complete .node-label {
  color: var(--green-light);
}

.stage-node.error .node-dot {
  border-color: var(--error);
  background: rgba(229,62,62,0.2);
}

.stage-node.error .node-label {
  color: var(--error);
}

.stage-connector.done {
  background: var(--green-light);
}

/* --- Status Bar --- */

.status-bar {
  padding: 10px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 20px;
}

.status-bar.running {
  border-color: var(--warning);
  color: var(--warning);
}

.status-bar.error {
  border-color: var(--error);
  color: var(--error);
}

.status-bar.success {
  border-color: var(--green-light);
  color: var(--green-light);
}

/* --- Cards --- */

.stage-output-card,
.image-upload-card,
.wp-result-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 20px;
}

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

.card-header h3 {
  font-size: 15px;
  font-weight: 600;
}

.card-badges {
  display: flex;
  gap: 8px;
}

.badge {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(39,103,73,0.15);
  color: var(--green-light);
}

.card-body {
  padding: 20px;
}

/* --- Stage Output --- */

.stage-output-content {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 600px;
  overflow-y: auto;
  color: var(--text);
}

.stage-output-content:empty::before {
  content: 'Waiting for output...';
  color: var(--text-muted);
}

/* --- Image Upload --- */

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s;
}

.upload-zone:hover {
  border-color: var(--green-light);
}

.upload-icon {
  font-size: 36px;
  margin-bottom: 8px;
}

.upload-zone p {
  color: var(--text-dim);
  font-size: 14px;
}

.image-preview {
  text-align: center;
}

.image-preview img {
  max-width: 100%;
  max-height: 300px;
  border-radius: var(--radius);
  margin-bottom: 12px;
}

.upload-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

/* --- WordPress Result --- */

.wp-result-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wp-result-info p {
  font-size: 14px;
  color: var(--text-dim);
}

.wp-result-info strong {
  color: var(--text);
}

.wp-links {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

/* --- Settings --- */

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 500px;
}

.settings-note {
  padding: 16px;
  background: var(--bg-input);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.settings-note p {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.settings-note p:last-child {
  margin-bottom: 0;
}

.settings-note code {
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--green-light);
}

/* --- Responsive --- */

@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    min-height: auto;
    position: relative;
    flex-direction: row;
    padding: 12px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .sidebar-brand { display: none; }
  .sidebar-footer { display: none; }

  .sidebar-nav {
    flex-direction: row;
    gap: 4px;
    padding: 0;
    width: 100%;
  }

  .nav-btn {
    flex: 1;
    justify-content: center;
    padding: 8px;
    font-size: 12px;
  }

  .main {
    margin-left: 0;
    padding: 20px 16px;
  }

  .stage-timeline {
    padding: 12px 0;
  }
}
