/* Componentes — Creator (Agency BRN) */

/* ============ Botões ============ */
.btn {
  display: inline-flex; align-items: center; gap: var(--space-2);
  font-weight: 600; font-size: var(--text-base);
  padding: 0 var(--space-4); height: 36px;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  background: transparent; cursor: pointer; text-decoration: none;
  color: var(--text-primary); white-space: nowrap;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
  justify-content: flex-start; /* rótulo à esquerda, nunca centralizado */
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--color-primary); color: var(--color-on-primary); }
.btn-primary:hover { background: var(--color-primary-hover); color: var(--color-on-primary); }
.btn-primary:active { background: var(--color-primary-active); }
.btn-secondary { border-color: var(--border-medium); background: var(--surface-card); }
.btn-secondary:hover { border-color: var(--text-secondary); background: var(--surface-sunken); color: var(--text-primary); }
.btn-ghost { color: var(--text-secondary); }
.btn-ghost:hover { background: var(--surface-sunken); color: var(--text-primary); }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover { background: #B22525; color: #fff; }
.btn-sm { height: 30px; padding: 0 var(--space-3); font-size: var(--text-sm); }
.btn-lg { height: 44px; padding: 0 var(--space-5); font-size: var(--text-md); }
.btn-block { width: 100%; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; pointer-events: none; }
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; padding: 0; flex: none;
  border-radius: var(--radius-sm); border: none; background: transparent;
  color: var(--text-secondary); cursor: pointer;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.btn-icon:hover { background: var(--surface-sunken); color: var(--text-primary); }
.btn-icon.is-active { background: var(--primary-100); color: var(--primary-700); }

/* ============ Badges e tags ============ */
.tag {
  display: inline-flex; align-items: center; gap: var(--space-1);
  font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.02em;
  padding: 2px var(--space-2); border-radius: var(--radius-full);
  background: var(--surface-sunken); color: var(--text-secondary);
}
.tag-primary { background: var(--primary-100); color: var(--primary-700); }
[data-theme="dark"] .tag-primary { color: var(--primary-400); }
.tag-success { background: var(--color-success-bg); color: var(--color-success); }
.tag-warning { background: var(--color-warning-bg); color: var(--color-warning); }
.tag-danger { background: var(--color-danger-bg); color: var(--color-danger); }
.tag-info { background: var(--color-info-bg); color: var(--color-info); }
.tag-outline { background: transparent; border: 1px solid var(--border-medium); }
.tag-soon { background: transparent; border: 1px dashed var(--border-medium); color: var(--text-muted); font-weight: 500; }
.status-dot { width: 8px; height: 8px; border-radius: var(--radius-full); flex: none; }

/* ============ Formulários ============ */
.field { display: flex; flex-direction: column; gap: var(--space-1); }
.field > .row { flex-wrap: wrap; }
.field > label { font-size: var(--text-sm); font-weight: 600; color: var(--text-secondary); }
.field-hint { font-size: var(--text-sm); color: var(--text-muted); }
.field-error { font-size: var(--text-sm); color: var(--color-danger); display: flex; gap: var(--space-1); align-items: center; }
.input, .select, .textarea {
  width: 100%; height: 38px; padding: 0 var(--space-3);
  border: 1px solid var(--border-medium); border-radius: var(--radius-sm);
  background: var(--surface-card); color: var(--text-primary);
  font-size: 16px; /* evita zoom no iOS */
  transition: border-color var(--dur-fast) var(--ease);
}
@media (min-width: 769px) { .input, .select, .textarea { font-size: var(--text-base); } }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-muted); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { outline: var(--focus-ring); outline-offset: 0; border-color: var(--color-primary); }
.input::placeholder, .textarea::placeholder { color: var(--text-muted); }
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--color-danger); }
.textarea { height: auto; min-height: 88px; padding: var(--space-2) var(--space-3); resize: vertical; line-height: var(--leading-normal); }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238A8279' 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 10px center; padding-right: 34px; }
.input-group { position: relative; }
.input-group .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.input-group .input { padding-left: 34px; }
.checkbox, .radio { display: flex; align-items: center; gap: var(--space-2); cursor: pointer; font-size: var(--text-base); min-height: 24px; }
.checkbox input, .radio input { width: 16px; height: 16px; accent-color: var(--color-primary); margin: 0; flex: none; }
.switch { position: relative; display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 36px; height: 20px; margin: 0; cursor: pointer; }
.switch-track { width: 36px; height: 20px; border-radius: var(--radius-full); background: var(--border-medium); position: relative; transition: background var(--dur-base) var(--ease); flex: none; }
.switch-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: var(--radius-full); background: var(--surface-card); box-shadow: var(--shadow-sm); transition: transform var(--dur-base) var(--ease); }
.switch input:checked + .switch-track { background: var(--color-primary); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { outline: var(--focus-ring); outline-offset: var(--focus-offset); }

/* Segmentado */
.seg { display: inline-flex; border: 1px solid var(--border-medium); border-radius: var(--radius-sm); background: var(--surface-card); padding: 2px; gap: 2px; }
.seg-opt {
  border: 0; background: transparent; cursor: pointer;
  padding: 4px var(--space-3); border-radius: 4px;
  font-size: var(--text-sm); font-weight: 600; color: var(--text-secondary);
  display: inline-flex; align-items: center; gap: var(--space-1);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.seg-opt:hover { color: var(--text-primary); }
.seg-opt[aria-pressed="true"], .seg-opt.is-active { background: var(--surface-inverse); color: var(--text-inverse); }

/* ============ Tabs ============ */
.tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--border-subtle); overflow-x: auto; }
.tab {
  border: 0; background: transparent; cursor: pointer;
  padding: var(--space-2) var(--space-3); margin-bottom: -1px;
  font-size: var(--text-base); font-weight: 600; color: var(--text-secondary);
  border-bottom: 2px solid transparent; white-space: nowrap;
  display: inline-flex; align-items: center; gap: var(--space-2);
}
.tab:hover { color: var(--text-primary); }
.tab[aria-selected="true"] { color: var(--text-primary); border-bottom-color: var(--color-primary); }
[role="tabpanel"][hidden] { display: none; }

/* ============ Cards ============ */
.card {
  background: var(--surface-card); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}
.card-pad { padding: var(--space-5); }
.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-header h2, .card-header h3 { font-size: var(--text-md); }
.card-body { padding: var(--space-5); }
.card-footer { padding: var(--space-3) var(--space-5); border-top: 1px solid var(--border-subtle); display: flex; align-items: center; gap: var(--space-3); }

/* Metric card */
.metric { display: flex; flex-direction: column; gap: var(--space-1); padding: var(--space-4) var(--space-5); }
.metric-label { font-size: var(--text-sm); color: var(--text-secondary); display: flex; align-items: center; gap: var(--space-2); }
.metric-value { font-family: var(--font-heading); font-size: var(--text-2xl); font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.metric-delta { font-size: var(--text-sm); font-weight: 600; display: inline-flex; align-items: center; gap: 3px; }
.metric-note { font-size: var(--text-xs); color: var(--text-muted); }

/* Chip de ícone (marca visual BRN) */
.icon-chip {
  width: 34px; height: 34px; border-radius: var(--radius-sm); flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary-100); color: var(--primary-700);
}
[data-theme="dark"] .icon-chip { color: var(--primary-400); }
.icon-chip.chip-neutral { background: var(--surface-sunken); color: var(--text-secondary); }
.icon-chip.chip-success { background: var(--color-success-bg); color: var(--color-success); }
.icon-chip.chip-warning { background: var(--color-warning-bg); color: var(--color-warning); }
.icon-chip.chip-danger { background: var(--color-danger-bg); color: var(--color-danger); }
.icon-chip.chip-info { background: var(--color-info-bg); color: var(--color-info); }

/* ============ Avatar ============ */
.avatar {
  width: 32px; height: 32px; border-radius: var(--radius-full); flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-inverse); color: var(--text-inverse);
  font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.02em;
}
.avatar-sm { width: 24px; height: 24px; font-size: 9px; }
.avatar-lg { width: 44px; height: 44px; font-size: var(--text-base); }
.avatar-stack { display: inline-flex; }
.avatar-stack .avatar { border: 2px solid var(--surface-card); margin-left: -8px; }
.avatar-stack .avatar:first-child { margin-left: 0; }
.avatar-brand { border-radius: var(--radius-sm); background: var(--primary-100); color: var(--primary-800); }
[data-theme="dark"] .avatar-brand { color: var(--primary-300); }

/* ============ Tabela ============ */
.table th {
  text-align: left; font-size: var(--text-xs); font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted);
  padding: var(--space-2) var(--space-4); border-bottom: var(--rule);
  white-space: nowrap;
}
.table td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border-subtle); font-size: var(--text-base); vertical-align: middle; }
.table tbody tr:hover { background: var(--surface-sunken); }
.table .td-num { text-align: right; font-variant-numeric: tabular-nums; }
.table th.td-num { text-align: right; }

/* ============ Dropdown ============ */
.dropdown { position: relative; }
.menu {
  position: absolute; top: calc(100% + 6px); right: 0; min-width: 220px;
  background: var(--surface-elevated); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md); box-shadow: var(--shadow-md);
  padding: var(--space-1); z-index: var(--z-dropdown); display: none;
}
.menu.is-open { display: block; }
.menu-left { right: auto; left: 0; }
.menu-item {
  display: flex; align-items: center; gap: var(--space-2); width: 100%;
  padding: var(--space-2) var(--space-3); border: 0; background: transparent;
  border-radius: var(--radius-sm); cursor: pointer; text-align: left;
  font-size: var(--text-base); color: var(--text-primary); text-decoration: none;
}
.menu-item:hover { background: var(--surface-sunken); text-decoration: none; color: var(--text-primary); }
.menu-item.is-danger { color: var(--color-danger); }
.workspace-option { min-width: 300px; }
.workspace-option.is-current { background: var(--surface-sunken); }
.workspace-option-copy { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.workspace-option-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workspace-option-copy small { color: var(--text-muted); font-size: var(--text-xs); text-transform: capitalize; }
#wsList { max-height: 320px; overflow-y: auto; }
.menu-sep { border: 0; border-top: 1px solid var(--border-subtle); margin: var(--space-1) 0; }
.menu-label { padding: var(--space-2) var(--space-3) var(--space-1); font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }

/* ============ Modal / Drawer / Bottom sheet ============ */
.overlay {
  position: fixed; inset: 0; background: rgba(22, 19, 15, 0.5);
  z-index: var(--z-overlay); display: none;
}
.overlay.is-open { display: block; }
.modal {
  position: fixed; inset: 0; z-index: var(--z-modal); display: none;
  align-items: center; justify-content: center; padding: var(--space-5);
}
.modal.is-open { display: flex; }
.modal-box {
  background: var(--surface-elevated); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 520px;
  max-height: calc(100vh - 64px); display: flex; flex-direction: column;
}
.modal-box-lg { max-width: 960px; }
.modal-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); flex: none; }
.modal-body { padding: var(--space-5); overflow-y: auto; }
.modal-footer { padding: var(--space-4) var(--space-5); border-top: 1px solid var(--border-subtle); display: flex; gap: var(--space-3); align-items: center; flex: none; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 400px; max-width: 92vw;
  background: var(--surface-elevated); border-left: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-lg); z-index: var(--z-drawer);
  transform: translateX(100%); visibility: hidden;
  transition: transform var(--dur-slow) var(--ease), visibility 0s var(--dur-slow);
  display: flex; flex-direction: column;
}
.drawer.is-open { transform: translateX(0); visibility: visible; transition: transform var(--dur-slow) var(--ease), visibility 0s 0s; }
.drawer-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); flex: none; }
.drawer-body { padding: var(--space-5); overflow-y: auto; flex: 1; }
.drawer-footer { padding: var(--space-4) var(--space-5); border-top: 1px solid var(--border-subtle); flex: none; }

/* ============ Toast ============ */
.toast-region { position: fixed; bottom: var(--space-5); right: var(--space-5); z-index: var(--z-toast); display: flex; flex-direction: column; gap: var(--space-2); }
.toast {
  display: flex; align-items: flex-start; gap: var(--space-3);
  background: var(--surface-inverse); color: var(--text-inverse);
  border-radius: var(--radius-md); padding: var(--space-3) var(--space-4);
  box-shadow: var(--shadow-lg); max-width: 360px; font-size: var(--text-base);
  animation: toast-in var(--dur-base) var(--ease);
}
.toast .icon { margin-top: 1px; }
.toast-success .icon { color: #5AD397; }
.toast-danger .icon { color: #F58C8C; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ============ Alert ============ */
.alert {
  display: flex; gap: var(--space-3); padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-md);
  background: var(--surface-card); font-size: var(--text-base); align-items: flex-start;
}
.alert .icon { margin-top: 1px; flex: none; }
.alert-warning { background: var(--color-warning-bg); border-color: transparent; }
.alert-warning .icon { color: var(--color-warning); }
.alert-danger { background: var(--color-danger-bg); border-color: transparent; }
.alert-danger .icon { color: var(--color-danger); }
.alert-info { background: var(--color-info-bg); border-color: transparent; }
.alert-info .icon { color: var(--color-info); }

/* ============ Skeleton / estados ============ */
.skeleton { background: var(--surface-sunken); border-radius: var(--radius-sm); animation: pulse 1.4s ease-in-out infinite; min-height: 12px; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
.empty-state { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-2); padding: var(--space-7) var(--space-5); }
.empty-state .icon-chip { margin-bottom: var(--space-1); }
.empty-state h3 { font-size: var(--text-md); }
.empty-state p { color: var(--text-secondary); max-width: 40ch; }

/* ============ Créditos de IA ============ */
.credit-chip {
  display: inline-flex; align-items: center; gap: var(--space-2);
  height: 32px; padding: 0 var(--space-3);
  border: 1px solid var(--border-medium); border-radius: var(--radius-full);
  font-size: var(--text-sm); font-weight: 600; cursor: pointer; background: var(--surface-card);
  color: var(--text-primary); text-decoration: none;
}
.credit-chip:hover { border-color: var(--text-secondary); text-decoration: none; color: var(--text-primary); }
.credit-chip .icon { color: var(--color-primary); }
.meter { height: 6px; border-radius: var(--radius-full); background: var(--surface-sunken); overflow: hidden; }
.meter-fill { height: 100%; border-radius: var(--radius-full); background: var(--color-primary); }
.meter-fill.is-warning { background: var(--color-warning); }
.meter-fill.is-danger { background: var(--color-danger); }

/* ============ Redes sociais ============ */
.net {
  width: 28px; height: 28px; border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-sunken); color: var(--text-secondary); flex: none;
}
.net .icon { width: 15px; height: 15px; }
.net-sm { width: 22px; height: 22px; }
.net-sm .icon { width: 12px; height: 12px; }
.net.is-on { background: var(--surface-inverse); color: var(--text-inverse); }
.net-pick { display: inline-flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-3); border: 1px solid var(--border-medium); border-radius: var(--radius-sm); background: var(--surface-card); cursor: pointer; font-size: var(--text-sm); font-weight: 600; color: var(--text-secondary); }
.net-pick[aria-pressed="true"] { border-color: var(--color-primary); background: var(--primary-100); color: var(--primary-800); }
[data-theme="dark"] .net-pick[aria-pressed="true"] { color: var(--primary-300); }

/* ============ Post card (calendário/planejamento) ============ */
.post-chip {
  display: flex; flex-direction: column; gap: 3px;
  border-left: 3px solid var(--border-medium); border-radius: 4px;
  background: var(--surface-sunken); padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs); cursor: grab; text-align: left; width: 100%; border-top: 0; border-right: 0; border-bottom: 0;
}
.post-chip { min-width: 0; }
.post-chip strong { font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--text-sm); min-width: 0; }
.post-chip .post-meta { display: flex; align-items: center; gap: var(--space-1); color: var(--text-muted); }
.post-chip.is-published { border-left-color: var(--color-success); }
.post-chip.is-scheduled { border-left-color: var(--color-info); }
.post-chip.is-draft { border-left-color: var(--border-medium); border-left-style: dashed; }
.post-chip.is-approval { border-left-color: var(--color-warning); }
.post-chip.is-failed { border-left-color: var(--color-danger); background: var(--color-danger-bg); }

/* ============ Command palette ============ */
.cmdk { align-items: flex-start; padding-top: 12vh; }
.cmdk .modal-box { max-width: 560px; }
.cmdk-input { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border-subtle); }
.cmdk-input input { border: 0; outline: 0; background: transparent; flex: 1; font-size: var(--text-md); color: var(--text-primary); }
.cmdk-list { padding: var(--space-2); max-height: 320px; overflow-y: auto; }
.kbd {
  font-family: var(--font-body); font-size: var(--text-xs); font-weight: 600;
  border: 1px solid var(--border-medium); border-bottom-width: 2px;
  border-radius: 4px; padding: 1px 5px; color: var(--text-secondary); background: var(--surface-card);
}

/* ============ Tooltip (demonstrativo) ============ */
[data-tooltip] { position: relative; }
[data-tooltip]:hover::after, [data-tooltip]:focus-visible::after {
  content: attr(data-tooltip); position: absolute; bottom: calc(100% + 6px); left: 50%;
  transform: translateX(-50%); background: var(--surface-inverse); color: var(--text-inverse);
  font-size: var(--text-xs); font-weight: 500; padding: 4px 8px; border-radius: var(--radius-sm);
  white-space: nowrap; z-index: var(--z-dropdown); pointer-events: none;
}

/* ============ Breadcrumb ============ */
.breadcrumb { display: flex; align-items: center; gap: var(--space-1); font-size: var(--text-sm); color: var(--text-muted); }
.breadcrumb a { color: var(--text-secondary); }
.breadcrumb .icon { width: 13px; height: 13px; }

/* ============ Paginação ============ */
.pagination { display: flex; align-items: center; gap: var(--space-1); }
.page-btn {
  min-width: 30px; height: 30px; padding: 0 var(--space-2); border: 0; border-radius: var(--radius-sm);
  background: transparent; cursor: pointer; font-size: var(--text-sm); font-weight: 600; color: var(--text-secondary);
  display: inline-flex; align-items: center; justify-content: center;
}
.page-btn:hover { background: var(--surface-sunken); color: var(--text-primary); }
.page-btn[aria-current="page"] { background: var(--surface-inverse); color: var(--text-inverse); }

.bulkbar { flex-wrap: wrap; }
.bulkbar > .text-sm { min-width: 120px; }
