/* Precision Controller Lab — reusable controls and data components */

.gct-button {
  display: inline-flex;
  min-height: var(--gct-control-height);
  padding: .625rem 1rem;
  align-items: center;
  justify-content: center;
  gap: var(--gct-space-2);
  border: 1px solid transparent;
  border-radius: var(--gct-radius-sm);
  background: var(--gct-blue-600);
  box-shadow: var(--gct-shadow-xs);
  color: #fff;
  font-size: var(--gct-font-size-sm);
  font-weight: 750;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  transition: background var(--gct-duration-fast) ease, border-color var(--gct-duration-fast) ease, box-shadow var(--gct-duration-fast) ease, transform var(--gct-duration-fast) ease;
}

.gct-button:hover {
  background: var(--gct-blue-700);
  color: #fff;
}

.gct-button:active {
  transform: translateY(1px);
}

.gct-button--secondary {
  border-color: var(--gct-line-strong);
  background: var(--gct-surface);
  box-shadow: none;
  color: var(--gct-navy-900);
}

.gct-button--secondary:hover {
  border-color: var(--gct-blue-500);
  background: var(--gct-blue-050);
  color: var(--gct-blue-700);
}

.gct-button--quiet {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  color: var(--gct-ink-soft);
}

.gct-button--quiet:hover {
  background: var(--gct-blue-050);
  color: var(--gct-blue-700);
}

.gct-button--danger {
  background: var(--gct-red-600);
}

.gct-button--danger:hover {
  background: var(--gct-red-700);
}

.gct-button--large {
  min-height: 3.25rem;
  padding-inline: 1.375rem;
  border-radius: var(--gct-radius-md);
  font-size: 1rem;
}

.gct-button--small {
  min-height: 2.75rem;
  padding-inline: .75rem;
  font-size: var(--gct-font-size-xs);
}

.gct-icon-button {
  display: inline-grid;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--gct-line);
  border-radius: var(--gct-radius-sm);
  background: var(--gct-surface);
  color: var(--gct-navy-900);
}

.gct-icon-button:hover {
  border-color: var(--gct-blue-200);
  background: var(--gct-blue-050);
  color: var(--gct-blue-700);
}

.gct-badge,
.gct-status {
  display: inline-flex;
  min-height: 1.75rem;
  padding: .25rem .625rem;
  align-items: center;
  gap: .375rem;
  border: 1px solid var(--gct-line);
  border-radius: var(--gct-radius-pill);
  background: var(--gct-surface-muted);
  color: var(--gct-ink-soft);
  font-size: var(--gct-font-size-xs);
  font-weight: 750;
  line-height: 1.1;
}

.gct-status::before {
  width: .4375rem;
  height: .4375rem;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--gct-muted-light);
  content: "";
}

.gct-status--success {
  border-color: #abdcc3;
  background: var(--gct-green-100);
  color: var(--gct-green-700);
}

.gct-status--success::before {
  background: var(--gct-green-600);
}

.gct-status--warning {
  border-color: #ebd09b;
  background: var(--gct-amber-100);
  color: var(--gct-amber-800);
}

.gct-status--warning::before {
  background: var(--gct-warning);
}

.gct-status--danger {
  border-color: #f0b3bb;
  background: var(--gct-red-100);
  color: var(--gct-red-700);
}

.gct-status--danger::before {
  background: var(--gct-red-600);
}

.gct-panel,
.gct-card {
  min-width: 0;
  border: 1px solid var(--gct-line);
  border-radius: var(--gct-radius-md);
  background: var(--gct-surface);
  box-shadow: var(--gct-shadow-xs);
}

.gct-panel {
  padding: var(--gct-space-panel, var(--gct-space-6));
}

.gct-card {
  padding: var(--gct-space-5);
}

.gct-panel__header,
.gct-card__header {
  display: flex;
  margin-bottom: var(--gct-space-5);
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--gct-space-4);
}

.gct-panel__header :where(h2, h3),
.gct-card__header :where(h2, h3) {
  margin-bottom: .25rem;
}

.gct-panel__header p,
.gct-card__header p {
  margin-bottom: 0;
  color: var(--gct-muted);
  font-size: var(--gct-font-size-sm);
}

.gct-field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: .375rem;
}

.gct-field__label {
  color: var(--gct-ink-soft);
  font-size: var(--gct-font-size-sm);
  font-weight: 750;
}

.gct-field :where(input:not([type="checkbox"]):not([type="radio"]), select, textarea),
.gct-input {
  width: 100%;
  min-height: var(--gct-control-height);
  padding: .625rem .75rem;
  border: 1px solid var(--gct-line-strong);
  border-radius: var(--gct-radius-sm);
  background: var(--gct-surface);
  box-shadow: inset 0 1px 2px rgb(7 17 31 / 4%);
  color: var(--gct-ink);
  line-height: 1.35;
}

.gct-field textarea {
  min-height: 8rem;
  resize: vertical;
}

.gct-field :where(input, select, textarea):focus,
.gct-input:focus {
  border-color: var(--gct-blue-600);
  box-shadow: var(--gct-ring);
  outline: 0;
}

.gct-field :where(input, select, textarea)[aria-invalid="true"] {
  border-color: var(--gct-red-600);
}

.gct-field__help,
.gct-field__error {
  margin: 0;
  color: var(--gct-muted);
  font-size: var(--gct-font-size-xs);
  line-height: 1.45;
}

.gct-field__error {
  color: var(--gct-red-700);
}

.gct-check {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  gap: .625rem;
  color: var(--gct-ink-soft);
  font-size: var(--gct-font-size-sm);
}

.gct-check input {
  width: 1.125rem;
  height: 1.125rem;
  flex: 0 0 auto;
  accent-color: var(--gct-blue-600);
}

.gct-switch {
  position: relative;
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  gap: .625rem;
}

.gct-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.gct-switch__track {
  position: relative;
  width: 2.625rem;
  height: 1.5rem;
  flex: 0 0 auto;
  border: 1px solid var(--gct-line-strong);
  border-radius: var(--gct-radius-pill);
  background: var(--gct-line);
  transition: background var(--gct-duration-fast) ease;
}

.gct-switch__track::after {
  position: absolute;
  top: .1875rem;
  left: .1875rem;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgb(7 17 31 / 28%);
  content: "";
  transition: transform var(--gct-duration-fast) var(--gct-ease-standard);
}

.gct-switch input:checked + .gct-switch__track {
  border-color: var(--gct-blue-600);
  background: var(--gct-blue-600);
}

.gct-switch input:checked + .gct-switch__track::after {
  transform: translateX(1.125rem);
}

.gct-switch input:focus-visible + .gct-switch__track {
  outline: 3px solid var(--gct-focus);
  outline-offset: 3px;
}

.gct-alert {
  display: grid;
  padding: var(--gct-space-4);
  border: 1px solid var(--gct-blue-200);
  border-left: 4px solid var(--gct-blue-600);
  border-radius: var(--gct-radius-sm);
  background: var(--gct-blue-050);
  color: var(--gct-ink-soft);
  gap: var(--gct-space-2);
  grid-template-columns: auto minmax(0, 1fr);
}

.gct-alert--success {
  border-color: #abdcc3;
  border-left-color: var(--gct-green-600);
  background: #f0faf5;
}

.gct-alert--warning {
  border-color: #ebd09b;
  border-left-color: var(--gct-warning);
  background: #fffaf0;
}

.gct-alert--danger {
  border-color: #f0b3bb;
  border-left-color: var(--gct-red-600);
  background: var(--gct-red-050);
}

.gct-tabs {
  display: flex;
  min-height: 2.75rem;
  margin: 0;
  padding: .25rem;
  overflow-x: auto;
  align-items: center;
  gap: .25rem;
  border: 1px solid var(--gct-line);
  border-radius: var(--gct-radius-sm);
  background: var(--gct-surface-muted);
  scrollbar-width: thin;
}

.gct-tab {
  display: inline-flex;
  min-height: 2.25rem;
  padding: .5rem .75rem;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: .5rem;
  background: transparent;
  color: var(--gct-muted);
  font-size: var(--gct-font-size-sm);
  font-weight: 750;
  white-space: nowrap;
}

.gct-tab[aria-selected="true"],
.gct-tab.is-active {
  background: var(--gct-surface);
  box-shadow: var(--gct-shadow-xs);
  color: var(--gct-blue-700);
}

.gct-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--gct-line);
  border-radius: var(--gct-radius-md);
  background: var(--gct-surface);
}

.gct-table {
  width: 100%;
  min-width: 42rem;
  border-collapse: collapse;
  font-size: var(--gct-font-size-sm);
}

.gct-table th,
.gct-table td {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--gct-line);
  text-align: left;
  vertical-align: middle;
}

.gct-table th {
  background: var(--gct-surface-muted);
  color: var(--gct-muted);
  font-size: var(--gct-font-size-xs);
  font-weight: 800;
  letter-spacing: .035em;
  text-transform: uppercase;
}

.gct-table tbody tr:hover {
  background: var(--gct-blue-050);
}

.gct-table tr:last-child td {
  border-bottom: 0;
}

.gct-empty-state {
  display: grid;
  min-height: 18rem;
  padding: var(--gct-space-8);
  place-items: center;
  align-content: center;
  border: 1px dashed var(--gct-line-strong);
  border-radius: var(--gct-radius-lg);
  background: var(--gct-surface-muted);
  color: var(--gct-muted);
  text-align: center;
}

.gct-empty-state h2,
.gct-empty-state h3 {
  margin-bottom: var(--gct-space-2);
}

.gct-empty-state p {
  max-width: 32rem;
}

.gct-toast {
  position: fixed;
  z-index: 3000;
  right: var(--gct-space-4);
  bottom: var(--gct-space-4);
  width: min(calc(100% - 2rem), 24rem);
  padding: var(--gct-space-4);
  border: 1px solid var(--gct-line);
  border-radius: var(--gct-radius-md);
  background: var(--gct-navy-950);
  box-shadow: var(--gct-shadow-lg);
  color: #fff;
}

.gct-modal-backdrop {
  position: fixed;
  z-index: 2900;
  inset: 0;
  display: grid;
  padding: var(--gct-space-4);
  place-items: center;
  background: var(--gct-overlay);
}

.gct-modal {
  width: min(100%, 37.5rem);
  max-height: min(90vh, 50rem);
  padding: var(--gct-space-6);
  overflow: auto;
  border: 1px solid var(--gct-line);
  border-radius: var(--gct-radius-lg);
  background: var(--gct-surface);
  box-shadow: var(--gct-shadow-lg);
}

.gct-skeleton {
  overflow: hidden;
  border-radius: var(--gct-radius-xs);
  background: linear-gradient(90deg, #e7edf4 20%, #f4f7fa 38%, #e7edf4 56%);
  background-size: 200% 100%;
  animation: gct-shimmer 1.4s linear infinite;
}

@keyframes gct-shimmer {
  to { background-position-x: -200%; }
}

@media (max-width: 48rem) {
  .gct-panel,
  .gct-card {
    padding: var(--gct-space-4);
  }

  .gct-panel__header,
  .gct-card__header {
    align-items: flex-start;
    flex-direction: column;
  }

  .gct-toast {
    bottom: calc(var(--gct-mobile-dock-height) + env(safe-area-inset-bottom) + var(--gct-space-3));
  }
}

@media (forced-colors: active) {
  .gct-button,
  .gct-icon-button,
  .gct-badge,
  .gct-status,
  .gct-panel,
  .gct-card,
  .gct-field :where(input, select, textarea),
  .gct-tab {
    border: 1px solid ButtonText;
    forced-color-adjust: auto;
  }
}

