/* Blog AI Generator — Custom Styles
   Lifts the seo_stats palette and primitives so visual identity carries
   across.  Additions below the divider are specific to the blog app:
   forms, markdown rendering, indeterminate progress, copy buttons, etc. */

:root {
  --primary: #4f46e5;
  --primary-dark: #3730a3;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --sidebar-bg: #1e1b4b;
  --sidebar-text: #c7d2fe;
  --sidebar-active: #4f46e5;
  --sidebar-hover: #312e81;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ── Layout / Sidebar / Topbar (identical to seo_stats) ── */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px; background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column; flex-shrink: 0;
  position: fixed; top: 0; left: 0; bottom: 0; overflow-y: auto; z-index: 100;
}
.sidebar-brand { padding: 20px 16px 16px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.sidebar-brand h1 { font-size: 15px; font-weight: 700; color: #fff; letter-spacing: 0.02em; }
.sidebar-brand p  { font-size: 11px; color: var(--sidebar-text); margin-top: 2px; opacity: 0.7; }
.sidebar-nav { flex: 1; padding: 12px 0; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 16px;
  color: var(--sidebar-text); text-decoration: none; font-size: 13px;
  font-weight: 500; border-left: 3px solid transparent;
  transition: background 0.15s, color 0.15s;
}
.sidebar-nav a:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-nav a.active {
  background: rgba(79, 70, 229, 0.25); color: #fff;
  border-left-color: var(--primary);
}
.sidebar-nav .nav-icon { font-size: 16px; width: 20px; text-align: center; }
.sidebar-footer {
  padding: 12px 16px; border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 12px; color: var(--sidebar-text); opacity: 0.6;
}
.sidebar-footer a { color: var(--sidebar-text); text-decoration: none; }
.sidebar-footer a:hover { opacity: 1; color: #fff; }

.main {
  margin-left: 220px; flex: 1; display: flex; flex-direction: column;
  min-height: 100vh;
}
.topbar {
  background: var(--card-bg); border-bottom: 1px solid var(--border);
  padding: 14px 28px; display: flex; align-items: center;
  justify-content: space-between; position: sticky; top: 0; z-index: 50;
}
.topbar h2 { font-size: 17px; font-weight: 600; color: var(--text); }
.topbar-right {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-muted);
}
.content { padding: 24px 28px; flex: 1; max-width: 1280px; }

/* ── Cards / Panels ── */
.card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 10px; margin-bottom: 20px; overflow: hidden;
}
.card-header {
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.card-header h3 { font-size: 14px; font-weight: 600; color: var(--text); }
.card-header .card-subtitle { font-size: 12px; color: var(--text-muted); }
.card-body { padding: 20px; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  background: #f1f5f9; padding: 9px 12px; text-align: left;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-muted);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background 0.1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }
tbody td { padding: 9px 12px; color: var(--text); vertical-align: middle; }
.td-mono  { font-family: 'JetBrains Mono', 'Fira Code', monospace; font-size: 12px; }
.td-muted { color: var(--text-muted); }

/* ── Badges ── */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
}
.badge-success  { background: #d1fae5; color: #065f46; }
.badge-info     { background: #dbeafe; color: #1e40af; }
.badge-warning  { background: #fef3c7; color: #92400e; }
.badge-primary  { background: #ede9fe; color: #4c1d95; }
.badge-danger   { background: #fee2e2; color: #991b1b; }
.badge-secondary{ background: #f1f5f9; color: #475569; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px;
  border-radius: 6px; font-size: 13px; font-weight: 500; cursor: pointer;
  border: none; text-decoration: none; transition: background 0.15s, opacity 0.15s;
}
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { opacity: 0.55; cursor: wait; }
.btn-secondary { background: #f1f5f9; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #e2e8f0; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm        { padding: 4px 10px; font-size: 12px; }

/* ── Forms (login + persona form + writer view share) ── */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; font-size: 12px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px;
}
.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group textarea,
.form-group select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 7px; font-size: 14px; color: var(--text);
  background: var(--card-bg); outline: none;
  transition: border-color 0.15s; font-family: inherit;
}
.form-group textarea { resize: vertical; min-height: 60px; font-family: inherit; }
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus { border-color: var(--primary); }
.form-help {
  font-size: 12px; color: var(--text-muted); margin-top: 5px;
}
.form-help code {
  background: #f1f5f9; padding: 1px 4px; border-radius: 3px;
  font-family: 'JetBrains Mono', monospace; font-size: 11px;
}
.form-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}
.form-row .form-group { margin-bottom: 16px; }
@media (max-width: 800px) { .form-row { grid-template-columns: 1fr; } }

.form-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px;
}
@media (max-width: 1100px) { .form-grid { grid-template-columns: 1fr; } }

.form-actions {
  display: flex; gap: 10px; padding: 16px 0; align-items: center;
}

/* ── Alerts ── */
.alert {
  padding: 10px 14px; border-radius: 7px; font-size: 13px; margin-bottom: 16px;
}
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.alert-info    { background: #dbeafe; color: #1e3a8a; border: 1px solid #93c5fd; }

/* ── Progress (indeterminate) ── */
.progress {
  height: 6px; background: #e2e8f0; border-radius: 999px;
  overflow: hidden; min-width: 80px; position: relative;
}
.progress-bar {
  height: 100%; border-radius: 999px; background: var(--primary);
  transition: width 0.3s;
}
.progress-indeterminate .progress-bar {
  width: 35%; animation: indet 1.3s ease-in-out infinite;
  background: linear-gradient(90deg, var(--primary), #818cf8, var(--primary));
}
@keyframes indet {
  0%   { transform: translateX(-100%); }
  50%  { transform: translateX(180%); }
  100% { transform: translateX(-100%); }
}

/* ── Login page ── */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--sidebar-bg);
}
.login-box {
  background: var(--card-bg); border-radius: 12px; padding: 40px 36px;
  width: 360px; box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-box h1 { font-size: 22px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.login-box p  { font-size: 13px; color: var(--text-muted); margin-bottom: 28px; }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); font-size: 14px; }
.empty-state .empty-icon { font-size: 36px; margin-bottom: 10px; }

/* ── Misc utilities ── */
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-muted   { color: var(--text-muted); }
.text-right   { text-align: right; }
.text-center  { text-align: center; }
.fw-bold      { font-weight: 700; }
.mono         { font-family: 'JetBrains Mono', monospace; font-size: 12px; }

/* ============================================================
   Blog-app-specific additions below
   ============================================================ */

/* Cost-preview chip on the writer view */
.cost-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 999px;
  background: #f1f5f9; color: var(--text);
  font-size: 13px; font-weight: 500;
  border: 1px solid var(--border); min-width: 220px;
}
.cost-chip[data-state="idle"]    { background: #f1f5f9; color: var(--text-muted); }
.cost-chip[data-state="cheap"]   { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.cost-chip[data-state="medium"]  { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.cost-chip[data-state="pricey"]  { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }

/* Final-prompt preview (collapsible <details>) */
.preview-prompt {
  margin-top: 18px; border: 1px dashed var(--border); border-radius: 8px;
  padding: 12px 16px;
}
.preview-prompt > summary {
  cursor: pointer; font-size: 13px; font-weight: 500;
  display: flex; gap: 8px; align-items: center; user-select: none;
}
.preview-prompt > summary::-webkit-details-marker { display: none; }
.prompt-debug {
  font-family: 'JetBrains Mono', monospace; font-size: 12px; line-height: 1.45;
  background: #0f172a; color: #e2e8f0; padding: 14px 16px;
  border-radius: 6px; margin: 10px 0; max-height: 360px;
  overflow: auto; white-space: pre-wrap; word-break: break-word;
}

/* Output panel rows — text on the left, copy button on the right */
.output-row {
  display: flex; gap: 12px; align-items: flex-start;
}
.output-blob {
  flex: 1; padding: 10px 12px; background: #f8fafc;
  border: 1px solid var(--border); border-radius: 7px;
  font-size: 14px; line-height: 1.55; white-space: pre-wrap;
}
.output-blob.td-mono { font-family: 'JetBrains Mono', monospace; font-size: 13px; }

/* Markdown rendered output */
.markdown-rendered {
  font-size: 15px; line-height: 1.7; color: var(--text);
}
.markdown-rendered h1,
.markdown-rendered h2,
.markdown-rendered h3 {
  font-weight: 700; margin: 22px 0 10px;
}
.markdown-rendered h1 { font-size: 22px; }
.markdown-rendered h2 { font-size: 18px; }
.markdown-rendered h3 { font-size: 16px; }
.markdown-rendered p { margin: 10px 0; }
.markdown-rendered ul,
.markdown-rendered ol { margin: 10px 0 10px 24px; }
.markdown-rendered li { margin: 4px 0; }
.markdown-rendered a { color: var(--primary); }
.markdown-rendered code {
  background: #f1f5f9; padding: 1px 5px; border-radius: 4px;
  font-family: 'JetBrains Mono', monospace; font-size: 13px;
}
.markdown-rendered pre {
  background: #0f172a; color: #e2e8f0;
  padding: 12px 14px; border-radius: 7px;
  overflow-x: auto; margin: 12px 0;
}
.markdown-rendered pre code { background: transparent; padding: 0; }
.markdown-rendered blockquote {
  border-left: 3px solid var(--primary); padding: 4px 12px;
  margin: 10px 0; color: var(--text-muted); background: #f8fafc;
}
.markdown-rendered table {
  width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 13px;
}
.markdown-rendered th,
.markdown-rendered td {
  border: 1px solid var(--border); padding: 7px 10px; text-align: left;
}

.raw-markdown {
  font-family: 'JetBrains Mono', monospace; font-size: 13px; line-height: 1.5;
  background: #f8fafc; padding: 12px 14px; border-radius: 7px;
  border: 1px solid var(--border);
  white-space: pre-wrap; word-break: break-word; max-height: 700px; overflow: auto;
}

/* Keyword density chip — sits in the body card header */
.density-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
}
.density-chip.green { background: #d1fae5; color: #065f46; }
.density-chip.amber { background: #fef3c7; color: #92400e; }
.density-chip.red   { background: #fee2e2; color: #991b1b; }

/* View toggle (rendered ↔ raw) */
.view-toggle.active {
  background: var(--primary); color: #fff; border-color: var(--primary);
}

/* Section-title label (used inside cards) */
.section-title {
  font-size: 13px; font-weight: 700; color: var(--text);
  text-transform: uppercase; letter-spacing: 0.05em;
  margin: 16px 0 10px;
}

/* Responsive */
@media (max-width: 640px) {
  .sidebar { width: 0; overflow: hidden; }
  .main    { margin-left: 0; }
}
