/* Empire State Design Platform: brand theme.
   Palette and type from the empirestate.co.za identity.
   Primary azure #20aada. Platform UI is all sans-serif (Manrope). */

:root {
  --es-azure: #20aada;
  --es-azure-bright: #0aa9dc;
  --es-azure-dark: #1d99c4;
  --es-ink: #1a1919;
  --es-ink-2: #262626;
  --es-grey: #bfbfbf;
  --es-grey-2: #666666;
  --es-line: #e6e5e5;
  --es-surface: #ffffff;
  --es-bg: #fafafa;
  --es-bg-2: #f2f2f2;
  --es-danger: #c0392b;

  --sans: "Manrope", system-ui, -apple-system, Segoe UI, sans-serif;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(26, 25, 25, 0.06), 0 8px 28px rgba(26, 25, 25, 0.08);
}

* { box-sizing: border-box; }

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

.muted { color: var(--es-grey-2); margin: 0.3rem 0 0; }
.logo { display: block; width: auto; }
.eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--es-azure);
  font-weight: 700;
  margin: 0 0 0.3rem;
}
.signin-card .eyebrow { text-align: center; }
.display {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 2.1rem;
  line-height: 1.05;
  margin: 0;
}

/* Buttons */
.btn {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.92rem;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.6rem 1.1rem;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn-primary { background: var(--es-azure); color: #fff; }
.btn-primary:hover { background: var(--es-azure-dark); }
.btn-ghost { background: transparent; color: var(--es-ink); border-color: var(--es-line); }
.btn-ghost:hover { background: var(--es-bg-2); }

.error { color: var(--es-danger); font-size: 0.88rem; margin: 0.2rem 0 0; }

/* Sign-in */
.signin-view {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.2rem;
  padding: 2rem 1rem;
  background:
    radial-gradient(900px 420px at 50% -8%, rgba(32, 170, 218, 0.10), transparent 62%),
    var(--es-bg);
}
.signin-card {
  width: 100%;
  max-width: 400px;
  background: var(--es-surface);
  border: 1px solid var(--es-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2.4rem 2.2rem 2.6rem;
}
.logo-signin { height: 46px; margin: 0 auto 1.6rem; }

.form { margin-top: 1.5rem; display: flex; flex-direction: column; gap: 0.9rem; }
.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field span { font-size: 0.82rem; font-weight: 600; color: var(--es-ink-2); }
.field input {
  font-family: var(--sans);
  font-size: 0.98rem;
  padding: 0.62rem 0.7rem;
  border: 1px solid var(--es-line);
  border-radius: 9px;
  background: #fff;
  color: var(--es-ink);
}
.field input:focus {
  outline: none;
  border-color: var(--es-azure);
  box-shadow: 0 0 0 3px rgba(32, 170, 218, 0.16);
}
.form .btn-primary { margin-top: 0.4rem; }
.footnote { font-size: 0.78rem; color: var(--es-grey); margin: 0; }

/* App shell: light top bar (logo is black, so the bar is light). */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 1.4rem;
  background: var(--es-surface);
  border-bottom: 1px solid var(--es-line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-brand { display: flex; align-items: center; gap: 0.8rem; }
.logo-topbar { height: 30px; }
.topbar-sep { width: 1px; height: 22px; background: var(--es-line); }
.topbar-title { font-family: var(--sans); font-size: 1.05rem; font-weight: 500; }
.topbar-user { display: flex; align-items: center; gap: 0.9rem; }
.user-label { font-size: 0.85rem; color: var(--es-grey-2); }

.main { max-width: 980px; margin: 0 auto; padding: 2.2rem 1.4rem 4rem; }
.main-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.4rem;
}
.section-title { font-family: var(--sans); font-weight: 700; font-size: 1.7rem; margin: 0; }
.create-form { display: flex; gap: 0.6rem; }
.create-form input {
  font-family: var(--sans);
  font-size: 0.95rem;
  padding: 0.58rem 0.7rem;
  border: 1px solid var(--es-line);
  border-radius: 9px;
  min-width: 240px;
}
.create-form input:focus {
  outline: none;
  border-color: var(--es-azure);
  box-shadow: 0 0 0 3px rgba(32, 170, 218, 0.16);
}

.projects { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.project-card {
  background: var(--es-surface);
  border: 1px solid var(--es-line);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  box-shadow: 0 1px 2px rgba(26, 25, 25, 0.04);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.project-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.project-card h3 { font-family: var(--sans); font-weight: 700; font-size: 1.2rem; margin: 0 0 0.3rem; }
.project-card .slug { font-size: 0.8rem; color: var(--es-grey-2); }
.project-meta { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.9rem; flex-wrap: wrap; }
.badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--es-bg-2);
  color: var(--es-ink-2);
}
.badge-draft { background: rgba(32, 170, 218, 0.12); color: var(--es-azure-dark); }
.badge-published { background: rgba(32, 170, 218, 0.16); color: var(--es-azure-dark); }
.project-date { font-size: 0.78rem; color: var(--es-grey); }
.empty { margin-top: 2rem; }

/* Buttons: smaller sizes */
.btn-sm { padding: 0.32rem 0.6rem; font-size: 0.8rem; border-radius: 8px; }
.btn-xs { padding: 0.2rem 0.5rem; font-size: 0.74rem; border-radius: 7px; }
.btn:disabled { opacity: 0.5; cursor: default; }

/* Project detail / authoring */
.back-btn { margin-bottom: 1rem; }
.detail-head { display: flex; align-items: center; gap: 0.8rem; margin-bottom: 1.2rem; }
.artifact-crumb { font-size: 0.85rem; }

/* Phases view: phase list + project brief side by side */
.phase-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); gap: 1.2rem; align-items: start; }
.brief-intro { margin: 0 0 0.8rem; font-size: 0.82rem; }
.phases, .artifacts { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0.9rem; }
.phase-card, .artifact-card {
  background: var(--es-surface);
  border: 1px solid var(--es-line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: 0 1px 2px rgba(26, 25, 25, 0.04);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
  cursor: pointer;
}
.phase-card:hover, .artifact-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.phase-card h4, .artifact-card h4 { font-family: var(--sans); font-weight: 700; font-size: 1.1rem; margin: 0 0 0.4rem; }
.artifact-card .slug { font-size: 0.78rem; color: var(--es-grey-2); }
.phase-card-meta { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.phase-count { font-size: 0.78rem; }

/* Phase status controls + badges */
.phase-controls { margin-bottom: 1.2rem; }
.field-inline { display: inline-flex; align-items: center; gap: 0.5rem; }
.field-inline span { font-size: 0.82rem; font-weight: 600; color: var(--es-ink-2); }
.select {
  font-family: var(--sans);
  font-size: 0.9rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--es-line);
  border-radius: 9px;
  background: #fff;
  color: var(--es-ink);
}
.select:focus { outline: none; border-color: var(--es-azure); box-shadow: 0 0 0 3px rgba(32, 170, 218, 0.16); }
.phase-status-authoring { background: rgba(32, 170, 218, 0.12); color: var(--es-azure-dark); }
.phase-status-internal_review { background: rgba(230, 162, 60, 0.18); color: #9a6a12; }
.phase-status-published { background: rgba(39, 174, 96, 0.16); color: #1e8449; }
.phase-status-signed_off { background: rgba(39, 174, 96, 0.24); color: #14613a; }

.phase-side { display: flex; flex-direction: column; gap: 1.2rem; }

/* Members panel */
.members { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.7rem; }
.member-row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; border: 1px solid var(--es-line); border-radius: 9px; padding: 0.5rem 0.6rem; }
.member-top { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.member-name { font-size: 0.86rem; font-weight: 600; }
.member-email { font-size: 0.74rem; color: var(--es-grey); margin-top: 0.15rem; }
.invite-form { display: flex; gap: 0.5rem; }
.invite-form input {
  flex: 1; min-width: 0;
  font-family: var(--sans); font-size: 0.88rem;
  padding: 0.45rem 0.6rem; border: 1px solid var(--es-line); border-radius: 9px;
}
.invite-form input:focus { outline: none; border-color: var(--es-azure); box-shadow: 0 0 0 3px rgba(32, 170, 218, 0.16); }

/* Users admin */
.user-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; }
.users-list { display: flex; flex-direction: column; gap: 0.6rem; }
.user-row {
  display: flex; align-items: center; gap: 0.7rem;
  background: var(--es-surface);
  border: 1px solid var(--es-line);
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem;
}
.user-row.inactive { opacity: 0.6; }
.user-main { flex: 1; min-width: 0; }
.user-name { font-size: 0.92rem; font-weight: 600; }
.user-email { font-size: 0.78rem; color: var(--es-grey-2); }
.user-role { flex-shrink: 0; }

@media (max-width: 900px) {
  .phase-layout { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .user-form-grid { grid-template-columns: 1fr; }
  .user-row { flex-wrap: wrap; }
}
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(320px, 1fr); gap: 1.2rem; align-items: start; }

.preview-col {
  position: sticky;
  top: 76px;
  border: 1px solid var(--es-line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
  box-shadow: var(--shadow);
}
.preview-bar {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.5rem 0.8rem;
  border-bottom: 1px solid var(--es-line);
  background: var(--es-bg);
}
.preview-label { font-weight: 600; font-size: 0.85rem; }
.preview-version { font-size: 0.78rem; color: var(--es-grey-2); }
.preview-spacer { flex: 1; }
.preview-stage { position: relative; }
.artifact-frame { width: 100%; height: 70vh; border: 0; background: #fff; display: block; }

/* Pin layer: a transparent overlay above the iframe. Inert until comment mode
   is on (then it captures the placement click); existing pins stay clickable. */
.pin-layer { position: absolute; inset: 0; pointer-events: none; }
.preview-stage.commenting .pin-layer { pointer-events: auto; cursor: crosshair; }
.preview-stage.commenting .artifact-frame { pointer-events: none; }

.pin {
  position: absolute;
  width: 24px; height: 24px;
  margin: -12px 0 0 -12px;
  border-radius: 999px 999px 999px 2px;
  background: var(--es-azure);
  color: #fff;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(26, 25, 25, 0.35);
  font-size: 0.74rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  pointer-events: auto;
  cursor: pointer;
  transition: transform 0.12s ease;
}
.pin:hover, .pin.active { transform: scale(1.18); }
.pin.pin-addressed { background: #1e8449; }
.pin.pin-declined { background: var(--es-grey-2); }
.pin.draft { background: var(--es-ink); }

.pin-composer {
  position: absolute;
  z-index: 5;
  width: 240px;
  background: var(--es-surface);
  border: 1px solid var(--es-line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 0.6rem;
}
.pin-text {
  width: 100%;
  font-family: var(--sans);
  font-size: 0.86rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--es-line);
  border-radius: 8px;
  resize: vertical;
}
.pin-text:focus { outline: none; border-color: var(--es-azure); box-shadow: 0 0 0 3px rgba(32, 170, 218, 0.16); }
.pin-composer-actions { display: flex; justify-content: flex-end; gap: 0.4rem; margin-top: 0.45rem; }
.comment-hint { font-size: 0.78rem; color: var(--es-azure-dark); margin: 0.4rem 0.2rem 0; }
.preview-bar #comment-toggle.active { background: var(--es-azure); color: #fff; border-color: var(--es-azure); }

/* Comments panel */
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.7rem; }
.panel-head .panel-title { margin: 0; }
.comments { display: flex; flex-direction: column; gap: 0.7rem; max-height: 380px; overflow-y: auto; }
.comment {
  border: 1px solid var(--es-line);
  border-radius: 9px;
  padding: 0.6rem 0.7rem;
  scroll-margin-top: 0.5rem;
}
.comment.active { border-color: var(--es-azure); box-shadow: 0 0 0 2px rgba(32, 170, 218, 0.18); }
.comment-top { display: flex; align-items: center; gap: 0.45rem; margin-bottom: 0.3rem; flex-wrap: wrap; }
.comment-num {
  width: 18px; height: 18px; flex-shrink: 0;
  border-radius: 999px 999px 999px 2px;
  background: var(--es-azure); color: #fff;
  font-size: 0.66rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.comment-author { font-size: 0.8rem; font-weight: 600; }
.comment-date { font-size: 0.72rem; color: var(--es-grey); margin-left: auto; }
.comment-body { font-size: 0.86rem; }
.comment-snippet { font-size: 0.74rem; color: var(--es-grey-2); margin-top: 0.25rem; font-style: italic; }
.comment-response {
  font-size: 0.82rem; color: var(--es-ink-2);
  background: rgba(39, 174, 96, 0.08);
  border-left: 2px solid #1e8449;
  border-radius: 4px;
  padding: 0.4rem 0.5rem; margin-top: 0.45rem;
}
.comment-note {
  font-size: 0.8rem; color: var(--es-grey-2);
  background: var(--es-bg-2); border-radius: 6px;
  padding: 0.35rem 0.5rem; margin-top: 0.4rem;
}
.comment-error { font-size: 0.78rem; color: var(--es-danger); margin-top: 0.35rem; white-space: pre-wrap; }
.comment-actions { display: flex; align-items: center; gap: 0.4rem; margin-top: 0.5rem; flex-wrap: wrap; }
.comment-resolve { display: flex; align-items: center; gap: 0.3rem; font-size: 0.78rem; color: var(--es-grey-2); margin-left: auto; cursor: pointer; }

.pill-submitted { background: rgba(32, 170, 218, 0.16); color: var(--es-azure-dark); }
.pill-approved { background: rgba(39, 174, 96, 0.16); color: #1e8449; }
.pill-declined { background: rgba(192, 57, 43, 0.12); color: var(--es-danger); }
.pill-addressed { background: rgba(39, 174, 96, 0.16); color: #1e8449; }
.pill-pending { background: var(--es-bg-2); color: var(--es-grey-2); }
.pill-resolved { background: rgba(39, 174, 96, 0.2); color: #1e8449; }

.work-col { display: flex; flex-direction: column; gap: 1rem; }
.panel {
  background: var(--es-surface);
  border: 1px solid var(--es-line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}
.panel-title { font-family: var(--sans); font-size: 1.05rem; font-weight: 700; margin: 0 0 0.7rem; }

.prompt-input, .brief-input {
  width: 100%;
  font-family: var(--sans);
  font-size: 0.92rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--es-line);
  border-radius: 9px;
  resize: vertical;
  color: var(--es-ink);
}
.prompt-input:focus, .brief-input:focus {
  outline: none; border-color: var(--es-azure);
  box-shadow: 0 0 0 3px rgba(32, 170, 218, 0.16);
}
.composer-actions { display: flex; align-items: center; justify-content: flex-end; gap: 0.8rem; margin-top: 0.6rem; }
.pending { font-size: 0.82rem; }

/* Turns */
.turns { display: flex; flex-direction: column; gap: 0.7rem; max-height: 320px; overflow-y: auto; }
.turn { border: 1px solid var(--es-line); border-radius: 9px; padding: 0.6rem 0.7rem; }
.turn-head { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.35rem; }
.turn-date { font-size: 0.74rem; color: var(--es-grey); }
.turn-prompt { font-size: 0.86rem; font-weight: 600; }
.turn-summary { font-size: 0.84rem; color: var(--es-grey-2); margin-top: 0.3rem; }
.turn-error { font-size: 0.82rem; color: var(--es-danger); margin-top: 0.3rem; white-space: pre-wrap; }

.pill { font-size: 0.7rem; font-weight: 700; padding: 0.12rem 0.45rem; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.03em; }
.pill-queued { background: var(--es-bg-2); color: var(--es-grey-2); }
.pill-running { background: rgba(32, 170, 218, 0.16); color: var(--es-azure-dark); }
.pill-done { background: rgba(39, 174, 96, 0.16); color: #1e8449; }
.pill-error { background: rgba(192, 57, 43, 0.12); color: var(--es-danger); }

/* Brief */
.field + .field { margin-top: 0.7rem; }
.brief-files { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.6rem 0; }
.file-chip { font-size: 0.76rem; background: var(--es-bg-2); border-radius: 999px; padding: 0.18rem 0.55rem; }
.brief-actions { display: flex; gap: 0.5rem; margin-top: 0.7rem; }
.file-label { cursor: pointer; }
.brief-msg { font-size: 0.8rem; margin-top: 0.5rem; }
.brief-intro { font-size: 0.82rem; margin: 0 0 0.8rem; }

/* Create-project panel */
.create-panel { margin-bottom: 1.4rem; max-width: 640px; }
.create-panel .field + .field { margin-top: 0.7rem; }
.create-actions { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 1rem; }

/* Colour inputs with a live swatch */
.colour-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; margin-top: 0.7rem; }
.colour-row { display: flex; align-items: center; gap: 0.5rem; }
.colour-input {
  font-family: var(--sans);
  font-size: 0.92rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--es-line);
  border-radius: 9px;
  width: 100%;
}
.colour-input:focus { outline: none; border-color: var(--es-azure); box-shadow: 0 0 0 3px rgba(32, 170, 218, 0.16); }
.swatch {
  width: 24px; height: 24px; flex-shrink: 0;
  border-radius: 6px;
  border: 1px solid var(--es-line);
  background-image: linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%), linear-gradient(45deg, #eee 25%, #fff 25%, #fff 75%, #eee 75%);
  background-size: 10px 10px;
  background-position: 0 0, 5px 5px;
}

/* Categorised brand-input uploads */
.upload-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; margin-top: 0.8rem; }
.upload-slot { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.82rem; font-weight: 600; color: var(--es-ink-2); }
.upload-slot input[type="file"] { font-size: 0.8rem; font-weight: 400; }
.brief-assets-label { font-size: 0.82rem; font-weight: 600; color: var(--es-ink-2); margin: 0.9rem 0 0.4rem; }
.brief-assets { display: flex; flex-direction: column; gap: 0.35rem; }
.asset-row { display: flex; align-items: center; gap: 0.5rem; }
.asset-label { font-size: 0.8rem; font-weight: 600; width: 38%; flex-shrink: 0; }
.asset-file { font-size: 0.78rem; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 560px) {
  .colour-fields, .upload-fields { grid-template-columns: 1fr; }
}

/* Versions */
.versions { display: flex; flex-direction: column; gap: 0.5rem; max-height: 300px; overflow-y: auto; }
.version { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; border: 1px solid var(--es-line); border-radius: 9px; padding: 0.5rem 0.6rem; }
.version-msg { font-size: 0.85rem; font-weight: 600; }
.version-meta { font-size: 0.74rem; color: var(--es-grey); margin-top: 0.15rem; }
.version-actions { display: flex; gap: 0.35rem; flex-shrink: 0; }

@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; }
  .preview-col { position: static; }
  .artifact-frame { height: 56vh; }
}
@media (max-width: 560px) {
  .create-form { width: 100%; }
  .create-form input { flex: 1; min-width: 0; }
  .topbar-title { display: none; }
  .topbar-sep { display: none; }
}
