/*
 * PAM — camada de tema Ploomes (ver DESIGN.md).
 * Carregada DEPOIS do CSS do build: redefine os tokens do app (shadcn/Tailwind)
 * com os do design system do Ploomes. Não edita o build; para desfazer, basta
 * tirar o <link> do index.html.
 */

/* ---------- Fonte: Source Sans Pro, a mesma que o CRM carrega (OFL) ---------- */
@font-face { font-family: "Source Sans Pro"; font-weight: 300; font-display: swap; src: url("fonts/SourceSansPro-Light.ttf.woff2") format("woff2"); }
@font-face { font-family: "Source Sans Pro"; font-weight: 400; font-display: swap; src: url("fonts/SourceSansPro-Regular.ttf.woff2") format("woff2"); }
@font-face { font-family: "Source Sans Pro"; font-weight: 600; font-display: swap; src: url("fonts/SourceSansPro-Semibold.ttf.woff2") format("woff2"); }
@font-face { font-family: "Source Sans Pro"; font-weight: 700; font-display: swap; src: url("fonts/SourceSansPro-Bold.ttf.woff2") format("woff2"); }

/* ---------- Tokens Ploomes (nomes do DS) ---------- */
:root {
  --pl-brand: #7E33E6;
  --pl-brand-1: #8D49E9;            /* hover */
  --pl-brand-2: #701CE3;            /* active */
  --pl-brand-soft: rgb(126 51 230 / .08);
  --pl-confirmation: #1A94FF;       /* CTA primário */
  --pl-success: #3BDDAD;
  --pl-alert: #FFC01A;
  --pl-danger: #F22727;
  --pl-font: #1B102C;
  --pl-font-1: rgb(27 16 44 / .7);
  --pl-font-2: rgb(27 16 44 / .5);
  --pl-neutral-1: rgb(27 16 44 / .05);
  --pl-neutral-2: rgb(27 16 44 / .10);
  --pl-neutral-3: rgb(27 16 44 / .15);
  --pl-bg: #FFFFFF;
  --pl-bg-1: #FAFAFB;
  --pl-rail: #1E0C45;
  --pl-gradient-brand: linear-gradient(135deg, #5A16B6 0%, #431188 100%);
  --pl-gradient-active: linear-gradient(102.35deg, #7D33E6 0%, #431188 100%);
  --pl-shadow-4dp: 0 4px 5px 0 #00000024, 0 1px 10px 0 #0000001f, 0 2px 4px 0 #0003;
  --pl-shadow-8dp: 0 8px 10px 0 #00000024, 0 3px 14px 0 #0000001f, 0 5px 5px 0 #0003;
  --pl-shadow-24dp: 0 24px 38px 0 #00000024, 0 9px 46px 0 #0000001f, 0 11px 15px 0 #0003;
  --pl-ease: cubic-bezier(.2, 0, 0, 1);

  /* ---------- Tokens do app (HSL sem hsl(), padrão shadcn) ---------- */
  --background: 0 0% 100%;
  --foreground: 264 47% 12%;                /* #1B102C */
  --card: 0 0% 100%;
  --card-foreground: 264 47% 12%;
  --popover: 0 0% 100%;
  --popover-foreground: 264 47% 12%;
  --primary: 208 100% 55%;                  /* #1A94FF — CTA */
  --primary-hover: 208 100% 49%;
  --primary-foreground: 0 0% 100%;
  --secondary: 240 8% 96%;                  /* neutral-level_1 sobre branco */
  --secondary-hover: 260 7% 92%;
  --secondary-foreground: 264 47% 12%;
  --muted: 240 14% 98%;                     /* #FAFAFB */
  --muted-foreground: 264 9% 39%;           /* font-level_1 (70%) */
  --accent: 265 78% 96%;                    /* seleção/hover de item: roxo da marca bem claro */
  --accent-hover: 265 78% 92%;
  --accent-foreground: 265 78% 45%;
  --destructive: 0 89% 55%;                 /* #F22727 */
  --destructive-foreground: 0 0% 100%;
  --success: 162 70% 55%;                   /* #3BDDAD */
  --success-foreground: 264 47% 12%;
  --warning: 44 100% 55%;                   /* #FFC01A */
  --warning-foreground: 264 47% 12%;
  --border: 260 7% 91%;                     /* neutral-level_2 */
  --input: 260 7% 91%;
  --ring: 208 100% 55%;
  --radius: 5px;
  --sidebar-background: 259 70% 16%;        /* #1E0C45 — fundo do rail do CRM */
  --sidebar-foreground: 270 60% 98%;
  --sidebar-primary: 265 78% 55%;
  --sidebar-primary-foreground: 0 0% 100%;
  --sidebar-accent: 265 78% 55%;
  --sidebar-accent-foreground: 0 0% 100%;
  --sidebar-border: 259 50% 24%;
  --sidebar-ring: 208 100% 55%;
  --gradient-primary: var(--pl-gradient-brand);
  --gradient-subtle: none;
  --shadow-elegant: none;                   /* superfície no fluxo é plana */
  --shadow-card: none;
  --transition-smooth: all 150ms var(--pl-ease);
}

/* hidden sempre esconde (o Tailwind inline-flex vencia o atributo). */
[hidden] { display: none !important; }

/* ---------- Tipografia ---------- */
html, body, button, input, textarea, select {
  font-family: "Source Sans Pro", "Source Sans 3", system-ui, sans-serif;
}
body { color: var(--pl-font); -webkit-font-smoothing: antialiased; }
.font-medium { font-weight: 600; }        /* o DS não tem peso 500 */

/* ---------- Raio: 5px no geral, 10px em card de conteúdo, pílula continua pílula ---------- */
.rounded-sm { border-radius: 3px; }
.rounded, .rounded-md, .rounded-lg { border-radius: 5px; }
.rounded-xl, .rounded-2xl, .rounded-3xl { border-radius: 10px; }

/* ---------- Elevação: borda XOR sombra ---------- */
/* Superfícies no fluxo (cards, painéis, tiles) ficam planas. */
.shadow-sm, .shadow { --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; }
/* Camadas flutuantes usam os valores reais do DS. */
.shadow-md { --tw-shadow: var(--pl-shadow-4dp); }
.shadow-lg { --tw-shadow: var(--pl-shadow-8dp); }
.shadow-xl, .shadow-2xl { --tw-shadow: var(--pl-shadow-24dp); }
/* Tem borda? Então está no fluxo: sombra nenhuma. */
.border:is(.shadow-md, .shadow-lg, .shadow-xl, .shadow-2xl) { --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; }
/* Flutua sobre o conteúdo? Sombra do DS e borda nenhuma. */
[role="dialog"], [role="alertdialog"] { --tw-shadow: var(--pl-shadow-24dp) !important; border-color: transparent !important; }
[role="menu"], [role="listbox"], [data-radix-popper-content-wrapper] > * { --tw-shadow: var(--pl-shadow-4dp) !important; border-color: transparent !important; }

/* ---------- Login: card plano, branco, borda neutra (era lilás translúcido com sombra) ---------- */
[class~="bg-[#7443f6]/20"] { background-color: var(--pl-bg); border-color: var(--pl-neutral-2); -webkit-backdrop-filter: none; backdrop-filter: none; }

/* ---------- Roxos fora da marca -> roxo Ploomes ---------- */
/* A escala de estágios (#610fc7 #7814eb #8529ff #ab82ff #c7b0ff #dbd4ff #330870) é a paleta BPMN e fica. */
[class~="bg-[#6D5DF6]"] { background-color: var(--pl-brand); }
[class~="border-[#6D5DF6]"] { border-color: var(--pl-brand); }
[class~="hover:border-[#6D5DF6]"]:hover { border-color: var(--pl-brand); }
[class~="hover:text-[#6D5DF6]"]:hover,
.group:hover [class~="group-hover:text-[#6D5DF6]"] { color: var(--pl-brand); }
[class~="text-[#6d5aa7]"], [class~="text-[#6f45d8]"], [class~="text-[#7357b8]"] { color: var(--pl-brand-2); }
[class~="from-[#3D2B80]"] { --tw-gradient-from: #5A16B6 var(--tw-gradient-from-position); --tw-gradient-to: rgb(90 22 182 / 0) var(--tw-gradient-to-position); --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to); }
[class~="via-[#4B2DB8]"] { --tw-gradient-to: rgb(74 20 160 / 0) var(--tw-gradient-to-position); --tw-gradient-stops: var(--tw-gradient-from), #4E14A0 var(--tw-gradient-via-position), var(--tw-gradient-to); }
[class~="to-[#2B1C66]"] { --tw-gradient-to: #431188 var(--tw-gradient-to-position); }
[class~="bg-[#2A185E]"] { background-color: var(--pl-rail); }

/* ---------- Item ativo do menu lateral: indicador com o gradiente do CRM ---------- */
[data-sidebar="menu-button"][data-active="true"] {
  background-image: var(--pl-gradient-active);
  color: #fff;
}

/* ---------- Editor de mapeamento ---------- */
/* A barra (Importar, Exportar, Salvar…) era absolute por cima do canvas: cobria elementos do
   diagrama e a paleta. Vira uma faixa fixa no topo e o canvas ocupa o resto da altura. */
[class~="bg-muted/30"]:has(> .bjs-container) { display: flex; flex-direction: column; }
[class~="bg-muted/30"]:has(> .bjs-container) > [class~="absolute"][class~="z-50"][class~="top-2"][class~="flex-wrap"] {
  position: static; order: -1; flex: none;
  justify-content: flex-start; gap: 8px; padding: 8px 12px;
  background: var(--pl-bg); border-bottom: 1px solid var(--pl-neutral-2);
}
[class~="bg-muted/30"]:has(> .bjs-container) > .bjs-container { flex: 1 1 auto; min-height: 0; height: auto !important; }
/* Botões da barra na altura de controle do CRM (30px, 13px), para caber numa linha. */
[class~="bg-muted/30"]:has(> .bjs-container) > [class~="z-50"][class~="flex-wrap"] button {
  height: 30px; padding: 0 10px; font-size: 13px; gap: 6px; line-height: 1;
}
[class~="bg-muted/30"]:has(> .bjs-container) > [class~="z-50"][class~="flex-wrap"] button svg { width: 14px; height: 14px; }
/* "Implementar" estava em indigo do Tailwind; vira o roxo da marca. */
[class~="bg-indigo-600"] { background-color: var(--pl-brand); }
[class~="hover:bg-indigo-700"]:hover { background-color: var(--pl-brand-2); }

/* ---------- Página do projeto: Mapeamentos ---------- */
/* Mapeamentos e Arquivos dividiam a largura em duas colunas e truncavam data e autor.
   Agora cada seção ocupa a largura toda, Mapeamentos primeiro. */
[class~="xl:grid-cols-2"][class~="items-start"]:has(th) { grid-template-columns: minmax(0, 1fr) !important; }
/* Tipo do mapeamento: As-Is em lilás (marca), To-Be em azul claro (ação). */
td [class~="rounded-full"][class~="bg-secondary"],
td [class~="rounded-full"][class~="bg-primary"] { padding: 2px 10px !important; font-size: 12px; font-weight: 600; border-color: transparent; }
td [class~="rounded-full"][class~="bg-secondary"] { background: #EFE6FC; color: var(--pl-brand-2); }
td [class~="rounded-full"][class~="bg-primary"] { background: #E3F1FF; color: #0B6FCC; }
/* Nome do mapeamento: o link principal da linha. */
tbody td button.group > span { font-size: 14px; font-weight: 600; }
tbody td { padding-top: 10px !important; padding-bottom: 10px !important; }
/* Arquivar: ícone discreto (sem caixa vermelha em toda linha), vermelho só no hover. */
td button[title="Arquivar"] { border-color: transparent; background: transparent; color: var(--pl-font-2); }
td button[title="Arquivar"]:hover { color: var(--pl-danger); background: rgb(242 39 39 / .08); }
thead th:last-child { background: inherit !important; }

/* ---------- Botões: estados e foco ---------- */
button:is(.rounded-xl, .rounded-2xl, .rounded-3xl) { border-radius: 5px; }
button, [role="button"], a { transition: background-color 100ms var(--pl-ease), color 100ms var(--pl-ease), border-color 100ms var(--pl-ease); }
button:disabled, [role="button"][aria-disabled="true"] { opacity: .45; }
:focus-visible { outline: none; box-shadow: 0 0 0 2px rgb(26 148 255 / .5) !important; }

/* ---------- Tabelas: densidade de CRM ---------- */
thead th { font-size: 13px; font-weight: 600; color: var(--pl-font-1); }
tbody tr:hover { background-color: var(--pl-neutral-1); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; }
}

/* ---------- Editor: painel de Propriedades ---------- */
/* Antes: títulos de seção iguais aos rótulos, campos com borda crua, descrição em caixa pequena,
   cores empilhadas, nota técnica para desenvolvedor e botão de salvar solto no meio. */
[class~="w-[360px]"][class~="border-l"] { padding: 20px 20px 0 !important; color: var(--pl-font); }
[class~="w-[360px]"][class~="border-l"] > .font-semibold { font-size: 16px; font-weight: 700; }
[class~="w-[360px]"][class~="border-l"] > [class~="break-all"] {
  display: inline-block; margin: 0 0 6px; padding: 2px 8px; border-radius: 10px;
  font: 600 11px/1.5 ui-monospace, Menlo, Consolas, monospace; color: var(--pl-font-1); background: var(--pl-neutral-1);
}
/* Títulos de seção: hierarquia clara, separados por uma linha. */
[class~="w-[360px]"][class~="border-l"] section > div:first-child:not(:has(*)) {
  margin-top: 6px; padding-top: 14px; border-top: 1px solid var(--pl-neutral-2);
  font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--pl-font-2);
}
[class~="w-[360px]"][class~="border-l"] > section > section:first-child > div:first-child { border-top: 0; padding-top: 4px; }
[class~="w-[360px]"][class~="border-l"] label > div:first-child { font-size: 13px; font-weight: 600; color: var(--pl-font-1); margin-bottom: 5px; }
/* Campos no padrão do CRM: contorno inset, 30px, foco azul. */
[class~="w-[360px]"][class~="border-l"] input:not([type="color"]),
[class~="w-[360px]"][class~="border-l"] textarea {
  border: 0 !important; border-radius: 5px; background: var(--pl-bg); color: var(--pl-font);
  box-shadow: inset 0 0 0 1px var(--pl-neutral-2); font-size: 14px; outline: 0;
}
[class~="w-[360px]"][class~="border-l"] input:not([type="color"]) { height: 30px; padding: 0 10px !important; }
[class~="w-[360px]"][class~="border-l"] textarea { height: auto !important; min-height: 130px; max-height: 50vh; field-sizing: content; overflow-y: auto; padding: 8px 10px !important; line-height: 1.45; resize: vertical; }
[class~="w-[360px]"][class~="border-l"] input:not([type="color"]):focus,
[class~="w-[360px]"][class~="border-l"] textarea:focus { box-shadow: inset 0 0 0 1px var(--pl-confirmation); }
/* Cores: borda e preenchimento lado a lado, amostra quadrada + código. */
[class~="w-[360px]"][class~="border-l"] section:has(> label input[type="color"]) { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
[class~="w-[360px]"][class~="border-l"] section:has(> label input[type="color"]) > div:first-child { grid-column: 1 / -1; margin-bottom: 8px; }
[class~="w-[360px]"][class~="border-l"] section:has(> label input[type="color"]) > label { margin: 0 !important; }
[class~="w-[360px]"][class~="border-l"] input[type="color"] {
  flex: none; width: 30px !important; height: 30px !important; padding: 0; border: 0 !important; border-radius: 5px;
  background: none; box-shadow: inset 0 0 0 1px var(--pl-neutral-2); cursor: pointer;
}
[class~="w-[360px]"][class~="border-l"] input[type="color"]::-webkit-color-swatch-wrapper { padding: 3px; }
[class~="w-[360px]"][class~="border-l"] input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 3px; }
[class~="w-[360px]"][class~="border-l"] input[type="color"]::-moz-color-swatch { border: 0; border-radius: 3px; }
[class~="w-[360px]"][class~="border-l"] input[type="color"] + input { font: 13px ui-monospace, Menlo, Consolas, monospace !important; text-transform: uppercase; }
[class~="w-[360px]"][class~="border-l"] label:has(input[type="color"]) > div:last-child { gap: 6px; }
/* Texto auxiliar legível; nota técnica (onde o dado é gravado) não é para o usuário. */
[class~="w-[360px]"][class~="border-l"] [class~="text-neutral-500"] { font-size: 13px; color: var(--pl-font-2); }
[class~="w-[360px]"][class~="border-l"] [class~="text-[11px]"]:has(code) { display: none; }
/* Salvar: ação principal fixa no rodapé do painel, largura total. */
[class~="w-[360px]"][class~="border-l"] > button:last-child {
  position: sticky; bottom: 12px; z-index: 1; display: block; width: 100%; height: 34px; margin: 16px 0 12px;
  padding: 0 !important; border-radius: 5px; background: var(--pl-confirmation) !important; color: #fff;
  font-size: 14px; font-weight: 600; box-shadow: 0 0 0 12px var(--pl-bg);
}
[class~="w-[360px]"][class~="border-l"] > button:last-child:hover { background: #0B85F0 !important; }
