/* ================================================================
   CPA — Tela de Aplicações
   css/aplicacoes.css
   Versão: 2.0 — Consistente com questionarios.css (padrão SUAP)
   ================================================================ */

/* ────────────────────────────────────────────────────────────────
   ÍCONE DO CABEÇALHO DA PÁGINA
   ──────────────────────────────────────────────────────────────── */
.apl-header-icon {
  background: linear-gradient(135deg, #d1fae5, #a7f3d0) !important;
  color: #065f46 !important;
}

/* ────────────────────────────────────────────────────────────────
   ÍCONE DA SEÇÃO DE FORMULÁRIO
   ──────────────────────────────────────────────────────────────── */
.apl-section-icon--orange {
  background: #fff7ed;
  color: #c2410c;
}

/* ────────────────────────────────────────────────────────────────
   BOTÃO PRIMÁRIO DA APLICAÇÃO (laranja/gradiente)
   ──────────────────────────────────────────────────────────────── */
.apl-btn--primary {
  background: linear-gradient(135deg, #c2410c, #ea580c);
  color: #fff;
  border-color: #c2410c;
}
.apl-btn--primary:hover {
  background: linear-gradient(135deg, #9a3412, #c2410c);
  border-color: #9a3412;
}

/* ────────────────────────────────────────────────────────────────
   QUESTIONÁRIO — SELECT COM BUSCA EMBUTIDA
   ──────────────────────────────────────────────────────────────── */
.apl-qselect {
  position: relative;
}

/* Trigger (barra de busca) */
.apl-qselect-trigger {
  display: flex;
  align-items: center;
  height: 36px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  overflow: hidden;
  transition: border-color .2s, box-shadow .2s;
  cursor: text;
}

.apl-qselect-trigger:focus-within {
  border-color: var(--color-primary-light);
  box-shadow: 0 0 0 3px rgba(76,175,110,.12);
}

.apl-qselect-icon {
  padding: 0 10px;
  color: var(--color-text-muted);
  font-size: .8rem;
  flex-shrink: 0;
  pointer-events: none;
}

.apl-qselect-input {
  flex: 1;
  height: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--font-base);
  font-size: .82rem;
  color: var(--color-text-primary);
  min-width: 0;
}

.apl-qselect-input::placeholder { color: var(--color-text-muted); }

.apl-qselect-arrow {
  padding: 0 10px;
  color: var(--color-text-muted);
  font-size: .65rem;
  transition: transform .2s;
  flex-shrink: 0;
  cursor: pointer;
}

/* Dropdown do questionário */
.apl-qselect-dropdown {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 28px rgba(0,0,0,.12), 0 2px 8px rgba(0,0,0,.06);
  max-height: 320px;
  overflow-y: auto;
  z-index: 600;
  display: none;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

.apl-qselect-dropdown.open { display: block; }

.apl-qselect-list { display: flex; flex-direction: column; }

/* Item do dropdown */
.apl-qselect-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 11px 14px;
  cursor: pointer;
  transition: background .1s;
  border-bottom: 1px solid var(--color-border);
}

.apl-qselect-item:last-child { border-bottom: none; }
.apl-qselect-item:hover { background: var(--color-bg); }
.apl-qselect-item--selected { background: var(--color-primary-xlight); }

.apl-qselect-item-main {
  display: flex;
  align-items: center;
  gap: 8px;
}

.apl-qselect-item-icon {
  color: var(--color-text-muted);
  font-size: .8rem;
  flex-shrink: 0;
}

.apl-qselect-item--selected .apl-qselect-item-icon { color: var(--color-primary); }

.apl-qselect-item-nome {
  font-size: .82rem;
  font-weight: 500;
  color: var(--color-text-primary);
  flex: 1;
  line-height: 1.3;
}

.apl-qselect-check {
  color: var(--color-primary);
  font-size: .75rem;
  flex-shrink: 0;
}

.apl-qselect-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-left: 24px;
}

/* Tags de tipo/ciclo/status dentro do dropdown */
.apl-q-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: .67rem;
  font-weight: 600;
}

.apl-q-tag--inst   { background: #ebf4ff; color: #2b6cb0; border: 1px solid #bee3f8; }
.apl-q-tag--curso  { background: #fdf2f8; color: #97266d; border: 1px solid #fbb6ce; }
.apl-q-tag--ciclo  { background: #f0f4f8; color: var(--color-text-secondary); border: 1px solid var(--color-border); }
.apl-q-tag--status-ativo   { background: #d4edda; color: #155724; border: 1px solid #b3d9bc; }
.apl-q-tag--status-inativo { background: #f5f5f5; color: #6b7280; border: 1px solid #d1d5db; }

/* Empty de busca no dropdown */
.apl-qselect-empty {
  display: none;
  align-items: center;
  gap: 8px;
  justify-content: center;
  padding: 20px 16px;
  color: var(--color-text-muted);
  font-size: .78rem;
  font-style: italic;
}

/* ────────────────────────────────────────────────────────────────
   PREVIEW DO QUESTIONÁRIO SELECIONADO
   ──────────────────────────────────────────────────────────────── */
.apl-q-preview {
  margin-top: 10px;
  padding: 12px 14px;
  background: #f6faf7;
  border: 1px solid #c3dfc8;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: aplFadeIn .2s ease;
}

@keyframes aplFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.apl-q-preview-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.apl-q-preview-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: .74rem;
  font-weight: 600;
}

.apl-q-preview-dims {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

/* ────────────────────────────────────────────────────────────────
   CHIPS — VARIAÇÕES DE APLICAÇÕES
   ──────────────────────────────────────────────────────────────── */

/* Chip "Todos os campi" */
.q-chip--especial {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1e40af;
}

.q-chip--especial .q-chip-icon { color: #3b82f6; }
.q-chip--especial .q-chip-remove { color: #3b82f6; }
.q-chip--especial .q-chip-remove:hover { background: #3b82f6; color: #fff; }

/* Chip de curso individual */
.q-chip--curso {
  background: #fefce8;
  border-color: #fde68a;
  color: #92400e;
}

.q-chip--curso .q-chip-icon { color: #d97706; }
.q-chip--curso .q-chip-remove { color: #d97706; }
.q-chip--curso .q-chip-remove:hover { background: #d97706; color: #fff; }

/* Chip de público */
.q-chip--publico {
  background: #fdf4ff;
  border-color: #e9d5ff;
  color: #7e22ce;
}

.q-chip--publico .q-chip-icon { color: #9333ea; }
.q-chip--publico .q-chip-remove { color: #9333ea; }
.q-chip--publico .q-chip-remove:hover { background: #9333ea; color: #fff; }

/* Item especial no multiselect (Todos os campi) */
.q-ms-item--especial {
  background: #f0f7ff;
  border-bottom: 1px solid #bfdbfe;
}

.q-ms-item--especial:hover { background: #dbeafe; }
.q-ms-item--especial:has(input:checked) { background: #dbeafe; }

.q-ms-item-label--especial {
  color: #1e40af;
  font-weight: 600;
}

/* ────────────────────────────────────────────────────────────────
   TABELA — ELEMENTOS ESPECÍFICOS DE APLICAÇÕES
   ──────────────────────────────────────────────────────────────── */

/* Meta (datas + campi) abaixo do nome */
.apl-nome-meta {
  display: block;
  font-size: .7rem;
  color: var(--color-text-muted);
  margin-top: 2px;
  font-family: 'Courier New', monospace;
}

.apl-nome-publico {
  display: block;
  font-size: .68rem;
  color: var(--color-text-muted);
  margin-top: 1px;
  font-style: italic;
}

/* Ano na tabela */
.apl-td-ano {
  font-family: 'Courier New', monospace;
  font-size: .78rem;
  font-weight: 600;
  color: var(--color-text-secondary);
}

/* Respostas */
.apl-resp-num {
  font-size: .84rem;
  color: var(--color-text-muted);
  font-weight: 400;
}

.apl-resp-num--pos {
  color: var(--color-primary);
  font-weight: 700;
}

/* ────────────────────────────────────────────────────────────────
   BADGES DE STATUS — APLICAÇÕES
   ──────────────────────────────────────────────────────────────── */
.apl-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: .71rem;
  font-weight: 700;
  white-space: nowrap;
}

.apl-badge--gray  { background: #f3f4f6; color: #6b7280; border: 1px solid #d1d5db; }
.apl-badge--green { background: #d4edda; color: #155724; border: 1px solid #b3d9bc; }
.apl-badge--red   { background: #fde8e8; color: #9b2c2c; border: 1px solid #fbb6b6; }

/* ────────────────────────────────────────────────────────────────
   BOTÕES DE AÇÃO ESPECÍFICOS (Publicar / Encerrar)
   ──────────────────────────────────────────────────────────────── */
.apl-action-btn--pub {
  color: #1c5c2f;
  background: var(--color-primary-xlight);
  border: 1px solid #c3dfc8;
}

.apl-action-btn--end {
  color: #744210;
  background: #fffbeb;
  border: 1px solid #fcd99a;
}

.apl-action-btn--pub:hover,
.apl-action-btn--end:hover {
  filter: brightness(.9);
  transform: scale(1.09);
}

/* ────────────────────────────────────────────────────────────────
   MODAL VISUALIZAÇÃO — ÁREA DE CHIPS
   ──────────────────────────────────────────────────────────────── */
.apl-view-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

/* ícone do modal de aplicação */
.apl-modal-icon--orange {
  color: #c2410c;
}

/* ────────────────────────────────────────────────────────────────
   CAMPO: Input com ícone de calendário (reutiliza q-input-icon-wrap)
   ──────────────────────────────────────────────────────────────── */
.q-input-icon-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.q-input-icon {
  position: absolute;
  left: 10px;
  color: var(--color-text-muted);
  font-size: .8rem;
  pointer-events: none;
  z-index: 1;
}

.q-input--date { padding-left: 32px; cursor: pointer; }

/* ────────────────────────────────────────────────────────────────
   RESPONSIVIDADE ESPECÍFICA DE APLICAÇÕES
   ──────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .apl-qselect-item-meta { margin-left: 0; }
}

@media (max-width: 768px) {
  /* Oculta colunas secundárias no mobile */
  .q-table th:nth-child(3),
  .q-table td:nth-child(3),
  .q-table th:nth-child(4),
  .q-table td:nth-child(4) { display: none; }
}

@media (max-width: 480px) {
  /* Oculta Dimensões no mobile pequeno */
  .q-table th:nth-child(5),
  .q-table td:nth-child(5) { display: none; }

  .apl-nome-meta,
  .apl-nome-publico { display: none; }
}
