/* MELAPORA V354 — cross-feature display repair.
   Presentation only. No API/auth/payment/subscription/data changes.
   The application's selected theme is stored in data-melapora-theme,
   NOT data-theme. All overrides intentionally scope to the true theme. */

/* Consistent contrast for controls and feature help. */
html[data-melapora-theme="dark"] #app :is(.mel-tool-help details,.mel-tool-help details[open],.mel-tool-help summary),
html[data-melapora-theme="dark"] #app .mel-tool-help details > p {
  background:#1d2d46 !important;
  color:#edf4ff !important;
  border-color:#405777 !important;
}
html[data-melapora-theme="dark"] #app .mel-tool-help details p,
html[data-melapora-theme="dark"] #app .mel-tool-help details strong,
html[data-melapora-theme="dark"] #app .mel-tool-help details summary {
  color:#edf4ff !important;
}
html[data-melapora-theme="dark"] #app .mel-tool-help details > p {
  padding:12px 15px;
  margin:0;
  font-size:13px;
  line-height:1.6;
  border-radius:0 0 9px 9px;
}
html[data-melapora-theme="dark"] #app .mel-tool-help details summary {
  border-radius:8px;
}

/* Business documents: old 21st-tool widgets had hardcoded white cards
   and dark-mode text was almost white on white. */
html[data-melapora-theme="dark"] #md21Panel .md21-metric,
html[data-melapora-theme="dark"] #md21Panel .md21-surface {
  background:#1d2d47 !important;
  background-image:none !important;
  color:#edf4ff !important;
  border:1px solid #435675 !important;
  box-shadow:0 2px 9px #0002 !important;
}
html[data-melapora-theme="dark"] #md21Panel .md21-metric strong,
html[data-melapora-theme="dark"] #md21Panel .md21-metric span,
html[data-melapora-theme="dark"] #md21Panel .md21-surface :is(h3,h4,label,b,strong) {
  color:#edf4ff !important;
}
html[data-melapora-theme="dark"] #md21Panel :is(.md21-metric span,.md21-surface .mini,.md21-surface small,.md21-label) {
  color:#c1d3ee !important;
}
html[data-melapora-theme="dark"] #md21Panel :is(.md21-file,.md21-file-row,.md21-entry,.md21-folder,.md21-folder-row,.md21-list-item) {
  background:#192940 !important;
  color:#f1f6ff !important;
  border-color:#3b5275 !important;
}
html[data-melapora-theme="dark"] #md21Panel :is(.md21-file,.md21-file-row,.md21-entry,.md21-folder,.md21-folder-row,.md21-list-item) :is(span,small,p) {
  color:#cfe0f7 !important;
}
html[data-melapora-theme="dark"] #md21Panel input[type="file"] {
  background:#1c2a41 !important;
  color:#f1f6ff !important;
}

/* Support tickets metrics: previously hardcoded #f8faff regardless of theme. */
html[data-melapora-theme="dark"] #melaporaSupport :is(.st-stat,.st-card,.st-history) {
  background:#1b2a43 !important;
  color:#edf3ff !important;
  border-color:#415674 !important;
}
html[data-melapora-theme="dark"] #melaporaSupport .st-stat strong { color:#e8f1ff !important; }
html[data-melapora-theme="dark"] #melaporaSupport :is(.st-stat span,.st-muted) { color:#c6d5ed !important; }
html[data-melapora-theme="dark"] #melaporaSupport .st-chip {
  background:#29416c !important;color:#d7e9ff !important;
}

/* Quotations: saved-catalogue picker was an almost white banner in dark mode. */
html[data-melapora-theme="dark"] #melaporaQuotes .mq-catalogue-picker {
  --panel-bg:#192b43;
  background:#1c2d46 !important;
  border:1px solid #425879 !important;
  color:#edf4ff !important;
}
html[data-melapora-theme="dark"] #melaporaQuotes .mq-catalogue-picker :is(label,p,small,span) {
  color:#d7e5f9 !important;
}
html[data-melapora-theme="dark"] #melaporaQuotes .mq-items :is(th,td) {
  border-color:#425778 !important;
}
html[data-melapora-theme="dark"] #melaporaQuotes .mq-card {
  background:#1a2a41 !important;
  color:#edf4ff !important;
  border-color:#425778 !important;
}

/* Internal chat: the legacy CSS uses data-theme, which is never set by the
   preference UI. Correct that mismatch without changing chat behavior. */
html[data-melapora-theme="dark"] #mt20DirectGroups .mt20-chat-sidebar,
html[data-melapora-theme="dark"] #mt20DirectGroups .mt20-room-topbar,
html[data-melapora-theme="dark"] #mt20DirectGroups .mt20-whatsapp-heading,
html[data-melapora-theme="dark"] #mt20DirectGroups .mt20-chat-compose,
html[data-melapora-theme="dark"] #mt20DirectGroups #mt20RoomSend,
html[data-melapora-theme="dark"] #mt20DirectGroups .mt20-app-rail {
  background:#1b2b43 !important;
  color:#eef5ff !important;
  border-color:#3b516d !important;
}
html[data-melapora-theme="dark"] #mt20DirectGroups .mt20-room-history,
html[data-melapora-theme="dark"] #mt20DirectGroups .mt20-room-content {
  background:#15243a !important;
  color:#eef5ff !important;
}
html[data-melapora-theme="dark"] #mt20DirectGroups .mt20-room-msg {
  background:#263a53 !important;
  color:#eef5ff !important;
  border-color:#445d7c !important;
}
html[data-melapora-theme="dark"] #mt20DirectGroups .mt20-room-msg.mine {
  background:#214b80 !important;
  color:#f5f9ff !important;
}
html[data-melapora-theme="dark"] #mt20DirectGroups .mt20-room-msg :is(small,span,time) {
  color:#cadcf2 !important;
}
html[data-melapora-theme="dark"] #mt20DirectGroups .mt20-room-choice,
html[data-melapora-theme="dark"] #mt20DirectGroups .mt20-chat-list-item > .mt20-room-choice {
  color:#f0f5ff !important;
}
html[data-melapora-theme="dark"] #mt20DirectGroups .mt20-room-choice.active,
html[data-melapora-theme="dark"] #mt20DirectGroups .mt20-chat-list-item > .mt20-room-choice.active {
  background:#283f63 !important;
}
html[data-melapora-theme="dark"] #mt20DirectGroups .mt20-room-choice:hover,
html[data-melapora-theme="dark"] #mt20DirectGroups .mt20-chat-list-item > .mt20-room-choice:hover {
  background:#314b70 !important;
}
html[data-melapora-theme="dark"] #mt20DirectGroups .mt20-chat-sidebar :is(h3,h4,strong,b,small,label,p,span),
html[data-melapora-theme="dark"] #mt20DirectGroups .mt20-room-topbar :is(h3,h4,strong,b,small,label,p,span) {
  color:#e7f0ff !important;
}
html[data-melapora-theme="dark"] #mt20DirectGroups .mt20-room-meta small,
html[data-melapora-theme="dark"] #mt20DirectGroups .mt20-chat-sidebar .mt20-room-preview {
  color:#adc2e1 !important;
}
html[data-melapora-theme="dark"] #mt20DirectGroups .mt20-chat-sidebar input[type="search"] {
  background:#233750 !important;
  color:#f6f9ff !important;
  border-color:#4b6083 !important;
}
html[data-melapora-theme="dark"] #mt20DirectGroups input::placeholder {
  color:#aabedb !important;
}

/* Consistent, legible text in the two main feature shells. */
#app :is(.campaign-panel,.mel-tool-help) :is(label,summary) { line-height:1.45; }
#app :is(.campaign-panel,.mel-tool-help) .mini { line-height:1.55; }
@media (max-width:800px){
  #md21Panel .md21-overview{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  #md21Panel .md21-grid{grid-template-columns:1fr!important}
  #melaporaSupport .st-stats{grid-template-columns:repeat(2,minmax(0,1fr))!important}
}
@media (max-width:440px){
  #md21Panel .md21-overview{grid-template-columns:1fr!important}
}
@media print {
  /* Do not recolor generated/printed GST, invoice, or quotation documents. */
  html[data-melapora-theme="dark"] :is(#melaporaQuotes,#melaporaSupport,#md21Panel) {
    color:initial;
  }
}
/* Chat labels with hardcoded light theme tokens from V253–V296. */
html[data-melapora-theme="dark"] #mt20DirectGroups #mt20RoomHeading,
html[data-melapora-theme="dark"] #mt20DirectGroups .mt20-room-heading,
html[data-melapora-theme="dark"] #mt20DirectGroups .mt20-header-meta small,
html[data-melapora-theme="dark"] #mt20DirectGroups #mt20RoomStatus {
  color:#eaf3ff !important;
}
html[data-melapora-theme="dark"] #mt20DirectGroups #mt20RoomSearch,
html[data-melapora-theme="dark"] #mt20DirectGroups #mt20CommunitySearch,
html[data-melapora-theme="dark"] #mt20DirectGroups #mt20RoomMessage {
  background:#233751 !important;
  border:1px solid #51698a !important;
  color:#f4f8ff !important;
}
html[data-melapora-theme="dark"] #mt20DirectGroups #mt20RoomStatus {
  background:#1b2b43 !important;
  border-color:#3b516d !important;
}
html[data-melapora-theme="dark"] #mt20DirectGroups .mt20-chat-filters .mt20-filter {
  background:#273b56 !important;
  color:#dceafd !important;
  border-color:#496280 !important;
}
html[data-melapora-theme="dark"] #mt20DirectGroups .mt20-chat-filters .mt20-filter.active {
  background:#245fba !important;
  color:#fff !important;
}
