/* MyHub - Components
   ------------------ */

/* --- Shell / Top bar --- */
.shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.appbar {
  height: var(--shell-h);
  background: var(--shell-bg);
  color: var(--shell-text);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.appbar__back {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  color: var(--shell-text);
}
.appbar__back:hover {
  background: rgba(255, 255, 255, 0.1);
}

.appbar__logo {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.appbar__logo svg {
  width: 22px;
  height: 22px;
}

.appbar__title {
  font-size: var(--fs-m);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}
.appbar__title:hover {
  background: rgba(255, 255, 255, 0.1);
}

.appbar__search {
  flex: 0 1 480px;
  margin: 0 auto;
  background: var(--shell-search-bg);
  border-radius: 4px;
  height: 30px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  color: var(--shell-search-text);
  font-style: italic;
  font-size: var(--fs-s);
  gap: 8px;
}
.appbar__search input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--shell-search-text);
  font-style: italic;
  font-size: var(--fs-s);
}
.appbar__search input::placeholder {
  color: var(--shell-search-text);
}

.appbar__icons {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}
.appbar__icon-btn {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  color: var(--shell-text);
}
.appbar__icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}
.appbar__avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #d6e6f5;
  color: #0a4f92;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: var(--fs-s);
  margin-left: 4px;
  cursor: pointer;
}

/* --- Page wrapper --- */
.page {
  flex: 1;
  background: var(--bg);
  padding: 0;
  display: flex;
  flex-direction: column;
}

.page__header {
  background: var(--bg);
  padding: 12px 24px 4px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.page__title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.page__title h1 {
  margin: 0;
  font-size: var(--fs-xxl);
  font-weight: 700;
  letter-spacing: 0.2px;
  color: var(--text);
}
.page__title .subtitle {
  font-size: var(--fs-s);
  color: var(--text-muted);
}

.page__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Variant selector ("Standard *") */
.variant {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 700;
  font-size: var(--fs-xl);
  color: var(--primary);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}
.variant:hover {
  background: var(--primary-soft);
}
.variant .variant__star {
  color: var(--primary);
  margin-left: 2px;
}

/* --- Filter bar --- */
.filterbar {
  background: var(--bg);
  padding: 8px 24px 16px;
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
  flex: 1 1 140px;
  max-width: 200px;
}
.filter-field__label {
  font-size: var(--fs-s);
  color: var(--text-muted);
}
.filter-field__input {
  height: 28px;
  border: 1px solid var(--border);
  border-bottom: 1px solid var(--text);
  border-radius: 0;
  background: var(--surface);
  padding: 0 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: var(--fs-m);
  color: var(--text);
}
.filter-field__input:focus-within {
  border-bottom-color: var(--primary);
  outline: 1px solid var(--primary);
  outline-offset: -1px;
}
.filter-field__input input,
.filter-field__input select {
  border: 0;
  outline: 0;
  background: transparent;
  flex: 1;
  height: 100%;
  font-size: var(--fs-m);
  min-width: 40px;
}
.filter-field__input select {
  appearance: none;
  cursor: pointer;
  padding-right: 16px;
}
.filter-field__input .vh-icon {
  color: var(--text-muted);
  cursor: pointer;
}

/* Token chip used inside filter input (multi-select) */
.tok {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--primary-soft);
  color: var(--text);
  padding: 1px 4px 1px 6px;
  border-radius: 2px;
  font-size: var(--fs-s);
  flex-shrink: 0;
}
.tok button {
  color: var(--text-muted);
  font-weight: 700;
  font-size: 13px;
  line-height: 1;
}

.filterbar__cta {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Toggle switch */
.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: 56px;
  height: 22px;
  background: var(--text-disabled);
  border-radius: 11px;
  padding: 2px;
  cursor: pointer;
  font-size: 10px;
  color: var(--shell-text);
  font-weight: 600;
  text-transform: uppercase;
  user-select: none;
}
.switch--on {
  background: var(--primary);
  justify-content: flex-start;
}
.switch::before {
  content: "OFF";
  margin-left: 18px;
}
.switch--on::before {
  content: "ON";
  margin-left: 6px;
}
.switch::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--surface);
  top: 2px;
  left: 2px;
  transition: left 0.18s;
}
.switch--on::after {
  left: 36px;
}

/* --- Buttons --- */
.btn {
  height: 28px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 4px;
  font-size: var(--fs-m);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
}
.btn--primary {
  background: var(--primary);
  color: #fff;
  border: 1px solid var(--primary);
}
.btn--primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}
.btn--ghost {
  color: var(--primary);
  background: transparent;
}
.btn--ghost:hover {
  background: var(--primary-soft);
}
.btn--ghost.is-active {
  background: var(--primary-soft);
}
.btn--secondary {
  background: var(--surface);
  color: var(--primary);
  border: 1px solid var(--border-strong);
}
.btn--secondary:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
}
.btn--danger {
  background: var(--critical-red);
  color: #fff;
  border: 1px solid var(--critical-red);
}
.btn--danger:hover {
  background: #b30037;
}
.btn--icon {
  width: 28px;
  padding: 0;
}
.btn--small {
  height: 24px;
  padding: 0 8px;
  font-size: var(--fs-s);
}
.btn--link {
  color: var(--primary);
  background: transparent;
  font-weight: 400;
  height: auto;
  padding: 4px 6px;
}
.btn--link:hover {
  text-decoration: underline;
}
.btn[disabled] {
  color: var(--text-disabled) !important;
  cursor: not-allowed;
  background: transparent !important;
}
.btn--primary[disabled] {
  background: var(--bg-soft) !important;
  color: var(--text-disabled) !important;
  border-color: var(--border) !important;
}

/* --- Section / Panel --- */
.section {
  background: var(--surface);
  margin: 0 16px 12px;
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-sm);
}
.section__header {
  padding: 12px 16px 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--divider);
}
.section__title {
  font-size: var(--fs-l);
  font-weight: 700;
  color: var(--text);
}
.section__title-count {
  font-weight: 700;
  color: var(--text);
  margin-left: 4px;
}
.section__actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Collapsible section (Dashboard) */
.section--collapsible > .section__header {
  cursor: pointer;
  border-bottom: 0;
}
.section--collapsible.is-collapsed > .section__body {
  display: none;
}

.section__body {
  padding: 8px 12px 12px;
}

/* --- Table --- */
.table-wrap {
  overflow: auto;
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-m);
}
.table thead th {
  background: var(--surface);
  text-align: left;
  font-weight: 700;
  color: var(--text);
  font-size: var(--fs-s);
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
.table tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--divider);
  vertical-align: top;
  color: var(--text);
}
.table tbody tr:hover {
  background: var(--row-hover);
}
.table tbody tr.is-selected {
  background: var(--row-selected);
}
.table--striped tbody tr:nth-child(even) {
  background: var(--surface-alt);
}
.table th.text-right,
.table td.text-right {
  text-align: right;
}
.table th.col-checkbox,
.table td.col-checkbox {
  width: 32px;
  padding-left: 14px;
}
.table th.col-action,
.table td.col-action {
  width: 32px;
  text-align: right;
  color: var(--text-muted);
}
.table .col-link {
  color: var(--primary);
  cursor: pointer;
}
.table .col-link:hover {
  text-decoration: underline;
}

.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 8px;
  background: var(--bg-soft);
  font-size: var(--fs-s);
  color: var(--text-muted);
}

/* --- Tabs --- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--divider);
  background: var(--surface);
  padding: 0 24px;
  position: sticky;
  top: var(--shell-h);
  z-index: 10;
}
.tab {
  padding: 10px 14px;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-weight: 600;
  font-size: var(--fs-m);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover {
  color: var(--primary);
}
.tab.is-active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* --- Status pill / track --- */
.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 10px;
  background: var(--bg-soft);
  font-size: var(--fs-s);
  font-weight: 600;
  color: var(--text);
}
.status-pill--success {
  background: var(--success-bg);
  color: var(--success);
}
.status-pill--warning {
  background: var(--warning-bg);
  color: var(--warning);
}
.status-pill--error {
  background: var(--error-bg);
  color: var(--error);
}
.status-pill--info {
  background: var(--info-bg);
  color: var(--info);
}

/* Status track widget on object page */
.status-track {
  display: flex;
  align-items: center;
  gap: 6px;
}
.status-track .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-disabled);
}
.status-track .dot.is-current {
  background: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.status-track .line {
  flex: 1;
  height: 2px;
  background: var(--text-disabled);
  min-width: 60px;
}

/* --- Modal --- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-backdrop.is-open {
  display: flex;
}
.modal {
  background: var(--surface);
  width: 480px;
  max-width: 92vw;
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 88vh;
}
.modal--wide {
  width: 720px;
}
.modal__header {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--divider);
}
.modal__title {
  font-size: var(--fs-l);
  font-weight: 700;
}
.modal__close-link {
  margin-left: auto;
  color: var(--primary);
  cursor: pointer;
}
.modal__body {
  padding: 14px 16px;
  overflow: auto;
  flex: 1;
}
.modal__footer {
  padding: 12px 16px;
  border-top: 1px solid var(--divider);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* --- Object page layout --- */
.object-header {
  background: var(--surface);
  padding: 16px 24px 0;
  border-bottom: 1px solid var(--divider);
}
.object-header__top {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}
.object-header__title {
  flex: 1;
}
.object-header__title h1 {
  margin: 0;
  font-size: var(--fs-xxl);
  font-weight: 700;
}
.object-header__title .subtitle {
  font-size: var(--fs-m);
  color: var(--text-muted);
}
.object-header__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}
.object-header__meta {
  display: flex;
  gap: 32px;
  padding: 12px 0 8px;
  flex-wrap: wrap;
  font-size: var(--fs-s);
  color: var(--text-muted);
}
.object-header__meta strong {
  color: var(--text);
  font-weight: 600;
  margin-left: 4px;
}

/* Field grid (object page section) */
.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 24px;
  padding: 12px 16px 16px;
}
.field-block h3 {
  font-size: var(--fs-m);
  font-weight: 700;
  margin: 0 0 10px;
  color: var(--text);
}
.field {
  margin-bottom: 12px;
}
.field__label {
  display: block;
  font-size: var(--fs-s);
  color: var(--text-muted);
  margin-bottom: 2px;
}
.field__value {
  font-size: var(--fs-m);
  color: var(--text);
}

/* Highlight bar on row (Changed Fields, Current/At Event Time) */
.row-marker-orange {
  border-left: 3px solid var(--bar-orange);
}

/* Empty state */
.empty {
  text-align: center;
  padding: 32px;
  color: var(--text-muted);
}
.empty--big {
  font-size: var(--fs-xxl);
  font-weight: 700;
  color: var(--text);
}

/* Pagination footer */
.table-footer {
  text-align: center;
  padding: 12px;
  border-top: 1px solid var(--divider);
  font-size: var(--fs-s);
  color: var(--text-muted);
}
.table-footer button {
  color: var(--primary);
  font-weight: 600;
  margin-right: 8px;
}

/* --- Notes / Posting input --- */
.note-input {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-alt);
  padding: 8px 12px;
  border-radius: var(--radius-m);
}
.note-input__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.note-input__field {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 10px;
  background: var(--surface);
  font-size: var(--fs-m);
  color: var(--text);
  outline: 0;
}
.note-input__send {
  color: var(--primary);
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}
.note-input__send:hover {
  background: var(--primary-soft);
}

/* --- Attachments empty --- */
.attachments-empty {
  text-align: center;
  padding: 80px 20px;
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
}

/* Rich text editor mock */
.rte {
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
}
.rte__toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--divider);
  flex-wrap: wrap;
  color: var(--text-muted);
}
.rte__toolbar .sep {
  width: 1px;
  height: 20px;
  background: var(--divider);
  margin: 0 4px;
}
.rte__toolbar button {
  padding: 4px 6px;
  border-radius: 3px;
  color: var(--text);
}
.rte__toolbar button:hover {
  background: var(--bg-soft);
}
.rte__toolbar select {
  height: 24px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 3px;
  padding: 0 6px;
  font-size: var(--fs-s);
}
.rte__editor {
  min-height: 140px;
  padding: 10px 12px;
  outline: 0;
  border: 2px solid var(--primary);
  border-top: 0;
  border-radius: 0 0 4px 4px;
}

/* --- Adapt Filters dialog body --- */
.adapt-filters__list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.adapt-filters__list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px;
  border-bottom: 1px solid var(--divider);
}
.adapt-filters__list li:hover {
  background: var(--row-hover);
}
.adapt-filters__list li.is-active {
  background: var(--primary-soft);
}
.adapt-filters__list .name {
  flex: 1;
}
.adapt-filters__list .active-dot {
  width: 6px;
  height: 6px;
  background: var(--text);
  border-radius: 50%;
}
.adapt-filters__head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--divider);
  margin-bottom: 8px;
}
.adapt-filters__head .label {
  font-size: var(--fs-s);
  color: var(--text-muted);
  margin-left: auto;
}

/* --- Pin / collapse handle --- */
.collapse-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: -2px 0 8px;
  color: var(--primary);
}
.collapse-handle button {
  width: 28px;
  height: 16px;
  background: var(--surface);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
}

/* --- Master / detail (split-screen) --- */
.master-detail {
  display: grid;
  grid-template-columns: 380px 1fr;
  flex: 1;
  background: var(--bg);
  min-height: 0;
}
.master-detail__master {
  background: var(--bg);
  overflow: auto;
  border-right: 1px solid var(--border);
}
.master-detail__detail {
  background: var(--surface);
  overflow: auto;
}

/* --- Checkbox / radio --- */
.cbox {
  appearance: none;
  width: 16px;
  height: 16px;
  border: 1px solid var(--border-strong);
  border-radius: 2px;
  background: var(--surface);
  display: inline-block;
  position: relative;
  cursor: pointer;
  vertical-align: middle;
}
.cbox:checked {
  background: var(--primary);
  border-color: var(--primary);
}
.cbox:checked::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 1px;
  width: 5px;
  height: 9px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.radio {
  appearance: none;
  width: 16px;
  height: 16px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface);
  display: inline-block;
  position: relative;
  cursor: pointer;
  vertical-align: middle;
}
.radio:checked {
  border-color: var(--primary);
  border-width: 4px;
}

/* Accent on selected row */
.row-accent::before {
  content: "";
  display: inline-block;
  width: 3px;
  height: 16px;
  background: var(--bar-orange);
  margin-right: 8px;
  vertical-align: middle;
}
