/* PUBLOG Stats - Cards, grids, charts */

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  padding: 0 24px;
}

.stat-card {
  background: var(--gh-bg-subtle);
  border: 1px solid var(--gh-border);
  border-radius: 8px;
  padding: 20px;
  text-align: center;
}

.stat-value {
  font-size: 2rem;
  font-weight: 600;
  color: var(--gh-blue);
  margin-bottom: 8px;
}

.stat-value.healthy {
  color: var(--gh-green);
}

.stat-value.warning {
  color: var(--gh-gold);
}

.stat-value.error {
  color: var(--gh-red);
}

.stat-label {
  color: var(--gh-text-subtle);
  font-size: 0.9rem;
}

/* Level Grid */
.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  padding: 0 24px;
}

.level-card {
  background: var(--gh-bg-subtle);
  border: 1px solid var(--gh-border);
  border-radius: 6px;
  padding: 16px;
  text-align: center;
}

.level-card .level-name {
  font-size: 0.85rem;
  text-transform: uppercase;
  font-weight: 600;
  margin-bottom: 8px;
}

.level-card .level-count {
  font-size: 1.5rem;
  font-weight: 600;
}

.level-card.level-debug .level-name { color: var(--gh-text-subtle); }
.level-card.level-debug .level-count { color: var(--gh-text-subtle); }

.level-card.level-info .level-name { color: var(--gh-blue); }
.level-card.level-info .level-count { color: var(--gh-blue); }

.level-card.level-warning .level-name { color: var(--gh-gold); }
.level-card.level-warning .level-count { color: var(--gh-gold); }

.level-card.level-error .level-name { color: var(--gh-red); }
.level-card.level-error .level-count { color: var(--gh-red); }


/* Source Grid - flexbox for better wrapping */
.source-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 0 24px;
}

.source-card {
  background: var(--gh-bg-subtle);
  border: 1px solid var(--gh-border);
  border-radius: 6px;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-width: 160px;
  max-width: 280px;
  flex: 1 1 auto;
}

.source-card .source-name {
  color: var(--gh-text);
  font-weight: 500;
  word-break: break-word;
  overflow-wrap: break-word;
  min-width: 0;
  flex: 1;
}

.source-card .source-count {
  color: var(--gh-blue);
  font-weight: 600;
  flex-shrink: 0;
}

/* Activity Chart - 24-hour view, 24 hourly stacked bars */
.activity-container {
  margin: 0 0 24px;
  padding: 0 24px;
}

.activity-chart {
  display: flex;
  gap: 6px;
  align-items: flex-end;
  height: 140px;
  padding: 12px 12px 28px;
  background: var(--gh-bg-subtle);
  border: 1px solid var(--gh-border);
  border-radius: 8px;
}

/* Each hour column */
.activity-column {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: 100%;
  min-width: 0;
}

/* Stacked bar container */
.activity-stack {
  display: flex;
  flex-direction: column;
  width: 100%;
  border-radius: 3px;
  overflow: hidden;
}

/* Individual level segments */
.stack-segment {
  width: 100%;
  min-height: 2px;
}
.stack-segment.info { background: var(--gh-blue); }
.stack-segment.warning { background: var(--gh-gold); }
.stack-segment.error { background: var(--gh-red); }

/* Current hour glow */
.activity-column.current .activity-stack {
  box-shadow: 0 0 8px 2px rgba(88, 166, 255, 0.5);
}

/* Hover effect */
.activity-column:hover .activity-stack {
  opacity: 0.85;
  transform: scaleY(1.02);
  transition: transform 0.1s, opacity 0.1s;
}

/* Hour labels below chart */
.hour-label {
  position: absolute;
  bottom: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.65rem;
  color: var(--gh-text-subtle);
  white-space: nowrap;
}

/* Activity header meta (rate + server time) */
.activity-meta {
  float: right;
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--gh-text-subtle);
  display: flex;
  gap: 16px;
  align-items: center;
}

.rate-display {
  color: var(--gh-blue);
}

.server-time {
  font-family: monospace;
  color: var(--gh-green);
}

/* No data state */
.no-data {
  text-align: center;
  padding: 40px;
  color: var(--gh-text-subtle);
}

/* Logs Modal */
.logs-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 1000;
  display: none;
  justify-content: center;
  align-items: flex-start;
  padding: 40px 20px;
  overflow-y: auto;
}

.logs-modal-overlay.show {
  display: flex;
}

.logs-modal {
  background: var(--gh-bg);
  border: 1px solid var(--gh-blue);
  border-radius: 12px;
  width: 100%;
  max-width: 900px;
  height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 20px rgba(88, 166, 255, 0.15);
}

.logs-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--gh-border);
}

.logs-modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logs-modal-refresh {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--gh-text-subtle);
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  transition: color 0.15s, transform 0.15s;
}

.logs-modal-refresh:hover {
  color: var(--gh-blue);
  transform: rotate(180deg);
}

.logs-modal-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--gh-text);
}

.logs-modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--gh-text-subtle);
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}

.logs-modal-close:hover {
  color: var(--gh-text);
}

.logs-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

.logs-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.log-entry {
  background: var(--gh-bg-subtle);
  border: 1px solid var(--gh-border);
  border-radius: 6px;
  padding: 12px;
}

.log-entry-header {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 6px;
  font-size: 0.8rem;
}

.log-entry-time {
  color: var(--gh-text-subtle);
  font-family: monospace;
}

.log-entry-level {
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 3px;
}

.log-entry-level.info { color: var(--gh-blue); background: rgba(88, 166, 255, 0.1); }
.log-entry-level.warning { color: var(--gh-gold); background: rgba(210, 153, 34, 0.1); }
.log-entry-level.error { color: var(--gh-red); background: rgba(248, 81, 73, 0.1); }
.log-entry-level.debug { color: var(--gh-text-subtle); background: rgba(139, 148, 158, 0.1); }

.log-entry-source {
  color: var(--gh-text-subtle);
}

.log-entry-level.clickable,
.log-entry-source.clickable {
  cursor: pointer;
  transition: opacity 0.15s;
}

.log-entry-level.clickable:hover,
.log-entry-source.clickable:hover {
  opacity: 0.7;
  text-decoration: underline;
}

.log-entry-message {
  color: var(--gh-text);
  font-family: monospace;
  font-size: 0.85rem;
  word-break: break-word;
  white-space: pre-wrap;
}

.logs-modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border-top: 1px solid var(--gh-border);
  font-size: 0.85rem;
}

.logs-pagination {
  display: flex;
  gap: 8px;
}

.logs-pagination button {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.logs-count {
  color: var(--gh-text-subtle);
}

/* Clickable cards */
.level-card.clickable,
.source-card.clickable {
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
}

.level-card.clickable:hover,
.source-card.clickable:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Live Logs Stream */
.live-indicator {
  float: right;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--gh-green);
  animation: pulse-live 2s ease-in-out infinite;
}

@keyframes pulse-live {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.live-logs-container {
  margin: 0 0 24px;
  padding: 0 24px;
}

.live-logs {
  background: var(--gh-bg-subtle);
  border: 1px solid var(--gh-border);
  border-radius: 8px;
  height: 400px;
  overflow-y: auto;
  overflow-x: hidden;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
  font-size: 0.75rem;
  line-height: 1.4;
  padding: 8px 0;
}

.live-log-entry {
  padding: 4px 12px;
  border-bottom: 1px solid var(--gh-border);
  display: flex;
  gap: 8px;
  align-items: flex-start;
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.live-log-entry:last-child {
  border-bottom: none;
}

.live-log-time {
  color: var(--gh-text-subtle);
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 70px;
}

.live-log-level {
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.65rem;
  padding: 1px 4px;
  border-radius: 2px;
  flex-shrink: 0;
  min-width: 50px;
  text-align: center;
}

.live-log-level.info { color: var(--gh-blue); background: rgba(88, 166, 255, 0.1); }
.live-log-level.warning { color: var(--gh-gold); background: rgba(210, 153, 34, 0.1); }
.live-log-level.error { color: var(--gh-red); background: rgba(248, 81, 73, 0.1); }
.live-log-level.debug { color: var(--gh-text-subtle); background: rgba(139, 148, 158, 0.1); }

.live-log-source {
  color: var(--gh-blue);
  flex-shrink: 0;
  white-space: nowrap;
}

.live-log-message {
  color: var(--gh-text);
  flex: 1;
  min-width: 0;
  word-break: break-word;
  overflow-wrap: break-word;
  white-space: pre-wrap;
}

.live-log-level.clickable,
.live-log-source.clickable {
  cursor: pointer;
  transition: opacity 0.15s;
}

.live-log-level.clickable:hover,
.live-log-source.clickable:hover {
  opacity: 0.7;
  text-decoration: underline;
}

/* Log filters */
.live-logs-filter,
.logs-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

/* Modal filter - fixed at top, doesn't scroll */
.logs-modal > .logs-filter {
  padding: 12px 20px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--gh-border);
  flex-shrink: 0;
}

.live-logs-filter input,
.logs-filter input {
  flex: 1;
  padding: 8px 12px;
  background: var(--gh-bg);
  border: 1px solid var(--gh-border);
  border-radius: 6px;
  color: var(--gh-text);
  font-size: 0.85rem;
}

.live-logs-filter input:focus,
.logs-filter input:focus {
  outline: none;
  border-color: var(--gh-blue);
}

.filter-count {
  color: var(--gh-text-subtle);
  font-size: 0.75rem;
  white-space: nowrap;
}

/* Hidden log entries when filtered */
.live-log-entry.hidden,
.log-entry.hidden {
  display: none;
}

/* Live logs header actions */
.live-logs-actions {
  float: right;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-weight: 400;
}

.live-refresh-btn {
  background: none;
  border: 1px solid var(--gh-border);
  border-radius: 4px;
  font-size: 1rem;
  color: var(--gh-text-subtle);
  cursor: pointer;
  padding: 2px 8px;
  line-height: 1.2;
  transition: color 0.15s, border-color 0.15s, transform 0.3s;
}

.live-refresh-btn:hover {
  color: var(--gh-blue);
  border-color: var(--gh-blue);
  transform: rotate(180deg);
}

.live-auto-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 0.75rem;
  color: var(--gh-text-subtle);
}

.live-auto-toggle input[type="checkbox"] {
  width: 14px;
  height: 14px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--gh-green);
}

.live-auto-toggle:hover {
  color: var(--gh-text);
}

.live-auto-toggle input:checked + .toggle-label {
  color: var(--gh-green);
}

/* Live logs header with filter and pagination */
.live-logs-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 8px;
}

.live-logs-header .live-logs-filter {
  flex: 1;
  margin-bottom: 0;
}

.live-logs-pagination {
  display: flex;
  align-items: center;
  gap: 8px;
}

.live-logs-pagination button {
  padding: 4px 10px;
  font-size: 0.75rem;
  background: var(--gh-bg-subtle);
  border: 1px solid var(--gh-border);
  border-radius: 4px;
  color: var(--gh-text);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.live-logs-pagination button:hover:not(:disabled) {
  border-color: var(--gh-blue);
  color: var(--gh-blue);
}

.live-logs-pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.live-logs-page {
  font-size: 0.75rem;
  color: var(--gh-text-subtle);
  min-width: 50px;
  text-align: center;
}
