/* ============================================================
   components.css — Badges, cards, tabelas, botões, modais, forms
   ============================================================ */

/* ── Botões ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: .875rem;
  font-weight: 500;
  border: 1px solid transparent;
  transition: all .15s;
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary {
  background: var(--brand-primary);
  color: #fff;
  border-color: var(--brand-primary);
}
.btn-primary:hover { background: #1d4ed8; border-color: #1d4ed8; text-decoration: none; color: #fff; }

.btn-secondary {
  background: #fff;
  color: var(--text-primary);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg-page); border-color: #cbd5e1; text-decoration: none; }

.btn-danger {
  background: var(--prio-urgente);
  color: #fff;
  border-color: var(--prio-urgente);
}
.btn-danger:hover { background: #dc2626; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--bg-page); color: var(--text-primary); text-decoration: none; }

.btn-sm { padding: var(--space-1) var(--space-3); font-size: .8125rem; }
.btn-lg { padding: var(--space-3) var(--space-6); font-size: 1rem; }

.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-icon {
  width: 32px; height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  transition: all .15s;
}
.btn-icon:hover { background: var(--bg-page); color: var(--text-primary); }

/* ── Badges de Status ──────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: .75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* Projeto status */
.badge-planejamento  { background: #f1f5f9; color: var(--status-planejamento); }
.badge-andamento     { background: #f0fdf4; color: #16a34a; }
.badge-pausado       { background: #fffbeb; color: #d97706; }
.badge-concluido     { background: #eff6ff; color: #2563eb; }
.badge-cancelado     { background: #f9fafb; color: #6b7280; }

/* Tarefa status */
.badge-a-fazer       { background: #f1f5f9; color: var(--status-a-fazer); }
.badge-em-andamento  { background: #eff6ff; color: #2563eb; }
.badge-aguardando    { background: #fffbeb; color: #d97706; }
.badge-concluida     { background: #f0fdf4; color: #16a34a; }
.badge-cancelada     { background: #f9fafb; color: #6b7280; }

/* Prioridade */
.badge-urgente       { background: #fef2f2; color: #dc2626; }
.badge-alta          { background: #fff7ed; color: #ea580c; }
.badge-media         { background: #eff6ff; color: #2563eb; }
.badge-baixa         { background: #f8fafc; color: #64748b; }

/* Demanda origem */
.badge-origem        { background: #f1f5f9; color: #475569; }

/* Utilitários */
.badge-atrasada      { background: #fef2f2; color: #dc2626; }
.badge-vencendo      { background: #fffbeb; color: #d97706; }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
}

.card-subtitle {
  font-size: .8125rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Counter card (dashboard) */
.counter-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.counter-label {
  font-size: .75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-secondary);
}

.counter-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text-primary);
}

.counter-card.danger .counter-value { color: var(--prio-urgente); }
.counter-card.warning .counter-value { color: var(--status-pausado); }
.counter-card.success .counter-value { color: var(--status-andamento); }

/* Projeto card */
.projeto-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  transition: box-shadow .15s, border-color .15s;
  text-decoration: none;
  color: inherit;
}

.projeto-card:hover {
  box-shadow: var(--shadow-md);
  border-color: #cbd5e1;
  text-decoration: none;
}

.projeto-card-info {
  flex: 1;
  min-width: 0;
}

.projeto-card-nome {
  font-size: .9375rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.projeto-card-meta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-1);
  font-size: .8125rem;
  color: var(--text-secondary);
}

/* Barra de progresso */
.progress-bar {
  width: 80px;
  height: 6px;
  background: var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
  flex-shrink: 0;
}

.progress-fill {
  height: 100%;
  background: var(--brand-primary);
  border-radius: var(--radius-full);
  transition: width .3s ease;
}

.progress-label {
  font-size: .75rem;
  color: var(--text-secondary);
  text-align: right;
  width: 32px;
  flex-shrink: 0;
}

/* ── Tabelas ───────────────────────────────────────────────── */
.table-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .8125rem;
}

.table thead {
  background: var(--bg-page);
}

.table th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }

.table tbody tr:hover { background: #fafafa; }

.table tbody tr.atrasada td { background: #fef9f9; }

.table-empty {
  text-align: center;
  padding: var(--space-10);
  color: var(--text-muted);
}

/* ── Forms ─────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-bottom: var(--space-4);
}

.form-label {
  font-size: .8125rem;
  font-weight: 500;
  color: var(--text-primary);
}

.form-label.required::after {
  content: ' *';
  color: var(--prio-urgente);
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--text-primary);
  transition: border-color .15s;
  outline: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59,130,246,.1);
}

.form-input::placeholder, .form-textarea::placeholder { color: var(--text-muted); }

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

.form-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 16px;
  padding-right: 32px;
}

.form-hint { font-size: .75rem; color: var(--text-muted); }
.form-error { font-size: .75rem; color: var(--prio-urgente); }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

/* ── Modal ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: var(--space-6);
  z-index: 1000;
  overflow-y: auto;
  animation: fadeIn .15s ease;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  width: 100%;
  max-width: 520px;
  margin: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp .2s ease;
}

.modal-lg { max-width: 720px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
}

.modal-title { font-size: 1.0625rem; font-weight: 600; }

.modal-close {
  width: 32px; height: 32px;
  border-radius: var(--radius-md);
  background: none;
  border: none;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  transition: background .15s;
}
.modal-close:hover { background: var(--bg-page); }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ── Alertas inline ────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: .875rem;
  margin-bottom: var(--space-4);
}

.alert-danger  { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert-warning { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.alert-info    { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }

/* ── Estado vazio ──────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: var(--space-10) var(--space-6);
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: var(--space-3);
}

.empty-state-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

/* ── Linha de tarefa (listagem inline) ─────────────────────── */
.tarefa-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  transition: background .1s;
}

.tarefa-row:hover { background: var(--bg-page); }

.tarefa-row-title {
  flex: 1;
  font-size: .875rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tarefa-row.atrasada .tarefa-row-title {
  color: var(--prio-urgente);
}

/* ── Chip de prazo ─────────────────────────────────────────── */
.prazo-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .75rem;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.prazo-chip.atrasado  { background: #fef2f2; color: #dc2626; }
.prazo-chip.urgente   { background: #fffbeb; color: #d97706; }
.prazo-chip.normal    { background: #f1f5f9; color: #64748b; }

/* ── Divisor ───────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-5) 0;
}

/* ── Skeleton loading ──────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Tooltip simples ───────────────────────────────────────── */
[data-tooltip] {
  position: relative;
}
[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-sidebar);
  color: #fff;
  font-size: .75rem;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  pointer-events: none;
  z-index: 999;
}
