/* ═══════════════════════════════════════════════════════════
   CataLink — Design System Base
   Reset + Variáveis + Tipografia + Componentes compartilhados
   ═══════════════════════════════════════════════════════════ */


/* ───────────────────────────────────────────────
   VARIÁVEIS
   ─────────────────────────────────────────────── */
:root {
  --bg: #F3F5F7;
  --card: #ffffff;
  --border: #e8e8e8;
  --border-hover: #111111;
  --text: #0d0d0d;
  --text-muted: #888899;
  --text-hint: #cccccc;
  --primary: #111111;
  --primary-hover: #333333;
  --primary-text: #ffffff;
  --success-bg: #eaf3de;
  --success-text: #1a8c4e;
  --danger: #e24b4a;
  --danger-bg: #fdecea;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --wpp-green: #25D366;
  --wpp-green-hover: #1da851;

  /* Pipeline */
  --novo: #f59e0b;
  --novo-bg: #fffbeb;
  --confirmado: #3b82f6;
  --confirmado-bg: #eff6ff;
  --separando: #8b5cf6;
  --separando-bg: #f5f3ff;
  --enviado: #22c55e;
  --enviado-bg: #f0fdf4;
  --entregue: #888888;
  --entregue-bg: #f5f5f5;

  --radius: 8px;
  --radius-sm: 6px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.10);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);

  --transition: 0.15s ease;
  --font: -apple-system, 'SF Pro Display', 'Helvetica Neue', sans-serif;

  /* Apelidos usados por modais criados via JS — seguem o tema */
  --bg-card: var(--card);
  --bg-input: var(--bg);

  /* Campos estilo Apple (selects, dropdowns) */
  --field-bg: #f5f5f7;
  --field-border: rgba(0, 0, 0, 0.05);
}

/* ───────────────────────────────────────────────
   DARK MODE
   ─────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg: #111111;
  --card: #1c1c1e;
  --border: #2c2c2e;
  --border-hover: #f0f0f0;
  --text: #f0f0f0;
  --text-muted: #888899;
  --text-hint: #484858;
  --primary: #f0f0f0;
  --primary-hover: #cccccc;
  --success-bg: #0d2b1a;
  --success-text: #22a060;
  --danger-bg: #2a1212;
  --warning-bg: #2a1e00;
  --novo-bg: #2a1e00;
  --confirmado-bg: #0d1a2e;
  --separando-bg: #1a1028;
  --enviado-bg: #0d2b1a;
  --entregue-bg: #1c1c1e;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.35);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);

  --field-bg: #2c2c2e;
  --field-border: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] body {
  background: #111111;
}

[data-theme="dark"] tbody tr:hover td {
  background: #242426;
}

/* ───────────────────────────────────────────────
   RESET
   ─────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: linear-gradient(180deg, #F8F9FB 0%, #F3F5F7 100%);
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  font-size: 14px;
}

input, textarea, select {
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  outline: none;
}

img {
  max-width: 100%;
  display: block;
}

ul, ol {
  list-style: none;
}

/* ───────────────────────────────────────────────
   TIPOGRAFIA
   ─────────────────────────────────────────────── */
.page-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
}

.label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.text-muted {
  color: var(--text-muted);
}

.text-hint {
  color: var(--text-hint);
  font-size: 12px;
}

/* ───────────────────────────────────────────────
   BOTÕES
   ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  transition: background var(--transition), border-color var(--transition),
              color var(--transition), opacity var(--transition);
  white-space: nowrap;
  cursor: pointer;
  border: 1px solid transparent;
}

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

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

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

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

.btn-secondary:hover:not(:disabled) {
  border-color: var(--border-hover);
}

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

.btn-danger:hover:not(:disabled) {
  background: var(--danger);
  color: white;
}

.btn-warning {
  background: #fff8ed;
  color: #b45309;
  border-color: #f59e0b;
}

.btn-warning:hover:not(:disabled) {
  background: #f59e0b;
  color: white;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
  padding: 6px 8px;
}

.btn-ghost:hover:not(:disabled) {
  color: var(--text);
  background: var(--bg);
}

.btn-wpp {
  background: var(--wpp-green);
  color: white;
  border-color: var(--wpp-green);
}

.btn-wpp:hover:not(:disabled) {
  background: var(--wpp-green-hover);
  border-color: var(--wpp-green-hover);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-lg {
  padding: 11px 20px;
  font-size: 14px;
}

.btn-block {
  width: 100%;
  justify-content: center;
}

.btn-icon {
  padding: 7px;
  border-radius: var(--radius-sm);
}

/* ───────────────────────────────────────────────
   INPUTS
   ─────────────────────────────────────────────── */
.input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  transition: border-color var(--transition);
}

.input:focus {
  border-color: var(--primary);
}

.input::placeholder {
  color: var(--text-hint);
}

/* Campo monetário: cifrão fixo dentro do input */
.money-field {
  position: relative;
  display: block;
}

.money-field::before {
  content: 'R$';
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  color: var(--text-muted);
  pointer-events: none;
}

.money-field .input {
  padding-left: 34px;
}

/* Variante compacta: grade de variações */
.money-field-sm {
  display: inline-block;
}

.money-field-sm::before {
  left: 6px;
  font-size: 11px;
}

.money-field-sm .input {
  padding-left: 22px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.input-group label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

.input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

textarea.input {
  resize: vertical;
  min-height: 80px;
}

/* ───────────────────────────────────────────────
   SELECT PADRÃO (estilo Apple)
   Pílula cinza suave + chevron à direita, nos dois temas
   ─────────────────────────────────────────────── */
select,
select.input,
select.ck-input {
  -webkit-appearance: none;
  appearance: none;
  font-family: var(--font);
  font-size: 13px;
  color: var(--text);
  padding: 9px 38px 9px 14px;
  background-color: var(--field-bg);
  border: 1px solid var(--field-border);
  border-radius: 999px;
  cursor: pointer;
  transition: border-color var(--transition), background-color var(--transition);
  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='%23888899' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

select:hover,
select:focus {
  outline: none;
  border-color: var(--text-hint);
}

/* Opções da lista nativa seguem o tema (Chrome/Edge) */
select option {
  background: var(--card);
  color: var(--text);
}

/* ───────────────────────────────────────────────
   CHECKBOX PADRÃO
   (Uiverse.io by SelfMadeSystem, adaptado ao tema)
   ─────────────────────────────────────────────── */
input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  font-size: 14px;
  width: 1.3em;
  height: 1.3em;
  margin: 0;
  flex-shrink: 0;
  vertical-align: middle;
  background-color: #efeff2;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.03), 0 1px 1px rgba(0, 0, 0, 0.04);
  border-radius: 0.25em;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.25s, box-shadow 0.25s;
}

[data-theme="dark"] input[type="checkbox"] {
  background-color: #3a3a3c;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

input[type="checkbox"]::after {
  content: "";
  box-sizing: content-box;
  position: absolute;
  left: 0;
  top: 0;
  width: 1.05em;
  height: 1.05em;
  border: 0.1em solid transparent;
  border-radius: 0.25em;
  transform: rotate(0deg);
  transition: all 0.25s, border-width 0.1s;
}

input[type="checkbox"]:checked {
  background-color: #007AFF;
}

[data-theme="dark"] input[type="checkbox"]:checked {
  background-color: #0A84FF;
}

input[type="checkbox"]:checked::after {
  left: 0.45em;
  top: 0.25em;
  width: 0.25em;
  height: 0.5em;
  border-color: transparent white white transparent;
  border-width: 0 0.15em 0.15em 0;
  border-radius: 0;
  transform: rotate(45deg);
}

input[type="checkbox"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ───────────────────────────────────────────────
   CARDS
   ─────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 0.5px solid rgba(0, 0, 0, 0.06);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06), 0 8px 20px rgba(0,0,0,0.08);
}

[data-theme="dark"] .card {
  background: #1c1c1e;
  border-color: rgba(255, 255, 255, 0.06);
  box-shadow: 0 2px 6px rgba(0,0,0,0.25), 0 8px 20px rgba(0,0,0,0.3);
}

/* ───────────────────────────────────────────────
   BADGES
   ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
}

.badge-ativo {
  background: var(--success-bg);
  color: var(--success-text);
}

.badge-inativo {
  background: #f5f5f5;
  color: var(--text-muted);
}

.badge-novo    { background: var(--novo-bg);        color: var(--novo); }
.badge-confirmado { background: var(--confirmado-bg); color: var(--confirmado); }
.badge-separando  { background: var(--separando-bg);  color: var(--separando); }
.badge-enviado    { background: var(--enviado-bg);    color: var(--enviado); }
.badge-entregue   { background: var(--entregue-bg);   color: var(--entregue); }

/* ───────────────────────────────────────────────
   DIVISOR
   ─────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

/* ───────────────────────────────────────────────
   LOADING SPINNER
   ─────────────────────────────────────────────── */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.spinner-lg {
  width: 32px;
  height: 32px;
  border-width: 3px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ───────────────────────────────────────────────
   LOADING STATE
   ─────────────────────────────────────────────── */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px;
  color: var(--text-muted);
  font-size: 13px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 48px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

.empty-state .empty-icon {
  font-size: 32px;
  margin-bottom: 4px;
}

/* ───────────────────────────────────────────────
   TABELA
   ─────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
}

thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
}

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

tbody tr:hover td {
  background: #fafafa;
}

/* ───────────────────────────────────────────────
   TAGS / CHIPS
   ─────────────────────────────────────────────── */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text);
}

.tag .tag-remove {
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  font-size: 14px;
  display: flex;
  align-items: center;
}

.tag .tag-remove:hover {
  color: var(--danger);
}

/* ───────────────────────────────────────────────
   OVERLAY / MODAL
   ─────────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}

.modal {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 90%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.2s ease;
}

/* ───────────────────────────────────────────────
   DRAWER (painel lateral)
   ─────────────────────────────────────────────── */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 900;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 420px;
  max-width: 100vw;
  height: 100vh;
  background: var(--card);
  border-left: 1px solid var(--border);
  z-index: 901;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: slideFromRight 0.25s ease;
  overflow: hidden;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.drawer-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ───────────────────────────────────────────────
   TOAST (criado via JS)
   ─────────────────────────────────────────────── */
@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--primary);
  color: var(--bg);
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  max-width: 340px;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.2s ease;
}

.toast-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.toast.toast-success .toast-icon { background: var(--success-text); color: #fff; }

.toast.toast-error   { background: var(--danger);  color: #fff; }
.toast.toast-warning { background: var(--warning); color: #fff; }

/* ───────────────────────────────────────────────
   ANIMAÇÕES
   ─────────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

@keyframes slideFromRight {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

/* ───────────────────────────────────────────────
   STATS GRID
   ─────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card);
  border: 0.5px solid rgba(0, 0, 0, 0.06);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06), 0 8px 20px rgba(0,0,0,0.08);
}

[data-theme="dark"] .stat-card {
  background: #1c1c1e;
  border-color: rgba(255, 255, 255, 0.06);
  box-shadow: 0 2px 6px rgba(0,0,0,0.25), 0 8px 20px rgba(0,0,0,0.3);
}

.stat-card .stat-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.stat-card .stat-value {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.stat-card .stat-value.highlight {
  color: var(--danger);
}

/* ───────────────────────────────────────────────
   UTILITÁRIOS
   ─────────────────────────────────────────────── */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
}

/* ───────────────────────────────────────────────
   SCROLLBAR CUSTOMIZADA
   ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ddd; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #bbb; }

/* Dark mode — botões */
[data-theme="dark"] .btn-primary {
  background: var(--primary);
  color: #111111;
  border-color: var(--primary);
}
[data-theme="dark"] .btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}
[data-theme="dark"] .btn-warning {
  background: #2a1e00;
  color: #f59e0b;
  border-color: #f59e0b;
}
[data-theme="dark"] .btn-warning:hover:not(:disabled) {
  background: #f59e0b;
  color: #111;
}
