/* ── Newsletter Platform — Design System ──────────────────────────────────── */

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

:root {
  /* Paleta główna — głęboki indigo z subtelnymi akcentami */
  --bg:           #0b1020;
  --surface:      #ffffff;
  --surface-2:    #f8fafc;
  --surface-3:    #f1f5f9;
  --border:       #e2e8f0;
  --border-2:     #cbd5e1;

  --text:         #0f172a;
  --text-2:       #475569;
  --text-3:       #94a3b8;

  --primary:      #6366f1;
  --primary-2:    #4f46e5;
  --primary-soft: #eef2ff;

  --success:      #10b981;
  --success-soft: #ecfdf5;
  --danger:       #ef4444;
  --danger-soft:  #fef2f2;
  --warning:      #f59e0b;
  --warning-soft: #fffbeb;
  --info:         #0ea5e9;
  --info-soft:    #f0f9ff;

  --shadow-sm:    0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow:       0 4px 12px -2px rgba(15, 23, 42, 0.08), 0 2px 4px -1px rgba(15, 23, 42, 0.04);
  --shadow-lg:    0 20px 40px -12px rgba(15, 23, 42, 0.18);
  --shadow-glow:  0 0 0 4px rgba(99, 102, 241, 0.18);

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;

  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

html { font-family: var(--font-sans); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body { margin: 0; background: var(--surface-2); color: var(--text); font-family: var(--font-sans); line-height: 1.5; }

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  width: 260px;
  background: linear-gradient(180deg, #0b1020 0%, #111733 100%);
  display: flex; flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid rgba(255,255,255,0.05);
}
.sidebar-brand {
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  display: flex; align-items: center; gap: 12px;
}
.sidebar-logo {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 20px -8px rgba(99, 102, 241, 0.6);
}
.sidebar-title { color: white; font-size: 14px; font-weight: 700; letter-spacing: -0.01em; }
.sidebar-subtitle { color: #94a3b8; font-size: 11px; margin-top: 2px; }
.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.sidebar-divider { padding: 16px 12px 6px; color: #64748b; font-size: 10px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.sidebar-link {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px;
  border-radius: 8px;
  color: #cbd5e1;
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  transition: all 150ms ease;
}
.sidebar-link:hover { background: rgba(255,255,255,0.05); color: white; }
.sidebar-link.active {
  background: linear-gradient(135deg, rgba(99,102,241,0.18), rgba(139,92,246,0.12));
  color: white;
  box-shadow: inset 0 0 0 1px rgba(99,102,241,0.3);
}
.sidebar-link svg { width: 16px; height: 16px; opacity: 0.85; flex-shrink: 0; }
.sidebar-footer { padding: 12px; border-top: 1px solid rgba(255,255,255,0.07); }
.sidebar-logout {
  width: 100%;
  background: transparent;
  border: 0;
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px;
  border-radius: 8px;
  color: #94a3b8;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: all 150ms ease;
}
.sidebar-logout:hover { background: rgba(239,68,68,0.1); color: #fca5a5; }

/* ── Layout ──────────────────────────────────────────────────────────────── */
.app-shell { display: flex; height: 100vh; overflow: hidden; }
.app-main  { flex: 1; overflow-y: auto; }
.app-content { max-width: 1100px; margin: 0 auto; padding: 32px 28px; }
.app-content-narrow { max-width: 760px; margin: 0 auto; padding: 32px 28px; }

.page-header { margin-bottom: 28px; }
.page-title { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); margin: 0; }
.page-subtitle { font-size: 14px; color: var(--text-2); margin-top: 4px; }

/* ── Card ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-pad   { padding: 24px; }
.card-pad-sm{ padding: 16px; }
.card-header { padding: 20px 24px; border-bottom: 1px solid var(--border); }
.card-title { font-size: 15px; font-weight: 600; color: var(--text); margin: 0; }
.card-stack > * + * { margin-top: 16px; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-row    { display: flex; flex-direction: column; gap: 8px; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.label { font-size: 13px; font-weight: 600; color: var(--text); }
.label-help { font-size: 12px; color: var(--text-3); margin-top: 4px; line-height: 1.4; }

.input, .select, .textarea {
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  color: var(--text);
  transition: all 150ms ease;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--shadow-glow);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
.select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; appearance: none; }

.checkbox-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 150ms ease;
}
.checkbox-row:hover { background: var(--primary-soft); border-color: var(--primary); }
.checkbox-row input { accent-color: var(--primary); width: 16px; height: 16px; }
.checkbox-row-text { display: flex; flex-direction: column; gap: 1px; }
.checkbox-row-label { font-size: 13.5px; font-weight: 500; color: var(--text); }
.checkbox-row-help  { font-size: 11.5px; color: var(--text-3); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 150ms ease;
  text-decoration: none;
  white-space: nowrap;
}
.btn:disabled { cursor: not-allowed; opacity: 0.6; }
.btn svg { width: 14px; height: 14px; }

.btn-primary {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: white;
  box-shadow: 0 4px 12px -4px rgba(99,102,241,0.5);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 8px 20px -6px rgba(99,102,241,0.6); transform: translateY(-1px); }
.btn-primary:disabled { background: var(--border-2); }

.btn-ghost {
  background: var(--surface);
  border-color: var(--border-2);
  color: var(--text);
}
.btn-ghost:hover { background: var(--surface-3); border-color: var(--text-3); }

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: rgba(239,68,68,0.2);
}
.btn-danger:hover { background: var(--danger); color: white; }

.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-lg { padding: 12px 22px; font-size: 14px; }
.btn-block { width: 100%; }

/* ── Badge ───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 999px;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger); }
.badge-warning { background: var(--warning-soft); color: #b45309; }
.badge-info    { background: var(--info-soft);    color: var(--info); }
.badge-neutral { background: var(--surface-3);    color: var(--text-2); }
.badge-primary { background: var(--primary-soft); color: var(--primary-2); }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ── Stats card (dashboard) ──────────────────────────────────────────────── */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), #8b5cf6);
}
.stat-label { font-size: 12px; color: var(--text-2); font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text); margin-top: 6px; letter-spacing: -0.02em; line-height: 1.1; }
.stat-meta  { font-size: 12.5px; color: var(--text-3); margin-top: 4px; }

/* ── Table ───────────────────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 12px 16px; text-align: left; }
.table th {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.table td { border-bottom: 1px solid var(--border); font-size: 13.5px; color: var(--text); }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: var(--primary-soft); }

/* ── Toast ───────────────────────────────────────────────────────────────── */
.toast-stack { position: fixed; bottom: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; max-width: 360px; }
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 12px 16px;
  display: flex; align-items: flex-start; gap: 10px;
  font-size: 13.5px;
  color: var(--text);
  animation: toast-in 220ms ease-out;
}
.toast-success { border-left-color: var(--success); }
.toast-error   { border-left-color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }
.toast-icon { flex-shrink: 0; width: 18px; height: 18px; }
.toast-success .toast-icon { color: var(--success); }
.toast-error   .toast-icon { color: var(--danger); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info    .toast-icon { color: var(--primary); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ── Spinner ─────────────────────────────────────────────────────────────── */
.spinner {
  width: 16px; height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 600ms linear infinite;
  display: inline-block;
}
.spinner-lg { width: 28px; height: 28px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 56px 24px; color: var(--text-2); }
.empty-state-icon { width: 56px; height: 56px; margin: 0 auto 16px; color: var(--text-3); opacity: 0.6; }
.empty-state-title { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty-state-text  { font-size: 13.5px; }

/* ── Progress steps (generate.html) ──────────────────────────────────────── */
.step-row { display: flex; align-items: center; gap: 14px; padding: 8px 0; }
.step-dot {
  width: 22px; height: 22px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: var(--surface-3);
  color: var(--text-3);
  transition: all 200ms ease;
}
.step-dot.done    { background: var(--success-soft); color: var(--success); }
.step-dot.active  { background: var(--primary-soft); color: var(--primary); }
.step-dot.active::after { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); animation: pulse 1.4s ease-in-out infinite; }
.step-label        { font-size: 13.5px; color: var(--text-3); transition: all 200ms ease; }
.step-label.done   { color: var(--text-3); text-decoration: line-through; }
.step-label.active { color: var(--text); font-weight: 600; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ── Warning card (Figma issues) ─────────────────────────────────────────── */
.warning-stack > * + * { margin-top: 10px; }
.warning-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--warning);
  border-radius: var(--radius);
  padding: 14px 16px;
  transition: all 150ms ease;
}
.warning-card.severity-critical { border-left-color: var(--danger); }
.warning-card.severity-info     { border-left-color: var(--info); }
.warning-card-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.warning-card-title { font-size: 13.5px; font-weight: 600; color: var(--text); }
.warning-card-meta { font-size: 11px; color: var(--text-3); font-family: var(--font-mono); }
.warning-card-message { font-size: 13px; color: var(--text-2); line-height: 1.5; }
.warning-card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
.warning-card-link {
  font-size: 12px; color: var(--primary-2); text-decoration: none;
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  background: var(--primary-soft);
  border-radius: 999px;
  transition: all 150ms ease;
}
.warning-card-link:hover { background: var(--primary); color: white; }
.warning-card-detail {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.5;
}
.warning-card-detail strong { color: var(--text); font-weight: 600; }

/* ── Chat (refine) ───────────────────────────────────────────────────────── */
.chat-stack > * + * { margin-top: 8px; }
.chat-bubble {
  max-width: 80%;
  padding: 10px 14px;
  font-size: 13.5px;
  line-height: 1.5;
  border-radius: 14px;
}
.chat-user {
  margin-left: auto;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: white;
  border-bottom-right-radius: 4px;
}
.chat-bot {
  background: var(--surface-3);
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.chat-thumb { display: block; max-width: 80px; max-height: 80px; border-radius: 8px; margin-bottom: 6px; border: 2px solid white; }

/* ── Misc helpers ────────────────────────────────────────────────────────── */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.hidden { display: none !important; }
.text-mono { font-family: var(--font-mono); }
.text-muted { color: var(--text-2); }
.text-faint { color: var(--text-3); }
.text-xs { font-size: 12px; } .text-sm { font-size: 13px; } .text-md { font-size: 14px; }
.font-semibold { font-weight: 600; }

/* ── Login page ──────────────────────────────────────────────────────────── */
.login-shell {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 30% 20%, rgba(99,102,241,0.12), transparent 40%),
              radial-gradient(circle at 70% 80%, rgba(139,92,246,0.10), transparent 40%),
              var(--surface-2);
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 32px;
}
.login-logo {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
  box-shadow: 0 12px 28px -10px rgba(99,102,241,0.5);
}

/* ── Animations ──────────────────────────────────────────────────────────── */
.fade-in { animation: fade-in 200ms ease-out; }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
