/* ═══════════════════════════════════════════
   COMPONENTS CSS — Componentes reutilizáveis
   Todos os valores vêm de css/variables.css
═══════════════════════════════════════════ */


/* ─────────────────────────────────────────
   1. BOTÕES
───────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: var(--btn-height);
  padding: 0 var(--btn-padding-x);
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
  transition: var(--transition-normal);
  white-space: nowrap;
  border: var(--border-width) solid transparent;
  text-decoration: none;
  font-family: inherit;
  outline: none;
  line-height: 1;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border-color: var(--color-primary);
}

.btn-primary:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text-secondary);
  border-color: var(--color-border);
}

.btn-secondary:hover {
  background: var(--color-surface-3);
  border-color: var(--color-border-strong);
}

.btn-danger {
  background: var(--color-danger);
  color: var(--color-text-inverse);
  border-color: var(--color-danger);
}

.btn-danger:hover {
  background: var(--color-danger-hover);
  border-color: var(--color-danger-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
}

.btn-ghost:hover {
  background: var(--color-surface-3);
}

.btn-sm {
  height: var(--btn-height-sm);
  padding: 0 var(--space-3);
  font-size: var(--font-size-sm);
}

.btn-lg {
  height: var(--btn-height-lg);
  padding: 0 var(--space-6);
  font-size: var(--font-size-md);
}

.btn-icon {
  width: var(--btn-height);
  padding: 0;
  justify-content: center;
}

.btn-icon.btn-sm {
  width: var(--btn-height-sm);
}

.btn-icon.btn-lg {
  width: var(--btn-height-lg);
}

.btn-loading {
  pointer-events: none;
  opacity: 0.75;
  position: relative;
}

.btn-loading::after {
  content: '';
  width: var(--font-size-base);
  height: var(--font-size-base);
  border: var(--border-width-2) solid transparent;
  border-top-color: currentColor;
  border-radius: var(--radius-full);
  animation: btn-spinner 0.6s linear infinite;
}

@keyframes btn-spinner {
  to { transform: rotate(360deg); }
}


/* ─────────────────────────────────────────
   2. CARDS
───────────────────────────────────────── */

.card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: var(--border-width) var(--border-style) var(--color-border);
  box-shadow: var(--shadow-sm);
  padding: var(--card-padding);
  transition: var(--transition-normal);
}

.card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--color-border-strong);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-4);
  border-bottom: var(--border-width) var(--border-style) var(--color-border);
}

.card-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
}

.card-body {
  /* Semântico — sem estilos extras */
}

.card-footer {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: var(--border-width) var(--border-style) var(--color-border);
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
}


/* ─────────────────────────────────────────
   3. BADGES
───────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  height: var(--badge-height);
  padding: 0 var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  white-space: nowrap;
  line-height: 1;
}

.badge-blue {
  background: var(--color-primary-light);
  color: var(--color-primary-active);
}

.badge-green {
  background: var(--color-success-light);
  color: var(--color-success-hover);
}

.badge-yellow {
  background: var(--color-warning-light);
  color: var(--color-warning-hover);
}

.badge-red {
  background: var(--color-danger-light);
  color: var(--color-danger-hover);
}

.badge-gray {
  background: var(--color-surface-3);
  color: var(--color-text-secondary);
}

.badge-dot::before {
  content: '';
  width: var(--space-1-5);
  height: var(--space-1-5);
  border-radius: var(--radius-full);
  background: currentColor;
  flex-shrink: 0;
}


/* ─────────────────────────────────────────
   4. TABELAS
───────────────────────────────────────── */

.table-wrapper {
  border: var(--border-width) var(--border-style) var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--color-surface);
}

table.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  background: var(--color-surface-2);
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-caps);
  border-bottom: var(--border-width) var(--border-style) var(--color-border);
  white-space: nowrap;
}

.table td {
  padding: var(--space-3) var(--space-4);
  font-size: var(--font-size-base);
  color: var(--color-text-primary);
  border-bottom: var(--border-width) var(--border-style) var(--color-border);
  vertical-align: middle;
}

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

.table tbody tr:hover {
  background: var(--color-surface-2);
}

.table-empty {
  text-align: center;
  padding: var(--space-12);
  color: var(--color-text-muted);
  font-size: var(--font-size-base);
}


/* ─────────────────────────────────────────
   5. AVATARS
───────────────────────────────────────── */

.avatar {
  width: var(--avatar-size-md);
  height: var(--avatar-size-md);
  border-radius: var(--radius-full);
  object-fit: cover;
  flex-shrink: 0;
}

.avatar-sm {
  width: var(--avatar-size-sm);
  height: var(--avatar-size-sm);
}

.avatar-lg {
  width: var(--avatar-size-lg);
  height: var(--avatar-size-lg);
}

.avatar-placeholder {
  background: var(--color-primary-muted);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--font-weight-bold);
  font-size: var(--font-size-sm);
  border-radius: var(--radius-full);
}


/* ─────────────────────────────────────────
   6. MODAIS
───────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  backdrop-filter: blur(var(--space-1));
}

.modal-overlay.active,
.modal-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.modal-container {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-2xl);
  width: 100%;
  max-width: var(--modal-max-width);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(var(--space-4));
  transition: var(--transition-bounce);
}

.modal-overlay.active .modal-container,
.modal-overlay.is-open .modal-container {
  transform: translateY(0);
}

.modal-container-lg {
  max-width: var(--modal-max-width-lg);
}

.modal-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: var(--border-width) var(--border-style) var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
}

.modal-close {
  width: var(--btn-height-sm);
  height: var(--btn-height-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: var(--transition-normal);
  font-size: var(--font-size-lg);
}

.modal-close:hover {
  background: var(--color-danger-muted);
  color: var(--color-danger);
}

.modal-body {
  padding: var(--space-6);
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: var(--space-4) var(--space-6);
  border-top: var(--border-width) var(--border-style) var(--color-border);
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
  flex-shrink: 0;
}


/* ─────────────────────────────────────────
   7. SKELETON LOADING
───────────────────────────────────────── */

.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-surface-3) 25%,
    var(--color-border) 50%,
    var(--color-surface-3) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

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

.skeleton-text {
  height: var(--font-size-base);
  margin-bottom: var(--space-2);
}

.skeleton-title {
  height: var(--font-size-xl);
  margin-bottom: var(--space-3);
}

.skeleton-image {
  height: var(--space-24);
  border-radius: var(--radius-md);
}

.skeleton-card {
  padding: var(--card-padding);
  border: var(--border-width) var(--border-style) var(--color-border);
  border-radius: var(--radius-lg);
}


/* ─────────────────────────────────────────
   8. TOAST (container já no layout)
───────────────────────────────────────── */

#toast-container {
  position: fixed;
  top: var(--space-6);
  right: var(--space-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  border: var(--border-width) var(--border-style) var(--color-border);
  box-shadow: var(--shadow-lg);
  font-size: var(--font-size-sm);
  color: var(--color-text-primary);
  pointer-events: auto;
  animation: toast-in var(--transition-bounce) forwards;
  max-width: var(--modal-max-width);
}

.toast.toast-success {
  border-left: var(--radius-xs) var(--border-style) var(--color-success);
}

.toast.toast-error {
  border-left: var(--radius-xs) var(--border-style) var(--color-danger);
}

.toast.toast-warning {
  border-left: var(--radius-xs) var(--border-style) var(--color-warning);
}

.toast.toast-info {
  border-left: var(--radius-xs) var(--border-style) var(--color-info);
}

.toast-out {
  animation: toast-out var(--transition-normal) forwards;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(var(--space-8)); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(var(--space-8)); }
}


/* ─────────────────────────────────────────
   9. CONFIRM DIALOG
───────────────────────────────────────── */

.confirm-icon {
  width: var(--space-12);
  height: var(--space-12);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-4);
  font-size: var(--font-size-2xl);
}

.confirm-icon.danger {
  background: var(--color-danger-muted);
  color: var(--color-danger);
}

.confirm-icon.warning {
  background: var(--color-warning-muted);
  color: var(--color-warning);
}

.confirm-message {
  text-align: center;
  font-size: var(--font-size-base);
  color: var(--color-text-secondary);
  line-height: var(--line-height-relaxed);
}
