/*
 * What is this app's own, on top of the Spera's design system (globals, button, surface, shell, form): the fonts,
 * the ad statuses and the three tabs. Colors by token only, so a dark theme keeps working. Mobile first.
 */

@font-face {
  font-family: "Sora";
  src: url("../fonts/sora-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 800;
  font-display: swap;
}

@font-face {
  font-family: "Inter";
  src: url("../fonts/inter-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("../fonts/jetbrains-mono-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 800;
  font-display: swap;
}

/* In the Spera next/font sets these; globals.css reads them. */
:root {
  --font-sora: "Sora";
  --font-inter: "Inter";
  --font-jetbrains: "JetBrains Mono";
}

/* An ad's status at Meta. "pausado" keeps the default of globals.css: a 1px outline. */
[data-status="ativo"] { --status-bg: var(--brand); --status-fg: var(--on-brand); --status-border: 1px solid var(--brand); }
[data-status="analise"] { --status-bg: var(--sol); --status-fg: var(--neverything); --status-border: 1px solid var(--sol); }
[data-status="reprovado"] { --status-bg: transparent; --status-fg: var(--ink); --status-border: 2px dashed var(--tangerina); }
[data-status="arquivado"] { --status-bg: transparent; --status-fg: var(--ink-muted); --status-border: 1px dashed var(--ink-muted); }

/* The list */
.ads-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.ad-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  color: var(--ink);
  text-decoration: none;
}

.ad-card:hover {
  border-color: var(--control-border);
}

.ad-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 176px;
  border-radius: var(--radius-md);
  background: var(--surface);
  overflow: hidden;
}

.ad-thumb img {
  display: block;
  max-width: 100%;
  max-height: 160px;
  border-radius: var(--radius-sm);
}

.ad-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.ad-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
}

.ad-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.ad-figures {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 10px;
  margin: 0;
}

.ad-figures dd {
  margin: 0;
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
}

/* The next cards load when this comes into view; without JavaScript it is a plain link. */
.ad-more {
  grid-column: 1 / -1;
  justify-self: center;
}

/* The detail */
.ad-heading {
  overflow-wrap: anywhere;
}

.ad-creative {
  display: flex;
  justify-content: center;
}

.ad-creative img {
  display: block;
  max-width: 100%;
  max-height: 480px;
  border-radius: var(--radius-md);
}

.ad-facts {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.ad-placement {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
}

.ad-placement div {
  display: flex;
  gap: 6px;
}

.ad-placement dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.ad-rejection {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border: 2px dashed var(--tangerina);
  border-radius: var(--radius-md);
}

/* Sessions */
.sessions-layout {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* On a phone the sessions are a strip above the chat. */
.sessions-list {
  flex-direction: row;
  gap: 6px;
  padding: 6px;
  overflow-x: auto;
}

.session-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: none;
  width: 168px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  color: var(--ink);
  text-decoration: none;
}

.session-item[aria-current="page"] {
  order: -1;
  background: color-mix(in srgb, var(--ink) 8%, transparent);
}

.session-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-mine,
.chat-claude {
  margin: 0;
  font-size: 14px;
  line-height: 21px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chat-mine {
  align-self: flex-end;
  max-width: 86%;
  padding: 10px 14px;
  border-radius: 20px;
  background: var(--line);
}

.chat-claude {
  max-width: 94%;
}

.chat-reference {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--ink);
  text-decoration: none;
}

.chat-reference img {
  flex: none;
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

.chat-referenceText {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.chat-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.chat-compose {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.chat-compose .control {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 48px;
}

.approval-feedback .control {
  min-height: 96px;
}

/* Shown while the form waits for Claude (htmx marks the form during the request). */
.chat-wait {
  display: none;
  margin: 0;
}

.htmx-request .chat-wait {
  display: block;
}

/* A batch card, inside the chat */
.batch {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.batch-head,
.batch-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.batch-pieces {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.batch-piece {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: baseline;
  gap: 2px 10px;
}

.batch-code {
  font-family: var(--font-mono);
  font-size: 13px;
}

.batch-headline,
.batch-result {
  grid-column: 1 / -1;
  overflow-wrap: anywhere;
}

.batch-headline {
  font-size: 14px;
  line-height: 20px;
}

.batch-result {
  color: var(--ink-muted);
}

.batch-result:empty {
  display: none;
}

/* Approval */
.approval-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.approval-done {
  margin: 0;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  font-size: 14px;
  line-height: 20px;
}

.approval-done[data-decision="aprovada"] {
  border-color: var(--brand);
  background: var(--brand);
  color: var(--on-brand);
}

.approval-done[data-decision="ajuste"] {
  border-color: var(--sol);
  background: var(--sol);
  color: var(--neverything);
}

.rule-proposal {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  background: var(--sol);
  color: var(--neverything);
}

.rule-proposal p {
  margin: 0;
}

.rule-text {
  font-size: 15px;
  line-height: 22px;
  font-weight: 500;
}

.rule-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.rule-proposal .button-secondary {
  border-color: var(--neverything);
  color: var(--neverything);
}

.approval-piece {
  display: flex;
  justify-content: center;
}

.approval-piece img {
  display: block;
  max-width: 100%;
  max-height: 520px;
  border-radius: var(--radius-md);
}

.teleprompter {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.teleprompter p {
  margin: 0;
  font-size: 15px;
  line-height: 24px;
}

.approval-info {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.approval-where {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
}

.approval-texts {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
}

.approval-texts dd {
  margin: 0;
  font-size: 14px;
  line-height: 20px;
  overflow-wrap: anywhere;
}

.approval-score {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.score {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: var(--radius-full);
  background: var(--line);
  color: var(--ink);
  font-size: 12px;
  font-weight: 500;
}

.score[data-low="true"] {
  background: var(--tangerina);
  color: var(--neverything);
}

.approval-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.approval-feedback {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

/* Login: the Spera's login page (src/app/login/login.module.css), classes prefixed with "login-". */
.login-page {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto 1fr;
}

/* Brand block: Horizonte gradient with the grain layer the MIQ gradients always carry. */
.login-hero {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: var(--space-4);
  min-height: 220px;
  padding: var(--space-6);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
  background:
    radial-gradient(90% 70% at 18% 115%, var(--sol) 0%, var(--tangerina) 32%, transparent 68%),
    linear-gradient(180deg, var(--neverything), var(--petroleo));
  color: var(--moonlight);
  overflow: hidden;
}

.login-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
  opacity: 0.4;
  pointer-events: none;
}

.login-heroEyebrow {
  position: relative;
  color: var(--moonlight);
}

.login-heroTitle {
  position: relative;
  max-width: 12ch;
  font-family: var(--font-display);
  font-size: 36px;
  line-height: 40px;
  font-weight: 300;
  letter-spacing: -0.04em;
}

.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-10) var(--space-6);
}

.login-box {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.login-watermark {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
}

@media (min-width: 860px) {
  .ad-detail {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    align-items: start;
    gap: 28px;
  }

  /* Beside the image there is no room for the Spera's four-in-a-row (from 1180px): two by two, as in the sketch. */
  .ad-detail .surface-stats[data-count="4"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sessions-layout {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    align-items: start;
  }

  .sessions-list {
    flex-direction: column;
    overflow: visible;
  }

  .session-item,
  .session-item[aria-current="page"] {
    width: auto;
    order: 0;
  }

  .batch-piece {
    grid-template-columns: 76px 84px minmax(0, 1fr) auto;
  }

  .batch-headline,
  .batch-result {
    grid-column: auto;
  }

  .approval {
    display: grid;
    grid-template-columns: minmax(0, 360px) minmax(0, 1fr);
    align-items: start;
    gap: 28px;
  }
}

@media (min-width: 860px) {
  .login-page {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: none;
  }

  .login-hero {
    min-height: 0;
    padding: var(--space-16);
    border-radius: 0 var(--radius-xl) var(--radius-xl) 0;
  }

  .login-heroTitle {
    font-size: 56px;
    line-height: 60px;
  }
}
