/**
 * ToughBlue CI — form system for IT Health Check
 * Think | Act | Solve · Primary #14478F · Secondary #6BB7E8 · Accent #F5A623
 */

/* --- Page shell --- */
body.tb-app {
  background: linear-gradient(165deg, #dce8f5 0%, var(--tb-surface) 45%, #eef2f8 100%);
  background-attachment: fixed;
}

.tb-page-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid transparent;
  border-image: linear-gradient(90deg, var(--tb-primary), var(--tb-secondary), var(--tb-accent)) 1;
}

.tb-page-header .tb-page-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--tb-primary), var(--tb-primary-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(20, 71, 143, 0.25);
}

.tb-page-header .tb-page-icon img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.tb-page-header h1 {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--tb-primary);
  margin-bottom: 0.25rem;
  letter-spacing: -0.02em;
}

.tb-page-header .lead {
  margin-bottom: 0;
  max-width: 52ch;
}

/* --- Stepper --- */
.tb-stepper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.tb-step {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--tb-muted);
}

.tb-step-num {
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 800;
  background: var(--tb-surface);
  border: 2px solid var(--tb-border);
  color: var(--tb-muted);
}

.tb-step.active .tb-step-num {
  background: var(--tb-primary);
  border-color: var(--tb-primary);
  color: white;
}

.tb-step.active {
  color: var(--tb-primary);
}

.tb-step.done .tb-step-num {
  background: var(--tb-good);
  border-color: var(--tb-good);
  color: white;
}

.tb-step-line {
  flex: 1;
  min-width: 24px;
  max-width: 48px;
  height: 2px;
  background: var(--tb-border);
  border-radius: 1px;
}

/* --- Form layout --- */
.tb-form {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.tb-form-section {
  margin-bottom: 1.75rem;
}

.tb-form-section-title {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--tb-primary);
  margin-bottom: 0.35rem;
}

.tb-form-section h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--tb-text);
  margin-bottom: 0.35rem;
}

.tb-form-section .section-desc {
  font-size: 0.88rem;
  color: var(--tb-muted);
  margin-bottom: 1rem;
  line-height: 1.5;
}

.tb-form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.15rem 1.25rem;
}

.tb-form-grid.cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

.tb-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.tb-field.full {
  grid-column: 1 / -1;
}

.tb-field label,
.tb-field .tb-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--tb-muted);
}

.tb-field label .required {
  color: var(--tb-poor);
  margin-left: 0.15rem;
}

.tb-input,
.tb-select,
.tb-textarea,
.tb-form input[type="text"],
.tb-form input[type="password"],
.tb-form input[type="number"],
.tb-form input[type="email"],
.tb-form select,
.tb-form textarea {
  width: 100%;
  padding: 0.7rem 0.9rem;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--tb-text);
  background: #fff;
  border: 1.5px solid rgba(20, 71, 143, 0.18);
  border-radius: 8px;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.tb-input:hover,
.tb-form input:hover,
.tb-form select:hover,
.tb-form textarea:hover {
  border-color: rgba(20, 71, 143, 0.35);
}

.tb-input:focus,
.tb-form input:focus,
.tb-form select:focus,
.tb-form textarea:focus {
  outline: none;
  border-color: var(--tb-primary);
  box-shadow: 0 0 0 3px rgba(20, 71, 143, 0.12);
  background: #fff;
}

.tb-input::placeholder,
.tb-form input::placeholder,
.tb-form textarea::placeholder {
  color: #94a3b8;
}

.tb-textarea,
.tb-form textarea {
  min-height: 5rem;
  resize: vertical;
  line-height: 1.5;
}

.tb-field-hint {
  font-size: 0.78rem;
  color: var(--tb-muted);
  line-height: 1.4;
}

/* --- Triage cards --- */
.tb-triage-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.tb-triage-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.15rem;
  background: #fff;
  border: 1.5px solid var(--tb-border);
  border-radius: 10px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.tb-triage-card:hover {
  border-color: rgba(107, 183, 232, 0.6);
  box-shadow: 0 2px 12px rgba(20, 71, 143, 0.06);
}

.tb-triage-card:has(input[value="yes"]:checked) {
  border-color: var(--tb-primary);
  background: linear-gradient(135deg, #f8fbff 0%, #fff 100%);
  box-shadow: 0 2px 12px rgba(20, 71, 143, 0.08);
}

.tb-triage-q {
  flex: 1;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--tb-text);
  line-height: 1.45;
}

.tb-pill-group {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.tb-pill {
  position: relative;
  cursor: pointer;
}

.tb-pill input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.tb-pill span {
  display: inline-block;
  padding: 0.45rem 1rem;
  font-size: 0.82rem;
  font-weight: 700;
  border-radius: 999px;
  border: 1.5px solid var(--tb-border);
  background: var(--tb-surface);
  color: var(--tb-muted);
  transition: all 0.15s;
  user-select: none;
}

.tb-pill:hover span {
  border-color: var(--tb-secondary);
  color: var(--tb-primary);
}

.tb-pill-yes input:checked + span {
  background: var(--tb-primary);
  border-color: var(--tb-primary);
  color: #fff;
}

.tb-pill-no input:checked + span {
  background: #fdeecf;
  border-color: var(--tb-accent);
  color: #92400e;
}

/* --- Answer pills (questionnaire) --- */
.tb-answer-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0;
}

.tb-answer-pill {
  position: relative;
  cursor: pointer;
}

.tb-answer-pill input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.tb-answer-pill span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 1rem;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 999px;
  border: 1.5px solid var(--tb-border);
  background: #fff;
  transition: all 0.15s;
}

.tb-answer-pill.good input:checked + span {
  background: #ecfdf5;
  border-color: var(--tb-good);
  color: #166534;
}

.tb-answer-pill.partial input:checked + span {
  background: #fffbeb;
  border-color: var(--tb-accent);
  color: #92400e;
}

.tb-answer-pill.poor input:checked + span {
  background: #fef2f2;
  border-color: var(--tb-poor);
  color: #991b1b;
}

.tb-answer-pill.na input:checked + span {
  background: var(--tb-surface);
  border-color: var(--tb-muted);
  color: var(--tb-muted);
}

.tb-answer-pill:hover span {
  border-color: var(--tb-secondary);
  box-shadow: 0 1px 4px rgba(20, 71, 143, 0.08);
}

/* --- Question card --- */
.tb-question-card {
  padding: 1.15rem 1.25rem;
  border: 1px solid var(--tb-border);
  border-top: none;
  background: #fff;
}

.tb-question-card:first-of-type {
  border-top: 1px solid var(--tb-border);
  border-radius: 10px 10px 0 0;
}

.tb-question-card:last-of-type {
  border-radius: 0 0 10px 10px;
  margin-bottom: 0;
}

.tb-question-card .q-text {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--tb-text);
  margin-bottom: 0.5rem;
  line-height: 1.45;
}

.tb-question-card .q-notes {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px dashed var(--tb-border);
}

/* --- Section panel wrapper --- */
.tb-section-panel {
  border: 1px solid var(--tb-border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(20, 71, 143, 0.05);
}

.tb-section-panel-head {
  background: linear-gradient(135deg, var(--tb-primary-dark) 0%, var(--tb-primary) 100%);
  color: #fff;
  padding: 1.1rem 1.25rem;
}

.tb-section-panel-head h2 {
  color: #fff;
  font-size: 1.1rem;
  margin-bottom: 0.2rem;
}

.tb-section-panel-head p {
  font-size: 0.85rem;
  opacity: 0.88;
  margin: 0;
}

/* --- Auth layout --- */
.tb-auth-wrap {
  min-height: calc(100vh - 120px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 0;
}

.tb-auth-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  max-width: 880px;
  width: 100%;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(20, 71, 143, 0.15);
  border: 1px solid var(--tb-border);
}

.tb-auth-brand {
  background: linear-gradient(160deg, var(--tb-primary-dark) 0%, var(--tb-primary) 55%, #1a5aa8 100%);
  color: #fff;
  padding: 2.5rem 2rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.tb-auth-brand::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--tb-accent), var(--tb-secondary), var(--tb-accent));
}

.tb-auth-brand .tb-logo-roundel {
  width: 56px;
  height: 56px;
  background: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.25rem;
  padding: 8px;
}

.tb-auth-brand .tb-logo-roundel img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.tb-auth-brand .tb-name {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 0.35rem;
}

.tb-auth-brand .tb-name .blue {
  color: var(--tb-secondary);
}

.tb-auth-brand .tb-tagline {
  font-size: 0.85rem;
  opacity: 0.9;
  margin-bottom: 1.5rem;
}

.tb-auth-brand .tb-motto {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.tb-auth-brand .tb-motto .think { color: var(--tb-accent); }
.tb-auth-brand .tb-motto .act { color: #5AC8FA; }
.tb-auth-brand .tb-motto .solve { color: var(--tb-secondary); }

.tb-auth-form {
  background: #fff;
  padding: 2.25rem 2rem;
}

.tb-auth-form h1 {
  font-size: 1.35rem;
  margin-bottom: 0.35rem;
}

.tb-auth-form .lead {
  margin-bottom: 1.5rem;
}

/* --- Form actions bar --- */
.tb-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  padding-top: 0.5rem;
}

.tb-form-actions.primary-bar {
  background: linear-gradient(180deg, #fff 0%, var(--tb-surface) 100%);
  border-top: 1px solid var(--tb-border);
  margin: 0 -1.75rem -1.5rem;
  padding: 1.15rem 1.75rem;
  border-radius: 0 0 10px 10px;
}

/* --- Buttons enhancement --- */
.btn {
  transition: transform 0.12s, box-shadow 0.12s, opacity 0.12s;
}

.btn-primary {
  background: linear-gradient(180deg, #1a5cad 0%, var(--tb-primary) 100%);
  box-shadow: 0 2px 8px rgba(20, 71, 143, 0.25);
}

.btn-primary:hover {
  box-shadow: 0 4px 14px rgba(20, 71, 143, 0.35);
  transform: translateY(-1px);
  opacity: 1;
}

.btn-accent {
  box-shadow: 0 2px 8px rgba(245, 166, 35, 0.35);
}

.btn-secondary {
  background: #fff;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

/* --- Topbar CI accent (legacy — sidebar layout uses app-topbar) --- */
.app-topbar {
  border-bottom: 3px solid transparent;
  border-image: linear-gradient(90deg, var(--tb-accent), var(--tb-secondary), var(--tb-primary)) 1;
  box-shadow: 0 2px 16px rgba(13, 50, 102, 0.2);
}

.btn-link {
  background: none;
  border: none;
  color: var(--tb-primary);
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
  padding: 0;
}

/* --- Tab nav polish --- */
.tab-nav-card {
  background: linear-gradient(180deg, #fff 0%, var(--tb-surface) 100%);
}

.tab-btn {
  border-radius: 8px;
  transition: all 0.15s;
}

.tab-btn:hover:not(.active) {
  border-color: var(--tb-secondary);
  background: #fff;
}

/* --- Sticky actions --- */
.sticky-actions {
  border: 1px solid var(--tb-border);
  border-radius: 12px;
  padding: 1.15rem 1.35rem;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(8px);
}

/* --- Admin table forms --- */
.tb-admin-card .data input[type="number"] {
  padding: 0.45rem 0.55rem;
  border: 1.5px solid var(--tb-border);
  border-radius: 6px;
  font-size: 0.88rem;
}

/* --- Checkbox field --- */
.tb-checkbox-field {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.85rem 1rem;
  background: var(--tb-surface);
  border-radius: 8px;
  border: 1px solid var(--tb-border);
  cursor: pointer;
}

.tb-checkbox-field input {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--tb-primary);
}

.tb-checkbox-field span {
  font-size: 0.9rem;
  font-weight: 500;
}

/* --- Staff accounts table & action menu --- */
.tb-staff-table-card {
  overflow: visible;
}

.tb-staff-table-card .tb-table-wrap {
  overflow-x: auto;
  margin-top: 0.75rem;
}

.tb-staff-table {
  overflow: visible;
}

.tb-staff-table .tb-col-actions {
  width: 9rem;
  text-align: right;
}

.tb-staff-table .tb-cell-email {
  max-width: 14rem;
  word-break: break-word;
}

.tb-role-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: var(--tb-surface);
  color: var(--tb-muted);
  border: 1px solid var(--tb-border);
}

.tb-role-pill--admin {
  background: #e8f0fb;
  color: var(--tb-primary);
  border-color: #c7daf5;
}

.tb-user-actions {
  position: relative;
  overflow: visible;
  text-align: right;
  vertical-align: middle;
}

.tb-action-bar {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
}

.tb-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 2rem;
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--tb-border);
  background: #fff;
  color: var(--tb-primary);
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.12s;
  list-style: none;
}

.tb-action-btn svg {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

.tb-action-btn--primary {
  background: linear-gradient(180deg, #1a5cad 0%, var(--tb-primary) 100%);
  border-color: var(--tb-primary);
  color: #fff;
  box-shadow: 0 1px 4px rgba(20, 71, 143, 0.2);
}

.tb-action-btn--primary:hover {
  box-shadow: 0 3px 10px rgba(20, 71, 143, 0.28);
  transform: translateY(-1px);
  opacity: 1;
}

.tb-action-btn--menu {
  width: 2rem;
  min-width: 2rem;
  padding: 0;
  color: var(--tb-muted);
  background: var(--tb-surface);
}

.tb-action-btn--menu:hover,
.tb-action-menu[open] > .tb-action-btn--menu {
  background: #fff;
  border-color: #c7daf5;
  color: var(--tb-primary);
  box-shadow: 0 2px 8px rgba(20, 71, 143, 0.1);
}

.tb-action-menu {
  position: relative;
}

.tb-action-menu > summary {
  list-style: none;
}

.tb-action-menu > summary::-webkit-details-marker {
  display: none;
}

.tb-action-menu-panel {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  z-index: 40;
  min-width: 13.5rem;
  padding: 0.35rem;
  background: #fff;
  border: 1px solid var(--tb-border);
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(13, 50, 102, 0.14);
}

.tb-action-menu-panel form {
  margin: 0;
}

.tb-action-menu-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--tb-text);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.tb-action-menu-item svg {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  color: var(--tb-muted);
}

.tb-action-menu-item:hover {
  background: var(--tb-surface);
  color: var(--tb-primary);
}

.tb-action-menu-item:hover svg {
  color: var(--tb-primary);
}

.tb-action-menu-item--danger {
  color: #b42318;
}

.tb-action-menu-item--danger svg {
  color: #d92d20;
}

.tb-action-menu-item--danger:hover {
  background: #fef3f2;
  color: #912018;
}

.tb-username-preview {
  display: flex;
  align-items: center;
  min-height: 2.65rem;
  padding: 0.55rem 0.85rem;
  background: var(--tb-surface);
  border: 1.5px dashed #c7daf5;
  border-radius: 8px;
}

.tb-username-preview code {
  font-size: 1rem;
  font-weight: 700;
  color: var(--tb-primary);
  letter-spacing: 0.02em;
}

@media (max-width: 768px) {
  .tb-form-grid,
  .tb-form-grid.cols-3,
  .tb-auth-layout {
    grid-template-columns: 1fr;
  }

  .tb-triage-card {
    flex-direction: column;
    align-items: stretch;
  }

  .tb-pill-group {
    justify-content: flex-end;
  }

  .tb-auth-brand {
    padding: 1.75rem 1.5rem;
  }

  .tb-auth-form {
    padding: 1.75rem 1.5rem;
  }
}
