/* The look of every page. UI-U1-VISUAL-LAYOUT (docs/UI-U1-VISUAL-LAYOUT-build-plan-V0-1.md).
   Served by web/static_assets.py. Nothing from outside: the page policy allows only
   this app's own stylesheet and font. Starting point: docs/design/mockups/source/app.css.
   Elements that tests pin keep their bare markup, so many rules use element selectors. */

@font-face {
  font-family: "Manrope";
  src: url("/static/fonts/manrope.ttf") format("truetype");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --navy: #102A4C;
  --teal: #10B981;
  --steel: #475569;
  --paper: #F8FAFC;
  --line: #E2E8F0;
  --muted: #64748B;
  --white: #FFFFFF;
  --amber-bg: #FEF3C7;
  --amber-ink: #92400E;
  --green-bg: #D1FAE5;
  --green-ink: #065F46;
  --red-bg: #FEE2E2;
  --red-ink: #991B1B;
  --radius: 10px;
}

/* One colour per stream, picked by name (web/presentation.py). Distinct from each other and
   from the brand colours. */
.tone-a { --tone: #3B82F6; }
.tone-b { --tone: #F97316; }
.tone-c { --tone: #8B5CF6; }
.tone-d { --tone: #EC4899; }
.tone-e { --tone: #EAB308; }
.tone-f { --tone: #84CC16; }
.tone-g { --tone: #EF4444; }
.tone-h { --tone: #0EA5E9; }

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Manrope", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--navy);
  background: var(--paper);
}

a { color: var(--teal); }
a:hover { color: var(--navy); }
:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; border-radius: 4px; }

h1 { font-size: 24px; line-height: 1.25; margin: 0 0 4px; }
h2 { font-size: 18px; margin: 28px 0 8px; }
h3 { font-size: 15px; margin: 16px 0 6px; }
p { margin: 0 0 10px; }
ul { margin: 0 0 10px; padding-left: 20px; }
pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 0 0 10px;
}
code { font-size: 13px; background: var(--paper); padding: 1px 5px; border-radius: 4px; }

/* ---- Top bar ------------------------------------------------------------------------ */

.topbar {
  display: flex;
  align-items: center;
  gap: 28px;
  min-height: 58px;
  padding: 0 28px;
  background: var(--white);
  border-bottom: 1px solid var(--line);
}
.topbar .brand { font-weight: 800; font-size: 18px; letter-spacing: 0.2px; }
.topbar nav { display: flex; gap: 22px; align-self: stretch; }
.topbar nav a {
  display: flex;
  align-items: center;
  color: var(--steel);
  text-decoration: none;
  font-weight: 500;
  border-bottom: 2px solid transparent;
}
.topbar nav a:hover { color: var(--navy); }
.topbar nav a[aria-current="page"] {
  color: var(--navy);
  font-weight: 700;
  border-bottom-color: var(--teal);
}
.topbar .who { margin-left: auto; display: flex; align-items: center; gap: 10px; color: var(--steel); }
.topbar .avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--navy);
  color: var(--white);
  font-size: 12px;
  font-weight: 700;
}

/* ---- Page area ---------------------------------------------------------------------- */

body.app main { max-width: 1240px; margin: 0 auto; padding: 24px 28px 56px; }
/* The "Your workspaces > name" line that sits above the heading. */
body.app main > p:first-child { font-size: 13px; color: var(--muted); margin-bottom: 14px; }
body.app main > p:first-child a { color: var(--steel); }
/* The one sentence under a heading. */
main > h1 + p { color: var(--muted); margin-bottom: 18px; max-width: 70ch; }

.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin: 0 0 18px;
}
.card > :last-child { margin-bottom: 0; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card h2 { padding-top: 18px; border-top: 1px solid var(--line); }
.card h2:first-child { padding-top: 0; border-top: 0; }
.card.flush { padding: 0; overflow: hidden; }
.muted { color: var(--muted); }

/* A notice or a refusal. */
[role="status"], [role="alert"] {
  padding: 9px 13px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--green-bg);
  color: var(--green-ink);
}
[role="alert"] { background: var(--red-bg); color: var(--red-ink); border-color: var(--red-bg); }

/* Tables live inside cards. */
table { width: 100%; border-collapse: collapse; margin: 0 0 10px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); font-weight: 700; }
tbody tr:last-child td { border-bottom: 0; }

/* ---- Forms and buttons -------------------------------------------------------------- */

label { font-weight: 600; font-size: 13px; color: var(--steel); }
input[type="text"], input[type="email"], input[type="password"], input[type="url"],
input[type="number"], input[type="time"], input[type="file"], select, textarea {
  font: inherit;
  color: var(--navy);
  background: var(--white);
  border: 1px solid #CBD5E1;
  border-radius: 8px;
  padding: 8px 11px;
  max-width: 100%;
  margin-top: 4px;
  font-weight: 400;
}
textarea { width: 100%; }
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--teal); }

button {
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  padding: 8px 15px;
  border-radius: 8px;
  border: 1px solid #CBD5E1;
  background: var(--white);
  color: var(--navy);
}
button:hover { border-color: var(--navy); }
/* One primary button per screen: approving, generating, or the only action on a card page.
   A refusal is a plain text link, not a button. */
form[action$="/approve"] button,
form[action$="/generate"] button,
body.plain form button {
  background: var(--navy);
  border-color: var(--navy);
  color: var(--white);
}
form[action$="/reject"] button {
  border: 0;
  background: none;
  padding: 0;
  font-weight: 600;
  color: var(--muted);
  text-decoration: underline;
}
form[action$="/reject"] button:hover { color: var(--red-ink); }

/* ---- Pills and badges --------------------------------------------------------------- */

.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 700;
  background: var(--line);
  color: var(--steel);
}
.pill-wait { background: var(--amber-bg); color: var(--amber-ink); }
.pill-ok { background: var(--green-bg); color: var(--green-ink); }
.pill-bad { background: var(--red-bg); color: var(--red-ink); }

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--tone, var(--muted));
  margin-right: 7px;
}

/* Channel badges: the letters come from the style sheet, not the page. */
.ch {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 4px;
  margin-right: 7px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 800;
  color: var(--white);
  background: var(--steel);
  vertical-align: middle;
}
.ch-facebook { background: #3B5EA8; }
.ch-facebook::before { content: "f"; content: "f" / ""; }
.ch-instagram { background: #B4458A; }
.ch-instagram::before { content: "ig"; content: "ig" / ""; }
.ch-linkedin { background: #2A6FA8; }
.ch-linkedin::before { content: "in"; content: "in" / ""; }
.ch-pinterest { background: #B8333A; }
.ch-pinterest::before { content: "P"; content: "P" / ""; }
.ch-tiktok { background: #111827; }
.ch-tiktok::before { content: "tt"; content: "tt" / ""; }
.ch-other::before { content: "?"; content: "?" / ""; }

/* ---- Signed-out and single-purpose pages: a centred card ----------------------------- */

body.plain main {
  max-width: 440px;
  margin: 8vh auto 40px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px 30px;
}
body.plain main > h1 { margin-bottom: 14px; }
body.plain.wide main { max-width: 760px; }
body.plain input[type="text"], body.plain input[type="email"], body.plain input[type="password"] {
  width: 100%;
}

/* ---- Approval screen ---------------------------------------------------------------- */

.with-list { display: grid; grid-template-columns: 270px 1fr; gap: 22px; align-items: start; }
.post-list { position: sticky; top: 16px; }
.post-list a {
  display: block;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  border-left: 4px solid var(--tone, var(--line));
  color: var(--navy);
  text-decoration: none;
  font-weight: 600;
}
.post-list a:last-child { border-bottom: 0; }
.post-list a:hover { background: var(--paper); }
.post-list .pill { margin-top: 2px; }

.posts section {
  display: grid;
  grid-template-columns: minmax(240px, 330px) 1fr;
  grid-template-areas:
    "head head"
    "media channels";
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin: 0 0 18px;
  overflow: hidden;
}
.post-head {
  grid-area: head;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 14px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  border-left: 4px solid var(--tone, var(--line));
}
.post-head h2 { margin: 0; font-size: 18px; }
.post-head p { margin: 0; color: var(--muted); }
.post-media { grid-area: media; padding: 18px; border-right: 1px solid var(--line); background: var(--paper); }
.post-media img { max-width: 100%; height: auto; border-radius: 8px; display: block; }
.post-channels { grid-area: channels; padding: 18px 22px; min-width: 0; }
.post-channels h3 {
  display: inline-block;
  margin: 0 0 10px;
  padding: 6px 12px 7px 0;
  border-bottom: 2px solid var(--teal);
}
.post-channels textarea, .post-channels input[type="text"] { width: 100%; }
.post-actions { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.post-actions form { margin-bottom: 8px; }
.post-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.box { background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 0 0 12px; font-size: 13px; }
.box > :last-child { margin-bottom: 0; }

/* ---- Calendar ----------------------------------------------------------------------- */

.entry {
  border: 1px solid var(--line);
  border-left: 4px solid var(--tone, var(--line));
  border-radius: 8px;
  padding: 10px 14px;
  margin: 0 0 10px;
  background: var(--white);
}
.entry p { margin: 0 0 6px; }
body.app main > section { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; margin: 0 0 14px; }
body.app main > section > h3:first-child { margin-top: 0; }

/* ---- Small screens ------------------------------------------------------------------ */

@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; gap: 8px 18px; padding: 8px 16px; }
  body.app main { padding: 16px; }
  .with-list { grid-template-columns: 1fr; }
  .post-list { position: static; }
  .posts section { grid-template-columns: 1fr; grid-template-areas: "head" "media" "channels"; }
  .post-media { border-right: 0; border-bottom: 1px solid var(--line); }
}
