/* Triggers Tab Dark Theme Professional Styling */

/* Statistics Cards - Dark Theme */
.stats-card {
  background: var(--panel);
  border: 1px solid var(--soft);
  color: var(--text);
  text-align: center;
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 8px 25px rgba(0,0,0,0.2);
  transition: all 0.3s ease;
}

.stats-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 35px rgba(0,0,0,0.15);
}

.stats-card h3 {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 10px 0;
  opacity: 0.9;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  margin: 8px 0;
  text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.stat-subtitle {
  font-size: 12px;
  opacity: 0.8;
  font-weight: 400;
}

/* Status Indicators */
.status-indicator {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-indicator.online {
  background: #27ae60;
  color: white;
}

.status-indicator.offline {
  background: #e74c3c;
  color: white;
}

.status-indicator.warning {
  background: #f39c12;
  color: white;
}

/* Status Display */
.status-display {
  padding: 16px;
}

.status-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(0,0,0,0.05);
}

.status-item:last-child {
  border-bottom: none;
}

.status-value {
  font-weight: 600;
  color: var(--primary);
}

/* Analytics Metrics */
.analytics-metric {
  text-align: center;
  padding: 16px;
  background: var(--panel);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  border: 1px solid var(--soft);
}

.analytics-metric h4 {
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 8px 0;
  font-weight: 500;
}

.metric-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  margin: 8px 0;
}

.metric-trend {
  font-size: 12px;
  font-weight: 600;
}

.metric-trend.up {
  color: #27ae60;
}

.metric-trend.down {
  color: #e74c3c;
}

.metric-subtitle {
  font-size: 11px;
  color: #95a5a6;
  margin-top: 4px;
}

/* Button Groups */
.button-group-vertical {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.button-group-vertical button {
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  font-size: 13px;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.button-group-vertical button:hover {
  transform: translateX(2px);
}

/* Live Trigger Stream */
.trigger-stream {
  max-height: 600px;
  overflow-y: auto;
  border: 1px solid #e8ecef;
  border-radius: 8px;
}

/* Enhanced Filter Panel */
.filter-panel {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border: 1px solid #dee2e6;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
}

.filter-panel h3 {
  color: #495057;
  margin-bottom: 16px;
  font-weight: 600;
}

/* Professional Table Styling for Triggers */
.triggers-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  border: 1px solid var(--soft);
  table-layout: auto;
}

.triggers-table thead {
  background: var(--bg);
  border-bottom: 2px solid var(--acc);
  color: var(--text);
}

.triggers-table th {
  padding: 12px 8px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.5px;
  border: none;
  color: var(--text);
  text-transform: uppercase;
}

.triggers-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--soft);
  font-size: 12px;
  vertical-align: middle;
  color: var(--text);
  background: var(--panel);
  font-weight: 500;
  white-space: nowrap;
}

/* Auto-sizing columns that fit content properly */
.triggers-table th:nth-child(1), .triggers-table td:nth-child(1) { width: auto; white-space: nowrap; padding: 10px 6px; } /* DATE/TIME */
.triggers-table th:nth-child(2), .triggers-table td:nth-child(2) { width: auto; white-space: nowrap; padding: 10px 8px; } /* MATCH */
.triggers-table th:nth-child(3), .triggers-table td:nth-child(3) { width: auto; white-space: nowrap; padding: 10px 6px; } /* TRIGGER */
.triggers-table th:nth-child(4), .triggers-table td:nth-child(4) { width: auto; white-space: nowrap; padding: 10px 6px; } /* GOAL */
.triggers-table th:nth-child(5), .triggers-table td:nth-child(5) { width: auto; white-space: nowrap; padding: 10px 6px; } /* FT SCORE */
.triggers-table th:nth-child(6), .triggers-table td:nth-child(6) { width: auto; text-align: center; white-space: nowrap; padding: 10px 6px; } /* STATUS */
.triggers-table th:nth-child(7), .triggers-table td:nth-child(7) { width: auto; white-space: nowrap; padding: 10px 8px; } /* INFO */

/* Allow multi-line content in specific cells */
.triggers-table .time-display,
.triggers-table .match-display {
  white-space: normal;
}

/* Professional Trigger Info Modal Styling */
.trigger-info-modal {
  max-width: 900px;
  max-height: 80vh;
  overflow-y: auto;
}

.payload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
  margin-top: 15px;
}

.payload-section {
  background: var(--panel);
  padding: 15px;
  border-radius: 8px;
  border: 1px solid var(--soft);
}

.payload-section.full-width {
  grid-column: 1 / -1;
}

.payload-section h5 {
  margin: 0 0 12px 0;
  color: var(--acc);
  font-size: 14px;
  font-weight: 600;
  border-bottom: 2px solid var(--acc);
  padding-bottom: 6px;
}

.field-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--soft);
}

.field-row:last-child {
  border-bottom: none;
}

.field-label {
  font-weight: 500;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.field-value {
  font-weight: 600;
  color: var(--text);
  font-size: 13px;
}

.field-value.success {
  color: var(--ok);
}

.field-value.error {
  color: var(--bad);
}

.field-value.pending {
  color: #ffc107;
}

.verification-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.verification-grid .field-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 8px;
  background: var(--bg);
  border-radius: 4px;
  border: 1px solid var(--soft);
}

.verification-grid .field-label {
  margin-bottom: 4px;
}

.verification-grid .field-value {
  font-size: 12px;
}

/* Stronger contrast for better readability */
.triggers-table tbody tr {
  background: var(--bg);
}

.triggers-table tbody tr:nth-child(even) {
  background: var(--panel);
}

.triggers-table tbody tr:hover {
  background: var(--soft);
  color: #ffffff;
  transition: all 0.2s ease;
}

.triggers-table tbody tr:last-child td {
  border-bottom: none;
}

/* Enhanced text visibility */
.triggers-table .match-info {
  color: #ffffff;
  font-weight: 600;
}

.triggers-table .time-info {
  color: var(--muted);
  font-size: 12px;
}

.triggers-table .trigger-data {
  color: var(--acc);
  font-weight: 600;
  font-family: 'Courier New', monospace;
}

.triggers-table .goal-data {
  color: #27ae60;
  font-weight: 600;
}

.triggers-table .score-data {
  color: #ffffff;
  font-weight: 700;
}

/* Trigger Status Badges */
.trigger-status {
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: inline-block;
  min-width: 70px;
  text-align: center;
}

.trigger-status.success {
  background: #27ae60;
  color: white;
  box-shadow: 0 2px 4px rgba(39, 174, 96, 0.3);
}

.trigger-status.failed {
  background: #e74c3c;
  color: white;
  box-shadow: 0 2px 4px rgba(231, 76, 60, 0.3);
}

.trigger-status.pending {
  background: #f39c12;
  color: white;
  box-shadow: 0 2px 4px rgba(243, 156, 18, 0.3);
}

/* Pagination */
.pagination-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 16px 0;
  padding: 12px 16px;
  background: var(--panel);
  border-radius: 6px;
  border: 1px solid var(--soft);
}

.pagination-info {
  font-size: 13px;
  color: var(--text);
}

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

.pagination-btn {
  padding: 6px 12px;
  font-size: 12px;
  border: 1px solid var(--soft);
  background: var(--bg);
  color: var(--text);
  border-radius: 4px;
  cursor: pointer;
  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;
  color: var(--muted);
}

/* Real-time Updates */
.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #28a745;
  font-weight: 600;
}

.live-indicator::before {
  content: "●";
  animation: pulse 2s infinite;
}

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

/* Health Status Indicators */
.health-good {
  color: #28a745;
}

.health-warning {
  color: #ffc107;
}

.health-critical {
  color: #dc3545;
}

/* Auto-refresh Toggle */
.auto-refresh-control {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.auto-refresh-control input[type="checkbox"] {
  transform: scale(1.2);
}

/* Loading States */
.loading-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 768px) {
  .grid4 {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  
  .grid3 {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  .stat-value {
    font-size: 24px;
  }
  
  .triggers-table {
    font-size: 12px;
  }
  
  .triggers-table th,
  .triggers-table td {
    padding: 8px 6px;
  }
}

/* Enhanced Info Banner for Triggers */
.panel-triggers .info-banner {
  background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
  color: white;
  border: none;
  box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}

.panel-triggers .info-banner h3 {
  color: white;
}

.panel-triggers .info-banner strong {
  color: #ecf0f1;
}

/* Table Container */
.triggers-table-container {
  background: var(--panel);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  border: 1px solid var(--soft);
  overflow: hidden;
}

/* Improve readability */
.no-data, .error {
  padding: 40px;
  text-align: center;
  color: var(--muted);
  font-size: 16px;
  background: var(--panel);
  border-radius: 8px;
  border: 1px solid var(--soft);
}

/* Section Toggle Animations */
.section-content {
  transition: all 0.3s ease;
  overflow: hidden;
}

.section-content.collapsed {
  max-height: 0;
  opacity: 0;
}

.section-content.expanded {
  max-height: 1000px;
  opacity: 1;
}

/* Filter Info Display */
.filter-info {
  background: #e3f2fd;
  border: 1px solid #90caf9;
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 12px;
  color: #1565c0;
}

/* Export Button Styling */
.export-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.export-btn {
  background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.export-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

/* NEW: Filter Buttons */
.filter-buttons {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-preset {
  padding: 8px 16px;
  border: 1px solid var(--soft);
  background: var(--bg);
  color: var(--text);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
  font-weight: 500;
}

.filter-preset:hover {
  background: var(--soft);
  border-color: var(--acc);
}

.filter-preset.active {
  background: var(--acc);
  border-color: var(--acc);
  color: white;
  font-weight: 600;
}

/* NEW: Result Chips */
.result-chips {
  display: flex;
  gap: 6px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.result-chip {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  opacity: 0.7;
}

.result-chip:hover {
  opacity: 0.9;
}

.result-chip.active {
  opacity: 1;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

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

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

.result-chip.pending {
  background-color: rgba(255, 193, 7, 0.2);
  color: #856404;
  border: 1px solid #ffc107;
}

.result-chip.all {
  background: #6c757d;
  color: white;
}

/* NEW: Enhanced NEW Indicators */
.new-indicator {
  background: #ff6b35;
  color: white;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: help;
}

/* NEW: Details Button */
.details-btn {
  background: #007bff;
  color: white;
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.details-btn:hover {
  background: #0056b3;
}

/* NEW: Trigger Details Modal */
.trigger-details {
  max-width: 600px;
}

.details-section {
  margin-bottom: 24px;
}

.details-section h4 {
  margin: 0 0 12px 0;
  color: #495057;
  font-size: 16px;
  font-weight: 600;
  border-bottom: 2px solid #e9ecef;
  padding-bottom: 8px;
}

.details-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  font-size: 14px;
}

.details-grid > div {
  padding: 8px;
  background: var(--soft);
  border-radius: 4px;
}

.details-grid strong {
  color: var(--text);
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* NEW: Match Events */
.events-list {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  background: #f8f9fa;
}

.event-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid #e9ecef;
}

.event-item:last-child {
  border-bottom: none;
}

.event-minute {
  background: #007bff;
  color: white;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 12px;
  font-weight: bold;
  min-width: 30px;
  text-align: center;
}

.event-type {
  font-weight: 600;
  color: #495057;
  min-width: 80px;
  font-size: 12px;
  text-transform: uppercase;
}

.event-description {
  color: #6c757d;
  font-size: 13px;
}

.no-events {
  text-align: center;
  padding: 20px;
  color: #6c757d;
  font-style: italic;
}

/* NEW: Advanced Filters */
.advanced-filters summary {
  cursor: pointer;
  padding: 8px 0;
  color: #007bff;
}

.advanced-filters summary:hover {
  color: #0056b3;
}

.advanced-filters[open] summary {
  margin-bottom: 8px;
}

/* ====== UNIFIED TRIGGERS BADGES ====== */

.badge{padding:.15rem .45rem;border-radius:.5rem;font-weight:600}
.badge-success{background:#e8f7ee;color:#16794c}
.badge-missed{background:#fde8ea;color:#b42318}
.badge-pending{background:#fff6e5;color:#8a5a00}

.row-live td{background:rgba(0,128,255,.03)}
.row-success td{background:rgba(22,121,76,.03)}
.row-missed td{background:rgba(180,35,24,.03)}

.dt-main{font-weight:600}
.dt-sub{opacity:.7;font-size:.85em}
.match-sub,.live-score{opacity:.8;font-size:.9em}

/* ====== NEW RESULT BADGES ====== */
.result-badge { 
  padding: 3px 8px; 
  border-radius: 10px; 
  font-weight: 600; 
  font-size: 12px; 
}
.result-success { 
  background: #e6f9ee; 
  color: #0a7a3d; 
}
.result-missed { 
  background: #fde8e8; 
  color: #b02121; 
}
.result-pending { 
  background: #fff5d9; 
  color: #8a5a00; 
}

/* ====== ROW STATES ====== */
tr.row-success { 
  background: #f8fffb; 
}
tr.row-missed { 
  background: #fff8f8; 
}
tr.row-live { 
  background: #f3f8ff; 
}

/* ====== QUICK FILTERS READABILITY ====== */
.quick-filters .pill {
  font-size: 13px; 
  line-height: 1; 
  padding: 8px 16px; 
  border-radius: 18px;
  border: 1px solid var(--soft); 
  background: var(--bg); 
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
}
.quick-filters .pill.active {
  background: var(--acc); 
  color: white; 
  border-color: var(--acc);
  font-weight: 600;
}
.quick-filters .pill:hover { 
  background: var(--soft);
  border-color: var(--acc);
}

/* ====== MODAL IMPLEMENTATION ====== */
#global-modal-host .modal-backdrop {
  position: fixed; 
  inset: 0; 
  background: rgba(0,0,0,.45);
  display: flex; 
  align-items: center; 
  justify-content: center; 
  z-index: 9999;
}
#global-modal-host .modal-card {
  width: min(860px, 92vw); 
  max-height: 85vh; 
  overflow: auto;
  background: var(--panel); 
  border-radius: 12px; 
  box-shadow: 0 10px 40px rgba(0,0,0,.5);
  border: 1px solid var(--soft);
}
.modal-header { 
  display: flex; 
  align-items: center; 
  justify-content: space-between; 
  padding: 14px 16px; 
  border-bottom: 1px solid var(--soft); 
}
.modal-header h3 { 
  margin: 0; 
  font-size: 18px; 
  color: var(--text);
}
.modal-close { 
  background: transparent; 
  border: 0; 
  font-size: 20px; 
  cursor: pointer; 
  color: var(--text);
}
.modal-body { 
  padding: 16px; 
}
.details-section { 
  margin-bottom: 16px; 
}
.details-section h4 { 
  margin: 0 0 8px; 
  font-size: 16px; 
}
.details-subsection h5 { 
  margin: 8px 0; 
  font-size: 14px; 
}
.details-grid { 
  display: grid; 
  grid-template-columns: repeat(2, minmax(0,1fr)); 
  gap: 6px 14px; 
}

/* Modal enhancements */
.details section { margin-bottom: 1rem; }
.details h4 { margin: 0.5rem 0; color: var(--text); font-weight: 600; }
.trigger-line { margin: 0.25rem 0; color: var(--text); }
.perf-block { 
  border-left: 3px solid var(--acc); 
  padding-left: 0.75rem; 
  margin: 0.5rem 0; 
  background: var(--soft);
  border-radius: 4px;
  padding: 8px 0 8px 12px;
}

/* Enhanced Information Section Styling */
.info-section {
  background: var(--panel);
  border: 1px solid var(--soft);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

.info-section h3 {
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 12px 0;
  border-bottom: 2px solid var(--acc);
  padding-bottom: 8px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.info-item {
  background: var(--soft);
  padding: 12px;
  border-radius: 6px;
  border-left: 3px solid var(--acc);
}

.info-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
  font-weight: 600;
}

.info-value {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}

/* Status Badge Improvements */
.status-badge {
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-live {
  background: var(--acc);
  color: white;
}

.status-finished {
  background: var(--muted);
  color: white;
}

.status-upcoming {
  background: var(--warn);
  color: white;
}