/* Analytics Dashboard Styles - Dark Theme */

.grid4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

@media (max-width: 768px) {
  .grid4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .grid4 {
    grid-template-columns: 1fr;
  }
}

.analytics-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  table-layout: fixed;
}

.analytics-table th,
.analytics-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--soft);
}

.analytics-table th {
  background-color: var(--bg);
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text);
}

.analytics-table td {
  font-size: 0.875rem;
  color: var(--text);
}

.analytics-table tr:hover {
  background-color: var(--soft);
}

.status-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
}

.status-active {
  background-color: rgba(46, 204, 113, 0.2);
  color: var(--ok);
  border: 1px solid var(--ok);
}

.status-inactive {
  background-color: rgba(231, 76, 60, 0.2);
  color: var(--bad);
  border: 1px solid var(--bad);
}

.analytics-loading {
  text-align: center;
  padding: 20px;
  color: var(--muted);
}

.analytics-error {
  text-align: center;
  padding: 20px;
  color: var(--bad);
  background-color: rgba(231, 76, 60, 0.1);
  border: 1px solid var(--bad);
  border-radius: 6px;
  margin: 10px 0;
}

.analytics-empty {
  text-align: center;
  padding: 20px;
  color: var(--muted);
  font-style: italic;
}

.number-stat {
  font-weight: 600;
  color: var(--acc);
}

.time-stat {
  font-size: 0.75rem;
  color: var(--muted);
}

/* Enhanced triggers table - auto-sizing columns */
.enhanced-triggers-table {
  table-layout: auto !important; /* Override fixed layout for triggers */
}

.enhanced-triggers-table th,
.enhanced-triggers-table td {
  width: auto !important; /* Let columns size to content */
  white-space: nowrap; /* Prevent text wrapping */
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Payload column specific styling */
.enhanced-triggers-table .payload-cell {
  max-width: 200px;
  white-space: normal; /* Allow wrapping for payload */
}

/* Enhanced triggers table column widths */
.enhanced-triggers-table th:nth-child(1),
.enhanced-triggers-table td:nth-child(1) {
  width: 12%; /* Date */
  min-width: 100px;
}

.enhanced-triggers-table th:nth-child(2),
.enhanced-triggers-table td:nth-child(2) {
  width: 25%; /* Teams */
}

.enhanced-triggers-table th:nth-child(3),
.enhanced-triggers-table td:nth-child(3) {
  width: 18%; /* Rule */
}

.enhanced-triggers-table th:nth-child(4),
.enhanced-triggers-table td:nth-child(4) {
  width: 20%; /* Trigger Time */
}

.enhanced-triggers-table th:nth-child(5),
.enhanced-triggers-table td:nth-child(5) {
  width: 10%; /* Status */
  text-align: center;
}

.enhanced-triggers-table th:nth-child(6),
.enhanced-triggers-table td:nth-child(6) {
  width: 15%; /* Payload */
}

/* Date cell styling */
.date-cell .time-display {
  text-align: left;
}

.date-cell .date {
  font-weight: 500;
  font-size: 0.875rem;
}

.date-cell .time {
  color: var(--muted);
  font-size: 0.75rem;
}

/* Column alignment for analytics tables */
.analytics-table th:nth-child(1),
.analytics-table td:nth-child(1) {
  width: 20%; /* Rule ID */
}

.analytics-table th:nth-child(2),
.analytics-table td:nth-child(2) {
  width: 30%; /* Rule Name */
}

.analytics-table th:nth-child(3),
.analytics-table td:nth-child(3) {
  width: 15%; /* Hits/Total Hits */
  text-align: center;
}

.analytics-table th:nth-child(4),
.analytics-table td:nth-child(4) {
  width: 20%; /* Last Fired */
  text-align: center;
}

.analytics-table th:nth-child(5),
.analytics-table td:nth-child(5) {
  width: 15%; /* Status */
  text-align: center;
}

/* Analytics table controls styling */
#panel-analytics h2 button {
  margin-left: 4px;
  padding: 4px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s ease;
}

#panel-analytics h2 button:hover {
  background: var(--soft);
  border-color: var(--acc);
}

#panel-analytics h2 button:active {
  background: var(--acc);
  color: var(--bg);
}

/* Sort indicators in table headers */
.sort-indicator {
  font-size: 10px;
  color: var(--muted);
  margin-left: 4px;
}

.analytics-table th[onclick] {
  cursor: pointer;
  user-select: none;
}

.analytics-table th[onclick]:hover {
  background-color: var(--soft);
}


/* Legacy table support - keep existing tables working */
#tablesOverviewTable {
  table-layout: fixed;
  width: 100%;
}

#tablesOverviewTable th,
#tablesOverviewTable td {
  text-align: center;
}

#tablesOverviewTable th:nth-child(1),
#tablesOverviewTable td:nth-child(1) {
  width: 15%; /* Table Name - reduced width */
  text-align: left; /* Table names left-aligned */
}

#tablesOverviewTable th:nth-child(2),
#tablesOverviewTable td:nth-child(2) {
  width: 13%; /* Live Rows - moved right to 13% */
}

#tablesOverviewTable th:nth-child(3),
#tablesOverviewTable td:nth-child(3) {
  width: 15%; /* Total Size - further reduced for Live Rows 13% */
}

#tablesOverviewTable th:nth-child(4),
#tablesOverviewTable td:nth-child(4) {
  width: 7%; /* Inserts - compressed */
}

#tablesOverviewTable th:nth-child(5),
#tablesOverviewTable td:nth-child(5) {
  width: 8%; /* Updates - moved left a tiny bit */
}

#tablesOverviewTable th:nth-child(6),
#tablesOverviewTable td:nth-child(6) {
  width: 22%; /* Last Analyze - moved right */
}

#tablesOverviewTable th:nth-child(7),
#tablesOverviewTable td:nth-child(7) {
  width: 15%; /* Actions - perfectly aligns with Status */
  text-align: center;
}

/* Dark styling for Hide System Tables and Hide Empty checkboxes */
#hideSystemTables,
#hideEmptyTables {
  accent-color: var(--text);
  background-color: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
}

#hideSystemTables:checked,
#hideEmptyTables:checked {
  accent-color: var(--acc);
  background-color: var(--acc);
}

/* Dark labels for the checkboxes */
label:has(#hideSystemTables),
label:has(#hideEmptyTables) {
  color: var(--text);
  font-weight: 500;
}

/* Analytics metrics cards styled like Production Status */
.analytics-metric-card {
  background: var(--bg);
  border: 1px solid var(--soft);
  border-radius: 8px;
  padding: 16px;
}

.analytics-metric-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.analytics-metric-header h4 {
  margin: 0;
  font-size: 14px;
  color: var(--text);
}

.analytics-metric-value {
  font-size: 24px;
  font-weight: 600;
  color: var(--acc);
  margin: 4px 0;
}

.analytics-metric-details {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

/* Grid layout for analytics metrics */
.analytics-metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

/* Rule Sources Table specific styling */
#ruleSourcesTable .analytics-table {
  table-layout: fixed;
  width: 100%;
}

#ruleSourcesTable .analytics-table th:nth-child(1),
#ruleSourcesTable .analytics-table td:nth-child(1) {
  width: 15%; /* Table */
}

#ruleSourcesTable .analytics-table th:nth-child(2),
#ruleSourcesTable .analytics-table td:nth-child(2) {
  width: 25%; /* Description */
}

#ruleSourcesTable .analytics-table th:nth-child(3),
#ruleSourcesTable .analytics-table td:nth-child(3) {
  width: 15%; /* Use */
}

#ruleSourcesTable .analytics-table th:nth-child(4),
#ruleSourcesTable .analytics-table td:nth-child(4) {
  width: 12%; /* Row Count */
  text-align: center;
}

#ruleSourcesTable .analytics-table th:nth-child(5),
#ruleSourcesTable .analytics-table td:nth-child(5) {
  width: 18%; /* Key Columns */
}

#ruleSourcesTable .analytics-table th:nth-child(6),
#ruleSourcesTable .analytics-table td:nth-child(6) {
  width: 10%; /* Status */
  text-align: center;
}

#ruleSourcesTable .analytics-table th:nth-child(7),
#ruleSourcesTable .analytics-table td:nth-child(7) {
  width: 5%; /* Info */
  text-align: center;
}

/* Rule Source Tables header controls positioning */
.rule-sources-controls {
  float: right !important;
  margin-left: auto !important;
}

/* Triggers table pagination styling */
.triggers-pagination-top,
.triggers-pagination-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--soft);
}

.triggers-pagination-bottom {
  border-top: 1px solid var(--soft);
  border-bottom: none;
  margin-top: 8px;
}

.pagination-info {
  font-size: 0.875rem;
  color: var(--muted);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pagination-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.875rem;
  transition: all 0.2s ease;
}

.pagination-btn:hover:not(:disabled) {
  background: var(--soft);
  border-color: var(--acc);
}

.pagination-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.page-info {
  font-size: 0.875rem;
  color: var(--text);
  font-weight: 500;
  min-width: 100px;
  text-align: center;
}

@media (max-width: 768px) {
  .triggers-pagination-top,
  .triggers-pagination-bottom {
    flex-direction: column;
    gap: 8px;
  }
  
  .pagination-controls {
    justify-content: center;
  }
}

/* Scheduler Status Header */
.scheduler-mode-left {
  margin-left: 8px;
  font-weight: normal;
  color: var(--muted);
  font-size: 0.9em;
}