/* health.css
 * Extracted from public/styles.css (Phase 0.3).
 * Lazy-loaded by public/modules/panels/nav.js on openPanel('health')
 * or relevant tab switch in switchMode().
 */

.health-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--md-sys-shape-corner-md);
  margin-bottom: 20px;
  border: 1px solid;
  transition: background var(--md-sys-motion-duration-medium1) var(--md-sys-motion-easing-emphasized-decel),
              border-color var(--md-sys-motion-duration-medium1) var(--md-sys-motion-easing-emphasized-decel);
}

.health-banner--ok {
  background: var(--md-sys-color-success-bg);
  border-color: var(--md-sys-color-success-fg);
}

.health-banner--warn {
  background: var(--md-sys-color-warning-bg);
  border-color: var(--md-sys-color-warning-fg);
}

.health-banner--down {
  background: var(--md-sys-color-error-container);
  border-color: var(--md-sys-color-error);
}

.health-banner-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.health-banner--ok .health-banner-dot { background: var(--md-sys-color-success-fg); box-shadow: 0 0 6px rgba(16, 185, 129, 0.5); }

.health-banner--warn .health-banner-dot { background: var(--md-sys-color-warning-fg); box-shadow: 0 0 6px rgba(245, 158, 11, 0.5); }

.health-banner--down .health-banner-dot { background: var(--md-sys-color-error); box-shadow: 0 0 6px rgba(239, 68, 68, 0.5); }

.health-banner-dot--pulse {
  animation: health-pulse 2s ease-in-out infinite;
}

.health-banner-text {
  font-size: var(--md-sys-typescale-title-medium-size);
  line-height: var(--md-sys-typescale-title-medium-line);
  font-weight: var(--md-sys-typescale-title-medium-weight);
  letter-spacing: var(--md-sys-typescale-title-medium-tracking);
  color: var(--md-sys-color-on-surface);
}

.health-banner-sub {
  font-size: var(--md-sys-typescale-body-medium-size);
  line-height: var(--md-sys-typescale-body-medium-line);
  letter-spacing: var(--md-sys-typescale-body-medium-tracking);
  color: var(--md-sys-color-on-surface-variant);
  margin-left: auto;
  white-space: nowrap;
}

.health-services {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.health-svc {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--md-sys-color-surface-container);
  border: none;
  border-radius: var(--md-sys-shape-corner-sm);
  min-height: 44px;
  transition: background var(--md-sys-motion-duration-short2) var(--md-sys-motion-easing-standard);
}

.health-svc--down {
  background: var(--md-sys-color-error-container);
}

.health-svc-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.health-svc-dot--ok {
  background: var(--md-sys-color-success-fg);
  box-shadow: 0 0 4px rgba(16, 185, 129, 0.4);
}

.health-svc-dot--down {
  background: var(--md-sys-color-error);
  box-shadow: 0 0 4px rgba(239, 68, 68, 0.4);
  animation: health-pulse 1.5s ease-in-out infinite;
}

.health-svc-name {
  font-size: var(--md-sys-typescale-body-medium-size);
  line-height: var(--md-sys-typescale-body-medium-line);
  letter-spacing: var(--md-sys-typescale-body-medium-tracking);
  font-weight: 500;
  color: var(--md-sys-color-on-surface);
  flex: 1;
}

.health-svc-badge {
  font-size: var(--md-sys-typescale-label-small-size);
  line-height: var(--md-sys-typescale-label-small-line);
  font-weight: var(--md-sys-typescale-label-small-weight);
  letter-spacing: var(--md-sys-typescale-label-small-tracking);
  padding: 2px 8px;
  border-radius: var(--md-sys-shape-corner-sm);
  text-transform: uppercase;
}

.health-svc-badge--ok {
  background: var(--md-sys-color-success-bg);
  color: var(--md-sys-color-success-fg);
}

.health-svc-badge--down {
  background: var(--md-sys-color-error-container);
  color: var(--md-sys-color-on-error-container);
}

.health-resources {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 20px;
}

.health-res {
  padding: 12px 14px;
  background: var(--md-sys-color-surface-container);
  border: none;
  border-radius: var(--md-sys-shape-corner-sm);
  transition: background var(--md-sys-motion-duration-short2) var(--md-sys-motion-easing-standard);
}

.health-res--alert {
  border-left: 2px solid var(--md-sys-color-error);
}

.health-res--warn {
  border-left: 2px solid var(--md-sys-color-warning-fg);
}

.health-res-label {
  font-size: var(--md-sys-typescale-label-medium-size);
  line-height: var(--md-sys-typescale-label-medium-line);
  font-weight: var(--md-sys-typescale-label-medium-weight);
  letter-spacing: var(--md-sys-typescale-label-medium-tracking);
  color: var(--md-sys-color-on-surface-variant);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.health-res-value {
  font-size: var(--md-sys-typescale-title-large-size);
  line-height: var(--md-sys-typescale-title-large-line);
  font-weight: var(--md-sys-typescale-title-large-weight);
  letter-spacing: var(--md-sys-typescale-title-large-tracking);
  color: var(--md-sys-color-on-surface);
  margin-bottom: 8px;
}

.health-res-detail {
  font-size: var(--md-sys-typescale-label-medium-size);
  line-height: var(--md-sys-typescale-label-medium-line);
  letter-spacing: var(--md-sys-typescale-label-medium-tracking);
  color: var(--md-sys-color-on-surface-variant);
  margin-bottom: 0;
}

.health-res--full {
  grid-column: 1 / -1;
}

.health-bar {
  height: 4px;
  background: var(--md-sys-color-surface-container-high);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 8px;
}

.health-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.6s var(--md-sys-motion-easing-emphasized-decel);
}

.health-bar-fill--ok { background: var(--md-sys-color-success-fg); }

.health-bar-fill--warn { background: var(--md-sys-color-warning-fg); }

.health-bar-fill--alert { background: var(--md-sys-color-error); }

.health-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 4px;
}

.health-updated {
  font-size: var(--md-sys-typescale-label-medium-size);
  line-height: var(--md-sys-typescale-label-medium-line);
  letter-spacing: var(--md-sys-typescale-label-medium-tracking);
  color: var(--md-sys-color-on-surface-variant);
}

/* M3 tonal chip-style button */
.health-refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--md-sys-typescale-font-family);
  font-size: var(--md-sys-typescale-label-large-size);
  line-height: var(--md-sys-typescale-label-large-line);
  font-weight: var(--md-sys-typescale-label-large-weight);
  letter-spacing: var(--md-sys-typescale-label-large-tracking);
  color: var(--md-sys-color-on-secondary-container);
  background: var(--md-sys-color-secondary-container);
  border: none;
  border-radius: var(--md-sys-shape-corner-sm);
  padding: 6px 16px;
  cursor: pointer;
  min-height: 32px;
  position: relative;
  overflow: hidden;
  isolation: isolate;
  transition: background var(--md-sys-motion-duration-short2) var(--md-sys-motion-easing-standard);
  -webkit-tap-highlight-color: transparent;
}

.health-refresh-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: currentColor;
  opacity: 0;
  transition: opacity var(--md-sys-motion-duration-short2) var(--md-sys-motion-easing-standard);
  pointer-events: none;
  z-index: -1;
}

@media (hover: hover) {
  .health-refresh-btn:hover::after { opacity: var(--md-sys-state-hover-opacity); }
}

.health-refresh-btn:active::after { opacity: var(--md-sys-state-pressed-opacity); }

.health-refresh-icon {
  display: inline-block;
  width: 14px;
  height: 14px;
  transition: transform var(--md-sys-motion-duration-long1) var(--md-sys-motion-easing-emphasized-decel);
}

.health-refresh-btn:active .health-refresh-icon {
  transform: rotate(180deg);
}

/* M3 outlined button */
.health-restart-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--md-sys-typescale-font-family);
  font-size: var(--md-sys-typescale-label-large-size);
  line-height: var(--md-sys-typescale-label-large-line);
  font-weight: var(--md-sys-typescale-label-large-weight);
  letter-spacing: var(--md-sys-typescale-label-large-tracking);
  color: var(--md-sys-color-primary);
  background: transparent;
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--md-sys-shape-corner-full);
  padding: 10px 24px;
  cursor: pointer;
  min-height: 40px;
  width: 100%;
  justify-content: center;
  position: relative;
  overflow: hidden;
  isolation: isolate;
  transition: background var(--md-sys-motion-duration-short2) var(--md-sys-motion-easing-standard);
  -webkit-tap-highlight-color: transparent;
}

.health-restart-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: currentColor;
  opacity: 0;
  transition: opacity var(--md-sys-motion-duration-short2) var(--md-sys-motion-easing-standard);
  pointer-events: none;
  z-index: -1;
}

@media (hover: hover) {
  .health-restart-btn:hover::after { opacity: var(--md-sys-state-hover-opacity); }
}

.health-restart-btn:active::after { opacity: var(--md-sys-state-pressed-opacity); }

.health-restart-btn:disabled {
  opacity: 0.38;
  cursor: default;
  pointer-events: none;
}

.health-panel-enter {
  animation: health-fade-in 0.25s var(--ease-out) both;
}

.health-svc-meta {
  font-size: var(--md-sys-typescale-label-medium-size);
  line-height: var(--md-sys-typescale-label-medium-line);
  letter-spacing: var(--md-sys-typescale-label-medium-tracking);
  color: var(--md-sys-color-on-surface-variant);
  padding: 2px 6px;
  background: var(--md-sys-color-surface-container-high);
  border-radius: var(--md-sys-shape-corner-xs);
}

.health-svc-meta--warn {
  color: var(--md-sys-color-warning-fg);
  background: var(--md-sys-color-warning-bg);
}

.health-svc-dot--warn {
  background: var(--md-sys-color-warning-fg);
  box-shadow: 0 0 4px rgba(245, 158, 11, 0.4);
}

.health-errors {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.health-error-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 12px;
  background: var(--md-sys-color-surface-container);
  border: none;
  border-radius: var(--md-sys-shape-corner-sm);
  font-size: var(--md-sys-typescale-body-medium-size);
  line-height: var(--md-sys-typescale-body-medium-line);
  letter-spacing: var(--md-sys-typescale-body-medium-tracking);
}

.health-error-time {
  color: var(--md-sys-color-on-surface-variant);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.health-error-unit {
  color: var(--md-sys-color-error);
  font-weight: 500;
  flex-shrink: 0;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.health-error-msg {
  color: var(--md-sys-color-on-surface);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.health-details {
  margin-top: 10px;
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--md-sys-shape-corner-sm);
  overflow: hidden;
}

.health-details-summary {
  padding: 8px 12px;
  cursor: pointer;
  font-size: var(--md-sys-typescale-body-medium-size);
  line-height: var(--md-sys-typescale-body-medium-line);
  letter-spacing: var(--md-sys-typescale-body-medium-tracking);
  color: var(--md-sys-color-on-surface-variant);
  background: var(--md-sys-color-surface-container);
  user-select: none;
  transition: background var(--md-sys-motion-duration-short2) var(--md-sys-motion-easing-standard);
}

.health-details-summary:hover {
  background: var(--md-sys-color-surface-container-high);
}

.health-details[open] > .health-details-summary {
  border-bottom: 1px solid var(--md-sys-color-outline);
}

.health-details > .health-errors {
  padding: 8px 12px;
}

@media (max-width: 400px) {
  .health-resources {
    grid-template-columns: 1fr;
  }
  .health-error-row {
    flex-wrap: wrap;
  }
  .health-error-msg {
    white-space: normal;
    flex-basis: 100%;
  }
}

@media (min-width: 1024px) {
  #panel-content {
    max-width: 900px;
    margin: 0 auto;
    padding: 24px 32px;
  }

  #tools-launcher {
    padding: 24px 32px;
  }

  .health-services {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (pointer: coarse) {
  .health-refresh-btn { min-height: 48px; }
  .health-restart-btn { min-height: 48px; }
}
