/* Ad Creatives — Studio + Gallery layout
 * Loaded by portal-layout.php after portal.css.
 *
 * Pulse uses multi-class buttons (`.btn.primary`) but the ad-creatives
 * views were written with BEM-style (`.btn-primary`). We alias the
 * BEM names to the Pulse base styles so existing markup works without
 * rewriting every view.
 */

/* ── Button aliases (BEM → Pulse multi-class) ──────────────────────────── */
.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(124,58,237,0.3); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #E5E7EB; }
.btn-ghost     { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: #D1D5DB; background: var(--surface2); }
.btn-danger    { background: #fdeceb; color: #d14a3a; border: 1px solid #f5c8c2; }
.btn-danger:hover { background: #fbd8d3; color: #b93b2c; }
.btn-link      { background: transparent; color: var(--accent); border: none; padding: 4px 0; text-decoration: underline; }
.btn-link:hover { color: var(--accent-dark); }
.btn-icon      { background: transparent; border: 1px solid var(--border); color: var(--muted); width: 28px; height: 28px; border-radius: 6px; cursor: pointer; }
.btn-icon:hover { background: var(--surface2); color: var(--text); }

/* ── Page-level container (shared across both views) ───────────────────── */
.portal-page { display: flex; flex-direction: column; gap: 24px; }
.portal-page .page-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.portal-page .page-header h1 { margin: 0; font-size: 24px; letter-spacing: -0.02em; font-weight: 700; }
.portal-page .page-actions { display: flex; align-items: center; gap: 8px; }
.portal-page .page-actions select { padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); min-width: 200px; }

/* ── Gallery (sessions grid) ───────────────────────────────────────────── */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.card-grid .card { display: block; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; text-decoration: none; color: inherit; transition: box-shadow 0.15s, transform 0.15s; }
.card-grid .card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.card-grid .card-title { font-weight: 700; margin-bottom: 4px; font-size: 14px; }
.card-grid .card-meta { font-size: 11px; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; }

/* ── Studio (three-column layout) ──────────────────────────────────────── */
.studio-grid { display: grid; grid-template-columns: 280px 1fr 320px; gap: 20px; align-items: flex-start; }
.studio-col { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px; }
.studio-col h3 { margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; }

@media (max-width: 1100px) {
  .studio-grid { grid-template-columns: 1fr; }
  /* Order: Brand config → Chat → History on stacked layout */
  .studio-col-brand  { order: 3; }
  .studio-col-chat   { order: 1; }
  .studio-col-history { order: 2; }
}

@media (max-width: 768px) {
  /* Studio columns: cap height so user can scroll within each panel */
  .studio-col-brand,
  .studio-col-history { max-height: 300px; overflow-y: auto; }
  /* Chat log taller on small screens for readability */
  .chat-log { max-height: 280px; }
  /* Session card grid: 1 column */
  .card-grid { grid-template-columns: 1fr; }
  /* Page header actions wrap */
  .portal-page .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .portal-page .page-actions { flex-wrap: wrap; }
  .portal-page .page-actions select { min-width: 0; width: 100%; }
}

/* Brand-Config column */
.studio-col-brand .kv { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.studio-col-brand .kv li { padding: 6px 0; border-bottom: 1px solid var(--border); }
.studio-col-brand .kv li:last-child { border-bottom: none; }
.studio-col-brand .kv strong { color: var(--muted); margin-right: 6px; font-weight: 600; }
.studio-col-brand a.btn-link { display: inline-block; margin-top: 10px; font-size: 13px; }

/* Chat column */
.studio-col-chat { display: flex; flex-direction: column; min-height: 420px; }
.chat-log { flex: 1; overflow-y: auto; min-height: 200px; max-height: 460px; padding: 4px; margin-bottom: 12px; }
.chat-log:empty::before { content: 'Beschreibe was du brauchst — die KI optimiert deinen Prompt für die Bildgenerierung.'; color: var(--muted); font-style: italic; font-size: 13px; }
.msg { padding: 10px 14px; margin-bottom: 10px; border-radius: 10px; font-size: 14px; line-height: 1.5; }
.msg-user { background: var(--accent); color: #fff; margin-left: 40px; }
.msg-assistant { background: var(--surface2); color: var(--text); margin-right: 40px; }
.msg-system { background: #fff8e1; color: #6b5d00; font-size: 12px; }
.msg-refined { margin-top: 8px; padding: 8px; background: rgba(0,0,0,0.06); border-radius: 6px; font-size: 12px; }
.msg-refined .label { color: var(--muted); font-weight: 600; margin-right: 4px; text-transform: uppercase; font-size: 10px; letter-spacing: 0.06em; }
.msg-refined code { word-break: break-word; }
.chat-form { display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--border); padding-top: 12px; }
.chat-form textarea { width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 10px; font-family: inherit; font-size: 14px; resize: vertical; box-sizing: border-box; }
.chat-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* History column */
.studio-col-history { max-height: 720px; overflow-y: auto; }
.history-gallery { display: flex; flex-direction: column; gap: 12px; }
.frame-card { border: 1px solid var(--border); border-radius: 10px; padding: 10px; background: var(--surface2); }
.frame-thumb { width: 100%; aspect-ratio: 1 / 1; background: #fff; border-radius: 8px; overflow: hidden; display: flex; align-items: center; justify-content: center; margin-bottom: 8px; }
.frame-thumb img { width: 100%; height: 100%; object-fit: cover; }
.frame-thumb .skeleton { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; }
.frame-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.frame-actions .btn, .frame-actions .btn-primary, .frame-actions .btn-ghost { padding: 4px 8px; font-size: 11px; }
.variant-row, .video-row { display: flex; gap: 4px; margin-top: 8px; flex-wrap: wrap; }
.video-row video { max-width: 100%; border-radius: 6px; }

/* Chips (variant/video status indicators) */
.chip { display: inline-block; padding: 2px 8px; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; border-radius: 999px; background: var(--surface2); color: var(--muted); border: 1px solid var(--border); }
.chip-pending { background: #fff8e1; color: #856404; border-color: #f0d770; }
.chip-ready   { background: #e6f7e6; color: #1f7d1f; border-color: #bdebbd; }
.chip-failed  { background: #fdeceb; color: #b93b2c; border-color: #f5c8c2; }
.chip-cancelable { cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.chip-cancelable:hover { opacity: .75; }
.chip-x { font-size: 12px; line-height: 1; font-weight: 700; opacity: .7; }

/* ── Admin / brand-config forms ────────────────────────────────────────── */
.admin-page, .brand-config-page { display: flex; flex-direction: column; gap: 20px; }
.admin-page h1, .brand-config-page h1 { margin: 0; font-size: 22px; }
.admin-page .muted, .brand-config-page .muted { color: var(--muted); font-size: 13px; margin: 0; }
.info-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 18px; }
.info-card h3 { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.info-card ul { margin: 0; padding-left: 18px; font-size: 13px; line-height: 1.7; }

.form-stack { display: flex; flex-direction: column; gap: 14px; }
.form-stack label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text); font-weight: 600; }
.form-stack input, .form-stack textarea { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-family: inherit; font-size: 14px; font-weight: 400; }
.form-stack button { align-self: flex-start; }

.data-table { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.data-table th, .data-table td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.data-table thead { background: var(--surface2); }
.data-table th { font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.data-table tbody tr:last-child td { border-bottom: none; }
