/* PTW trend chart — matches Risk Assessment ex-dash-trend design */

.ptw-dashboard-trend-section {
  width: 100%;
  min-width: 0;
}

.ptw-trend-chart-embed.ex-dash {
  font-family: inherit;
  color: inherit;
  --ex-muted: #64748b;
  --ex-text: var(--swi-text, #0f172a);
  --ex-border: var(--swi-border, #e2e8f0);
  --ex-subtle: var(--swi-surface-muted, #f8fafc);
  --panel-ex: var(--portal-accent, #8b1538);
}

.ptw-trend-chart-embed .ex-dash-trend--role-admin .ex-dash-trend-key--assigned {
  background: #8b1538;
}

.ptw-trend-chart-embed .ex-dash-trend--role-admin .ex-dash-trend-key--completed {
  background: #189e52;
}

.ptw-trend-chart-embed .ex-dash-trend {
  background: linear-gradient(165deg, #ffffff 0%, #f8fafc 55%, #f1f5f9 100%);
  border: none;
  border-radius: 16px;
  padding: 14px 16px 12px;
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.04),
    0 12px 40px rgba(15, 23, 42, 0.07);
}

.ptw-trend-chart-embed .ex-dash-trend--empty,
.ptw-trend-chart-embed .ex-dash-trend--loading {
  min-height: 88px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 8px;
}

.ptw-trend-chart-embed .ex-dash-trend-empty-msg {
  margin: 0;
  padding: 1rem 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--ex-muted);
  text-align: center;
  max-width: 28rem;
  align-self: center;
}

.ptw-trend-chart-embed .ex-dash-trend-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.ptw-trend-chart-embed .ex-dash-trend-head-intro {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-width: 0;
  flex: 1 1 auto;
}

.ptw-trend-chart-embed .ex-dash-trend-title {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ex-text);
  line-height: 1.2;
}

.ptw-trend-chart-embed .ex-dash-trend-subtitle {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
  color: var(--ex-muted);
}

.ptw-trend-chart-embed .ex-dash-trend-head-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
}

.ptw-trend-chart-embed .ex-dash-trend-head--empty {
  margin-bottom: 12px;
}

.ptw-trend-chart-embed .ex-dash-trend-period {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  background: var(--ex-subtle);
  border: 1px solid var(--ex-border);
  border-radius: 10px;
}

.ptw-trend-chart-embed button.ex-dash-trend-period-btn {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 0.45rem 0.95rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ex-muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  box-shadow: none;
  min-height: unset;
  line-height: 1.2;
}

.ptw-trend-chart-embed button.ex-dash-trend-period-btn:hover:not(:disabled) {
  color: var(--ex-text);
  background: rgba(0, 0, 0, 0.04);
}

.ptw-trend-chart-embed button.ex-dash-trend-period-btn--active {
  background: #ffffff;
  color: var(--ex-text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.ptw-trend-chart-embed button.ex-dash-trend-period-btn:focus-visible {
  outline: 2px solid var(--panel-ex);
  outline-offset: 2px;
}

.ptw-trend-chart-embed button.ex-dash-trend-period-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.ptw-trend-chart-embed .ex-dash-trend-legend-inline {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ex-muted);
}

.ptw-trend-chart-embed .ex-dash-trend-key {
  display: inline-block;
  width: 10px;
  height: 3px;
  border-radius: 2px;
  margin-right: 6px;
  vertical-align: middle;
}

.ptw-trend-chart-embed .ex-dash-trend-key--assigned {
  background: #8b1538;
}

.ptw-trend-chart-embed .ex-dash-trend-key--completed {
  background: #189e52;
}

.ptw-trend-chart-embed .ex-dash-trend-chart-wrap {
  width: 100%;
  min-width: 0;
  min-height: 240px;
}

:root[data-theme="dark"] .ptw-trend-chart-embed .ex-dash-trend {
  background: linear-gradient(165deg, #1e2430 0%, #171c26 55%, #12161e 100%);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.2),
    0 12px 40px rgba(0, 0, 0, 0.35);
}

:root[data-theme="dark"] .ptw-trend-chart-embed button.ex-dash-trend-period-btn--active {
  background: var(--swi-surface, #252b38);
}

:root[data-theme="dark"] .ptw-trend-chart-embed button.ex-dash-trend-period-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.06);
}

.ptw-trend-chart-embed .ex-dash-trend-chart-wrap {
  min-height: 240px;
}

.ptw-trend-chart-embed--clickable .ex-dash-trend-chart-wrap--clickable {
  cursor: pointer;
  border-radius: 12px;
  transition: background 0.14s ease, box-shadow 0.14s ease;
}

.ptw-trend-chart-embed--clickable .ex-dash-trend-chart-wrap--clickable:hover,
.ptw-trend-chart-embed--clickable .ex-dash-trend-chart-wrap--clickable:focus-visible {
  background: color-mix(in srgb, var(--portal-accent, #8b1538) 4%, transparent);
  outline: none;
}

.ptw-trend-chart-embed--clickable .ex-dash-trend-chart-wrap--clickable:focus-visible {
  outline: 2px solid var(--portal-accent, #8b1538);
  outline-offset: 2px;
}

@media (max-width: 720px) {
  .ptw-trend-chart-embed .ex-dash-trend-title {
    font-size: 1.15rem;
    letter-spacing: 0.06em;
  }

  .ptw-trend-chart-embed .ex-dash-trend-head-controls {
    width: 100%;
  }

  .ptw-trend-chart-embed .ex-dash-trend-period {
    width: 100%;
    justify-content: stretch;
  }

  .ptw-trend-chart-embed button.ex-dash-trend-period-btn {
    flex: 1 1 auto;
    text-align: center;
  }
}
