/**
 * Duck Golden — Golden Factory v2
 * Reusable Components Library
 */

/* --------------------------------------------------------------------------
   BOTÕES
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: inherit;
  font-size: 0.925rem;
  font-weight: 600;
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition-fast);
  user-select: none;
  white-space: nowrap;
}

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

.btn-primary {
  background-color: var(--color-primary);
  color: #000;
  border-color: var(--color-primary-hover);
}
.btn-primary:hover:not(:disabled) {
  background-color: var(--color-primary-hover);
}

.btn-secondary {
  background-color: var(--bg-surface);
  color: var(--text-main);
  border-color: var(--border-medium);
}
.btn-secondary:hover:not(:disabled) {
  background-color: var(--bg-hover);
}

.btn-success {
  background-color: var(--color-success);
  color: #fff;
}
.btn-success:hover:not(:disabled) {
  filter: brightness(0.9);
}

.btn-danger {
  background-color: var(--color-danger);
  color: #fff;
}
.btn-danger:hover:not(:disabled) {
  filter: brightness(0.9);
}

.btn-sm {
  font-size: 0.8rem;
  padding: 0.35rem 0.65rem;
}

.btn-lg {
  font-size: 1.05rem;
  padding: 0.85rem 1.5rem;
}

/* --------------------------------------------------------------------------
   CARDS & PAINÉIS
   -------------------------------------------------------------------------- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background-color: var(--bg-surface-alt);
}

.card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-body {
  padding: 1.25rem;
}

.card-footer {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border-light);
  background-color: var(--bg-surface-alt);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* --------------------------------------------------------------------------
   KPI / CARDS DE MÉTRICAS & INDICADORES
   -------------------------------------------------------------------------- */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.metric-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--border-medium);
}

.metric-card.gold::before    { background: var(--color-primary); }
.metric-card.success::before { background: var(--color-success); }
.metric-card.info::before    { background: var(--color-info); }
.metric-card.danger::before  { background: var(--color-danger); }

.metric-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.metric-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.metric-sub {
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* --------------------------------------------------------------------------
   BADGES & TAGS
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-success { background: var(--color-success-bg); color: var(--color-success-text); }
.badge-warning { background: var(--color-warning-bg); color: var(--color-warning-text); }
.badge-danger  { background: var(--color-danger-bg);  color: var(--color-danger-text); }
.badge-info    { background: var(--color-info-bg);    color: var(--color-info-text); }
.badge-gold    { background: var(--color-primary-light); color: var(--color-primary-text); }
.badge-neutral { background: var(--bg-hover); color: var(--text-muted); border: 1px solid var(--border-light); }

/* --------------------------------------------------------------------------
   FORMULÁRIOS & INPUTS
   -------------------------------------------------------------------------- */
.form-group {
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.form-control {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface);
  color: var(--text-main);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2);
}

.input-addon-group {
  display: flex;
  align-items: stretch;
}

.input-addon-group .form-control {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  flex: 1;
}

.input-addon {
  display: flex;
  align-items: center;
  padding: 0 0.85rem;
  background-color: var(--bg-surface-alt);
  border: 1px solid var(--border-medium);
  border-left: none;
  border-top-right-radius: var(--radius-sm);
  border-bottom-right-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   GRADE UNIVERSAL DE TAMANHOS (PP..XXG / Infantil / Numérico)
   -------------------------------------------------------------------------- */
.grade-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(75px, 1fr));
  gap: 0.5rem;
  margin: 1rem 0;
}

.grade-box {
  background: var(--bg-surface);
  border: 1.5px solid var(--border-medium);
  border-radius: var(--radius-sm);
  text-align: center;
  padding: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  transition: all var(--transition-fast);
}

.grade-box:focus-within {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

.grade-label {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
}

.grade-input {
  width: 100%;
  text-align: center;
  font-size: 1.15rem;
  font-weight: 700;
  border: 1px solid var(--border-light);
  border-radius: 4px;
  padding: 0.3rem 0;
  outline: none;
  background: transparent;
  color: var(--text-main);
}

.grade-total-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1.25rem;
  font-weight: 700;
}

.grade-total-num {
  font-size: 1.25rem;
  color: var(--color-primary-text);
  background: var(--color-primary-light);
  padding: 0.2rem 0.75rem;
  border-radius: var(--radius-sm);
}

/* --------------------------------------------------------------------------
   TABELAS
   -------------------------------------------------------------------------- */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.925rem;
  text-align: left;
}

.table th {
  background-color: var(--bg-surface-alt);
  padding: 0.75rem 1rem;
  font-weight: 700;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-light);
}

.table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-main);
  vertical-align: middle;
}

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

/* --------------------------------------------------------------------------
   TABS / ABAS DE NAVEGAÇÃO
   -------------------------------------------------------------------------- */
.tabs-nav {
  display: flex;
  gap: 0.5rem;
  border-bottom: 2px solid var(--border-light);
  margin-bottom: 1.25rem;
}

.tab-btn {
  background: none;
  border: none;
  padding: 0.65rem 1.25rem;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition-fast);
}

.tab-btn:hover {
  color: var(--text-main);
}

.tab-btn.active {
  color: var(--color-primary-text);
  border-bottom-color: var(--color-primary);
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
  animation: fadeIn var(--transition-fast);
}

/* --------------------------------------------------------------------------
   MODAL / JANELA FLUTUANTE
   -------------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
  padding: 1rem;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-dialog {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(20px) scale(0.98);
  transition: transform var(--transition-normal);
}

.modal-backdrop.open .modal-dialog {
  transform: translateY(0) scale(1);
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-main);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
}
.modal-close:hover {
  background-color: var(--bg-hover);
  color: var(--text-main);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-light);
  background: var(--bg-surface-alt);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* --------------------------------------------------------------------------
   TOASTS / NOTIFICAÇÕES FLUTUANTES
   -------------------------------------------------------------------------- */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 380px;
}

.toast {
  background: var(--color-dark);
  color: #fff;
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-left: 5px solid var(--color-primary);
  animation: slideIn var(--transition-fast);
}

.toast.toast-success { border-left-color: var(--color-success); }
.toast.toast-danger  { border-left-color: var(--color-danger); }
.toast.toast-info    { border-left-color: var(--color-info); }

/* --------------------------------------------------------------------------
   SPINNERS / LOADING
   -------------------------------------------------------------------------- */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border-medium);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

.spinner-sm {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

/* --------------------------------------------------------------------------
   ANIMAÇÕES
   -------------------------------------------------------------------------- */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideIn {
  from { transform: translateX(50px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
