* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --roxo: #4A1B7A;
  --laranja: #E85D04;
  --azul: #0077B6;
  --verde: #2D6A4F;
  --vermelho: #C1121F;
  --amarelo: #E09F3E;
  --cinza-bg: #F5F5F5;
  --cinza-borda: #DDD;
  --branco: #FFF;
  --preto: #1A1A1A;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--cinza-bg);
  color: var(--preto);
  line-height: 1.6;
}

header {
  background: var(--roxo);
  color: var(--branco);
  padding: 1.5rem 2rem;
}

.header-content h1 {
  font-family: 'Poppins', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
}

.subtitle {
  font-size: 0.9rem;
  opacity: 0.8;
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

/* Cards Resumo */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

.card {
  padding: 1.5rem;
  border-radius: 12px;
  color: var(--branco);
  text-align: center;
}

.card h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.card .count {
  font-size: 2.5rem;
  font-weight: 700;
}

.card-forca { background: var(--verde); }
.card-fraqueza { background: var(--vermelho); }
.card-oportunidade { background: var(--azul); }
.card-ameaca { background: var(--amarelo); color: var(--preto); }

/* Matriz FOFA */
.matriz-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 2rem;
}

.quadrante {
  background: var(--branco);
  border-radius: 12px;
  padding: 1.5rem;
  border-left: 4px solid;
  min-height: 200px;
}

.q-forca { border-color: var(--verde); }
.q-fraqueza { border-color: var(--vermelho); }
.q-oportunidade { border-color: var(--azul); }
.q-ameaca { border-color: var(--amarelo); }

.quadrante h2 {
  font-size: 1rem;
  margin-bottom: 1rem;
  font-weight: 600;
}

.quadrante ul {
  list-style: none;
}

.quadrante li {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--cinza-borda);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.quadrante li:last-child {
  border-bottom: none;
}

.badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 600;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge-baixo { background: #E8F5E9; color: #2E7D32; }
.badge-medio { background: #FFF3E0; color: #E65100; }
.badge-alto { background: #FFE0B2; color: #BF360C; }
.badge-critico { background: #FFCDD2; color: #B71C1C; }

.btn-delete {
  background: none;
  border: none;
  color: #999;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0 4px;
}

.btn-delete:hover {
  color: var(--vermelho);
}

/* Formulario */
.form-section {
  background: var(--branco);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.form-section h2 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
  color: var(--roxo);
}

.form-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}

select, textarea, input {
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--cinza-borda);
  border-radius: 8px;
  width: 100%;
}

textarea {
  min-height: 80px;
  resize: vertical;
  margin-bottom: 1rem;
}

button {
  background: var(--roxo);
  color: var(--branco);
  border: none;
  padding: 0.7rem 1.5rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  transition: opacity 0.2s;
}

button:hover {
  opacity: 0.85;
}

/* IA */
.ia-buttons {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.ia-buttons button {
  background: var(--azul);
}

.ia-resultado {
  white-space: pre-wrap;
  font-size: 0.9rem;
  line-height: 1.7;
  padding: 1rem;
  background: #F8F9FA;
  border-radius: 8px;
  min-height: 40px;
}

.hidden { display: none; }

#historico-list {
  margin-top: 1rem;
}

.historico-item {
  background: #F8F9FA;
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 0.75rem;
}

.historico-item .meta {
  font-size: 0.8rem;
  color: #666;
  margin-bottom: 0.5rem;
}

.historico-item .content {
  white-space: pre-wrap;
  font-size: 0.85rem;
}

/* Items */
.item-desc {
  cursor: pointer;
  flex: 1;
}

.item-desc:hover {
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}

.item-meta {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.badge-select, .move-select {
  font-size: 0.7rem;
  padding: 2px 4px;
  border-radius: 6px;
  border: 1px solid var(--cinza-borda);
  cursor: pointer;
  width: auto;
  font-weight: 600;
}

.badge-select.badge-baixo  { background: #E8F5E9; color: #2E7D32; }
.badge-select.badge-medio  { background: #FFF3E0; color: #E65100; }
.badge-select.badge-alto   { background: #FFE0B2; color: #BF360C; }
.badge-select.badge-critico { background: #FFCDD2; color: #B71C1C; }

.move-select {
  font-size: 0.65rem;
  background: #F0F0F0;
  color: #555;
}

.edit-inline {
  font-family: inherit;
  font-size: inherit;
  padding: 2px 6px;
  border: 2px solid var(--azul);
  border-radius: 6px;
  width: 100%;
  outline: none;
}

/* Drag and Drop */
.quadrante li[draggable] {
  cursor: grab;
}

.quadrante li.dragging {
  opacity: 0.4;
}

.quadrante.drag-over {
  outline: 2px dashed var(--azul);
  outline-offset: -4px;
  background: rgba(0, 119, 182, 0.04);
}

.vazio {
  color: #999;
  font-style: italic;
  font-size: 0.85rem;
  padding: 0.5rem 0;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--branco);
  background: var(--preto);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 999;
  max-width: 320px;
}

.toast.show {
  opacity: 1;
}

.toast-sucesso { background: var(--verde); }
.toast-erro    { background: var(--vermelho); }

/* Responsive */
@media (max-width: 768px) {
  .cards-grid { grid-template-columns: repeat(2, 1fr); }
  .matriz-grid { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; }
  .ia-buttons { flex-direction: column; }
  main { padding: 1rem; }
}
