/* ============================================================
   NexoERP — Components CSS
   Apple.com Design Language — componentes exatos
   ============================================================ */

/* ════════════════════════════════════════
   BOTÕES — pill shape, o traço mais apple
   ════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-pill);   /* pill — idêntico ao apple.com */
  border: none;
  background: var(--bg-subtle);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 400;
  cursor: pointer;
  transition: background var(--transition-fast), opacity var(--transition-fast), transform 0.1s;
  white-space: nowrap;
  line-height: 1.4;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
}

.btn:hover { background: var(--bg-hover); }
.btn:active { transform: scale(0.97); opacity: 0.85; }

/* Primário — exato do apple.com: fundo azul, pill, sem border */
.btn-primary {
  background: var(--accent);
  color: #fff;
}

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

/* Secundário — contorno azul, pill (apple usa para CTAs secundários) */
.btn-secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.btn-secondary:hover { background: var(--accent-light); }

/* Danger */
.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.btn-danger:hover { background: #fbd7d7; }

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

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

.btn-sm   { font-size: 0.76rem; padding: 5px 13px; }
.btn-lg   { font-size: 0.94rem; padding: 12px 26px; }
.btn-full { width: 100%; justify-content: center; }

/* ════════════════════════════════════════
   BADGES — pill, muted
   ════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.71rem;
  font-weight: 500;
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger);  }
.badge-error   { background: var(--danger-bg);  color: var(--danger);  }
.badge-info    { background: var(--info-bg);    color: var(--info);    }
.badge-neutral { background: var(--bg-subtle);  color: var(--text-secondary); }
.badge-dark    { background: var(--text-primary); color: var(--text-inverse); }

/* ════════════════════════════════════════
   CARDS — sem border, fundo branco sobre
           página #fbfbfd (estilo apple)
   ════════════════════════════════════════ */
.card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);   /* 18px — apple usa 18-20px */
  overflow: hidden;
  /* sem border — apple separa por cor de fundo */
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}

.card-body   { padding: 22px; }

.card-header {
  padding: 16px 22px;
  border-bottom: 0.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.card-title {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

/* ════════════════════════════════════════
   MÉTRICAS — números grandes apple-style
   ════════════════════════════════════════ */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(172px, 1fr));
  gap: 12px;
}

.metric-card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
}

.metric-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.metric-label {
  font-size: 0.76rem;
  color: var(--text-tertiary);
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.metric-value {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.035em;
  line-height: 1;
}

.metric-delta {
  font-size: 0.76rem;
  margin-top: 6px;
  color: var(--text-tertiary);
}

.metric-delta.up   { color: var(--success); }
.metric-delta.down { color: var(--danger);  }

/* ════════════════════════════════════════
   TABELAS — sem zebra, hover sutil
   ════════════════════════════════════════ */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

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

thead tr { border-bottom: 0.5px solid var(--border); }

thead th {
  padding: 10px 18px;
  font-size: 0.71rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  text-align: left;
  white-space: nowrap;
}

tbody tr {
  border-bottom: 0.5px solid var(--border);
  transition: background 0.1s;
}

tbody tr:last-child { border-bottom: none; }
/* sem zebra — apple não usa */
tbody tr:hover { background: var(--bg-subtle) !important; }

tbody td {
  padding: 12px 18px;
  font-size: 0.82rem;
  color: var(--text-primary);
}

.td-muted { color: var(--text-secondary) !important; font-size: 0.76rem !important; }
.td-mono  { font-family: var(--font-mono) !important; font-size: 0.76rem !important; color: var(--text-tertiary) !important; }

/* ════════════════════════════════════════
   FORMULÁRIOS — inputs gray, sem border
   ════════════════════════════════════════ */
.form-group { margin-bottom: 16px; }
.form-row   { display: grid; grid-template-columns: 1fr 1fr;     gap: 14px; }
.form-row3  { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

label, .form-label {
  display: block;
  font-size: 0.76rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="tel"],
select,
textarea {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-md);   /* 12px */
  border: none;                       /* sem border — apple usa fundo cinza */
  background: var(--bg-subtle);       /* #f5f5f7 */
  color: var(--text-primary);
  font-size: 0.82rem;
  font-family: var(--font);
  outline: none;
  transition: box-shadow var(--transition-fast), background var(--transition-fast);
}

/* focus — apple usa outline azul, não border */
input:focus, select:focus, textarea:focus {
  background: var(--bg-subtle);
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.25);
}

[data-theme="dark"] input:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus {
  box-shadow: 0 0 0 4px rgba(41, 151, 255, 0.30);
}

textarea { resize: vertical; min-height: 90px; line-height: 1.5; }

.input-error { box-shadow: 0 0 0 4px rgba(207, 42, 42, 0.25) !important; }
.form-error  { font-size: 0.76rem; color: var(--danger); margin-top: 4px; }

/* ════════════════════════════════════════
   SEARCHBAR
   ════════════════════════════════════════ */
.searchbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  transition: box-shadow var(--transition-fast);
}

.searchbar:focus-within {
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.25);
}

.searchbar input {
  border: none;
  background: transparent;
  flex: 1;
  padding: 0;
  font-size: 0.82rem;
  color: var(--text-primary);
  outline: none;
  width: 100%;
  box-shadow: none;
}

.searchbar input::placeholder { color: var(--text-tertiary); }
.searchbar svg { color: var(--text-tertiary); flex-shrink: 0; }

/* ════════════════════════════════════════
   FILTROS
   ════════════════════════════════════════ */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-select { padding: 6px 10px !important; width: auto !important; font-size: 0.76rem !important; }

/* ════════════════════════════════════════
   TABS — underline azul apple
   ════════════════════════════════════════ */
.tabs { display: flex; border-bottom: 0.5px solid var(--border); }

.tab-btn {
  padding: 10px 16px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-tertiary);
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  cursor: pointer;
  margin-bottom: -0.5px;
  transition: color var(--transition-fast), border-color var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: -0.01em;
}

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

.tab-count {
  font-size: 0.70rem;
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--bg-subtle);
  color: var(--text-tertiary);
}

.tab-btn.active .tab-count {
  background: var(--accent-light);
  color: var(--accent);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ════════════════════════════════════════
   TOGGLE — macOS style
   ════════════════════════════════════════ */
.toggle {
  width: 36px; height: 22px;
  border-radius: 11px;
  background: rgba(0, 0, 0, 0.15);
  position: relative;
  cursor: pointer;
  transition: background var(--transition-fast);
  flex-shrink: 0;
  border: none;
}

[data-theme="dark"] .toggle { background: rgba(255,255,255,0.18); }
.toggle.on { background: var(--accent); }

.toggle-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  position: absolute;
  top: 2px; left: 2px;
  transition: left var(--transition-fast);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.toggle.on .toggle-thumb { left: 16px; }

/* ════════════════════════════════════════
   MODAL — apple sheet
   ════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.30);
  backdrop-filter: blur(8px) saturate(180%);
  -webkit-backdrop-filter: blur(8px) saturate(180%);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s;
}

.modal-overlay.visible { opacity: 1; pointer-events: all; }

.modal {
  background: var(--bg-surface);
  border-radius: var(--radius-xl);   /* 24px */
  width: 100%;
  max-width: 520px;
  max-height: 86vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  /* spring — animação de abertura apple */
  transform: translateY(12px) scale(0.98);
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.visible .modal { transform: translateY(0) scale(1); }

.modal-header {
  padding: 20px 24px;
  border-bottom: 0.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title { font-size: 1rem; font-weight: 600; letter-spacing: -0.020em; }

.modal-close {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: none;
  background: var(--bg-subtle);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: background var(--transition-fast);
}

.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }

.modal-body   { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 0.5px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ════════════════════════════════════════
   TOAST — glass, apple notification style
   ════════════════════════════════════════ */
.toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  /* glass dark — como notificações do macOS */
  background: rgba(28, 28, 30, 0.88);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  color: #f5f5f7;
  padding: 12px 18px;
  border-radius: var(--radius-lg);
  font-size: 0.82rem;
  font-weight: 500;
  max-width: 340px;
  box-shadow: var(--shadow-lg);
  border: 0.5px solid rgba(255,255,255,0.10);
  animation: toastIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
             toastOut 0.2s ease 2.8s forwards;
  pointer-events: all;
  letter-spacing: -0.01em;
}

[data-theme="dark"] .toast { background: rgba(58, 58, 60, 0.92); }

.toast.success { background: rgba(28, 124, 63, 0.94); }
.toast.error   { background: rgba(207, 42, 42, 0.94); }
.toast.warning { background: rgba(154, 91, 10, 0.94); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(16px) scale(0.94); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

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

/* ════════════════════════════════════════
   MISC
   ════════════════════════════════════════ */
.divider { height: 0.5px; background: var(--border); margin: 14px 0; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-tertiary); }
.empty-state svg { margin: 0 auto 16px; opacity: 0.30; }
.empty-state p   { font-size: 0.88rem; }

.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}

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

/* ── Page header ── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.page-title {
  font-family: var(--font-display);
  font-size: 1.33rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.025em;
}

.page-subtitle { font-size: 0.82rem; color: var(--text-tertiary); margin-top: 3px; }

/* ── Alerts ── */
.alert { padding: 12px 16px; border-radius: var(--radius-md); font-size: 0.82rem; }
.alert-warning { background: var(--warning-bg); color: var(--warning); }
.alert-success { background: var(--success-bg); color: var(--success); }
.alert-danger  { background: var(--danger-bg);  color: var(--danger);  }

/* ── Grid ── */
.grid   { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }

@media (max-width: 900px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ── Kanban ── */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  align-items: start;
}
@media (max-width: 900px) { .kanban-board { grid-template-columns: 1fr; } }

.kanban-col {
  background: var(--bg-subtle);
  border-radius: var(--radius-lg);
  padding: 14px;
  min-height: 200px;
}

.kanban-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.kanban-col-title {
  font-size: 0.71rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-secondary);
}

.kanban-cards { display: flex; flex-direction: column; gap: 8px; }

.kanban-card {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
}

.kanban-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

/* ── Pipeline ── */
.pipeline-board {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 16px;
  align-items: flex-start;
  min-height: 420px;
  scrollbar-width: thin;
}

.pipeline-board::-webkit-scrollbar { height: 5px; }
.pipeline-board::-webkit-scrollbar-track { background: transparent; }
.pipeline-board::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

.pipeline-col {
  flex: 0 0 252px;
  background: var(--bg-subtle);
  border-radius: var(--radius-lg);
  padding: 14px;
  min-height: 120px;
  transition: background .15s;
}

.pipeline-col.drag-over {
  background: var(--accent-light);
  outline: 1px solid var(--accent);
}

.pipeline-col-header {
  display: flex;
  align-items: center;
  gap: .4rem;
  margin-bottom: 12px;
  min-height: 24px;
}

.pipeline-col-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

.pipeline-col-title {
  font-size: 0.71rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .07em; flex: 1; color: var(--text-secondary);
  cursor: pointer; border-radius: 4px; padding: 1px 3px;
}

.pipeline-col-title:hover { background: var(--bg-hover); }

.pipeline-col-title-input {
  font-size: 0.71rem; font-weight: 600; text-transform: uppercase; letter-spacing: .07em;
  border: none; background: var(--bg-surface); border-radius: 4px;
  padding: 1px 4px; width: 100%; outline: 2px solid var(--accent);
  color: var(--text-primary);
}

.pipeline-col-count { font-size: 0.70rem; flex-shrink: 0; color: var(--text-tertiary); }
.pipeline-col-actions { display: flex; gap: 2px; }

.pipeline-cards { display: flex; flex-direction: column; gap: 8px; min-height: 40px; }

.pipeline-card {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  cursor: grab;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s, transform .12s;
  user-select: none;
}

.pipeline-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.pipeline-card.dragging { opacity: .45; cursor: grabbing; transform: rotate(1.5deg) scale(1.02); }

.pipeline-add-col { flex: 0 0 auto; display: flex; align-items: flex-start; padding-top: 2px; }

/* ── Utilitários ── */
.flex             { display: flex; }
.flex-1           { flex: 1; }
.items-center     { align-items: center; }
.justify-between  { justify-content: space-between; }
.gap-2            { gap: 8px; }
.gap-3            { gap: 12px; }
.mt-1             { margin-top: 4px; }
.mt-2             { margin-top: 8px; }
.mt-3             { margin-top: 12px; }
.mb-2             { margin-bottom: 8px; }
.mb-3             { margin-bottom: 12px; }
.text-sm          { font-size: 0.76rem; }
.text-muted       { color: var(--text-secondary); }
.text-tertiary    { color: var(--text-tertiary); }
.font-mono        { font-family: var(--font-mono); }
.font-medium      { font-weight: 500; }
.font-semibold    { font-weight: 600; }
