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

:root {
  --bg: #F5F6FA;
  --surface: #FFFFFF;
  --ink: #14171F;
  --ink-soft: #565B6B;
  --line: #E3E5EE;
  --accent: #5B5FEF;
  --accent-ink: #FFFFFF;
  --cta: #FF6F59;
  --cta-ink: #FFFFFF;
  --radius: 14px;
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-display); margin: 0; }

a { color: inherit; }

button {
  font-family: var(--font-body);
  font-weight: 600;
  border: none;
  border-radius: 10px;
  padding: 12px 20px;
  cursor: pointer;
  font-size: 0.95rem;
  transition: transform 0.08s ease, opacity 0.15s ease;
}
button:active { transform: scale(0.97); }
button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary { background: var(--cta); color: var(--cta-ink); }
.btn-primary:hover { opacity: 0.92; }
.btn-secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn-secondary:hover { background: var(--bg); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

input, textarea, select {
  width: 100%;
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 11px 13px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}
textarea { resize: vertical; min-height: 90px; }
label { font-size: 0.82rem; font-weight: 600; color: var(--ink-soft); display: block; margin-bottom: 6px; }

.field { margin-bottom: 16px; }

/* ---- Auth pages ---- */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px;
}
.auth-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}
.auth-card h1 { font-size: 1.5rem; margin: 6px 0 22px; }
.auth-error {
  background: #FFF1EF;
  color: #B3311D;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.85rem;
  margin-bottom: 14px;
  display: none;
}
.auth-error.visible { display: block; }
.auth-switch { margin-top: 18px; font-size: 0.85rem; color: var(--ink-soft); text-align: center; }
.auth-switch a { color: var(--accent); font-weight: 600; text-decoration: none; }

/* ---- Dashboard shell ---- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.brand { font-size: 1.05rem; margin-bottom: 26px; padding: 0 8px; }
.brand span { color: var(--accent); }
.nav-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--ink-soft);
  font-weight: 600;
  padding: 10px 12px;
  border-radius: 9px;
}
.nav-item:hover { background: var(--bg); color: var(--ink); }
.nav-item.active { background: var(--accent); color: var(--accent-ink); }
.sidebar-footer { margin-top: auto; }

.main { flex: 1; padding: 32px 40px; max-width: 1100px; }
.view { display: none; }
.view.active { display: block; }
.view-header { margin-bottom: 24px; }
.view-header h2 { font-size: 1.4rem; }
.view-header p { color: var(--ink-soft); margin: 6px 0 0; font-size: 0.9rem; }

/* ---- Content generator layout ---- */
.composer { display: grid; grid-template-columns: 380px 1fr; gap: 28px; align-items: start; }
.composer-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
}
.content-type-toggle { display: flex; gap: 8px; margin-bottom: 16px; }
.content-type-toggle button { flex: 1; background: var(--bg); color: var(--ink-soft); }
.content-type-toggle button.active { background: var(--accent); color: var(--accent-ink); }

.palette-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.palette-chip {
  border: 2px solid transparent;
  border-radius: 999px;
  padding: 4px;
  display: flex;
  gap: 3px;
  cursor: pointer;
  background: var(--bg);
}
.palette-chip.selected { border-color: var(--accent); }
.palette-chip .dot { width: 14px; height: 14px; border-radius: 50%; }
.palette-name { font-size: 0.72rem; color: var(--ink-soft); text-align: center; margin-top: 3px; }
.palette-item { text-align: center; }

/* Instagram-shaped preview frame — o "signature element" */
.canvas-wrap { display: flex; justify-content: center; }
.ig-frame {
  width: 340px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 20px 40px -20px rgba(20, 23, 31, 0.25);
}
.ig-frame.story { aspect-ratio: 9 / 16; }
.ig-frame .ig-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-bottom: 1px solid var(--line);
  font-size: 0.8rem; font-weight: 600;
}
.ig-frame .ig-avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); }
.ig-image {
  width: 100%; aspect-ratio: 1 / 1; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-soft); font-size: 0.8rem; text-align: center; padding: 12px;
}
.ig-frame.story .ig-image { aspect-ratio: auto; flex: 1; }
.ig-image img { width: 100%; height: 100%; object-fit: cover; }
.ig-caption { padding: 12px 14px; font-size: 0.85rem; line-height: 1.45; white-space: pre-wrap; }
.ig-hashtags { font-family: var(--font-mono); color: var(--accent); font-size: 0.78rem; padding: 0 14px 14px; }

.caption-edit { margin-top: 16px; }
.caption-edit textarea { min-height: 110px; }
.canvas-actions { display: flex; gap: 10px; justify-content: center; margin-top: 16px; }

.empty-canvas {
  width: 340px; aspect-ratio: 1/1; border: 1px dashed var(--line); border-radius: 22px;
  display: flex; align-items: center; justify-content: center; text-align: center;
  color: var(--ink-soft); font-size: 0.85rem; padding: 24px;
}

/* ---- History table ---- */
.history-list { display: flex; flex-direction: column; gap: 10px; }
.history-item {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.history-item .meta { font-size: 0.78rem; color: var(--ink-soft); }
.history-item .caption-preview { font-size: 0.88rem; margin-top: 4px; max-width: 520px; }
.badge {
  font-family: var(--font-mono); font-size: 0.7rem; text-transform: uppercase;
  padding: 3px 9px; border-radius: 999px; background: var(--bg); color: var(--ink-soft);
}
.badge.feed { color: var(--accent); }
.badge.story { color: var(--cta); }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px;
  font-size: 0.85rem; opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
}
.toast.visible { opacity: 1; }

@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; overflow-x: auto; }
  .sidebar-footer { margin-top: 0; }
  .composer { grid-template-columns: 1fr; }
}
