/* Global page-level composition updates */

main.page {
  padding-top: 16px;
}

[data-admin-sms-root],
[data-client-detail-root],
[data-notes-reminders-root],
[data-ticket-detail-root] {
  display: contents;
}

main.page > .ui-card:first-of-type,
main.page > a.ui-card:first-of-type {
  position: relative;
  overflow: hidden;
}

main.page > .ui-card:first-of-type::before,
main.page > a.ui-card:first-of-type::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(126deg, rgba(0, 28, 56, 0.06) 15%, rgba(0, 108, 146, 0.04) 100%);
  pointer-events: none;
}

[data-theme="dark"] main.page > .ui-card:first-of-type::before,
[data-theme="dark"] main.page > a.ui-card:first-of-type::before {
  background: linear-gradient(126deg, rgba(255, 255, 255, 0.05) 12%, rgba(45, 45, 45, 0.04) 100%);
}

main.page > .ui-card:first-of-type > *,
main.page > a.ui-card:first-of-type > * {
  position: relative;
  z-index: 1;
}

.ui-card h3,
.ui-card h4,
.ui-title--page,
.ui-title--section,
.ui-title--subsection {
  letter-spacing: var(--ui-letter-spacing-heading);
}

@media (max-width: 700px) {
  main.page {
    padding-top: 14px;
  }
}

/* Dashboard module */
.dash-hero {
  padding: 14px;
  background:
    radial-gradient(900px 300px at 0% 0%, rgba(var(--ui-primary-rgb), .14), transparent 55%),
    radial-gradient(700px 280px at 100% 0%, rgba(18, 181, 166, .14), transparent 55%),
    var(--ui-color-surface);
  border: 1px solid var(--ui-color-border);
  border-radius: var(--ui-radius);
  margin-bottom: 14px;
  box-shadow: var(--ui-shadow-surface), inset 0 1px 0 var(--ui-color-edge-highlight);
}

.dash-hero h3 {
  margin-bottom: 4px;
}

.dash-hero .ui-help {
  max-width: 980px;
}

.dash-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 12px;
  align-items: start;
}

.dash-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.stat {
  border: 1px solid var(--ui-color-border);
  background: var(--ui-color-surface);
  border-radius: var(--ui-radius-sm);
  padding: 10px 12px;
  box-shadow: var(--ui-shadow-control), inset 0 1px 0 var(--ui-color-edge-highlight);
  transition: border-color .2s ease, background .2s ease, box-shadow .2s ease, transform .2s ease;
}

.stat-link {
  display: block;
  color: inherit;
  text-decoration: none;
}

.stat-link:hover {
  border-color: rgba(var(--ui-primary-rgb), .45);
  background: var(--ui-color-surface-raised);
  box-shadow: var(--ui-shadow-raised), inset 0 1px 0 var(--ui-color-edge-highlight);
  transform: translateY(-2px);
}

.stat .k {
  font-size: var(--ui-font-size-caption);
  color: var(--ui-color-text-muted);
}

.stat .v {
  font-family: var(--ui-font-heading);
  font-weight: var(--ui-font-weight-bold);
  font-size: var(--ui-font-size-display);
  line-height: var(--ui-line-height-tight);
  margin-top: 3px;
}

.stat .hint {
  margin-top: 5px;
  font-size: var(--ui-font-size-caption);
  color: var(--ui-color-text-muted);
}


.meta {
  margin-top: 5px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--ui-color-text-muted);
  font-size: var(--ui-font-size-caption);
}

.meta span {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.dot-sm {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--ui-color-text-muted);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.section-head h2,
.section-head h3 {
  margin: 0;
}

.section-head a {
  width: auto;
  font-size: var(--ui-font-size-caption);
  color: var(--ui-color-text-muted);
  border: 1px solid var(--ui-color-border);
  background: var(--ui-color-surface);
  padding: 5px 9px;
  border-radius: 999px;
  box-shadow: var(--ui-shadow-control);
}

.section-head a:hover {
  color: var(--ui-color-text);
  border-color: rgba(var(--ui-primary-rgb), .45);
  background: var(--ui-color-surface-raised);
  box-shadow: var(--ui-shadow-raised);
}

@media (prefers-reduced-motion: reduce) {
  .stat-link,
  .stat-link:hover,
}

.wa-performance-list {
  display: flex;
  flex-direction: column;
  gap: var(--ui-space-2);
}

.wa-performance-row {
  display: grid;
  grid-template-columns: 34px minmax(140px, 190px) minmax(160px, 1fr) minmax(68px, auto);
  gap: var(--ui-space-4);
  align-items: center;
  min-height: 54px;
  padding: var(--ui-space-3) var(--ui-space-4);
  border: 1px solid transparent;
  border-radius: var(--ui-radius-control);
  background: var(--ui-color-surface-muted);
}

.wa-performance-row--top {
  border-color: rgba(var(--ui-primary-rgb), .12);
  background: linear-gradient(90deg, rgba(var(--ui-primary-rgb), .055), var(--ui-color-surface-muted) 28%);
}

.wa-performance-rank {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--ui-color-border);
  border-radius: 999px;
  background: var(--ui-color-surface-raised);
  color: var(--ui-color-text-muted-strong);
  font-size: var(--ui-font-size-secondary);
  font-weight: var(--ui-font-weight-bold);
  box-shadow: var(--ui-shadow-control);
}

.wa-performance-row--top .wa-performance-rank {
  border-color: rgba(var(--ui-primary-rgb), .28);
  background: rgba(var(--ui-primary-rgb), .10);
  color: var(--ui-color-primary);
}

.wa-performance-name {
  color: var(--ui-color-text);
  font-size: var(--ui-font-size-body);
  font-weight: var(--ui-font-weight-bold);
  line-height: var(--ui-line-height-snug);
}

.wa-performance-role {
  margin-top: var(--ui-space-1);
  color: var(--ui-color-text-muted);
  font-size: var(--ui-font-size-caption);
  font-weight: var(--ui-font-weight-semibold);
  line-height: var(--ui-line-height-tight);
  letter-spacing: var(--ui-letter-spacing-caps);
  text-transform: uppercase;
}

.wa-performance-bar-wrap {
  min-width: 0;
}

.wa-performance-bar {
  display: block;
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  height: 10px;
  border-radius: 999px;
  background: var(--ui-color-surface-sunken);
  border: 1px solid var(--ui-color-border);
  overflow: hidden;
  box-shadow: var(--ui-shadow-inset);
}

.wa-performance-bar::-webkit-progress-bar {
  border-radius: 999px;
  background: var(--ui-color-surface-sunken);
}

.wa-performance-bar::-webkit-progress-value,
.wa-performance-bar::-moz-progress-bar {
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(var(--ui-primary-rgb), .48), var(--ui-color-primary));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .24);
}

[data-theme="dark"] .wa-performance-bar {
  background: var(--ui-color-surface-sunken);
  border-color: var(--ui-color-border);
}

.wa-performance-count {
  text-align: right;
  white-space: nowrap;
}

.wa-performance-count b {
  color: var(--ui-color-text);
  font-size: var(--ui-font-size-subsection);
  font-variant-numeric: tabular-nums;
}

.wa-performance-count span,
.wa-performance-total {
  color: var(--ui-color-text-muted);
  font-size: var(--ui-font-size-caption);
}

.wa-performance-head {
  gap: var(--ui-space-5);
}

.wa-performance-summary {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--ui-space-3);
  flex-wrap: wrap;
}

.wa-performance-total b {
  color: var(--ui-color-text);
  font-size: var(--ui-font-size-body);
  font-variant-numeric: tabular-nums;
}

.dashboard-card-spaced {
  margin-bottom: 18px;
}

.dashboard-health-summary {
  margin-bottom: 10px;
}

@media (max-width: 980px) {
  .wa-performance-row {
    grid-template-columns: 34px minmax(0, 1fr) auto;
    gap: var(--ui-space-3);
  }

  .wa-performance-bar-wrap {
    grid-column: 2 / -1;
  }
}

@media (max-width: 700px) {
  .wa-performance-head {
    align-items: flex-start;
  }

  .wa-performance-summary {
    width: 100%;
    justify-content: flex-start;
  }

  .wa-performance-row {
    padding-inline: var(--ui-space-3);
  }
}

.legal-copy {
  max-width: var(--ui-legal-width);
  font-size: var(--ui-font-size-body);
  line-height: var(--ui-line-height-relaxed);
}

.notification-panel-card,
.notifications-page-card {
  position: relative;
  overflow: visible;
}

.notification-panel-card {
  background: var(--ui-color-surface);
  border: 1px solid var(--ui-color-border);
  border-radius: var(--ui-radius);
  padding: 12px;
  box-shadow: var(--ui-shadow-surface);
}

.notification-popover .notification-panel-card {
  max-height: min(680px, calc(100vh - 96px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.notification-popover .notification-panel-head {
  flex: 0 0 auto;
}

.notification-popover .notification-items {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
}

.notification-panel-head,
.notification-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.notification-panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.notification-items {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.notification-item {
  border: 1px solid var(--ui-color-border);
  border-radius: 12px;
  background: var(--ui-color-surface);
  padding: 10px 12px;
}

.notification-item.is-unread {
  border-color: rgba(var(--ui-primary-rgb), .36);
  background: rgba(var(--ui-primary-rgb), .05);
}

.notification-link {
  display: block;
  color: inherit;
  text-decoration: none;
}

.notification-link:hover .notification-item-title {
  text-decoration: underline;
}

.notification-item-title {
  font-family: var(--ui-font-heading);
  font-weight: var(--ui-font-weight-bold);
}

.notification-item-body {
  margin-top: 4px;
  color: var(--ui-color-text);
  overflow-wrap: anywhere;
}

.notification-item-meta {
  margin-top: 6px;
  font-size: var(--ui-font-size-caption);
}

.notification-read-form {
  margin-top: 8px;
}

.notification-item-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.notification-reminder-details {
  margin: 0;
}

.notification-reminder-details summary {
  list-style: none;
  cursor: pointer;
}

.notification-reminder-details summary::-webkit-details-marker,
.notification-reminder-details summary::marker {
  display: none;
  content: "";
}

.notification-reminder-form {
  display: flex;
  align-items: end;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
  padding: 10px 12px;
  border: 1px solid var(--ui-color-border);
  border-radius: 10px;
  background: var(--ui-color-surface-raised);
}

@media (max-width: 700px) {
  /* Avoid nested scroll containers on mobile; let the page scroll naturally. */
  .ticket-detail-page {
    overflow: auto;
  }

  .ticket-detail-page .page {
    height: auto;
    overflow: visible;
    padding-bottom: 0;
  }

  .ticket-detail-page .ticket-detail-shell {
    height: auto;
  }

  .ticket-detail-page .ticket-detail-shell .ui-sidebar-layout {
    height: auto;
  }

  .ticket-detail-page .ticket-detail-shell .ui-sidebar-layout__main,
  .ticket-detail-page .ticket-detail-shell .ui-sidebar-layout__aside {
    height: auto;
    overflow: visible;
  }

  .ticket-detail-page .ticket-settings-card,
  .ticket-detail-page .ticket-detail-card {
    height: auto;
  }

  .ticket-detail-page .ticket-timeline {
    overflow: visible;
    padding-right: 0;
  }

  .ticket-detail-page .ticket-timeline .comment-message {
    max-width: 100%;
  }

  .ticket-detail-page iframe.email-frame {
    height: 78vh;
    min-height: 520px;
  }
}
