/* Contrato Plataforma - folha de estilo dos componentes.
   Depende de tokens.css. Todas as classes usam o prefixo ct-.
   Escrita para ser consumida direto em HTML servido por PHP, sem framework. */

/* ---------------------------------------------------------------- base */

.ct-root {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 23px;
  color: var(--ink);
  background: var(--surface-100);
  -webkit-font-smoothing: antialiased;
}

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

.ct-root :focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

.ct-on-inverse :focus-visible { outline-color: var(--focus-ring-inverse); }

.ct-link {
  color: var(--primary-ink);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}
.ct-link:hover { text-decoration-thickness: 2px; }

.ct-muted { color: var(--ink-muted); }
.ct-subtle { color: var(--ink-subtle); }
.ct-num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* layout auxiliar */
.ct-stack { display: flex; flex-direction: column; gap: var(--space-4); }
.ct-row { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.ct-row-end { margin-left: auto; }
.ct-grid { display: grid; gap: var(--space-6); grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); }

/* ------------------------------------------------------------- botoes */

.ct-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: var(--control-h);
  padding: 0 var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font: inherit;
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  letter-spacing: 0.005em;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .14s ease, border-color .14s ease, color .14s ease;
}

.ct-btn:disabled,
.ct-btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }

.ct-btn--primary { background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-xs); }
.ct-btn--primary:hover:not(:disabled) { background: var(--primary-hover); }
.ct-btn--primary:active:not(:disabled) { background: var(--primary-active); }

.ct-btn--accent { background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow-xs); }
.ct-btn--accent:hover:not(:disabled) { filter: brightness(.94); }

.ct-btn--outline { background: transparent; border-color: var(--border-strong); color: var(--ink); }
.ct-btn--outline:hover:not(:disabled) { background: var(--surface-300); border-color: var(--ink-muted); }

.ct-btn--ghost { background: transparent; color: var(--primary-ink); }
.ct-btn--ghost:hover:not(:disabled) { background: var(--primary-soft); }

.ct-btn--danger { background: var(--danger); color: var(--on-danger); }
.ct-btn--danger:hover:not(:disabled) { filter: brightness(1.06); }

.ct-btn--sm { height: var(--control-h-sm); padding: 0 var(--space-3); font-size: 13px; border-radius: var(--radius-sm); }
.ct-btn--lg { height: var(--control-h-lg); padding: 0 var(--space-6); font-size: 15px; }
.ct-btn--block { display: flex; width: 100%; }
.ct-btn--icon { width: var(--control-h); padding: 0; }
.ct-btn--icon.ct-btn--sm { width: var(--control-h-sm); }

.ct-btn__spinner {
  width: 15px; height: 15px; flex: none;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: var(--radius-pill);
  animation: ct-spin .7s linear infinite;
}
@keyframes ct-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ct-btn__spinner { animation-duration: 2.4s; } }

/* ------------------------------------------------------------- campos */

.ct-field { display: flex; flex-direction: column; gap: var(--space-2); }

.ct-label {
  font-size: 13px; line-height: 18px; font-weight: 600; color: var(--ink);
  display: flex; align-items: center; gap: var(--space-1);
}
.ct-label__req { color: var(--danger); }
.ct-label__opt { color: var(--ink-subtle); font-weight: 500; }

.ct-input,
.ct-select,
.ct-textarea {
  width: 100%;
  min-height: var(--control-h);
  padding: 9px var(--space-3);
  font: inherit;
  font-size: 15px;
  line-height: 21px;
  color: var(--ink);
  background: var(--surface-200);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  transition: border-color .14s ease, box-shadow .14s ease;
}

.ct-input::placeholder,
.ct-textarea::placeholder { color: var(--ink-subtle); }

.ct-input:hover:not(:disabled),
.ct-select:hover:not(:disabled),
.ct-textarea:hover:not(:disabled) { border-color: var(--ink-muted); }

.ct-input:disabled,
.ct-select:disabled,
.ct-textarea:disabled { background: var(--surface-300); color: var(--ink-subtle); cursor: not-allowed; }

.ct-textarea { min-height: 96px; resize: vertical; }

.ct-select {
  appearance: none;
  padding-right: var(--space-8);
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: right 18px center, right 13px center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.ct-field--invalid .ct-input,
.ct-field--invalid .ct-select,
.ct-field--invalid .ct-textarea { border-color: var(--danger); }

.ct-hint { font-size: 13px; line-height: 18px; color: var(--ink-muted); }
.ct-error { font-size: 13px; line-height: 18px; color: var(--danger-ink); display: flex; gap: var(--space-1); }

.ct-field--lg .ct-input,
.ct-field--lg .ct-select { min-height: var(--control-h-lg); padding: 12px var(--space-4); }

/* prefixo/sufixo */
.ct-input-group { display: flex; align-items: stretch; }
.ct-input-group .ct-input { border-radius: var(--radius-md) 0 0 var(--radius-md); }
.ct-input-group__addon {
  display: flex; align-items: center; padding: 0 var(--space-3);
  font-size: 13px; font-weight: 600; color: var(--ink-muted);
  background: var(--surface-300);
  border: 1px solid var(--border-strong); border-left: 0;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

/* interruptor */
.ct-switch { display: inline-flex; align-items: center; gap: var(--space-3); cursor: pointer; }
.ct-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.ct-switch__track {
  width: 42px; height: 24px; flex: none; padding: 3px;
  background: var(--border-strong);
  border-radius: var(--radius-pill);
  transition: background-color .16s ease;
}
.ct-switch__thumb {
  display: block; width: 18px; height: 18px;
  background: var(--surface-200);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-xs);
  transition: transform .16s ease;
}
.ct-switch input:checked + .ct-switch__track { background: var(--primary); }
.ct-switch input:checked + .ct-switch__track .ct-switch__thumb { transform: translateX(18px); }
.ct-switch input:focus-visible + .ct-switch__track { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.ct-switch input:disabled + .ct-switch__track { opacity: .5; }
.ct-switch__label { font-size: 14px; font-weight: 500; }

/* -------------------------------------------------------------- cards */

.ct-card {
  background: var(--surface-200);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.ct-card__head {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
}
.ct-card__title { font-size: 17px; line-height: 24px; font-weight: 600; margin: 0; }
.ct-card__sub { font-size: 13px; line-height: 18px; color: var(--ink-muted); margin: 2px 0 0; }
.ct-card__body { padding: var(--space-6); }
.ct-card__foot {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  background: var(--surface-300);
  border-top: 1px solid var(--border);
}
.ct-card--flat { box-shadow: none; }
.ct-card--tight .ct-card__body { padding: var(--space-4); }

/* ---------------------------------------------------- card de modulo */

.ct-module {
  position: relative;
  display: flex; flex-direction: column; gap: var(--space-3);
  padding: var(--space-6);
  text-align: left;
  background: var(--surface-200);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  color: inherit; text-decoration: none;
  transition: box-shadow .16s ease, border-color .16s ease, transform .16s ease;
}
a.ct-module:hover, button.ct-module:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
  transform: translateY(-2px);
}
@media (prefers-reduced-motion: reduce) { .ct-module { transition: none; } a.ct-module:hover, button.ct-module:hover { transform: none; } }

.ct-module__icon {
  display: grid; place-items: center;
  width: 46px; height: 46px;
  border-radius: var(--radius-md);
  background: var(--primary-soft);
  color: var(--primary-ink);
}
.ct-module__icon svg { width: 24px; height: 24px; }
.ct-module--accent .ct-module__icon { background: var(--accent-soft); color: var(--accent-ink); }
.ct-module__title { font-size: 17px; line-height: 24px; font-weight: 600; margin: 0; }
.ct-module__desc { font-size: 13px; line-height: 20px; color: var(--ink-muted); margin: 0; flex: 1; }
.ct-module__foot { display: flex; align-items: center; gap: var(--space-2); padding-top: var(--space-1); }

.ct-module--locked { background: var(--surface-300); }
.ct-module--locked .ct-module__icon { background: var(--surface-200); color: var(--ink-subtle); }
.ct-module--locked .ct-module__title { color: var(--ink-muted); }

/* ------------------------------------------------------ card de plano */

.ct-plan {
  display: flex; flex-direction: column; gap: var(--space-4);
  padding: var(--space-6);
  background: var(--surface-200);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}
.ct-plan--featured { border-color: var(--primary); box-shadow: var(--shadow-md); }
.ct-plan__name { font-size: 15px; line-height: 22px; font-weight: 600; margin: 0; }
.ct-plan__price { display: flex; align-items: baseline; gap: var(--space-1); font-family: var(--font-mono); }
.ct-plan__amount { font-size: 30px; line-height: 34px; font-weight: 600; letter-spacing: -0.01em; }
.ct-plan__period { font-size: 13px; color: var(--ink-muted); font-family: var(--font-sans); }
.ct-plan__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); flex: 1; }
.ct-plan__list li { display: flex; gap: var(--space-2); font-size: 14px; line-height: 21px; color: var(--ink-muted); }
.ct-plan__list svg { width: 16px; height: 16px; flex: none; margin-top: 3px; color: var(--success); }

/* ------------------------------------------------------------ badges */

.ct-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px;
  font-size: 12px; line-height: 16px; font-weight: 600;
  border-radius: var(--radius-pill);
  background: var(--surface-300); color: var(--ink-muted);
  border: 1px solid transparent;
  white-space: nowrap;
}
.ct-badge svg { width: 13px; height: 13px; flex: none; }
.ct-badge--info { background: var(--primary-soft); color: var(--primary-ink); }
.ct-badge--accent { background: var(--accent-soft); color: var(--accent-ink); }
.ct-badge--success { background: var(--success-soft); color: var(--success-ink); }
.ct-badge--warning { background: var(--warning-soft); color: var(--warning-ink); }
.ct-badge--danger { background: var(--danger-soft); color: var(--danger-ink); }
.ct-badge--solid { background: var(--primary); color: var(--on-primary); }

/* --------------------------------------------------------- indicador */

.ct-stat {
  display: flex; flex-direction: column; gap: var(--space-2);
  padding: var(--space-5);
  background: var(--surface-200);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.ct-stat__label {
  font-size: 11px; line-height: 14px; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--ink-muted);
}
.ct-stat__value {
  font-family: var(--font-mono);
  font-size: 30px; line-height: 34px; font-weight: 600; letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.ct-stat__delta { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; }
.ct-stat__delta svg { width: 14px; height: 14px; }
.ct-stat__delta--up { color: var(--success-ink); }
.ct-stat__delta--down { color: var(--danger-ink); }
.ct-stat__delta--flat { color: var(--ink-muted); }
.ct-stat__note { font-size: 12px; line-height: 16px; color: var(--ink-subtle); }

/* ------------------------------------------------------------ alerta */

.ct-alert {
  display: flex; gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  border: 1px solid transparent;
  font-size: 14px; line-height: 21px;
}
.ct-alert svg { width: 18px; height: 18px; flex: none; margin-top: 2px; }
.ct-alert__title { font-weight: 600; margin: 0 0 2px; }
.ct-alert__body { margin: 0; }
.ct-alert--info { background: var(--primary-soft); color: var(--primary-ink); }
.ct-alert--success { background: var(--success-soft); color: var(--success-ink); }
.ct-alert--warning { background: var(--warning-soft); color: var(--warning-ink); }
.ct-alert--danger { background: var(--danger-soft); color: var(--danger-ink); }

/* ------------------------------------------------------------ tabela */

.ct-table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: auto;
  background: var(--surface-200);
}
.ct-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.ct-table th, .ct-table td {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.ct-table thead th {
  position: sticky; top: 0;
  background: var(--surface-300);
  font-size: 11px; line-height: 14px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-muted);
  white-space: nowrap;
}
.ct-table tbody tr:last-child td { border-bottom: 0; }
.ct-table tbody tr:hover td { background: var(--surface-300); }
.ct-table .ct-td-num {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.ct-table--compact th, .ct-table--compact td { padding: var(--space-2) var(--space-3); }

/* -------------------------------------------------------------- abas */

.ct-tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--border); overflow-x: auto; }
.ct-tab {
  appearance: none; background: none; border: 0;
  padding: var(--space-3) var(--space-4);
  margin-bottom: -1px;
  font: inherit; font-size: 14px; font-weight: 600;
  color: var(--ink-muted);
  border-bottom: 2px solid transparent;
  cursor: pointer; white-space: nowrap;
}
.ct-tab:hover { color: var(--ink); }
.ct-tab[aria-selected="true"] { color: var(--primary-ink); border-bottom-color: var(--primary); }

/* ------------------------------------------------------- navegacao */

.ct-nav {
  display: flex; flex-direction: column; gap: var(--space-1);
  padding: var(--space-4);
  background: var(--surface-inverse);
  color: var(--ink-inverse);
}
.ct-nav__group {
  padding: var(--space-4) var(--space-3) var(--space-1);
  font-size: 11px; line-height: 14px; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--ink-inverse-muted);
}
.ct-nav__item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 9px var(--space-3);
  border-radius: var(--radius-md);
  font-size: 14px; font-weight: 500;
  color: var(--ink-inverse-muted);
  text-decoration: none;
  transition: background-color .14s ease, color .14s ease;
}
.ct-nav__item svg { width: 18px; height: 18px; flex: none; }
.ct-nav__item:hover { background: rgba(255,255,255,.07); color: var(--ink-inverse); }
.ct-nav__item[aria-current="page"] { background: var(--primary); color: var(--on-primary); font-weight: 600; }
.ct-nav__item:focus-visible { outline: 2px solid var(--focus-ring-inverse); outline-offset: 2px; }
.ct-nav__badge { margin-left: auto; }
.ct-nav__item--locked { opacity: .55; }

/* submenus aninhados sob um item (ex.: Conciliacao e Movimentacao sob "Contabilidade") */
.ct-nav__sub {
  display: flex; flex-direction: column; gap: var(--space-1);
  margin: 2px 0 var(--space-1) 15px;
  padding-left: var(--space-3);
  border-left: 1px solid rgba(255,255,255,.14);
}
.ct-nav__sub .ct-nav__item { font-size: 13.5px; }
.ct-nav__sub .ct-nav__item svg { width: 16px; height: 16px; }
/* rotulo-pai nao clicavel (fallback: equipe sem o modulo Contabilidade) */
.ct-nav__parent-label { cursor: default; }
.ct-nav__parent-label:hover { background: transparent; color: var(--ink-inverse-muted); }

/* --------------------------------------------------------- progresso */

.ct-progress {
  height: 8px;
  background: var(--surface-300);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.ct-progress__bar { height: 100%; background: var(--primary); border-radius: var(--radius-pill); transition: width .3s ease; }
.ct-progress--accent .ct-progress__bar { background: var(--accent); }
.ct-progress--success .ct-progress__bar { background: var(--success); }
.ct-progress__meta { display: flex; justify-content: space-between; font-size: 12px; line-height: 16px; color: var(--ink-muted); margin-bottom: 6px; }

/* ------------------------------------------------------ estado vazio */

.ct-empty {
  display: flex; flex-direction: column; align-items: center; gap: var(--space-3);
  padding: var(--space-12) var(--space-6);
  text-align: center;
  background: var(--surface-200);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
}
.ct-empty svg { width: 34px; height: 34px; color: var(--ink-subtle); }
.ct-empty__title { font-size: 17px; line-height: 24px; font-weight: 600; margin: 0; }
.ct-empty__desc { font-size: 14px; line-height: 21px; color: var(--ink-muted); margin: 0; max-width: 46ch; }
