/* CSS Variables for Theming */
:root {
  --primary-color: #4f46e5;
  --primary-hover: #4338ca;
  --secondary-color: #6b7280;
  --success-color: #10b981;
  --danger-color: #ef4444;
  --warning-color: #f59e0b;
  --background: #f9fafb;
  --surface: #ffffff;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --border-color: #e5e7eb;
  --shadow: rgba(0, 0, 0, 0.1);
  --shadow-lg: rgba(0, 0, 0, 0.15);
  --radius: 8px;
  --radius-lg: 12px;
  --transition: all 0.3s ease;
}

/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--background);
  color: var(--text-primary);
  line-height: 1.6;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border-color);
  padding: 20px 0;
  box-shadow: 0 1px 3px var(--shadow);
}

.header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-logo {
  height: 32px;
  width: auto;
}

.logo-text {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary-color);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.username {
  color: var(--text-secondary);
  font-weight: 500;
}

/* Main Content */
.main-content {
  padding: 30px 20px;
}

/* Action Bar */
.action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  flex-wrap: wrap;
  gap: 15px;
}

.loop-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.loop-status {
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
}

.loop-status.running {
  background: #dcfce7;
  color: #166534;
}

.loop-status.stopped {
  background: #fee2e2;
  color: #991b1b;
}

.loop-status.stopping {
  background: #fef3c7;
  color: #92400e;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.search-box {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.search-box input {
  padding: 10px 35px 10px 15px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  width: 250px;
  font-size: 14px;
  transition: var(--transition);
}

.search-box input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.search-clear-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  background: var(--secondary-color);
  color: white;
  border-radius: 50%;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: var(--transition);
}

.search-clear-btn:hover {
  background: var(--text-primary);
}

.search-clear-btn:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.3);
}

/* Statistics Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.stat-card {
  background: var(--surface);
  padding: 20px;
  border-radius: var(--radius-lg);
  box-shadow: 0 1px 3px var(--shadow);
  text-align: center;
  transition: var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 6px var(--shadow-lg);
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 5px;
}

.stat-label {
  color: var(--text-secondary);
  font-size: 14px;
}

/* Crawlers Grid */
.crawlers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 20px;
}

.crawler-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: 0 1px 3px var(--shadow);
  transition: var(--transition);
  border: 2px solid transparent;
}

.crawler-card:hover {
  box-shadow: 0 4px 6px var(--shadow-lg);
  border-color: var(--primary-color);
}

.crawler-card.disabled {
  opacity: 0.6;
}

.crawler-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 15px;
}

.crawler-header h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.crawler-status {
  display: flex;
  gap: 5px;
}

.badge {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-running {
  background: #dcfce7;
  color: #166534;
}

.badge-success {
  background: #d1fae5;
  color: #065f46;
}

.badge-failed {
  background: #fee2e2;
  color: #991b1b;
}

.badge-idle {
  background: #e5e7eb;
  color: #374151;
}

.crawler-description {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 15px;
  min-height: 40px;
}

.crawler-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 15px;
  padding: 15px;
  background: var(--background);
  border-radius: var(--radius);
}

.info-item {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
}

.info-item .label {
  color: var(--text-secondary);
  font-weight: 500;
}

.info-item .value {
  color: var(--text-primary);
  font-weight: 600;
}

.crawler-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 15px;
}

.crawler-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 15px;
  border-top: 1px solid var(--border-color);
}

/* Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #cbd5e1;
  transition: 0.3s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--success-color);
}

input:checked + .slider:before {
  transform: translateX(24px);
}

/* Buttons */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary-color);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--secondary-color);
  color: white;
}

.btn-secondary:hover:not(:disabled) {
  background: #4b5563;
}

.btn-success {
  background: var(--success-color);
  color: white;
}

.btn-success:hover:not(:disabled) {
  background: #059669;
}

.btn-danger {
  background: var(--danger-color);
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background: #dc2626;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-block {
  width: 100%;
  justify-content: center;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 1px 3px var(--shadow);
}

.empty-state h2 {
  font-size: 24px;
  margin-bottom: 10px;
  color: var(--text-primary);
}

.empty-state p {
  color: var(--text-secondary);
  margin-bottom: 20px;
}

/* No Results State - slightly different styling */
.empty-state.no-results-state {
  background: linear-gradient(135deg, var(--surface) 0%, #f8fafc 100%);
  border: 1px dashed var(--border-color);
}

.empty-state.no-results-state h2 {
  color: var(--text-secondary);
}

/* Loading State */
.loading-state {
  text-align: center;
  padding: 60px 20px;
}

.spinner {
  border: 4px solid var(--border-color);
  border-top: 4px solid var(--primary-color);
  border-radius: 50%;
  width: 50px;
  height: 50px;
  animation: spin 1s linear infinite;
  margin: 0 auto 20px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  overflow-y: auto;
  padding: 20px;
}

.modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 600px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  animation: modalSlideIn 0.3s ease;
}

.modal-large {
  max-width: 900px;
}

.modal-small {
  max-width: 400px;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
  font-size: 20px;
  font-weight: 600;
}

.close-btn {
  background: none;
  border: none;
  font-size: 28px;
  color: var(--text-secondary);
  cursor: pointer;
  line-height: 1;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  transition: var(--transition);
}

.close-btn:hover {
  background: var(--background);
  color: var(--text-primary);
}

/* Forms */
form {
  padding: 20px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--text-primary);
  font-size: 14px;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="file"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.form-group small {
  display: block;
  margin-top: 5px;
  color: var(--text-secondary);
  font-size: 12px;
}

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 15px;
  border-top: 1px solid var(--border-color);
}

.error-message {
  background: #fee2e2;
  color: #991b1b;
  padding: 12px;
  border-radius: var(--radius);
  font-size: 14px;
  border-left: 4px solid var(--danger-color);
}

.warning-message {
  background: #fef3c7;
  color: #92400e;
  padding: 12px;
  border-radius: var(--radius);
  font-size: 14px;
  border-left: 4px solid var(--warning-color);
}

.progress-bar {
  position: relative;
  height: 30px;
  background: var(--background);
  border-radius: var(--radius);
  overflow: hidden;
  margin-top: 15px;
}

.progress-fill {
  height: 100%;
  background: var(--primary-color);
  transition: width 0.3s ease;
}

.progress-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-weight: 600;
  color: var(--text-primary);
  font-size: 14px;
}

/* Log Viewer */
.log-viewer {
  padding: 20px;
}

.log-controls {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
}

.log-content {
  background: #1e293b;
  color: #e2e8f0;
  padding: 20px;
  border-radius: var(--radius);
  font-family: 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.5;
  max-height: 500px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.log-content::-webkit-scrollbar {
  width: 10px;
}

.log-content::-webkit-scrollbar-track {
  background: #0f172a;
  border-radius: var(--radius);
}

.log-content::-webkit-scrollbar-thumb {
  background: #475569;
  border-radius: var(--radius);
}

.log-content::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: -100px;
  right: 20px;
  background: var(--surface);
  padding: 15px 20px;
  border-radius: var(--radius);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  transition: bottom 0.3s ease;
  z-index: 2000;
  max-width: 400px;
  font-weight: 500;
}

.toast.show {
  bottom: 20px;
}

.toast-success {
  border-left: 4px solid var(--success-color);
  color: var(--success-color);
}

.toast-error {
  border-left: 4px solid var(--danger-color);
  color: var(--danger-color);
}

.toast-info {
  border-left: 4px solid var(--primary-color);
  color: var(--primary-color);
}

/* Login Page */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
  width: 100%;
  max-width: 400px;
  padding: 20px;
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
}

.logo-container {
  text-align: center;
  margin-bottom: 24px;
}

.login-logo {
  height: 48px;
  width: auto;
}

.login-card h1 {
  text-align: center;
  margin-bottom: 10px;
  color: var(--primary-color);
  font-size: 28px;
}

.login-card .subtitle {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 30px;
}

.btn-google {
  background: #ffffff;
  color: #111827;
  border: 1px solid #e5e7eb;
  gap: 10px;
}

.btn-google:hover:not(:disabled) {
  background: #f9fafb;
}

.btn-google:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}

.google-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  color: var(--text-secondary);
  font-size: 13px;
  user-select: none;
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-color);
}

.login-divider span {
  padding: 0 2px;
}

.login-footer {
  text-align: center;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
}

.login-footer p {
  color: var(--text-secondary);
  font-size: 13px;
  margin: 5px 0;
}

.login-footer .small {
  font-size: 11px;
  color: var(--warning-color);
}

/* Responsive Design */
@media (max-width: 768px) {
  .header .container {
    flex-direction: column;
    gap: 15px;
  }
  
  .action-bar {
    flex-direction: column;
    align-items: stretch;
  }
  
  .search-box {
    width: 100%;
  }
  
  .search-box input {
    width: 100%;
  }
  
  .crawlers-grid {
    grid-template-columns: 1fr;
  }
  
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .crawler-actions {
    flex-direction: column;
  }
  
  .crawler-actions .btn {
    width: 100%;
  }
  
  .modal-content {
    margin: 0;
    max-height: 100vh;
    overflow-y: auto;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .login-card {
    padding: 30px 20px;
  }
}

/* =================================
   Health & Status Badges
   ================================= */

.badge-quarantined {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.badge-warning {
  background: #fef3c7;
  color: #92400e;
}

.badge-healthy {
  background: #d1fae5;
  color: #065f46;
}

.badge-critical {
  background: #fee2e2;
  color: #991b1b;
}

.badge-info {
  background: #dbeafe;
  color: #1e40af;
}

/* Quarantined Card */
.crawler-card.quarantined {
  border-color: var(--danger-color);
  background: linear-gradient(135deg, #fff 0%, #fef2f2 100%);
}

.quarantine-banner {
  background: #fee2e2;
  border: 1px solid #fca5a5;
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.quarantine-icon {
  font-size: 18px;
}

.quarantine-banner span {
  flex: 1;
  color: #991b1b;
  font-weight: 500;
  font-size: 13px;
}

.btn-warning {
  background: var(--warning-color);
  color: white;
}

.btn-warning:hover:not(:disabled) {
  background: #d97706;
}

/* Success Rate Indicators */
.success-rate-good {
  color: var(--success-color);
}

.success-rate-medium {
  color: var(--warning-color);
}

.success-rate-poor {
  color: var(--danger-color);
}

.failure-count {
  color: var(--danger-color);
  font-weight: 700;
}

/* Stats Card Clickable */
.stat-card-clickable {
  cursor: pointer;
}

.stat-card-clickable:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 12px var(--shadow-lg);
}

/* =================================
   Alerts Dropdown & Panel
   ================================= */

.alerts-dropdown {
  position: relative;
}

.btn-icon {
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  position: relative;
  color: var(--text-secondary);
  border-radius: var(--radius);
  transition: var(--transition);
}

.btn-icon:hover {
  background: var(--background);
  color: var(--text-primary);
}

.alerts-btn svg {
  display: block;
}

.alert-badge {
  position: absolute;
  top: 0;
  right: 0;
  background: var(--danger-color);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.alerts-panel {
  position: absolute;
  top: 100%;
  right: 0;
  width: 380px;
  max-height: 500px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  display: none;
  z-index: 1000;
  overflow: hidden;
}

.alerts-panel.show {
  display: block;
}

.alerts-header {
  padding: 15px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.alerts-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.alerts-actions {
  display: flex;
  gap: 5px;
}

.alerts-list {
  max-height: 350px;
  overflow-y: auto;
}

.alert-item {
  padding: 12px 15px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  gap: 10px;
  transition: var(--transition);
  cursor: pointer;
}

.alert-item:hover {
  background: var(--background);
}

.alert-item.unread {
  background: #f0f9ff;
}

.alert-item.severity-critical {
  border-left: 3px solid var(--danger-color);
}

.alert-item.severity-warning {
  border-left: 3px solid var(--warning-color);
}

.alert-item.severity-info {
  border-left: 3px solid var(--primary-color);
}

.alert-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.icon-critical {
  color: var(--danger-color);
}

.icon-warning {
  color: var(--warning-color);
}

.icon-info {
  color: var(--primary-color);
}

.alert-content {
  flex: 1;
  min-width: 0;
}

.alert-message {
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
  margin-bottom: 4px;
  word-break: break-word;
}

.alert-meta {
  font-size: 11px;
  color: var(--text-secondary);
  display: flex;
  gap: 8px;
}

.alert-crawler {
  font-weight: 600;
}

.alert-item .alert-actions {
  display: flex;
  gap: 5px;
  align-items: center;
}

.alert-item .btn-icon {
  padding: 4px;
  font-size: 14px;
}

.alerts-footer {
  padding: 10px 15px;
  border-top: 1px solid var(--border-color);
  text-align: center;
}

.alerts-footer a {
  color: var(--primary-color);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
}

.alerts-footer a:hover {
  text-decoration: underline;
}

.no-alerts {
  padding: 30px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
}

/* =================================
   Alerts Modal
   ================================= */

.alerts-filter {
  padding: 15px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  gap: 10px;
  align-items: center;
}

.alerts-filter select {
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  font-size: 14px;
}

.alerts-modal-list {
  max-height: 500px;
  overflow-y: auto;
  padding: 15px;
}

.alert-item-large {
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 15px;
  margin-bottom: 10px;
}

.alert-item-large.unread {
  background: #f0f9ff;
  border-color: var(--primary-color);
}

.alert-item-large.severity-critical {
  border-left: 4px solid var(--danger-color);
}

.alert-item-large.severity-warning {
  border-left: 4px solid var(--warning-color);
}

.alert-item-large .alert-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.alert-item-large .alert-body {
  margin-bottom: 12px;
}

.alert-item-large .alert-message {
  font-size: 14px;
  margin-bottom: 5px;
}

.alert-item-large .alert-crawler {
  font-size: 12px;
  color: var(--text-secondary);
}

.alert-item-large .alert-footer {
  display: flex;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
}

/* =================================
   Crawler Card Highlight Animation
   ================================= */

.crawler-card.highlight {
  animation: highlightPulse 0.5s ease-in-out 3;
}

@keyframes highlightPulse {
  0%, 100% {
    box-shadow: 0 1px 3px var(--shadow);
  }
  50% {
    box-shadow: 0 0 0 4px var(--primary-color), 0 4px 6px var(--shadow-lg);
  }
}

/* =================================
   Toast Warning Style
   ================================= */

.toast-warning {
  border-left: 4px solid var(--warning-color);
  color: var(--warning-color);
}

/* =================================
   Crawler Stats Modal
   ================================= */

.stats-modal-body {
  padding: 20px;
  max-height: 70vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 15px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Health Banner */
.stats-health-banner {
  margin-bottom: 20px;
}

.stats-banner {
  padding: 15px 20px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 15px;
  font-size: 14px;
}

.stats-banner-critical {
  background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
  border: 1px solid #fca5a5;
  color: #991b1b;
}

.stats-banner-warning {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 1px solid #fcd34d;
  color: #92400e;
}

.stats-banner-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.stats-banner-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stats-banner-content strong {
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Metrics Grid */
.stats-metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
  margin-bottom: 30px;
}

.stats-metric-card {
  background: linear-gradient(135deg, #ffffff 0%, #f9fafb 100%);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-align: center;
  transition: var(--transition);
}

.stats-metric-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
  border-color: var(--primary-color);
}

.stats-metric-icon {
  font-size: 32px;
  margin-bottom: 10px;
}

.stats-metric-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 5px;
  line-height: 1.2;
}

.stats-metric-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Stats Sections */
.stats-section {
  margin-bottom: 25px;
  padding: 20px;
  background: var(--background);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
}

.stats-section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.stats-loading {
  text-align: center;
  padding: 20px;
  color: var(--text-secondary);
}

.stats-empty {
  text-align: center;
  padding: 20px;
  color: var(--text-secondary);
  font-size: 14px;
}

/* Recent Executions Timeline */
.stats-timeline {
  display: flex;
  gap: 4px;
  padding: 10px;
  background: var(--surface);
  border-radius: var(--radius);
  overflow-x: auto;
}

.timeline-item {
  flex: 1;
  min-width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 18px;
  transition: var(--transition);
  cursor: pointer;
}

.timeline-success {
  background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
  color: #065f46;
  border: 1px solid #6ee7b7;
}

.timeline-success:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 8px rgba(16, 185, 129, 0.3);
}

.timeline-failure {
  background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.timeline-failure:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 8px rgba(239, 68, 68, 0.3);
}

/* 7-Day Performance Chart */
.stats-chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  gap: 8px;
  padding: 20px;
  background: var(--surface);
  border-radius: var(--radius);
  min-height: 180px;
}

.chart-bar-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.chart-bar-container {
  width: 100%;
  height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 2px;
  position: relative;
}

.chart-bar {
  width: 100%;
  min-height: 2px;
  border-radius: 4px 4px 0 0;
  transition: var(--transition);
  cursor: pointer;
}

.chart-bar-success {
  background: linear-gradient(180deg, #10b981 0%, #059669 100%);
}

.chart-bar-failed {
  background: linear-gradient(180deg, #ef4444 0%, #dc2626 100%);
}

.chart-bar:hover {
  opacity: 0.8;
  transform: scaleY(1.05);
}

.chart-bar-label {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
  text-align: center;
}

.chart-bar-count {
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 700;
  text-align: center;
}

/* Failure Breakdown */
.stats-failures {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.failure-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.failure-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.failure-code {
  font-weight: 600;
  color: var(--text-primary);
  font-family: 'Courier New', monospace;
  background: var(--background);
  padding: 2px 8px;
  border-radius: 4px;
}

.failure-count {
  color: var(--text-secondary);
  font-size: 12px;
}

.failure-bar-container {
  position: relative;
  height: 24px;
  background: var(--background);
  border-radius: var(--radius);
  overflow: hidden;
}

.failure-bar {
  height: 100%;
  background: linear-gradient(90deg, #ef4444 0%, #dc2626 100%);
  border-radius: var(--radius);
  transition: width 0.5s ease;
}

.failure-percent {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-primary);
}

/* Health Details */
.health-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
}

.health-detail-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 12px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
}

.health-detail-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.health-detail-value {
  font-size: 15px;
  color: var(--text-primary);
  font-weight: 600;
}

.health-status-good {
  color: var(--success-color) !important;
}

.health-status-warning {
  color: var(--warning-color) !important;
}

.health-status-bad {
  color: var(--danger-color) !important;
}

.text-danger {
  color: var(--danger-color);
}

.text-warning {
  color: var(--warning-color);
}

/* Responsive Stats Modal */
@media (max-width: 768px) {
  .stats-metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .stats-modal-body {
    max-height: 60vh;
  }
  
  .chart-bar-label {
    font-size: 9px;
  }
  
  .health-detail-grid {
    grid-template-columns: 1fr;
  }
}
