/* ============================================
   COMPONENTS - Buttons, Cards, Inputs, etc.
   ============================================ */

/* ----- Buttons ----- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 0.9375rem;
  transition: all var(--transition-fast);
  min-height: 44px;
  min-width: 44px;
}

.btn-primary {
  background: var(--accent);
  color: var(--text-inverse);
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: var(--shadow-glow);
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
}

.btn-secondary:hover {
  background: var(--accent-muted);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #DC2626;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.875rem;
  min-height: 36px;
}

.btn-block {
  width: 100%;
}

/* ----- Cards ----- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-fast);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-accent {
  background: linear-gradient(135deg, #FF6B00 0%, #E55A00 100%);
  border: none;
  color: white;
}

.card-accent .text-muted,
.card-accent .text-secondary,
.card-accent .label {
  color: rgba(255, 255, 255, 0.85) !important;
}

.card-accent-purple {
  background: linear-gradient(135deg, #A855F7 0%, #7C3AED 100%);
  border: none;
  color: white;
}

.card-accent-purple .text-muted,
.card-accent-purple .text-secondary,
.card-accent-purple .label {
  color: rgba(255, 255, 255, 0.85) !important;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.card-title {
  font-size: 1.125rem;
  font-weight: 600;
}

/* ----- Inputs ----- */
.input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input::placeholder {
  color: var(--text-muted);
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-muted);
}

.input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.input-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}

/* ----- Badge ----- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-success { background: rgba(34, 197, 94, 0.2); color: var(--success); }
.badge-danger { background: rgba(239, 68, 68, 0.2); color: var(--danger); }
.badge-warning { background: rgba(245, 158, 11, 0.2); color: var(--warning); }
.badge-muted { background: var(--bg-elevated); color: var(--text-muted); }
.badge-info { background: rgba(59, 130, 246, 0.2); color: var(--info); }

/* ----- Avatar ----- */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1rem;
  color: var(--accent);
}

.avatar-sm {
  width: 32px;
  height: 32px;
  font-size: 0.875rem;
}

/* ----- Table ----- */
.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  text-align: left;
  padding: var(--space-3) var(--space-3);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.table td {
  padding: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover {
  background: var(--bg-elevated);
}

.table .col-right { text-align: right; }
.table .col-actions { text-align: right; white-space: nowrap; }

/* Botões de ícone reutilizáveis pra colunas de ação de qualquer tabela (Visualizar/Editar/Baixar/Excluir etc). */
.icon-action-btn {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.icon-action-btn:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.icon-action-btn.btn-excluir:hover,
.icon-action-btn.btn-excluir-doc:hover,
.icon-action-btn.btn-excluir-tipo:hover {
  color: var(--danger);
}

@media (max-width: 639px) {
  .icon-action-btn {
    width: 36px;
    height: 36px;
  }
}

@media (max-width: 767px) {
  .table thead { display: none; }

  .table, .table tbody, .table tr, .table td {
    display: block;
    width: 100%;
  }

  .table tr {
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--border-subtle);
  }

  .table td {
    border: none;
    padding: 4px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
  }

  .table td.col-actions {
    justify-content: flex-end;
  }

  .table td::before {
    content: attr(data-label);
    font-size: 0.75rem;
    color: var(--text-muted);
    flex-shrink: 0;
  }

  .table td[data-label=""]::before,
  .table td:not([data-label])::before {
    content: none;
  }
}

/* ----- List ----- */
.list-item {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition-fast);
}

.list-item:last-child {
  border-bottom: none;
}

.list-item:hover {
  background: var(--bg-elevated);
}

/* ----- Modal ----- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--space-4);
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease;
}

.modal-header {
  padding: var(--space-6);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 600;
}

.modal-close {
  width: 44px;
  height: 44px;
  font-size: 30px;
  line-height: 1;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.modal-body {
  padding: var(--space-6);
}

.modal-footer {
  padding: var(--space-6);
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ----- Toast ----- */
.toast-container {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.toast {
  padding: var(--space-4) var(--space-5);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  animation: slideIn 0.3s ease;
}

.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--danger); }
.toast-warning { border-left: 4px solid var(--warning); }

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ----- Loading ----- */
.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent);
  border-radius: var(--radius-full);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(13, 13, 13, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: inherit;
  z-index: 10;
}
