/* PulseBot v21.8.9 — shared module rhythm for Tickets, Automated Messages and Statistics.
   Visual-only layer. Mirrors the established Automod module structure. */

body#pulsebot-app:is(.dashboard-active-tickets,.dashboard-active-messages,.dashboard-active-statistics,.dashboard-active-templates) {
  --pbc-blue: #3b82f6;
  --pbc-blue-hover: #4c8df7;
  --pbc-blue-pressed: #2f6fd7;
  --pbc-blue-soft: rgba(59,130,246,.075);
  --pbc-blue-line: rgba(59,130,246,.28);
  --pbc-line: rgba(255,255,255,.075);
  --pbc-line-strong: rgba(255,255,255,.13);
  --pbc-surface: rgba(15,19,25,.78);
  --pbc-surface-head: rgba(255,255,255,.018);
  --pbc-text: #edf1f7;
  --pbc-text-2: #c8ced8;
  --pbc-muted: #8c96a4;
  --pbc-soft: #667180;
}

/* Match the Automod page header and status placement. */
body#pulsebot-app:is(.dashboard-active-tickets,.dashboard-active-messages,.dashboard-active-statistics,.dashboard-active-templates) .module-headline {
  min-height: 96px !important;
  margin: 0 0 20px !important;
  padding: 18px 4px 22px !important;
}

body#pulsebot-app:is(.dashboard-active-tickets,.dashboard-active-messages,.dashboard-active-statistics,.dashboard-active-templates) .module-heading-copy {
  gap: 15px !important;
}

body#pulsebot-app:is(.dashboard-active-tickets,.dashboard-active-messages,.dashboard-active-statistics,.dashboard-active-templates) .module-heading-icon {
  width: 44px !important;
  height: 44px !important;
  min-width: 44px !important;
  border-color: var(--pbc-blue-line) !important;
  border-radius: 11px !important;
  background: rgba(59,130,246,.07) !important;
  color: #a9c9ff !important;
}

body#pulsebot-app:is(.dashboard-active-tickets,.dashboard-active-messages,.dashboard-active-statistics,.dashboard-active-templates) .module-headline h2 {
  font-size: 1.3rem !important;
}

body#pulsebot-app:is(.dashboard-active-tickets,.dashboard-active-messages,.dashboard-active-statistics,.dashboard-active-templates) .module-headline p {
  max-width: 720px !important;
  font-size: .82rem !important;
  line-height: 1.55 !important;
}

body#pulsebot-app:is(.dashboard-active-tickets,.dashboard-active-messages,.dashboard-active-statistics,.dashboard-active-templates) .module-status {
  flex: 0 0 auto !important;
  min-height: 30px !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 0 !important;
  padding: 0 10px !important;
  border: 1px solid var(--pbc-line) !important;
  border-radius: 999px !important;
  background: rgba(255,255,255,.025) !important;
  color: var(--pbc-muted) !important;
  font-size: .7rem !important;
  font-weight: 600 !important;
}

body#pulsebot-app:is(.dashboard-active-tickets,.dashboard-active-messages,.dashboard-active-statistics,.dashboard-active-templates) .module-status::before {
  content: none !important;
  display: none !important;
}

body#pulsebot-app:is(.dashboard-active-tickets,.dashboard-active-messages,.dashboard-active-statistics,.dashboard-active-templates) .module-status.on {
  border-color: var(--pbc-blue-line) !important;
  background: var(--pbc-blue-soft) !important;
  color: #a9c9ff !important;
}

/* Same stacked card rhythm as Automod. */
body#pulsebot-app:is(.dashboard-active-tickets,.dashboard-active-messages,.dashboard-active-statistics,.dashboard-active-templates) .module-form {
  width: 100% !important;
  min-width: 0 !important;
  display: grid !important;
  gap: 18px !important;
  padding-bottom: 104px !important;
}

body#pulsebot-app:is(.dashboard-active-tickets,.dashboard-active-messages,.dashboard-active-statistics,.dashboard-active-templates) .module-form > .form-section,
body#pulsebot-app:is(.dashboard-active-tickets,.dashboard-active-messages,.dashboard-active-statistics,.dashboard-active-templates) .module-form > .module-panel-special {
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  border: 1px solid var(--pbc-line) !important;
  border-radius: 14px !important;
  background: var(--pbc-surface) !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
}

body#pulsebot-app:is(.dashboard-active-tickets,.dashboard-active-messages,.dashboard-active-statistics,.dashboard-active-templates) .module-form > .module-panel-special {
  padding: 16px 18px !important;
  border-left: 2px solid var(--pbc-blue) !important;
  border-radius: 0 12px 12px 0 !important;
  background: rgba(59,130,246,.04) !important;
}

body#pulsebot-app:is(.dashboard-active-tickets,.dashboard-active-messages,.dashboard-active-statistics,.dashboard-active-templates) .form-section-head {
  min-width: 0 !important;
  display: block !important;
  margin: 0 !important;
  padding: 17px 19px !important;
  border: 0 !important;
  border-bottom: 1px solid var(--pbc-line) !important;
  background: var(--pbc-surface-head) !important;
}

body#pulsebot-app:is(.dashboard-active-tickets,.dashboard-active-messages,.dashboard-active-statistics,.dashboard-active-templates) .form-section-head.messages-section-head {
  display: grid !important;
  grid-template-columns: minmax(0,1fr) auto !important;
  align-items: center !important;
  gap: 22px !important;
}

body#pulsebot-app:is(.dashboard-active-tickets,.dashboard-active-messages,.dashboard-active-statistics,.dashboard-active-templates) .form-section-head h3 {
  margin: 0 !important;
  color: var(--pbc-text) !important;
  font-size: .9rem !important;
  font-weight: 600 !important;
  line-height: 1.3 !important;
  letter-spacing: -.012em !important;
}

body#pulsebot-app:is(.dashboard-active-tickets,.dashboard-active-messages,.dashboard-active-statistics,.dashboard-active-templates) .form-section-head p {
  max-width: 760px !important;
  margin: 5px 0 0 !important;
  color: var(--pbc-muted) !important;
  font-size: .75rem !important;
  line-height: 1.5 !important;
}

body#pulsebot-app:is(.dashboard-active-tickets,.dashboard-active-messages,.dashboard-active-statistics,.dashboard-active-templates) .form-section-body {
  min-width: 0 !important;
  padding: 20px !important;
  background: transparent !important;
}

body#pulsebot-app:is(.dashboard-active-tickets,.dashboard-active-messages,.dashboard-active-statistics,.dashboard-active-templates) .field {
  min-width: 0 !important;
  gap: 8px !important;
  margin: 0 0 18px !important;
}

body#pulsebot-app:is(.dashboard-active-tickets,.dashboard-active-messages,.dashboard-active-statistics,.dashboard-active-templates) .field:last-child {
  margin-bottom: 0 !important;
}

body#pulsebot-app:is(.dashboard-active-tickets,.dashboard-active-messages,.dashboard-active-statistics,.dashboard-active-templates) .module-grid {
  min-width: 0 !important;
  gap: 20px 24px !important;
}

body#pulsebot-app:is(.dashboard-active-tickets,.dashboard-active-messages,.dashboard-active-statistics,.dashboard-active-templates) .check-grid {
  gap: 9px !important;
}

body#pulsebot-app:is(.dashboard-active-tickets,.dashboard-active-messages,.dashboard-active-statistics,.dashboard-active-templates) .action-row {
  gap: 12px !important;
  margin: 22px 0 2px !important;
}

/* One save button implementation, identical to the established core modules. */
body#pulsebot-app:is(.dashboard-active-tickets,.dashboard-active-messages,.dashboard-active-statistics,.dashboard-active-templates) .module-form > .module-savebar {
  position: fixed !important;
  inset: auto 22px 22px auto !important;
  z-index: 980 !important;
  width: auto !important;
  min-width: 0 !important;
  min-height: 0 !important;
  display: block !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  backdrop-filter: none !important;
  box-shadow: none !important;
}

body#pulsebot-app:is(.dashboard-active-tickets,.dashboard-active-messages,.dashboard-active-statistics,.dashboard-active-templates) .module-form > .module-savebar > .notice {
  display: none !important;
}

body#pulsebot-app:is(.dashboard-active-tickets,.dashboard-active-messages,.dashboard-active-statistics,.dashboard-active-templates) .module-save-button {
  min-width: 196px !important;
  min-height: 46px !important;
  padding: 0 20px !important;
  border: 1px solid rgba(134,180,255,.32) !important;
  border-radius: 9px !important;
  background: #3478e5 !important;
  background-image: none !important;
  color: #fff !important;
  font-size: .86rem !important;
  font-weight: 600 !important;
  letter-spacing: -.005em !important;
  box-shadow: 0 12px 28px rgba(0,0,0,.30) !important;
  transform: none !important;
}

body#pulsebot-app:is(.dashboard-active-tickets,.dashboard-active-messages,.dashboard-active-statistics,.dashboard-active-templates) .module-save-button::before,
body#pulsebot-app:is(.dashboard-active-tickets,.dashboard-active-messages,.dashboard-active-statistics,.dashboard-active-templates) .module-save-button::after {
  content: none !important;
  display: none !important;
}

body#pulsebot-app:is(.dashboard-active-tickets,.dashboard-active-messages,.dashboard-active-statistics,.dashboard-active-templates) .module-save-button:hover:not(:disabled),
body#pulsebot-app:is(.dashboard-active-tickets,.dashboard-active-messages,.dashboard-active-statistics,.dashboard-active-templates) .module-save-button:focus-visible:not(:disabled) {
  border-color: rgba(164,199,255,.44) !important;
  background: #3d82ef !important;
  background-image: none !important;
  box-shadow: 0 12px 28px rgba(0,0,0,.30) !important;
  transform: none !important;
}

body#pulsebot-app:is(.dashboard-active-tickets,.dashboard-active-messages,.dashboard-active-statistics,.dashboard-active-templates) .module-save-button:active:not(:disabled) {
  background: #2e69c9 !important;
}

/* Ticket panels: prevent horizontal shifting/clipping and keep all content inside the module column. */
body#pulsebot-app.dashboard-active-tickets .ticket-panels-section,
body#pulsebot-app.dashboard-active-tickets .ticket-questions-section,
body#pulsebot-app.dashboard-active-tickets .premium-locked-section,
body#pulsebot-app.dashboard-active-tickets .ticket-panel-list,
body#pulsebot-app.dashboard-active-tickets .message-list,
body#pulsebot-app.dashboard-active-tickets .premium-workflow-grid {
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  transform: none !important;
}

body#pulsebot-app.dashboard-active-tickets .ticket-panels-section,
body#pulsebot-app.dashboard-active-tickets .ticket-questions-section,
body#pulsebot-app.dashboard-active-tickets .premium-locked-section {
  overflow: hidden !important;
}

body#pulsebot-app.dashboard-active-tickets .ticket-panel-card,
body#pulsebot-app.dashboard-active-tickets .ticket-question-card,
body#pulsebot-app.dashboard-active-tickets .message-list > article {
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  min-height: 72px !important;
  display: grid !important;
  grid-template-columns: minmax(0,1fr) auto !important;
  align-items: center !important;
  gap: 18px !important;
  padding: 15px 0 !important;
  overflow: hidden !important;
  border: 0 !important;
  border-bottom: 1px solid var(--pbc-line) !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

body#pulsebot-app.dashboard-active-tickets .ticket-panel-card-copy,
body#pulsebot-app.dashboard-active-tickets .ticket-panel-card-text,
body#pulsebot-app.dashboard-active-tickets .ticket-question-card > div:first-child {
  min-width: 0 !important;
  max-width: 100% !important;
}

body#pulsebot-app.dashboard-active-tickets .ticket-panel-card-text strong,
body#pulsebot-app.dashboard-active-tickets .ticket-panel-card-text small {
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

body#pulsebot-app.dashboard-active-tickets .ticket-panel-card-actions,
body#pulsebot-app.dashboard-active-tickets .message-rule-actions {
  flex: 0 0 auto !important;
  display: flex !important;
  align-items: center !important;
  gap: 9px !important;
}

body#pulsebot-app.dashboard-active-tickets .ticket-panel-card-main > .btn {
  flex: 0 0 auto !important;
  white-space: nowrap !important;
}

body#pulsebot-app.dashboard-active-tickets .empty-state {
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  margin: 14px 0 0 !important;
  padding: 16px !important;
  overflow-wrap: anywhere !important;
}

body#pulsebot-app.dashboard-active-tickets .counter-pill {
  flex: 0 0 auto !important;
}

/* Messages and statistics use the same inner card rhythm. */
body#pulsebot-app.dashboard-active-messages .messages-section,
body#pulsebot-app.dashboard-active-statistics .statistics-rule,
body#pulsebot-app.dashboard-active-statistics .statistics-control,
body#pulsebot-app.dashboard-active-statistics .notice-card {
  min-width: 0 !important;
  max-width: 100% !important;
}

body#pulsebot-app.dashboard-active-messages .message-rule-list {
  margin-top: 4px !important;
}

body#pulsebot-app.dashboard-active-messages .message-rule-card {
  min-height: 72px !important;
  padding: 15px 0 !important;
}

body#pulsebot-app.dashboard-active-statistics .statistics-control {
  min-height: 78px !important;
  padding: 15px 0 !important;
}

body#pulsebot-app.dashboard-active-statistics .statistics-rules {
  display: grid !important;
  gap: 8px !important;
  margin-top: 0 !important;
}

body#pulsebot-app.dashboard-active-statistics .statistics-rule {
  overflow: hidden !important;
  border: 1px solid var(--pbc-line) !important;
  border-radius: 9px !important;
  background: rgba(255,255,255,.014) !important;
}

body#pulsebot-app.dashboard-active-statistics .statistics-rule[open] {
  border-color: var(--pbc-blue-line) !important;
  background: rgba(59,130,246,.025) !important;
}

body#pulsebot-app.dashboard-active-statistics .statistics-rule > summary {
  min-height: 52px !important;
  padding: 10px 13px !important;
}

body#pulsebot-app.dashboard-active-statistics .statistics-rule .rule-options {
  padding: 18px 19px 20px !important;
  border: 0 !important;
  border-top: 1px solid var(--pbc-line) !important;
  background: rgba(0,0,0,.10) !important;
}

@media (max-width: 760px) {
  body#pulsebot-app:is(.dashboard-active-tickets,.dashboard-active-messages,.dashboard-active-statistics,.dashboard-active-templates) .module-headline {
    align-items: flex-start !important;
    flex-direction: column !important;
  }

  body#pulsebot-app:is(.dashboard-active-tickets,.dashboard-active-messages,.dashboard-active-statistics,.dashboard-active-templates) .form-section-head.messages-section-head {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }

  body#pulsebot-app:is(.dashboard-active-tickets,.dashboard-active-messages,.dashboard-active-statistics,.dashboard-active-templates) .form-section-head.messages-section-head > .btn {
    width: 100% !important;
  }

  body#pulsebot-app.dashboard-active-tickets .ticket-panel-card,
  body#pulsebot-app.dashboard-active-tickets .ticket-question-card,
  body#pulsebot-app.dashboard-active-tickets .message-list > article,
  body#pulsebot-app.dashboard-active-messages .message-rule-card {
    grid-template-columns: 1fr !important;
    align-items: stretch !important;
  }

  body#pulsebot-app.dashboard-active-tickets .ticket-panel-card-actions,
  body#pulsebot-app.dashboard-active-tickets .message-rule-actions,
  body#pulsebot-app.dashboard-active-messages .message-rule-actions {
    width: 100% !important;
  }

  body#pulsebot-app.dashboard-active-tickets .ticket-panel-card-actions .btn,
  body#pulsebot-app.dashboard-active-tickets .ticket-panel-card-main > .btn,
  body#pulsebot-app.dashboard-active-messages .message-rule-actions .btn {
    flex: 1 1 auto !important;
  }
}

@media (max-width: 680px) {
  body#pulsebot-app:is(.dashboard-active-tickets,.dashboard-active-messages,.dashboard-active-statistics,.dashboard-active-templates) .form-section-body {
    padding: 16px !important;
  }

  body#pulsebot-app:is(.dashboard-active-tickets,.dashboard-active-messages,.dashboard-active-statistics,.dashboard-active-templates) .module-form > .module-savebar {
    inset: auto 12px 12px 12px !important;
  }

  body#pulsebot-app:is(.dashboard-active-tickets,.dashboard-active-messages,.dashboard-active-statistics,.dashboard-active-templates) .module-save-button {
    width: 100% !important;
    min-width: 0 !important;
  }
}

/* Same opening sequence as Automod: module intro, status, configuration sections. */
body#pulsebot-app:is(.dashboard-active-tickets,.dashboard-active-messages,.dashboard-active-statistics,.dashboard-active-templates) .module-form > .module-panel-special {
  order: -2 !important;
}

body#pulsebot-app:is(.dashboard-active-tickets,.dashboard-active-messages,.dashboard-active-statistics,.dashboard-active-templates) .module-form > .form-section:first-of-type {
  order: -1 !important;
}

body#pulsebot-app:is(.dashboard-active-tickets,.dashboard-active-messages,.dashboard-active-statistics,.dashboard-active-templates) .module-panel-special h2 {
  margin: 0 0 5px !important;
  color: var(--pbc-text) !important;
  font-size: .98rem !important;
  font-weight: 600 !important;
  line-height: 1.3 !important;
  letter-spacing: -.015em !important;
}

body#pulsebot-app:is(.dashboard-active-tickets,.dashboard-active-messages,.dashboard-active-statistics,.dashboard-active-templates) .module-panel-special p {
  max-width: 760px !important;
  margin: 0 !important;
  color: var(--pbc-muted) !important;
  font-size: .8rem !important;
  line-height: 1.55 !important;
}
