/* =========================================================================
   TFTTQ admin + auth styles. Loaded after style.css, so the brand tokens,
   reset and .btn styles are already available. Light working surface for
   comfortable writing, navy chrome, orange accents.
   ========================================================================= */

body.admin { background: var(--light); }

/* ---- Top bar ------------------------------------------------------------ */
.admin-bar {
  background: var(--navy);
  border-bottom: 1px solid var(--line-dark);
  position: sticky;
  top: 0;
  z-index: 30;
}
.admin-bar__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 64px;
}
.admin-bar__brand { display: flex; align-items: center; gap: 12px; }
.admin-bar__mark { height: 30px; width: auto; display: block; }
.admin-bar__tag {
  font-family: var(--f-mono);
  font-size: 12px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--orange);
}
.admin-bar__right { display: flex; align-items: center; gap: 16px; }
.admin-bar__user { font-family: var(--f-mono); font-size: 12px; color: rgba(255,255,255,.6); }
.admin-bar__link {
  font-family: var(--f-sub);
  font-weight: 500;
  font-size: 14px;
  color: rgba(255,255,255,.8);
}
.admin-bar__link:hover { color: #fff; }

.admin-main { padding: 40px 0 80px; }

/* ---- Flash / notices ---------------------------------------------------- */
.flash {
  font-family: var(--f-body);
  font-size: 14px;
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 24px;
}
.flash--ok { background: rgba(34,197,94,.12); border: 1px solid rgba(34,197,94,.4); color: #15803D; }
.flash--err { background: rgba(220,38,38,.1); border: 1px solid rgba(220,38,38,.35); color: #B91C1C; }

/* ---- List --------------------------------------------------------------- */
.admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.admin-head__title { font-family: var(--f-display); font-size: clamp(34px, 5vw, 50px); letter-spacing: .01em; text-transform: uppercase; color: var(--navy); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.filter {
  font-family: var(--f-sub);
  font-weight: 600;
  font-size: 13px;
  color: var(--slate);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 100px;
  padding: 8px 16px;
}
.filter:hover { border-color: var(--line-strong); }
.filter.is-active { background: var(--navy); border-color: var(--navy); color: #fff; }
.filter__count { opacity: .6; margin-left: 4px; }

.alist { display: flex; flex-direction: column; gap: 10px; }
.arow {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
}
.arow__main { min-width: 0; }
.arow__title { font-family: var(--f-sub); font-weight: 600; font-size: 16px; color: var(--navy); text-decoration: none; }
.arow__title:hover { color: var(--link-ink); }
.arow__meta { font-family: var(--f-mono); font-size: 11px; color: var(--slate); margin-top: 4px; }
.arow__actions { display: flex; gap: 8px; align-items: center; }

.badge {
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 100px;
  white-space: nowrap;
}
.badge--draft { background: #EEF1F6; color: #475569; border: 1px solid var(--line); }
.badge--scheduled { background: rgba(255,138,0,.14); color: #B45309; border: 1px solid rgba(255,138,0,.35); }
.badge--published { background: rgba(34,197,94,.14); color: #15803D; border: 1px solid rgba(34,197,94,.35); }

.linkbtn {
  font-family: var(--f-sub);
  font-weight: 600;
  font-size: 13px;
  color: var(--navy);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 8px 12px;
  background: #fff;
  cursor: pointer;
}
.linkbtn:hover { border-color: var(--navy); }
.linkbtn--danger { color: #B91C1C; border-color: rgba(220,38,38,.4); }
.linkbtn--danger:hover { border-color: #B91C1C; background: rgba(220,38,38,.06); }

/* ---- Editor ------------------------------------------------------------- */
.editor-grid { display: grid; grid-template-columns: 1fr 320px; gap: 28px; align-items: start; }
.editor-main { display: flex; flex-direction: column; gap: 18px; }
.card-panel { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 22px; }
.editor-side { display: flex; flex-direction: column; gap: 18px; position: sticky; top: 88px; }

.field { display: flex; flex-direction: column; gap: 7px; }
.field + .field { margin-top: 16px; }
.field__label { font-family: var(--f-sub); font-weight: 600; font-size: 13px; color: var(--navy); }
.field__hint { font-family: var(--f-body); font-size: 12px; color: var(--slate); }
.input, .textarea, .select {
  font-family: var(--f-body);
  font-size: 15px;
  color: var(--navy);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 11px 13px;
  width: 100%;
}
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--orange); }
.textarea { resize: vertical; line-height: 1.6; }
.textarea--body { min-height: 460px; font-family: var(--f-mono); font-size: 14px; }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.toolbar__status { font-family: var(--f-mono); font-size: 12px; color: var(--slate); }

.imgbox { display: flex; flex-direction: column; gap: 10px; }
.imgbox__preview {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--navy) center/cover no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
}
.imgbox__placeholder { font-family: var(--f-mono); font-size: 12px; color: rgba(255,255,255,.5); }
.imgbox__row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.side-title { font-family: var(--f-sub); font-weight: 700; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; color: var(--navy); margin-bottom: 14px; }
.radio { display: flex; align-items: flex-start; gap: 10px; padding: 9px 0; cursor: pointer; }
.radio input { margin-top: 3px; }
.radio__label { font-family: var(--f-body); font-size: 14px; color: var(--navy); }
.radio__hint { font-family: var(--f-body); font-size: 12px; color: var(--slate); }
.schedule { margin: 6px 0 4px 28px; }
.side-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }

input[type="file"] { font-family: var(--f-body); font-size: 13px; color: var(--slate); }
.checkline { display: flex; align-items: center; gap: 8px; font-family: var(--f-body); font-size: 13px; color: var(--slate); }

/* ---- Auth / login ------------------------------------------------------- */
body.auth {
  background: var(--navy);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--navy-700);
  border: 1px solid var(--line-dark);
  border-radius: 18px;
  padding: 36px 32px;
}
.auth-brand { display: flex; justify-content: center; margin-bottom: 18px; }
.auth-brand svg { height: 40px; width: auto; }
.auth-title { font-family: var(--f-display); font-size: 34px; letter-spacing: .01em; text-transform: uppercase; color: #fff; text-align: center; }
.auth-sub { font-family: var(--f-body); font-size: 14px; color: rgba(255,255,255,.6); text-align: center; margin: 6px 0 24px; }

.auth-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.auth-field label { font-family: var(--f-sub); font-weight: 500; font-size: 13px; color: rgba(255,255,255,.8); }
.auth-input {
  font-family: var(--f-body);
  font-size: 15px;
  color: #fff;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--line-dark);
  border-radius: 9px;
  padding: 12px 14px;
}
.auth-input::placeholder { color: rgba(255,255,255,.4); }
.auth-input:focus { outline: none; border-color: var(--orange); background: rgba(255,255,255,.09); }
.auth-submit { width: 100%; margin-top: 6px; }

.auth-error {
  font-family: var(--f-body);
  font-size: 13px;
  color: #FCA5A5;
  background: rgba(220,38,38,.12);
  border: 1px solid rgba(220,38,38,.3);
  border-radius: 9px;
  padding: 10px 12px;
  margin-bottom: 18px;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 22px 0;
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(255,255,255,.4);
}
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--line-dark); }

.gbtn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  font-family: var(--f-sub);
  font-weight: 600;
  font-size: 15px;
  color: #1f2937;
  background: #fff;
  border: 1px solid #fff;
  border-radius: 9px;
  padding: 12px 16px;
  transition: background-color .2s ease;
}
.gbtn:hover { background: #f1f3f5; }
.gbtn svg { width: 18px; height: 18px; display: block; }

/* ---- Responsive --------------------------------------------------------- */
@media (max-width: 820px) {
  .editor-grid { grid-template-columns: 1fr; }
  .editor-side { position: static; }
}
@media (max-width: 700px) {
  /* Let the studio top bar wrap instead of running off a phone screen. */
  .admin-bar__row { height: auto; flex-direction: column; align-items: flex-start; gap: 8px; padding: 10px 0; }
  .admin-bar__right { width: 100%; flex-wrap: wrap; gap: 8px 14px; }
}
@media (max-width: 560px) {
  .arow { grid-template-columns: 1fr; }
  .arow__actions { justify-content: flex-start; }
  .admin-bar__user { display: none; }
}

/* ---- Phase 3: AI panel, derivatives, prompts ---------------------------- */
.ai-panel { border-left: 3px solid var(--orange); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-2 .field + .field { margin-top: 0; }

.seg { display: inline-flex; flex-wrap: wrap; gap: 6px; background: var(--light); border: 1px solid var(--line); border-radius: 10px; padding: 5px; margin-bottom: 14px; }
.seg__opt { font-family: var(--f-sub); font-weight: 600; font-size: 13px; color: var(--slate); padding: 7px 12px; border-radius: 7px; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; }
.seg__opt input { accent-color: var(--orange); }

.ai-row { display: flex; gap: 14px; align-items: flex-end; margin: 4px 0 6px; }
.ai-row .field + .field { margin-top: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip { font-family: var(--f-sub); font-weight: 600; font-size: 13px; color: var(--slate); background: #fff; border: 1px solid var(--line); border-radius: 100px; padding: 7px 14px; cursor: pointer; }
.chip:hover { border-color: var(--line-strong); }
.chip.is-active { background: var(--navy); border-color: var(--navy); color: #fff; }
.deriv .textarea { font-family: var(--f-body); font-size: 14px; line-height: 1.6; }

.prompt-intro { font-family: var(--f-body); font-size: 14px; color: var(--slate); max-width: 760px; margin-bottom: 22px; line-height: 1.6; }
.prompt__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.prompt__label { font-family: var(--f-sub); font-weight: 700; font-size: 15px; color: var(--navy); }
.prompt__text { font-family: var(--f-mono); font-size: 13px; line-height: 1.6; }
.prompt code, .ai-panel code, .imgbox code, .field__hint code { font-family: var(--f-mono); font-size: 12px; background: var(--light); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; }

/* ---- Phase 3b: newsletter assembly ------------------------------------- */
.nl-item { border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 12px; background: #fff; }
.nl-item__bar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.nl-item__num { font-family: var(--f-mono); font-size: 12px; color: #fff; background: var(--navy); width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.nl-item__heading { flex: 1; }
.nl-item__moves { display: flex; gap: 6px; flex: none; }
.nl-item__moves .linkbtn { padding: 7px 10px; }
.nl-item__moves .linkbtn:disabled { opacity: .4; cursor: default; }

.nl-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.nl-pool { display: flex; flex-direction: column; gap: 8px; }
.nl-pool__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid var(--line); border-radius: 9px; padding: 10px 14px; }
.nl-pool__title { font-family: var(--f-body); font-size: 14px; color: var(--navy); }

/* ---- Settings: integration status + connection tests ------------------- */
.intg__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.intg__test { display: flex; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.intg__result { font-family: var(--f-mono); font-size: 12px; }
.intg__result.is-ok { color: #15803D; }
.intg__result.is-bad { color: #B91C1C; }
.intg__result.is-testing { color: var(--slate); }
.intg__set { font-family: var(--f-mono); font-size: 11px; color: #15803D; }

/* ---- Phase 4: Postiz distribution -------------------------------------- */
.distrib { margin-top: 12px; padding: 14px; border: 1px dashed var(--line-strong); border-radius: 10px; background: var(--light); }
.distrib__title { font-family: var(--f-sub); font-weight: 700; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--slate); margin-bottom: 10px; }
.distrib__row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.distrib__row + .distrib__row { margin-top: 10px; }
.distrib-channel { flex: 1; min-width: 180px; }
.distrib-date { width: auto; }
