/* ============================================================
   PIPE TASK — Identidade Brevya e alternância de tema
   Isolado do CSS de componentes para reduzir conflito entre fases.
   ============================================================ */

html { color-scheme: dark; }

html[data-theme="light"] {
  color-scheme: light;

  --background: 40 20% 97%;
  --foreground: 0 0% 8%;

  --card: 40 15% 95%;
  --card-foreground: 0 0% 8%;

  --popover: 40 15% 95%;
  --popover-foreground: 0 0% 8%;

  --primary: 56 18% 40%;
  --primary-foreground: 0 0% 100%;

  --secondary: 40 10% 90%;
  --secondary-foreground: 0 0% 20%;

  --muted: 40 10% 92%;
  --muted-foreground: 0 0% 40%;

  --accent: 56 18% 40%;
  --accent-foreground: 0 0% 100%;

  --destructive: 0 72% 46%;
  --destructive-foreground: 0 0% 100%;
  --success: 145 50% 32%;
  --warning: 35 80% 40%;

  --border: 40 10% 82%;
  --input: 40 10% 78%;
  --ring: 56 18% 40%;

  --gold: 56 18% 40%;
  --gold-light: 56 18% 55%;
  --gold-dark: 56 18% 33%;

  --surface: 40 15% 94%;
  --surface-elevated: 40 12% 90%;

  --prio-baixa: 0 0% 38%;
  --prio-media: 210 55% 42%;
  --prio-alta: 32 78% 42%;
  --prio-urgente: 0 70% 45%;
}

body,
.sidebar,
.card,
.project-card,
.kanban-column,
.kanban-card,
.task-drawer,
.modal-dialog,
.input {
  transition-property: background-color, border-color, color;
  transition-duration: 0.18s;
  transition-timing-function: ease-out;
}

/* ── Logo responsivo ao tema ───────────────────────────── */
.brevya-logo {
  display: inline-flex;
  align-items: center;
  min-width: 0;
}

.brevya-logo__image {
  width: auto;
  height: 1.75rem;
  object-fit: contain;
}

.brevya-logo__on-light { display: none; }

html[data-theme="light"] .brevya-logo__on-dark { display: none; }
html[data-theme="light"] .brevya-logo__on-light { display: block; }

.brand--page {
  flex-direction: column;
  gap: 0.5rem;
}

.brand--page .brevya-logo__image { height: 2.5rem; }

.brand__product {
  color: hsl(var(--muted-foreground));
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  line-height: 1;
  text-transform: uppercase;
}

.sidebar__brand {
  align-items: flex-start;
  flex-direction: column;
  gap: 0.375rem;
  padding: 0.375rem 0.5rem 0.625rem;
}

.sidebar__brand .brevya-logo__image { height: 1.8rem; }

/* ── Controle de tema ──────────────────────────────────── */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 2.25rem;
  padding: 0.4375rem 0.75rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--surface-elevated));
  color: hsl(var(--muted-foreground));
  font-size: 0.75rem;
  font-weight: 600;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.theme-toggle:hover {
  border-color: hsl(var(--primary) / 0.5);
  background: hsl(var(--secondary));
  color: hsl(var(--foreground));
}

.theme-toggle__icon {
  width: 1rem;
  height: 1rem;
  flex: 0 0 auto;
}

.theme-toggle__moon { display: none; }
html[data-theme="light"] .theme-toggle__sun { display: none; }
html[data-theme="light"] .theme-toggle__moon { display: block; }

.sidebar__theme-toggle {
  width: 100%;
  justify-content: flex-start;
  margin-bottom: 0.875rem;
}

.theme-toggle--floating {
  position: fixed;
  z-index: 5;
  top: 1rem;
  right: 1rem;
  border-radius: 9999px;
  box-shadow: 0 0.5rem 1.5rem hsl(var(--background) / 0.2);
}

/* Cores semânticas precisam de contraste próprio no fundo claro. */
html[data-theme="light"] .alert--error { color: hsl(0 65% 34%); }
html[data-theme="light"] .alert--success { color: hsl(145 55% 27%); }
html[data-theme="light"] .alert--warning { color: hsl(35 72% 30%); }
html[data-theme="light"] .status-planejamento { color: hsl(210 58% 34%); }
html[data-theme="light"] .status-pausado { color: hsl(35 72% 30%); }
html[data-theme="light"] .status-concluido { color: hsl(145 55% 27%); }
html[data-theme="light"] .status-cancelado { color: hsl(0 65% 34%); }
html[data-theme="light"] .pipeline__step.is-done { color: hsl(145 55% 27%); }

@media (max-width: 800px) {
  .sidebar__brand {
    align-items: center;
    flex-direction: row;
    justify-content: space-between;
  }

  .sidebar__brand .brand__product { margin-left: auto; }
}

@media (max-width: 480px) {
  .theme-toggle--floating {
    top: 0.75rem;
    right: 0.75rem;
  }

  .theme-toggle--floating [data-theme-label] { display: none; }
}
