/* Task4Today layout consistency, sticky table headers, compact sidebars */
:root {
  --sidebar-default-w: 226px;
  --sidebar-w: var(--sidebar-default-w);
  --chat-sidebar-w: 232px;
  --page-inline-space: clamp(14px, 1.45vw, 24px);
  --page-block-space: 16px;
  --section-gap: 16px;
  --control-gap: 8px;
  --sticky-header-bg: var(--bg-surface, #fff);
}

/* More workspace without losing the draggable sidebar. */
.sidebar {
  width: var(--sidebar-w) !important;
  min-width: var(--sidebar-w) !important;
}
.sidebar-resize-handle {
  right: -4px !important;
  width: 8px !important;
}
.chat-sidebar {
  width: var(--chat-sidebar-w) !important;
  min-width: var(--chat-sidebar-w) !important;
}

/* Shared page alignment. */
.global-topbar,
.project-header,
.toolbar-row,
.browse-page-header,
.notification-page-wrap > header,
.report-bug-page > header {
  padding-left: var(--page-inline-space) !important;
  padding-right: var(--page-inline-space) !important;
}

.toolbar-row,
.project-header-actions,
.global-actions,
.tm-header-right,
.browse-teams-toolbar,
.team-create-actions,
.add-member-modal-footer {
  gap: var(--control-gap) !important;
}

.home-dashboard,
.team-page,
.superadmin-page,
.report-bug-page,
.notification-page-wrap,
.profile-page,
.settings-page,
.browse-page-content {
  margin-left: auto;
  margin-right: auto;
}

.view-panel,
.canvas-area,
.team-page,
.superadmin-page,
.notification-page-list,
.report-bug-page,
.profile-page {
  scroll-padding-top: 44px;
}

/* Freeze column names in every current table/list surface. */
table thead th,
.import-mapping-grid thead th,
.import-preview-table thead th,
.report-table thead th,
.taw-table thead th {
  position: sticky !important;
  top: 0;
  z-index: 12;
  background: var(--sticky-header-bg) !important;
  box-shadow: inset 0 -1px 0 var(--border, #dfeef0);
}

.grid-header,
#gridHeader,
#completedGridHeader,
.mytasks-grid-header,
.team-members-head,
.browse-teams-table-head,
.superadmin-table-head {
  position: sticky !important;
  top: 0;
  z-index: 14;
  background: var(--sticky-header-bg) !important;
  box-shadow: 0 1px 0 var(--border, #dfeef0);
}

.team-members-table-wrap,
.report-table-scroll,
.import-mapping-scroll,
.import-preview-scroll,
.browse-teams-list,
.superadmin-org-table,
.grid-shell {
  isolation: isolate;
}

/* Invitation-time category access. */
.add-member-modal {
  width: min(640px, 94vw) !important;
}
.add-member-selected {
  max-height: min(56vh, 520px) !important;
}
.add-member-chip {
  align-items: stretch !important;
}
.invite-category-access,
.invite-category-admin-note {
  margin: 10px 0 0 42px;
  border: 1px solid var(--border, #dfeef0);
  border-radius: 10px;
  background: var(--bg-input, #f7fbfc);
}
.invite-category-access summary {
  min-height: 38px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  font-weight: 700;
  list-style: none;
}
.invite-category-access summary::-webkit-details-marker { display: none; }
.invite-category-access summary span { display: inline-flex; align-items: center; gap: 7px; }
.invite-category-access summary small { color: var(--text-muted); font-weight: 600; white-space: nowrap; }
.invite-category-access-body {
  max-height: 230px;
  overflow: auto;
  padding: 4px 8px 8px;
  border-top: 1px solid var(--border-light, #edf8f9);
}
.invite-category-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(118px, 150px);
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 5px 2px;
}
.invite-category-name {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.invite-category-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.invite-category-row select { width: 100%; min-width: 0; }
.invite-category-actions {
  padding: 8px 10px;
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  border-top: 1px solid var(--border-light, #edf8f9);
}
.invite-category-actions button {
  border: 1px solid var(--border, #dfeef0);
  background: var(--bg-surface, #fff);
  border-radius: 7px;
  padding: 5px 9px;
  cursor: pointer;
}
.invite-category-admin-note {
  padding: 9px 11px;
  color: var(--accent, #007380);
  font-weight: 650;
}
.invite-category-admin-note i { margin-right: 6px; }
.invite-category-empty { padding: 12px 4px; color: var(--text-muted); }

.selected-team-members {
  display: grid !important;
  gap: 8px !important;
}
.selected-member-invite-card {
  display: block !important;
  width: 100%;
  padding: 9px !important;
  border-radius: 12px !important;
}
.selected-member-invite-main {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: 8px;
}
.selected-member-invite-identity {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.selected-member-invite-identity strong,
.selected-member-invite-identity span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.selected-member-role { min-width: 112px; }
.invite-category-access.compact,
.invite-category-admin-note.compact { margin-left: 38px; }
.team-create-card { width: min(680px, calc(100vw - 28px)) !important; }
.team-create-card .selected-team-members { max-height: 330px; overflow: auto; padding-right: 3px; }

@media (min-width: 1680px) {
  :root { --sidebar-w: 224px; --chat-sidebar-w: 240px; }
}
@media (max-width: 1280px) {
  :root { --sidebar-w: 190px; --chat-sidebar-w: 218px; }
}
@media (max-width: 1100px) {
  :root { --sidebar-w: 170px; --chat-sidebar-w: 205px; }
}
@media (max-width: 1024px) {
  :root { --sidebar-w: 60px; --chat-sidebar-w: 210px; }
  .invite-category-access,
  .invite-category-admin-note,
  .invite-category-access.compact,
  .invite-category-admin-note.compact { margin-left: 0; }
}
@media (max-width: 680px) {
  .selected-member-invite-main { grid-template-columns: auto minmax(0, 1fr) auto; }
  .selected-member-role { grid-column: 2 / 4; width: 100%; }
  .selected-member-invite-main .invite-label { display: none; }
  .invite-category-row { grid-template-columns: 1fr; gap: 4px; }
}


/* v97 - DemandNXT logo-balanced sidebar and inline Team Chat typing status. */
@media (min-width: 921px) {
  :root {
    --sidebar-default-w: 226px;
    --sidebar-w: 226px;
  }
  body:not(.sidebar-collapsed) .sidebar {
    width: var(--sidebar-w) !important;
    min-width: var(--sidebar-default-w) !important;
    flex: 0 0 var(--sidebar-w) !important;
  }
}

/* 170px logo + 12px plate padding on both sides = 194px plate.
   16px outside on both sides gives the 226px non-shrinkable default. */
body:not(.sidebar-collapsed) .sidebar .brand {
  box-sizing: border-box !important;
  padding-left: 16px !important;
  padding-right: 16px !important;
}
body:not(.sidebar-collapsed) .sidebar .app-logo {
  box-sizing: border-box !important;
  width: 194px !important;
  min-width: 194px !important;
  max-width: 194px !important;
  padding-left: 12px !important;
  padding-right: 12px !important;
}

.chat-input-wrap {
  position: relative !important;
}
.chat-typing-indicator.chat-typing-indicator-inline {
  position: absolute !important;
  left: 2px !important;
  right: 2px !important;
  top: 4px !important;
  min-height: 22px !important;
  display: flex !important;
  align-items: center !important;
  gap: 7px !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  color: var(--chat-text-muted, var(--text-muted, #718096)) !important;
  font-size: 13px !important;
  font-style: normal !important;
  line-height: 1.45 !important;
  pointer-events: none !important;
  z-index: 3 !important;
}
.chat-typing-indicator.chat-typing-indicator-inline.hidden {
  display: none !important;
}
.chat-input-wrap.chat-remote-typing .chat-rich-composer .ql-editor.ql-blank::before {
  content: '' !important;
  display: none !important;
}
.chat-typing-indicator-inline .typing-dots {
  display: inline-flex !important;
  align-items: center !important;
  gap: 3px !important;
  flex: 0 0 auto !important;
}
.chat-typing-indicator-inline .typing-dots span {
  width: 4px !important;
  height: 4px !important;
  border-radius: 50% !important;
  background: currentColor !important;
}
.chat-typing-indicator-inline .chat-typing-name {
  min-width: 0 !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}


/* Typing state reliability: keep the inline name above the Quill editor and
   reserve the first line only while another member is typing. */
.chat-input-wrap.chat-remote-typing .chat-typing-indicator-inline {
  opacity: 1 !important;
  visibility: visible !important;
}
.chat-input-wrap.chat-remote-typing .chat-rich-composer,
.chat-input-wrap.chat-remote-typing .chat-rich-composer .ql-container,
.chat-input-wrap.chat-remote-typing .chat-rich-composer .ql-editor {
  position: relative !important;
}
.chat-input-wrap.chat-remote-typing .chat-rich-composer .ql-editor {
  min-height: 56px !important;
  padding-top: 30px !important;
}
.chat-input-wrap.chat-remote-typing .chat-typing-indicator-inline {
  top: 7px !important;
  left: 14px !important;
  right: 14px !important;
  z-index: 20 !important;
}


/* v100: the typing label lives inside the composer and remains visible even
   when the recipient already has draft text. */
.chat-input-wrap.chat-remote-typing {
  min-height: 56px !important;
}
.chat-input-wrap.chat-remote-typing .chat-rich-composer .ql-editor.ql-blank::before {
  display: none !important;
}

/* v100: Dashboard scroll ownership. The fixed application shell must remain
   locked, while the active Dashboard panel itself is the only vertical
   scroller. This avoids the nested canvas/view overflow rules that could make
   the mouse wheel and scrollbar appear unresponsive. */
body.app-nav-home .canvas-area,
body.app-view-dashboard .canvas-area {
  height: 100% !important;
  max-height: 100% !important;
  min-height: 0 !important;
  overflow: hidden !important;
}
body.app-nav-home #dashboardView.active,
body.app-view-dashboard #dashboardView.active {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  max-height: 100% !important;
  min-height: 0 !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  scrollbar-gutter: stable !important;
  overscroll-behavior: contain !important;
  -webkit-overflow-scrolling: touch !important;
  padding-bottom: 36px !important;
}
body.app-nav-home #dashboardView.active > .home-dashboard,
body.app-view-dashboard #dashboardView.active > .home-dashboard,
body.app-nav-home #dashboardView.active .home-dashboard,
body.app-view-dashboard #dashboardView.active .home-dashboard {
  width: 100% !important;
  height: auto !important;
  min-height: max-content !important;
  overflow: visible !important;
  box-sizing: border-box !important;
}
