/* =============================================================================
   PixKit — Design System
   Tokens primeiro. Nenhum componente usa valor cru: tudo referencia var(--*).
   Tema claro por padrao, escuro via [data-theme="dark"] e prefers-color-scheme.
   ============================================================================= */

:root {
  /* ---------- Cor: rampa neutra ---------- */
  --gray-0:  #ffffff;
  --gray-25: #fcfcfd;
  --gray-50: #f8f9fb;
  --gray-100:#f1f3f7;
  --gray-150:#e9ecf2;
  --gray-200:#dfe3ec;
  --gray-300:#c7cde0;
  --gray-400:#9aa2bb;
  --gray-500:#6f778f;
  --gray-600:#535a70;
  --gray-700:#3c4257;
  --gray-800:#272c3d;
  --gray-900:#171a26;
  --gray-950:#0e1018;

  /* ---------- Cor: marca e semantica ---------- */
  --brand-50:  #eef3ff;
  --brand-100: #dbe5ff;
  --brand-200: #bdcefe;
  --brand-400: #6b8afb;
  --brand-500: #4361ee;
  --brand-600: #3449d4;
  --brand-700: #2937a8;

  --success-50:#e9f9f0; --success-500:#0f9d58; --success-600:#0b7f46; --success-700:#0a6b3c;
  --warning-50:#fff6e6; --warning-500:#d98324; --warning-600:#b56a17; --warning-700:#8f5310;
  --danger-50: #fdeced; --danger-500: #d93843;  --danger-600: #b92a34;  --danger-700: #96212a;
  --info-50:   #e8f3fb; --info-500:   #2b7fc4;  --info-600:   #1f6199;

  /* PIX tem identidade propria no checkout */
  --pix-500: #00a99d;
  --pix-600: #008c82;

  /* ---------- Papeis semanticos (o que os componentes usam) ---------- */
  --bg-app:        var(--gray-50);
  --bg-surface:    var(--gray-0);
  --bg-subtle:     var(--gray-100);
  --bg-muted:      var(--gray-150);
  --bg-inverse:    var(--gray-900);
  --bg-overlay:    rgb(14 16 24 / 0.45);

  --text-primary:  var(--gray-900);
  --text-secondary:var(--gray-600);
  --text-muted:    var(--gray-500);
  --text-inverse:  var(--gray-0);
  --text-brand:    var(--brand-600);

  --border-subtle: var(--gray-150);
  --border-default:var(--gray-200);
  --border-strong: var(--gray-300);
  --border-focus:  var(--brand-500);

  /* ---------- Tipografia ---------- */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --text-2xs: 0.6875rem;  /* 11px — labels de tabela, badges */
  --text-xs:  0.75rem;    /* 12px */
  --text-sm:  0.8125rem;  /* 13px — corpo do painel */
  --text-base:0.875rem;   /* 14px */
  --text-md:  1rem;       /* 16px — inputs (evita zoom no iOS) */
  --text-lg:  1.125rem;
  --text-xl:  1.375rem;
  --text-2xl: 1.75rem;
  --text-3xl: 2.25rem;    /* numero grande de KPI */

  --leading-tight: 1.2;
  --leading-snug:  1.4;
  --leading-normal:1.6;

  --weight-normal: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  --tracking-tight: -0.015em;
  --tracking-wide: 0.04em;

  /* ---------- Espacamento (escala de 4px) ---------- */
  --space-0: 0;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* ---------- Raio ---------- */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 999px;

  /* ---------- Sombra (discreta: profundidade sem drama) ---------- */
  --shadow-xs: 0 1px 2px rgb(16 24 40 / 0.05);
  --shadow-sm: 0 1px 3px rgb(16 24 40 / 0.08), 0 1px 2px rgb(16 24 40 / 0.04);
  --shadow-md: 0 4px 12px rgb(16 24 40 / 0.08), 0 2px 4px rgb(16 24 40 / 0.04);
  --shadow-lg: 0 12px 28px rgb(16 24 40 / 0.12), 0 4px 8px rgb(16 24 40 / 0.05);
  --shadow-focus: 0 0 0 3px rgb(67 97 238 / 0.18);

  /* ---------- Movimento ---------- */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --duration-fast: 120ms;
  --duration-base: 180ms;
  --duration-slow: 280ms;

  /* ---------- Layout ---------- */
  --sidebar-width: 244px;
  --topbar-height: 56px;
  --content-max: 1280px;
  --z-dropdown: 40;
  --z-sticky: 50;
  --z-modal: 100;
  --z-toast: 120;
}

[data-theme="dark"] {
  --bg-app:        var(--gray-950);
  --bg-surface:    #151824;
  --bg-subtle:     #1b1f2e;
  --bg-muted:      #232838;
  --bg-inverse:    var(--gray-0);
  --bg-overlay:    rgb(0 0 0 / 0.6);

  --text-primary:  #eceff7;
  --text-secondary:#a9b1c7;
  --text-muted:    #7c849c;
  --text-inverse:  var(--gray-900);
  --text-brand:    var(--brand-400);

  --border-subtle: #232838;
  --border-default:#2c3245;
  --border-strong: #3a4258;

  --shadow-xs: 0 1px 2px rgb(0 0 0 / 0.3);
  --shadow-sm: 0 1px 3px rgb(0 0 0 / 0.4);
  --shadow-md: 0 4px 12px rgb(0 0 0 / 0.45);
  --shadow-lg: 0 12px 28px rgb(0 0 0 / 0.5);
}

/* =============================================================================
   Reset
   ============================================================================= */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, p, figure { margin: 0; }
img, svg { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--text-brand); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* =============================================================================
   Tipografia utilitaria
   ============================================================================= */

.h1 { font-size: var(--text-2xl); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-tight); line-height: var(--leading-tight); }
.h2 { font-size: var(--text-xl); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-tight); line-height: var(--leading-tight); }
.h3 { font-size: var(--text-lg); font-weight: var(--weight-semibold); line-height: var(--leading-snug); }
.h4 { font-size: var(--text-base); font-weight: var(--weight-semibold); }

.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.font-medium { font-weight: var(--weight-medium); }
.font-semibold { font-weight: var(--weight-semibold); }
.mono { font-family: var(--font-mono); font-size: var(--text-xs); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.eyebrow {
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-muted);
}

/* =============================================================================
   Layout utilitario
   ============================================================================= */

.stack   { display: flex; flex-direction: column; gap: var(--space-4); }
.stack-2 { display: flex; flex-direction: column; gap: var(--space-2); }
.stack-6 { display: flex; flex-direction: column; gap: var(--space-6); }
.row     { display: flex; align-items: center; gap: var(--space-3); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.wrap    { flex-wrap: wrap; }
.grow    { flex: 1 1 auto; min-width: 0; }

.grid { display: grid; gap: var(--space-4); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px)  { .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); } }

/* =============================================================================
   Card
   ============================================================================= */

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
}

.card-title { font-size: var(--text-base); font-weight: var(--weight-semibold); }
.card-subtitle { font-size: var(--text-xs); color: var(--text-muted); margin-top: 2px; }
.card-body { padding: var(--space-5); }
.card-footer {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.card-flush .card-body { padding: 0; }

/* KPI */
.kpi { padding: var(--space-5); }
.kpi-label { font-size: var(--text-xs); color: var(--text-muted); font-weight: var(--weight-medium); }
.kpi-value {
  font-size: var(--text-3xl);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-tight);
  line-height: 1.1;
  margin-top: var(--space-2);
  font-variant-numeric: tabular-nums;
}
.kpi-delta { display: inline-flex; align-items: center; gap: 4px; font-size: var(--text-xs); font-weight: var(--weight-medium); margin-top: var(--space-2); }
.kpi-delta.up { color: var(--success-600); }
.kpi-delta.down { color: var(--danger-600); }
.kpi-delta.flat { color: var(--text-muted); }

/* =============================================================================
   Button
   ============================================================================= */

.btn {
  --btn-bg: var(--bg-surface);
  --btn-fg: var(--text-primary);
  --btn-border: var(--border-default);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 34px;
  padding: 0 var(--space-3);
  border: 1px solid var(--btn-border);
  border-radius: var(--radius-sm);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out);
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(0.5px); }
.btn:focus-visible { box-shadow: var(--shadow-focus); outline: none; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.btn-primary   { --btn-bg: var(--brand-500); --btn-fg: #fff; --btn-border: var(--brand-500); box-shadow: var(--shadow-xs); }
.btn-primary:hover { --btn-bg: var(--brand-600); --btn-border: var(--brand-600); }

.btn-secondary:hover { --btn-bg: var(--bg-subtle); --btn-border: var(--border-strong); }

.btn-ghost { --btn-border: transparent; --btn-bg: transparent; --btn-fg: var(--text-secondary); }
.btn-ghost:hover { --btn-bg: var(--bg-subtle); --btn-fg: var(--text-primary); }

.btn-danger { --btn-bg: var(--danger-500); --btn-fg: #fff; --btn-border: var(--danger-500); }
.btn-danger:hover { --btn-bg: var(--danger-600); --btn-border: var(--danger-600); }

.btn-danger-ghost { --btn-bg: transparent; --btn-fg: var(--danger-600); --btn-border: var(--border-default); }
.btn-danger-ghost:hover { --btn-bg: var(--danger-50); --btn-border: var(--danger-500); }

.btn-sm { height: 28px; padding: 0 var(--space-2); font-size: var(--text-xs); }
.btn-lg { height: 44px; padding: 0 var(--space-5); font-size: var(--text-md); border-radius: var(--radius-md); }
.btn-block { width: 100%; }
.btn-icon { width: 34px; padding: 0; }

.btn.is-loading { color: transparent !important; position: relative; pointer-events: none; }
.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 14px; height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  color: var(--btn-fg);
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =============================================================================
   Form
   ============================================================================= */

.field { display: flex; flex-direction: column; gap: var(--space-2); }
.label { font-size: var(--text-xs); font-weight: var(--weight-medium); color: var(--text-secondary); }
.label .req { color: var(--danger-500); margin-left: 2px; }
.hint { font-size: var(--text-xs); color: var(--text-muted); }
.error-text { font-size: var(--text-xs); color: var(--danger-600); }

.input, .select, .textarea {
  width: 100%;
  min-height: 38px;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  color: var(--text-primary);
  transition: border-color var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out);
}
.input::placeholder, .textarea::placeholder { color: var(--gray-400); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
}
.input[aria-invalid="true"] { border-color: var(--danger-500); }
.input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px rgb(217 56 67 / 0.15); }
.input[disabled], .select[disabled] { background: var(--bg-subtle); color: var(--text-muted); cursor: not-allowed; }
.textarea { min-height: 90px; resize: vertical; }

.select {
  appearance: none;
  padding-right: var(--space-8);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%236f778f' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M3 4.5 6 7.5 9 4.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
}

.input-group { display: flex; }
.input-group .input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin-left: -1px; height: auto; }

/* Switch */
.switch { display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  width: 36px; height: 20px;
  border-radius: var(--radius-full);
  background: var(--gray-300);
  position: relative;
  transition: background var(--duration-base) var(--ease-out);
  flex: none;
}
.switch-track::after {
  content: "";
  position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-xs);
  transition: transform var(--duration-base) var(--ease-out);
}
.switch input:checked + .switch-track { background: var(--brand-500); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { box-shadow: var(--shadow-focus); }

/* Checkbox / radio */
.check { display: inline-flex; align-items: flex-start; gap: var(--space-2); cursor: pointer; font-size: var(--text-sm); }
.check input { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--brand-500); }

/* =============================================================================
   Badge
   ============================================================================= */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 20px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-xs);
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.01em;
  background: var(--bg-muted);
  color: var(--text-secondary);
  white-space: nowrap;
}
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex: none; }
.badge-plain::before { display: none; }

.badge-success { background: var(--success-50); color: var(--success-700); }
.badge-warning { background: var(--warning-50); color: var(--warning-700); }
.badge-danger  { background: var(--danger-50);  color: var(--danger-700); }
.badge-info    { background: var(--info-50);    color: var(--info-600); }
.badge-brand   { background: var(--brand-50);   color: var(--brand-700); }

[data-theme="dark"] .badge-success { background: rgb(15 157 88 / 0.15); color: #52d295; }
[data-theme="dark"] .badge-warning { background: rgb(217 131 36 / 0.15); color: #e6a95c; }
[data-theme="dark"] .badge-danger  { background: rgb(217 56 67 / 0.15);  color: #f08b92; }
[data-theme="dark"] .badge-info    { background: rgb(43 127 196 / 0.15); color: #74b6e8; }
[data-theme="dark"] .badge-brand   { background: rgb(67 97 238 / 0.18);  color: #9db1fd; }

/* =============================================================================
   Table
   ============================================================================= */

.table-wrap { overflow-x: auto; }

.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--text-sm); }

.table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

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

.table tbody tr { transition: background var(--duration-fast) var(--ease-out); }
.table tbody tr:hover { background: var(--bg-subtle); }
.table tbody tr:last-child td { border-bottom: none; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .col-actions { width: 1%; white-space: nowrap; }
.table-linked tbody tr { cursor: pointer; }

.pagination { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }

/* =============================================================================
   Empty state / skeleton
   ============================================================================= */

.empty { padding: var(--space-12) var(--space-6); text-align: center; }
.empty-icon {
  width: 44px; height: 44px;
  margin: 0 auto var(--space-4);
  display: grid; place-items: center;
  border-radius: var(--radius-lg);
  background: var(--bg-subtle);
  color: var(--text-muted);
}
.empty-title { font-size: var(--text-base); font-weight: var(--weight-semibold); }
.empty-text { font-size: var(--text-sm); color: var(--text-muted); max-width: 42ch; margin: var(--space-2) auto var(--space-5); }

.skeleton {
  border-radius: var(--radius-xs);
  background: linear-gradient(90deg, var(--bg-muted) 25%, var(--bg-subtle) 50%, var(--bg-muted) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.skeleton-text { height: 10px; margin: 6px 0; }
.skeleton-title { height: 16px; width: 40%; }
.skeleton-kpi { height: 32px; width: 60%; margin-top: var(--space-2); }

/* =============================================================================
   Alert
   ============================================================================= */

.alert {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  font-size: var(--text-sm);
}
.alert-title { font-weight: var(--weight-semibold); }
.alert-success { background: var(--success-50); border-color: rgb(15 157 88 / 0.25); color: var(--success-700); }
.alert-warning { background: var(--warning-50); border-color: rgb(217 131 36 / 0.25); color: var(--warning-700); }
.alert-danger  { background: var(--danger-50);  border-color: rgb(217 56 67 / 0.25);  color: var(--danger-700); }
.alert-info    { background: var(--info-50);    border-color: rgb(43 127 196 / 0.25); color: var(--info-600); }

/* =============================================================================
   Toast
   ============================================================================= */

.toast-stack {
  position: fixed;
  right: var(--space-5);
  bottom: var(--space-5);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: min(380px, calc(100vw - var(--space-8)));
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-left: 3px solid var(--brand-500);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  animation: toast-in var(--duration-slow) var(--ease-out);
}
.toast.success { border-left-color: var(--success-500); }
.toast.error   { border-left-color: var(--danger-500); }
.toast.warning { border-left-color: var(--warning-500); }
.toast-close { margin-left: auto; background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 0 2px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* =============================================================================
   Modal
   ============================================================================= */

.modal-backdrop {
  position: fixed; inset: 0;
  background: var(--bg-overlay);
  z-index: var(--z-modal);
  display: grid;
  place-items: center;
  padding: var(--space-4);
  animation: fade-in var(--duration-base) var(--ease-out);
}
.modal {
  width: min(520px, 100%);
  max-height: calc(100vh - var(--space-16));
  overflow-y: auto;
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: modal-in var(--duration-base) var(--ease-out);
}
.modal-lg { width: min(760px, 100%); }
.modal-header { padding: var(--space-5) var(--space-5) var(--space-3); }
.modal-body { padding: 0 var(--space-5) var(--space-5); }
.modal-footer {
  display: flex; justify-content: flex-end; gap: var(--space-2);
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(0.99); } to { opacity: 1; transform: none; } }

/* =============================================================================
   Dropdown
   ============================================================================= */

.dropdown { position: relative; }
.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  min-width: 180px;
  padding: var(--space-1);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: var(--z-dropdown);
}
.dropdown-item {
  display: flex; align-items: center; gap: var(--space-2);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: none; background: none;
  border-radius: var(--radius-xs);
  font-size: var(--text-sm);
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
}
.dropdown-item:hover { background: var(--bg-subtle); text-decoration: none; }
.dropdown-item.danger { color: var(--danger-600); }
.dropdown-sep { height: 1px; background: var(--border-subtle); margin: var(--space-1) 0; }

/* =============================================================================
   Tabs
   ============================================================================= */

.tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--border-subtle); }
.tab {
  padding: var(--space-3) var(--space-3);
  border: none; background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  cursor: pointer;
}
.tab:hover { color: var(--text-primary); text-decoration: none; }
.tab[aria-selected="true"] { color: var(--text-brand); border-bottom-color: var(--brand-500); }

/* Segmented (seletor de periodo) */
.segmented { display: inline-flex; padding: 2px; background: var(--bg-muted); border-radius: var(--radius-sm); }
.segmented button {
  padding: var(--space-1) var(--space-3);
  border: none; background: none;
  border-radius: var(--radius-xs);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  cursor: pointer;
}
.segmented button[aria-pressed="true"] { background: var(--bg-surface); color: var(--text-primary); box-shadow: var(--shadow-xs); }

/* =============================================================================
   Tooltip
   ============================================================================= */

[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) translateY(3px);
  padding: 4px var(--space-2);
  border-radius: var(--radius-xs);
  background: var(--gray-900);
  color: #fff;
  font-size: var(--text-2xs);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-fast) var(--ease-out), transform var(--duration-fast) var(--ease-out);
  z-index: var(--z-sticky);
}
[data-tooltip]:hover::after, [data-tooltip]:focus-visible::after { opacity: 1; transform: translateX(-50%); }

/* =============================================================================
   Timeline (detalhe do pedido)
   ============================================================================= */

.timeline { display: flex; flex-direction: column; }
.timeline-item { display: grid; grid-template-columns: 20px 1fr; gap: var(--space-3); padding-bottom: var(--space-5); position: relative; }
.timeline-item:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 9px; top: 18px; bottom: 0;
  width: 2px;
  background: var(--border-subtle);
}
.timeline-dot {
  width: 20px; height: 20px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--bg-muted);
  color: var(--text-muted);
  border: 2px solid var(--bg-surface);
  z-index: 1;
}
.timeline-dot.done { background: var(--success-500); color: #fff; }
.timeline-dot.error { background: var(--danger-500); color: #fff; }
.timeline-dot.pending { background: var(--bg-muted); }
.timeline-title { font-size: var(--text-sm); font-weight: var(--weight-medium); }
.timeline-meta { font-size: var(--text-xs); color: var(--text-muted); }

/* =============================================================================
   Funil
   ============================================================================= */

.funnel { display: flex; flex-direction: column; gap: var(--space-3); }
.funnel-step { display: grid; grid-template-columns: 1fr auto; gap: var(--space-2); align-items: baseline; }
.funnel-bar { grid-column: 1 / -1; height: 8px; background: var(--bg-muted); border-radius: var(--radius-full); overflow: hidden; }
.funnel-fill { height: 100%; background: var(--brand-500); border-radius: var(--radius-full); transition: width var(--duration-slow) var(--ease-out); }
.funnel-step:nth-child(2) .funnel-fill { background: var(--brand-400); }
.funnel-step:nth-child(3) .funnel-fill { background: var(--success-500); }

/* =============================================================================
   Utilitarios
   ============================================================================= */

.divider { height: 1px; background: var(--border-subtle); border: none; margin: var(--space-5) 0; }
.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.copyable { display: inline-flex; align-items: center; gap: var(--space-2); font-family: var(--font-mono); font-size: var(--text-xs); }
