/* ============================================================
   ARCA — Design System: Componentes Reutilizáveis
   Botões, cards, inputs, dropdowns, tabelas, modais, badges,
   toasts, tabs, empty states, alertas.
   ============================================================ */

/* ---------------- Botões ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-btn);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: var(--fs-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--dur) var(--ease);
  background: var(--surface-2);
  color: var(--text);
}
.btn svg { width: 15px; height: 15px; }
.btn:hover { filter: brightness(0.97); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--brand-navy); color: #F8FAFC; box-shadow: var(--shadow-1); }
[data-theme="dark"] .btn-primary { background: #F8FAFC; color: var(--brand-navy); }
.btn-gold    { background: var(--brand-gold); color: #0F172A; }
.btn-ghost   { background: transparent; border-color: var(--border); color: var(--text-2); }
.btn-ghost:hover { color: var(--text); border-color: var(--surface-3); }
.btn-danger  { background: var(--negative-soft); color: var(--negative); }
.btn-sm      { padding: 6px 12px; font-size: var(--fs-xs); border-radius: 10px; }
.btn:disabled { opacity: 0.5; pointer-events: none; }

/* ---------------- Cards ---------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-card);
  padding: var(--sp-2);
  box-shadow: var(--shadow-1);
  transition: box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.card.hoverable:hover { box-shadow: var(--shadow-2); border-color: var(--border); }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-1); margin-bottom: var(--sp-2); }
.card-title h3 { font-size: var(--fs-md); font-weight: 700; }
.card-title svg { width: 16px; height: 16px; color: var(--text-3); }

/* KPI (indicadores do dashboard) */
.kpi { display: flex; flex-direction: column; gap: 4px; }
.kpi .kpi-label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-3); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.kpi .kpi-label svg { width: 14px; height: 14px; }
.kpi .kpi-value { font-family: var(--font-mono); font-size: var(--fs-xl); font-weight: 600; letter-spacing: -0.03em; }
.kpi .kpi-delta { font-size: var(--fs-xs); display: flex; align-items: center; gap: 4px; }
.kpi .kpi-delta.up { color: var(--positive); }
.kpi .kpi-delta.down { color: var(--negative); }

/* ---------------- Inputs / Forms ---------------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: var(--fs-xs); font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.06em; }
.field .req { color: var(--negative); }

.input, .select, .textarea {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-input);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-sm);
  outline: none;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand-gold);
  box-shadow: 0 0 0 3px var(--brand-gold-soft);
}
.textarea { min-height: 88px; resize: vertical; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
.field .hint { font-size: var(--fs-xs); color: var(--text-3); }
.field.invalid .input, .field.invalid .select { border-color: var(--negative); }
.field .error-msg { font-size: var(--fs-xs); color: var(--negative); }

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-2); }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

/* Toggle */
.toggle { position: relative; width: 42px; height: 24px; flex-shrink: 0; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.toggle .track { position: absolute; inset: 0; border-radius: var(--radius-full); background: var(--surface-3); transition: background var(--dur) var(--ease); }
.toggle .thumb { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-1); transition: transform var(--dur) var(--ease); }
.toggle input:checked ~ .track { background: var(--brand-gold); }
.toggle input:checked ~ .thumb { transform: translateX(18px); }

/* Busca */
.search-box { position: relative; }
.search-box svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--text-3); pointer-events: none; }
.search-box .input { padding-left: 36px; }

/* ---------------- Badges ---------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: var(--fs-xs);
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-2);
  white-space: nowrap;
}
.badge.green  { background: var(--positive-soft); color: var(--positive); }
.badge.red    { background: var(--negative-soft); color: var(--negative); }
.badge.orange { background: var(--warning-soft);  color: var(--warning); }
.badge.blue   { background: var(--info-soft);     color: var(--info); }
.badge.gold   { background: var(--brand-gold-soft); color: var(--brand-gold-strong); }
.badge.navy   { background: var(--brand-navy); color: var(--brand-gold); }

/* ---------------- Tabela ---------------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-card); border: 1px solid var(--border-soft); background: var(--surface); box-shadow: var(--shadow-1); }
table.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th {
  text-align: left;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
  font-weight: 600;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.table th.sorted { color: var(--text); }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.table tbody tr { transition: background var(--dur) var(--ease); cursor: pointer; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .row-actions { display: flex; gap: 4px; opacity: 0; transition: opacity var(--dur) var(--ease); justify-content: flex-end; }
.table tr:hover .row-actions { opacity: 1; }
@media (hover: none) { .table .row-actions { opacity: 1; } }

/* ---------------- Modal ---------------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: var(--scrim);
  z-index: 90;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: var(--sp-4) var(--sp-2);
  overflow-y: auto;
  animation: fadeIn var(--dur) var(--ease);
  backdrop-filter: blur(3px);
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-card);
  width: 100%;
  max-width: 680px;
  box-shadow: var(--shadow-3);
  animation: scaleIn var(--dur) var(--ease);
  border: 1px solid var(--border-soft);
}
.modal.modal-sm { max-width: 440px; }
.modal.modal-lg { max-width: 880px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--border-soft); }
.modal-body { padding: var(--sp-3); }
.modal-foot { display: flex; justify-content: flex-end; gap: var(--sp-1); padding: var(--sp-2) var(--sp-3); border-top: 1px solid var(--border-soft); }

/* ---------------- Dropdown ---------------- */
.dropdown {
  position: absolute;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-3);
  padding: 8px;
  z-index: 80;
  animation: scaleIn 200ms var(--ease);
}
.dropdown-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: 0; background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: var(--fs-sm);
  color: var(--text);
  text-align: left;
  transition: background var(--dur) var(--ease);
}
.dropdown-item:hover { background: var(--surface-2); }
.dropdown-item svg { width: 15px; height: 15px; color: var(--text-3); }
.dropdown-sep { height: 1px; background: var(--border-soft); margin: 6px 4px; }

/* ---------------- Toast ---------------- */
.toast-zone { position: fixed; bottom: var(--sp-3); right: var(--sp-3); z-index: 100; display: flex; flex-direction: column; gap: var(--sp-1); }
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--brand-navy);
  color: #F8FAFC;
  padding: 12px 18px;
  border-radius: var(--radius-btn);
  box-shadow: var(--shadow-3);
  font-size: var(--fs-sm);
  animation: slideInR var(--dur) var(--ease);
  max-width: 380px;
}
.toast svg { width: 16px; height: 16px; flex-shrink: 0; }
.toast.success svg { color: var(--positive); }
.toast.error svg { color: #F87171; }
.toast.gold svg { color: var(--brand-gold); }

/* ---------------- Tabs ---------------- */
.tabs { display: flex; gap: 4px; background: var(--surface-2); border-radius: var(--radius-btn); padding: 4px; width: fit-content; max-width: 100%; overflow-x: auto; }
.tab {
  padding: 7px 16px;
  border-radius: 10px;
  border: 0;
  background: transparent;
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--dur) var(--ease);
}
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }

/* ---------------- Empty state ---------------- */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--sp-1);
  padding: var(--sp-8) var(--sp-3);
  text-align: center;
  color: var(--text-3);
}
.empty svg { width: 40px; height: 40px; opacity: 0.4; }
.empty .empty-title { font-weight: 600; color: var(--text-2); font-size: var(--fs-md); }
.empty .empty-sub { font-size: var(--fs-sm); max-width: 380px; }

/* ---------------- Alert inline ---------------- */
.alert-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-btn);
  background: var(--surface-2);
  border-left: 3px solid var(--text-3);
}
.alert-row svg { width: 16px; height: 16px; margin-top: 2px; flex-shrink: 0; }
.alert-row.sev-high   { border-left-color: var(--negative); background: var(--negative-soft); }
.alert-row.sev-high svg { color: var(--negative); }
.alert-row.sev-med    { border-left-color: var(--warning); background: var(--warning-soft); }
.alert-row.sev-med svg { color: var(--warning); }
.alert-row.sev-low    { border-left-color: var(--info); background: var(--info-soft); }
.alert-row.sev-low svg { color: var(--info); }

/* ---------------- Progress ---------------- */
.progress { height: 8px; border-radius: var(--radius-full); background: var(--surface-2); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: var(--radius-full); background: var(--brand-navy); transition: width 600ms var(--ease); }
[data-theme="dark"] .progress > span { background: var(--brand-gold); }
.progress > span.gold { background: var(--brand-gold); }
.progress > span.green { background: var(--positive); }
.progress > span.red { background: var(--negative); }
.progress > span.orange { background: var(--warning); }

/* ---------------- Anexos ---------------- */
.attach-zone {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-btn);
  padding: var(--sp-2);
  text-align: center;
  color: var(--text-3);
  font-size: var(--fs-sm);
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.attach-zone:hover, .attach-zone.drag { border-color: var(--brand-gold); background: var(--brand-gold-soft); }
.attach-chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface-2);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: var(--fs-xs);
  max-width: 100%;
}
.attach-chip svg { width: 13px; height: 13px; color: var(--text-3); flex-shrink: 0; }
.attach-chip .x { cursor: pointer; color: var(--text-3); border: 0; background: none; padding: 0; display: inline-flex; }
.attach-chip .x:hover { color: var(--negative); }

/* ---------------- Avatar ---------------- */
.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--brand-navy);
  color: var(--brand-gold);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: var(--fs-xs);
  font-family: var(--font-display);
  flex-shrink: 0;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ---------------- Tooltip simples ---------------- */
[data-tip] { position: relative; }
[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--brand-navy);
  color: #F8FAFC;
  font-size: var(--fs-xs);
  padding: 5px 10px;
  border-radius: 8px;
  white-space: nowrap;
  z-index: 70;
  pointer-events: none;
  animation: fadeIn 150ms var(--ease);
}
