/* ============================================================
 * Central de Tarefas · Grupo Onda · estilos
 * Tema claro/escuro (html.tema-escuro)
 * ============================================================ */
:root {
  --cor-primaria: #0e2a47;
  --cor-primaria-2: #16456f;
  --cor-acento: #0ea5e9;
  --cor-bg: #f1f5f9;
  --cor-card: #ffffff;
  --cor-texto: #1e293b;
  --cor-texto-suave: #64748b;
  --cor-borda: #e2e8f0;
  --cor-ok: #16a34a;
  --cor-ok-bg: #dcfce7;
  --cor-erro: #dc2626;
  --cor-erro-bg: #fee2e2;
  --cor-aviso: #d97706;
  --cor-aviso-bg: #fef3c7;
  --raio: 12px;
  --sombra: 0 1px 3px rgba(15, 23, 42, .08), 0 6px 18px rgba(15, 23, 42, .07);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--cor-bg);
  color: var(--cor-texto);
  font-size: 15px;
  line-height: 1.5;
}

.hidden { display: none !important; }

h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; }
p { margin: 0 0 .75rem; }

/* ===== Botão de tema ===== */
.btn-tema {
  position: fixed;
  top: .9rem; right: .9rem;
  z-index: 200;
  width: 2.5rem; height: 2.5rem;
  border-radius: 50%;
  border: 1px solid var(--cor-borda);
  background: var(--cor-card);
  color: var(--cor-texto);
  font-size: 1.15rem;
  cursor: pointer;
  box-shadow: var(--sombra);
  transition: transform .15s ease;
}
.btn-tema:hover { transform: scale(1.08); }
.topbar .btn-tema { position: static; box-shadow: none; }

/* ===== Login ===== */
.tela-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0e2a47 0%, #16456f 55%, #0ea5e9 130%);
  padding: 1rem;
}
.card-login {
  background: var(--cor-card);
  border-radius: 16px;
  padding: 2.2rem 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .35);
}
.login-brand { text-align: center; margin-bottom: 1.4rem; }
.login-logo { font-size: 2.6rem; }
.login-brand h1 { font-size: 1.25rem; margin-bottom: .15rem; }
.login-sub { color: var(--cor-texto-suave); font-size: .9rem; }
.campo { display: block; margin-bottom: .9rem; }
.campo > span { display: block; font-size: .82rem; font-weight: 600; margin-bottom: .3rem; color: var(--cor-texto-suave); }
.campo .ajuda { font-size: .75rem; color: var(--cor-texto-suave); margin-top: .25rem; }
.campo input, .campo select, .campo textarea {
  width: 100%;
  padding: .55rem .7rem;
  border: 1px solid var(--cor-borda);
  border-radius: 8px;
  font-size: .95rem;
  font-family: inherit;
  background: #fff;
  color: var(--cor-texto);
}
.campo input:focus, .campo select:focus, .campo textarea:focus {
  outline: 2px solid var(--cor-acento);
  outline-offset: -1px;
  border-color: var(--cor-acento);
}
.campo textarea { resize: vertical; min-height: 90px; }
.erro-login { color: var(--cor-erro); font-size: .85rem; text-align: center; margin: .6rem 0 0; }
.login-rodape { text-align: center; color: var(--cor-texto-suave); font-size: .78rem; margin-top: 1rem; }

/* ===== Layout app ===== */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: .8rem;
  padding: .8rem 1.2rem;
  background: var(--cor-card);
  border-bottom: 1px solid var(--cor-borda);
  position: sticky; top: 0; z-index: 30;
}
.marca { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.logo {
  width: 2.1rem; height: 2.1rem;
  display: flex; align-items: center; justify-content: center;
  background: var(--cor-primaria);
  color: #fff; border-radius: 10px; font-size: 1.1rem;
}
.marca-txt { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.marca-txt strong { font-size: .98rem; }
.marca-txt span { font-size: .72rem; color: var(--cor-texto-suave); }
.topbar-dir { margin-left: auto; display: flex; align-items: center; gap: .6rem; }
.usuario-email {
  font-size: .82rem; color: var(--cor-texto-suave);
  max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.badge-papel {
  background: var(--cor-acento); color: #fff;
  font-size: .7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; padding: .25rem .7rem; border-radius: 999px;
}
.vista { flex: 1; width: 100%; max-width: 940px; margin: 0 auto; padding: 1.4rem 1.1rem 3rem; }

/* ===== Cards ===== */
.card {
  background: var(--cor-card);
  border: 1px solid var(--cor-borda);
  border-radius: var(--raio);
  box-shadow: var(--sombra);
  padding: 1.1rem 1.2rem;
  margin-bottom: 1.1rem;
}
.card-titulo { font-size: 1rem; font-weight: 700; margin-bottom: .8rem; }

.hero {
  background: linear-gradient(135deg, #0e2a47 0%, #16456f 70%);
  color: #fff; border-radius: var(--raio); padding: 1.3rem 1.4rem; margin-bottom: 1.1rem;
}
.hero h2 { color: #fff; margin-bottom: .2rem; font-size: 1.15rem; }
.hero p { color: #cbd5e1; margin: 0; font-size: .9rem; }

.cards-home { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 620px) { .cards-home { grid-template-columns: 1fr; } }
.card-home {
  display: flex; flex-direction: column; align-items: flex-start; gap: .3rem;
  background: var(--cor-card); border: 1.5px solid var(--cor-borda);
  border-radius: var(--raio); box-shadow: var(--sombra);
  padding: 1.4rem 1.3rem; cursor: pointer; text-align: left;
  font-family: inherit; color: inherit;
  transition: transform .12s ease, box-shadow .15s ease, border-color .15s ease;
}
.card-home:hover { transform: translateY(-2px); border-color: var(--cor-acento); box-shadow: 0 10px 28px rgba(15,23,42,.14); }
.card-home .emoji { font-size: 1.9rem; }
.card-home .titulo { font-size: 1.05rem; font-weight: 700; }
.card-home .desc { font-size: .85rem; color: var(--cor-texto-suave); }

/* ===== Form ===== */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem 1.1rem; }
.form-grid .coluna-toda { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.req { color: var(--cor-erro); }

.grupo-checks {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: .25rem .6rem; max-height: 220px; overflow-y: auto;
  border: 1px solid var(--cor-borda); border-radius: 8px; padding: .6rem; background: #f8fafc;
}
.grupo-checks label { display: flex; align-items: center; gap: .45rem; font-size: .86rem; cursor: pointer; }
.grupo-checks input[type="checkbox"] { accent-color: var(--cor-acento); width: 15px; height: 15px; }
.grupo-checks .vazio { color: var(--cor-texto-suave); font-size: .85rem; grid-column: 1 / -1; }

.aviso-box { background: var(--cor-aviso-bg); color: #92400e; font-size: .85rem; padding: .6rem .8rem; border-radius: 8px; margin-bottom: .9rem; }
.aviso-erro { background: var(--cor-erro-bg); color: #991b1b; font-size: .85rem; padding: .6rem .8rem; border-radius: 8px; margin-bottom: .9rem; }

/* ===== Botões ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  border: 1px solid transparent; border-radius: 8px;
  padding: .55rem .95rem; font-size: .88rem; font-weight: 600;
  font-family: inherit; cursor: pointer; background: #e2e8f0; color: var(--cor-texto);
  text-decoration: none; white-space: nowrap;
  transition: filter .15s ease, background .15s ease;
}
.btn:hover { filter: brightness(.96); }
.btn-primario { background: var(--cor-primaria-2); color: #fff; }
.btn-acento { background: var(--cor-acento); color: #fff; }
.btn-secundario { background: #fff; border-color: var(--cor-borda); }
.btn-bloco { width: 100%; }
.btn-pequeno { padding: .35rem .7rem; font-size: .8rem; }
.btn-icone { background: none; border: none; font-size: 1.15rem; cursor: pointer; color: var(--cor-texto); padding: .3rem .5rem; line-height: 1; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-voltar { font-size: 1.3rem; }

/* ===== Abas / filtros ===== */
.abas { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.aba {
  border: 1px solid var(--cor-borda); background: var(--cor-card); color: var(--cor-texto);
  border-radius: 999px; padding: .45rem .95rem; font-size: .86rem; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.aba.ativa { background: var(--cor-primaria-2); color: #fff; border-color: var(--cor-primaria-2); }
.toolbar { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar .busca {
  flex: 1; min-width: 200px; padding: .55rem .8rem;
  border: 1px solid var(--cor-borda); border-radius: 8px; font-size: .92rem;
  background: var(--cor-card); color: var(--cor-texto);
}

/* ===== Lista de tarefas ===== */
.tarefa {
  background: var(--cor-card); border: 1px solid var(--cor-borda);
  border-radius: var(--raio); box-shadow: var(--sombra);
  padding: .85rem 1rem; margin-bottom: .65rem;
}
.tarefa-top { display: flex; align-items: flex-start; gap: .6rem; flex-wrap: wrap; }
.tarefa .titulo { font-size: .97rem; font-weight: 600; flex: 1; min-width: 180px; }
.tarefa-meta {
  display: flex; gap: 1rem; flex-wrap: wrap; margin-top: .45rem;
  font-size: .82rem; color: var(--cor-texto-suave);
}
.tarefa-meta a { color: var(--cor-acento); font-weight: 600; text-decoration: none; }
.tarefa-meta a:hover { text-decoration: underline; }

/* ===== Badges de status (cores Bitrix) ===== */
.badge {
  display: inline-block; padding: .16rem .6rem; border-radius: 999px;
  font-size: .74rem; font-weight: 700; white-space: nowrap;
}
.badge.st-1 { background: #dbeafe; color: #1d4ed8; }   /* Nova */
.badge.st-2 { background: #ede9fe; color: #6d28d9; }   /* Pendente */
.badge.st-3 { background: #fef3c7; color: #b45309; }   /* Em andamento */
.badge.st-4 { background: #ffedd5; color: #c2410c; }   /* Aguardando conclusão */
.badge.st-5 { background: #dcfce7; color: #15803d; }   /* Concluída */
.badge.st-6 { background: #e2e8f0; color: #475569; }   /* Adiada */
.badge.st-7 { background: #fee2e2; color: #b91c1c; }   /* Recusada */
.badge.st-0 { background: #e2e8f0; color: #475569; }
.badge-pill-ok { background: var(--cor-ok-bg); color: var(--cor-ok); }

.sem-dados { text-align: center; color: var(--cor-texto-suave); padding: 1.8rem 0; }

/* ===== Paginação ===== */
.paginacao { display: flex; align-items: center; justify-content: center; gap: .8rem; margin-top: 1.1rem; }
.paginacao .info { font-size: .85rem; color: var(--cor-texto-suave); }

/* ===== Sucesso ===== */
.sucesso {
  text-align: center; background: var(--cor-card); border: 1px solid var(--cor-borda);
  border-radius: var(--raio); box-shadow: var(--sombra); padding: 2rem 1.4rem;
}
.sucesso .icone { font-size: 3rem; }
.sucesso h2 { color: var(--cor-ok); }
.sucesso .id { font-size: .95rem; color: var(--cor-texto-suave); }
.sucesso .acoes { display: flex; gap: .6rem; justify-content: center; flex-wrap: wrap; margin-top: 1.2rem; }

/* ===== Overlay / spinner ===== */
.loading-overlay {
  position: fixed; inset: 0; z-index: 150;
  background: rgba(15, 23, 42, .45);
  display: flex; align-items: center; justify-content: center;
}
.spinner {
  width: 44px; height: 44px;
  border: 4px solid rgba(255, 255, 255, .25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: girar .8s linear infinite;
}
.spinner-inline {
  width: 15px; height: 15px; border-width: 2px;
  border-color: rgba(14, 42, 71, .18); border-top-color: var(--cor-primaria);
  display: inline-block; vertical-align: -3px; margin-right: .5rem;
  border-radius: 50%; border-style: solid; animation: girar .8s linear infinite;
}
@keyframes girar { to { transform: rotate(360deg); } }

/* ===== Toast ===== */
.toast-container { position: fixed; bottom: 1.2rem; right: 1.2rem; z-index: 210; display: flex; flex-direction: column; gap: .5rem; }
.toast {
  background: var(--cor-texto); color: #fff; padding: .7rem 1.1rem; border-radius: 10px;
  font-size: .88rem; box-shadow: 0 8px 24px rgba(0,0,0,.25);
  display: flex; align-items: center; gap: .5rem; max-width: 360px;
  animation: toast-in .2s ease;
}
.toast.ok { background: var(--cor-ok); }
.toast.erro { background: var(--cor-erro); }
.toast.aviso { background: var(--cor-aviso); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ============================================================
 * MODO ESCURO
 * ============================================================ */
html.tema-escuro {
  --cor-primaria: #2b4c7e;
  --cor-primaria-2: #33598f;
  --cor-acento: #38bdf8;
  --cor-bg: #0b1220;
  --cor-card: #141e30;
  --cor-texto: #e2e8f0;
  --cor-texto-suave: #94a3b8;
  --cor-borda: #2b3b55;
  --cor-ok: #4ade80;
  --cor-ok-bg: #12301e;
  --cor-erro: #f87171;
  --cor-erro-bg: #3b1214;
  --cor-aviso: #fbbf24;
  --cor-aviso-bg: #3a2c0e;
  --sombra: 0 1px 3px rgba(0,0,0,.45), 0 8px 22px rgba(0,0,0,.4);
}
html.tema-escuro .campo input, html.tema-escuro .campo select, html.tema-escuro .campo textarea,
html.tema-escuro .toolbar .busca {
  background: #0d1727; color: var(--cor-texto);
}
html.tema-escuro .campo input::placeholder { color: #64748b; }
html.tema-escuro .btn-secundario { background: #141e30; color: var(--cor-texto); }
html.tema-escuro .btn { background: #1e2c44; color: var(--cor-texto); }
html.tema-escuro .btn-primario, html.tema-escuro .btn-acento { color: #fff; }
html.tema-escuro .btn-primario { background: var(--cor-primaria-2); }
html.tema-escuro .btn-acento { background: var(--cor-acento); }
html.tema-escuro .grupo-checks { background: #0f1a2c; }
html.tema-escuro .aviso-box { background: var(--cor-aviso-bg); color: #fde68a; }
html.tema-escuro .aviso-erro { background: var(--cor-erro-bg); color: #fecaca; }
html.tema-escuro .card-home:hover { box-shadow: 0 12px 30px rgba(0,0,0,.5); }
html.tema-escuro .badge.st-1 { background: #12294d; color: #93c5fd; }
html.tema-escuro .badge.st-2 { background: #2a2350; color: #c4b5fd; }
html.tema-escuro .badge.st-3 { background: #3a2c0e; color: #fcd34d; }
html.tema-escuro .badge.st-4 { background: #3a1f0e; color: #fdba74; }
html.tema-escuro .badge.st-5 { background: #12301e; color: #86efac; }
html.tema-escuro .badge.st-6 { background: #1e2c44; color: #cbd5e1; }
html.tema-escuro .badge.st-7 { background: #3b1214; color: #fca5a5; }
html.tema-escuro .badge.st-0 { background: #1e2c44; color: #cbd5e1; }

/* ============================================================
 * Combobox com busca por digitação (componente único)
 * ============================================================ */
.combo-host { position: relative; }
.combo { position: relative; }
.combo-controle {
  display: flex; align-items: center; gap: .2rem;
  border: 1px solid var(--cor-borda); border-radius: 8px;
  background: #fff; padding-right: .35rem;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.combo-controle:focus-within {
  border-color: var(--cor-acento);
  box-shadow: 0 0 0 2px rgba(14, 165, 233, .25);
}
.combo .combo-input {
  flex: 1 1 auto; min-width: 0; width: 100%;
  border: none !important; background: transparent !important;
  padding: .55rem .7rem; font-size: .95rem; font-family: inherit;
  color: var(--cor-texto); outline: none !important; border-radius: 8px;
}
.combo .combo-input::placeholder { color: var(--cor-texto-suave); opacity: .85; }
.combo-acao {
  border: none; background: none; cursor: pointer; line-height: 1;
  font-size: .85rem; color: var(--cor-texto-suave);
  padding: .25rem .35rem; border-radius: 6px;
}
.combo-acao:hover { color: var(--cor-erro); background: rgba(0, 0, 0, .06); }
.combo-seta { color: var(--cor-texto-suave); font-size: .72rem; pointer-events: none; padding-right: .1rem; }
.combo-lista {
  position: absolute; z-index: 60; left: 0; right: 0; top: calc(100% + 4px);
  max-height: 250px; overflow-y: auto;
  background: var(--cor-card); border: 1px solid var(--cor-borda);
  border-radius: 8px; box-shadow: var(--sombra); padding: .3rem;
}
.combo-opcao {
  padding: .45rem .6rem; border-radius: 6px; font-size: .9rem;
  cursor: pointer; white-space: normal;
}
.combo-opcao.ativo, .combo-opcao:hover { background: rgba(14, 165, 233, .14); }
.combo-opcao.selecionado { font-weight: 700; }
.combo-opcao.selecionado::after { content: " ✓"; color: var(--cor-acento); }
.combo-vazio { padding: .6rem; font-size: .85rem; color: var(--cor-texto-suave); text-align: center; }
.combo-chips { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .35rem; }
.chip {
  display: inline-flex; align-items: center; gap: .3rem;
  background: rgba(14, 165, 233, .14); color: var(--cor-texto);
  border-radius: 999px; padding: .18rem .3rem .18rem .65rem; font-size: .82rem;
}
.chip-x {
  border: none; background: none; cursor: pointer; line-height: 1;
  color: var(--cor-texto-suave); font-size: .78rem;
  padding: .12rem .28rem; border-radius: 50%;
}
.chip-x:hover { color: var(--cor-erro); background: rgba(0, 0, 0, .1); }
.combo-desabilitado .combo-controle { background: #f1f5f9; opacity: .7; cursor: not-allowed; }
.combo-desabilitado .combo-input { cursor: not-allowed; }
.combo-desabilitado .combo-seta { opacity: .5; }

html.tema-escuro .combo-controle { background: #0d1727; }
html.tema-escuro .combo-desabilitado .combo-controle { background: #0f1a2c; }
html.tema-escuro .combo-lista { background: var(--cor-card); }
html.tema-escuro .combo-opcao.ativo, html.tema-escuro .combo-opcao:hover { background: rgba(56, 189, 248, .18); }
html.tema-escuro .chip { background: rgba(56, 189, 248, .2); }
html.tema-escuro .combo-acao:hover { background: rgba(255, 255, 255, .08); }
html.tema-escuro .chip-x:hover { background: rgba(255, 255, 255, .12); }
