/* Componentes reutilizaveis: card, form, botao, tabela, toggle, flash. Dark. */

/* --------- Card --------- */
.cd {
  background: #0A111F;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--sombra-sm);
}

.cd + .cd { margin-top: 16px; }

.cd-cab {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.cd-titulo {
  font-family: 'Sora', 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 600;
}

.cd-contagem {
  font-size: 12px;
  color: rgba(245, 249, 251, 0.5);
}

/* --------- Botoes --------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  height: 40px;
  border-radius: 8px;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  font-weight: 600;
  border: 0;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; }

.btn-primary {
  background: var(--accent);
  color: var(--texto-sobre-accent);
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-ghost {
  background: transparent;
  color: rgba(245, 249, 251, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.04); color: #F5F9FB; }

.btn-danger {
  background: transparent;
  color: #F87171;
  border: 1px solid rgba(248, 113, 113, 0.4);
}
.btn-danger:hover { background: rgba(248, 113, 113, 0.08); }

.btn-icone {
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  color: rgba(245, 249, 251, 0.65);
  border: 0;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
}

.btn-icone:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #F5F9FB;
}

.btn-icone.desabilitado {
  color: rgba(245, 249, 251, 0.2);
  cursor: not-allowed;
}

/* --------- Formulario --------- */
.campo {
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
}

.campo label {
  font-size: 13px;
  font-weight: 600;
  color: rgba(245, 249, 251, 0.85);
  margin-bottom: 6px;
}

.campo input,
.campo select,
.campo textarea {
  height: 40px;
  padding: 0 12px;
  background: #050911;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: #F5F9FB;
  font-family: inherit;
  font-size: 14px;
  outline: none;
}

.campo textarea { height: auto; padding: 10px 12px; min-height: 88px; }

.campo input:focus,
.campo select:focus,
.campo textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-sombra);
}

.form-linha {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.form-acoes {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 8px;
}

/* --------- Tabela --------- */
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.tbl th {
  text-align: left;
  padding: 10px 12px;
  color: rgba(245, 249, 251, 0.55);
  font-weight: 600;
  font-size: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: transparent;
}

.tbl td {
  padding: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: #F5F9FB;
}

.tbl tr:hover td { background: rgba(255, 255, 255, 0.02); }

.tbl .col-acoes {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}

/* --------- Toggle on/off (Padrao_Toggle_OnOff, tipo 3) --------- */
.cv-sw {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  vertical-align: middle;
}

.cv-sw input {
  position: absolute;
  left: -9999px;
}

.cv-sw label {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.12);
  cursor: pointer;
  transition: background .15s ease;
}

.cv-sw label::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #FFFFFF;
  transition: transform .15s ease;
}

.cv-sw input:checked + label {
  background: #16a34a;
}
.cv-sw input:checked + label::before {
  transform: translateX(18px);
}

/* --------- Flash --------- */
.flash {
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 14px;
  font-size: 14px;
}
.flash.ok    { background: rgba(22, 163, 74, 0.12); color: #86EFAC; border: 1px solid rgba(22, 163, 74, 0.3); }
.flash.erro  { background: rgba(248, 113, 113, 0.10); color: #FCA5A5; border: 1px solid rgba(248, 113, 113, 0.28); }

/* --------- Chips / status --------- */
.chip {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.chip.ativo  { background: rgba(22, 163, 74, 0.15); color: #86EFAC; }
.chip.inativo { background: rgba(248, 113, 113, 0.12); color: #FCA5A5; }

/* --------- Estado vazio --------- */
.vz {
  padding: 40px 16px;
  text-align: center;
  color: rgba(245, 249, 251, 0.5);
  font-size: 14px;
}

/* --------- Grid de permissoes --------- */
.perm-grupo {
  margin-bottom: 20px;
}

.perm-grupo-cab {
  font-family: 'Sora', 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.perm-grupo-auto {
  font-size: 12px;
  color: rgba(245, 249, 251, 0.6);
  font-weight: 500;
  display: flex;
  gap: 14px;
  align-items: center;
}

.perm-grupo-auto label {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  cursor: pointer;
}

.perm-linha {
  display: grid;
  grid-template-columns: 1fr 90px 90px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.05);
}

.perm-linha:last-child { border-bottom: 0; }

.perm-linha input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* --------- Multi-select via checkbox pill (padrao Areas Adjacentes) --------- */
.chk-multi {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 4px 0;
}
.chk-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 20px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  color: #F5F9FB; font-size: 13px; cursor: pointer;
  transition: background 120ms, border-color 120ms;
  user-select: none;
}
.chk-pill:hover { background: rgba(0,176,255,0.08); border-color: var(--accent); }
.chk-pill:has(input:checked) {
  background: var(--accent-soft); border-color: var(--accent); color: var(--accent);
}
.chk-pill input { accent-color: var(--accent); }

.cnt-chip {
  display: inline-block; min-width: 22px; padding: 1px 8px;
  background: var(--accent-soft); color: var(--accent);
  border-radius: 12px; font-size: 11px; font-weight: 700;
  text-align: center; margin-left: 8px;
}

/* --------- Grid de correcao (admin) --------- */
.grid-card { padding: 12px 12px 4px; }
.grid-filtro {
  display: flex; gap: 8px; align-items: center;
  padding: 8px 4px 12px; border-bottom: 1px solid rgba(255,255,255,0.04);
  margin-bottom: 8px;
}
.grid-filtro input {
  flex: 1; height: 36px; padding: 0 12px;
  background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.08);
  color: #F5F9FB; border-radius: 8px; font-size: 13px;
}
.grid-filtro input:focus { outline: none; border-color: var(--accent); }
.grid-wrap {
  max-height: calc(100vh - 260px);
  overflow-x: scroll;   /* SEMPRE visivel, mesmo sem overflow */
  overflow-y: auto;
  border: 1px solid rgba(255,255,255,0.06); border-radius: 8px;
  scrollbar-gutter: stable;
}
.grid-wrap .grid-tbl { min-width: 2400px; width: max-content; }

/* Forca a scrollbar horizontal aparecer sempre no Chrome/Edge */
.grid-wrap::-webkit-scrollbar { height: 14px; width: 10px; }
.grid-wrap { scrollbar-width: auto; }
.grid-wrap::-webkit-scrollbar { height: 12px; width: 10px; }
.grid-wrap::-webkit-scrollbar-thumb { background: rgba(0,176,255,0.35); border-radius: 6px; }
.grid-wrap::-webkit-scrollbar-thumb:hover { background: var(--accent); }
.grid-wrap::-webkit-scrollbar-track { background: rgba(255,255,255,0.02); }

.grid-tbl thead th {
  position: sticky; top: 0; z-index: 2;
  background: #0F1626; color: #F5F9FB;
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 10px 12px; white-space: nowrap;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  user-select: none;
}
.grid-tbl thead th.sort-asc::after  { content: ' ▲'; color: var(--accent); font-size: 10px; }
.grid-tbl thead th.sort-desc::after { content: ' ▼'; color: var(--accent); font-size: 10px; }
.grid-tbl tbody td { white-space: nowrap; padding: 8px 12px; }
.grid-tbl tbody tr:hover td { background: rgba(0,176,255,0.05); }
.grid-tbl .acoes-fixas {
  position: sticky; left: 0; z-index: 1; background: #0A111F;
  border-right: 1px solid rgba(255,255,255,0.08);
}
.grid-tbl td[contenteditable] { cursor: text; }
.grid-tbl td[contenteditable]:hover { background: rgba(0,176,255,0.06); }
.grid-tbl td.td-editing {
  outline: 2px solid var(--accent); outline-offset: -2px; background: rgba(0,176,255,0.12);
}
.grid-tbl td.td-saved  { background: rgba(22,163,74,0.18); }
.grid-tbl td.td-pending { background: rgba(255,193,7,0.20); font-weight: 600; }
.grid-tbl td.td-error   { background: rgba(220,53,69,0.25); }

/* --------- Login (identidade landing) --------- */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 20% 20%, rgba(0, 176, 255, 0.10), transparent 40%),
              radial-gradient(circle at 80% 90%, rgba(97, 89, 225, 0.10), transparent 45%),
              #050911;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 32px 28px;
  background: #0A111F;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}

.login-brand {
  display: flex; align-items: center; gap: 12px;
  padding-bottom: 14px; margin-bottom: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.login-logo { width: 46px; height: 46px; object-fit: contain; flex: 0 0 auto; }

.login-marca {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.01em;
  line-height: 1.05;
}
.login-marca .marca-amply { color: #F5F9FB; }
.login-marca .marca-sol   { color: var(--accent); margin-left: 4px; }
.login-slogan {
  margin-top: 4px;
  font-size: 11px;
  color: rgba(245,249,251,.6);
}

.login-tit {
  font-family: 'Space Grotesk', 'Sora', sans-serif;
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 4px;
}

.login-sub {
  font-size: 13px;
  color: rgba(245, 249, 251, 0.55);
  margin-bottom: 22px;
}

.login-page .btn-primary {
  width: 100%;
  justify-content: center;
  background: linear-gradient(120deg, #00B0FF 0%, #6159E1 100%);
  color: #FFFFFF;
}

.login-page .btn-primary:hover {
  filter: brightness(1.08);
}
