/* HVL Assistant Application Shell, Layout, Lists, Settings, Sidebar & Responsive Styles */

:root {
  --asst-header-h: 56px;
  --asst-tabbar-h: 60px;
  --asst-max-w: 1180px;
  --asst-check-mask: var(--hvl-check-mask);
}

html,
body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  /* iPhone WebKit enlarges long runs of text on its own (a one-card "Waits on #N title" pill drew twice the size
     of "Waits on 2 cards"); text keeps the size the stylesheets give it */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html:has(.asst-viewport),
body:has(.asst-viewport) {
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
}

.asst-viewport {
  max-width: var(--asst-max-w);
  margin: 0 auto;
  height: 100%;
  height: 100dvh;
  box-sizing: border-box;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  transition: max-width 0.18s ease;
}

.asst-viewport.wide-mode,
.asst-viewport.wide-mode .asst-tabbar,
.asst-viewport:has(#tab-jarvis.active) {
  max-width: 100%;
  border-left: none;
  border-right: none;
}

.asst-navbar {
  min-height: var(--asst-header-h);
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: calc(8px + env(safe-area-inset-top, 0px)) calc(16px + env(safe-area-inset-right, 0px)) 8px
    calc(16px + env(safe-area-inset-left, 0px));
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-surface);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.asst-brand-title {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: var(--brand-primary);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

button.asst-brand-title {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.asst-navbar-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.asst-navbar .hvl-notif-bell-btn {
  width: var(--hvl-header-btn-height);
  height: var(--hvl-header-btn-height);
  box-sizing: border-box;
}

.asst-nav-btn,
.asst-secondary-btn.asst-nav-btn {
  height: var(--hvl-header-btn-height);
  box-sizing: border-box;
  padding: 0 10px;
  font-size: 0.78rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  text-decoration: none;
}

#app-update-pill,
.btn-update-pill {
  height: var(--hvl-header-btn-height) !important;
  box-sizing: border-box !important;
  padding: 0 10px !important;
  font-size: 0.75rem !important;
  display: inline-flex;
  align-items: center !important;
  gap: 5px;
  border-radius: var(--radius-sm) !important;
}

#app-update-pill[hidden],
.btn-update-pill[hidden] {
  display: none !important;
}

.asst-navbar-actions > .asst-scope-badge {
  height: var(--hvl-header-btn-height);
  padding: 0 10px;
  box-sizing: border-box;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
}
.asst-logout-btn,
.asst-secondary-btn.asst-logout-btn {
  color: var(--status-red);
  border-color: var(--status-red-border);
  background: var(--status-red-bg);
}

.asst-scope-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: var(--radius-badge);
  background: var(--brand-primary-bg);
  color: var(--brand-primary);
  border: 1px solid var(--brand-primary-border);
  text-decoration: none;
  white-space: nowrap;
}

.asst-scope-badge.parents {
  background: var(--status-red-bg);
  color: var(--status-red);
  border-color: var(--status-red-border);
}
.asst-scope-badge.private {
  background: var(--color-amber-bg);
  color: var(--color-amber);
  border-color: var(--color-amber-border);
}
.asst-scope-badge.ops {
  background: var(--status-gray-bg);
  color: var(--status-gray);
  border-color: var(--status-gray-border);
}

.asst-content {
  flex: 1;
  min-height: 0;
  padding: 14px 16px max(14px, env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.asst-content:has(#tab-jarvis.active) {
  padding: 0;
  background: var(--jarvis-bg-void);
}

.asst-main-column {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.asst-main-column:has(#tab-jarvis.active) {
  background: var(--jarvis-orb-stage-bg);
  background-color: var(--jarvis-bg-void);
}

.asst-main-column:has(#tab-chat.active) {
  overflow: hidden;
}
.asst-tab-pane {
  display: none;
}
.asst-tab-pane.active {
  display: block;
}
.asst-tab-pane:not(.active):has(dialog[open]),
.asst-tab-pane:not(.active)[data-modal-host="true"] {
  display: block;
  height: 0;
  overflow: hidden;
  visibility: hidden;
  pointer-events: none;
}
.asst-tab-pane:not(.active) dialog[open],
.asst-tab-pane:not(.active)[data-modal-host="true"] .modal-backdrop.open {
  visibility: visible;
  pointer-events: auto;
}

#tab-chat.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.asst-sidebar-divider {
  border-top: 1px solid var(--border-color);
  margin: 4px 0;
  width: 100%;
}

.asst-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--card-radius);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--card-shadow);
}

.asst-section-title {
  font-size: 1.02rem;
  font-weight: 700;
  margin: 0;
  color: var(--text-primary);
}

.asst-list-title {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text-primary);
}

.asst-list-item,
.asst-member-row,
.asst-unrecognized-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  margin-bottom: 6px;
}

.asst-list-item:last-child,
.asst-member-row:last-child {
  margin-bottom: 0;
}

.asst-list-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

input[type="checkbox"]:where(:not(.hvl-switch)),
.asst-checkbox {
  appearance: none;
  -webkit-appearance: none;
  display: inline-grid;
  place-content: center;
  width: 18px;
  height: 18px;
  margin: 0;
  border-radius: var(--radius-badge);
  border: 1.5px solid var(--border-bright);
  background: var(--bg-surface);
  cursor: pointer;
  flex-shrink: 0;
  transition:
    background-color 0.14s ease,
    border-color 0.14s ease,
    box-shadow 0.14s ease;
}

input[type="checkbox"]:where(:not(.hvl-switch))::before,
.asst-checkbox::before {
  content: "";
  width: 11px;
  height: 11px;
  background-color: var(--text-on-brand);
  mask: var(--asst-check-mask) no-repeat center / contain;
  -webkit-mask: var(--asst-check-mask) no-repeat center / contain;
  transform: scale(0);
  transition: transform 0.12s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

input[type="checkbox"]:where(:not(.hvl-switch)):checked,
.asst-checkbox:checked {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
}

input[type="checkbox"]:where(:not(.hvl-switch)):checked::before,
.asst-checkbox:checked::before {
  transform: scale(1);
}

input[type="checkbox"]:where(:not(.hvl-switch)):focus-visible,
.asst-checkbox:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--brand-primary-border);
}

input[type="checkbox"]:where(:not(.hvl-switch)):disabled,
.asst-checkbox:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.asst-check-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  font-size: 0.8rem;
  font-weight: 500;
  border-radius: var(--radius-badge);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
  transition:
    border-color 0.14s ease,
    background-color 0.14s ease;
}

.asst-check-chip:hover {
  border-color: var(--brand-primary);
}

.asst-check-chip:has(input:checked),
.onboarding-prompt-pill.is-selected {
  border-color: var(--brand-primary-border);
  background: var(--brand-primary-bg);
  color: var(--brand-primary);
}

.asst-check-chip:has(input:disabled) {
  opacity: 0.6;
  cursor: not-allowed;
}

.asst-check-chip:has(input:disabled):hover {
  border-color: var(--border-color);
}

.asst-item-text {
  font-size: 0.9rem;
  color: var(--text-primary);
  word-break: break-word;
}
.asst-item-text.completed {
  text-decoration: line-through;
  color: var(--text-muted);
}

.asst-select {
  width: auto;
  height: 38px;
  padding: 0 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  box-sizing: border-box;
}

.asst-select.form-select-sm {
  height: 32px;
  padding: 0 8px;
}

.asst-action-btn,
.asst-secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  gap: 6px;
}

.asst-action-btn {
  height: 38px;
  padding: 0 14px;
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--brand-primary);
  color: var(--text-on-brand);
  border: 1px solid var(--brand-primary);
}

.asst-action-btn:hover {
  background: var(--brand-primary-hover);
}

.asst-secondary-btn {
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 500;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.asst-secondary-btn:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.asst-delete-list-btn {
  border-color: var(--border-color);
  background: var(--bg-surface-elevated);
  color: var(--text-secondary);
}

.asst-action-btn.btn-sm,
.asst-secondary-btn.btn-sm {
  height: auto;
  padding: 6px 12px;
  font-size: 0.75rem;
  line-height: 1.2;
}

.asst-empty-state {
  padding: 18px 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Chat Sidebar & Thread List */
.asst-chat-layout {
  display: flex;
  gap: 16px;
  align-items: stretch;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.asst-chat-layout:has(#tab-jarvis.active) {
  gap: 0;
}

@media (min-width: 769px) {
  .asst-chat-layout:has(#tab-jarvis.active) > .asst-chat-sidebar {
    border-radius: 0;
    border-top: none;
    border-bottom: none;
    border-left: none;
  }
}
