/* ========================================
   Analytics Dashboard Styles
   ======================================== */

.analytics-page {
  padding: 2rem 0;
}

/* ========================================
   Metric Cards (Top Row)
   ======================================== */

.metric-card {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 16px;
  padding: 1.5rem;
  color: white;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  position: relative;
  overflow: hidden;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.metric-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 100px;
  height: 100px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  transform: translate(30%, -30%);
}

.metric-icon {
  font-size: 3rem;
  opacity: 0.9;
  flex-shrink: 0;
}

.metric-content {
  flex: 1;
}

.metric-label {
  font-size: 0.85rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.9;
  margin-bottom: 0.5rem;
}

.metric-value {
  font-size: 2.5rem;
  font-weight: 700;
  margin: 0;
  line-height: 1;
  display: inline-block;
}

.metric-unit {
  font-size: 1rem;
  font-weight: 500;
  opacity: 0.8;
  margin-left: 0.25rem;
}

/* Different gradient colors for variety */
.metric-card:nth-child(1) {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.metric-card:nth-child(2) {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.metric-card:nth-child(3) {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.metric-card:nth-child(4) {
  background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

/* ========================================
   Status Cards (Second Row)
   ======================================== */

.status-card {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  border-left: 4px solid #ccc;
  height: 100%;
}

.status-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.12);
}

.status-card h6 {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6c757d;
  margin-bottom: 0.75rem;
}

.status-card h3 {
  font-size: 2.5rem;
  font-weight: 700;
  margin: 0;
  line-height: 1;
}

.status-card small {
  font-size: 0.75rem;
  color: #6c757d;
  margin-top: 0.5rem;
  display: block;
}

.status-success {
  border-left-color: #28a745;
}

.status-success h3 {
  color: #28a745;
}

.status-warning {
  border-left-color: #ffc107;
}

.status-warning h3 {
  color: #ffc107;
}

.status-danger {
  border-left-color: #dc3545;
}

.status-danger h3 {
  color: #dc3545;
}

.status-info {
  border-left-color: #17a2b8;
}

.status-info h3 {
  color: #17a2b8;
}

/* ========================================
   Info Cards (Third Row)
   ======================================== */

.info-card {
  background: white;
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: box-shadow 0.2s ease;
}

.info-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.info-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: #6c757d;
}

.info-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #333;
}

/* ========================================
   Progress Bars
   ======================================== */

.progress {
  background-color: rgba(255, 255, 255, 0.3);
  border-radius: 10px;
  overflow: hidden;
}

.progress-bar {
  transition: width 1.5s ease-in-out;
  border-radius: 10px;
}

/* ========================================
   Date Range Selector
   ======================================== */

#dateRange {
  border: 2px solid #e9ecef;
  border-radius: 8px;
  padding: 0.5rem 2.5rem 0.5rem 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

#dateRange:hover {
  border-color: #667eea;
}

#dateRange:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
  outline: none;
}

/* ========================================
   Card Styling
   ======================================== */

.card {
  border: none;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.card-header {
  background: white;
  border-bottom: 2px solid #f0f0f0;
  border-radius: 12px 12px 0 0 !important;
  padding: 1.25rem 1.5rem;
}

.card-header h5 {
  color: #333;
  font-weight: 600;
}

/* ========================================
   Responsive Design
   ======================================== */

@media (max-width: 768px) {
  .metric-card {
    flex-direction: column;
    text-align: center;
  }

  .metric-icon {
    font-size: 2.5rem;
  }

  .metric-value {
    font-size: 2rem;
  }

  .status-card h3 {
    font-size: 2rem;
  }

  .info-card {
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
  }
}

/* ========================================
   Animation Classes
   ======================================== */

.fade-in {
  animation: fadeIn 0.5s ease-in;
}

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

.scale-in {
  animation: scaleIn 0.3s ease-out;
}

@keyframes scaleIn {
  from {
    transform: scale(0.95);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* ========================================
   Timeline Styles
   ======================================== */

.timeline-container {
  padding: 1rem;
  max-height: 800px;
  overflow-y: auto;
}

.timeline-item {
  display: flex;
  gap: 1.5rem;
  padding: 1.25rem;
  margin-bottom: 1rem;
  background: white;
  border: 1px solid #e9ecef;
  border-radius: 12px;
  transition: all 0.3s ease;
  cursor: pointer;
}

.timeline-item:hover {
  border-color: #667eea;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.1);
  transform: translateX(5px);
}

.timeline-date {
  flex-shrink: 0;
  width: 100px;
  text-align: right;
  font-weight: 600;
  color: #495057;
  padding-top: 0.25rem;
}

.timeline-time {
  display: block;
  font-size: 0.85rem;
  color: #6c757d;
  font-weight: 400;
  margin-top: 0.25rem;
}

.timeline-content {
  flex: 1;
  min-width: 0;
}

.timeline-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.timeline-icon {
  font-size: 1.5rem;
}

.timeline-header h6 {
  font-weight: 600;
  color: #212529;
  margin: 0;
  flex-shrink: 0;
}

.status-badge-loaded {
  background-color: #d4edda;
  color: #155724;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-badge-loaded-with-errors {
  background-color: #fff3cd;
  color: #856404;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-badge-failed {
  background-color: #f8d7da;
  color: #721c24;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.timeline-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-top: 0.75rem;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.stat-label {
  font-size: 0.75rem;
  color: #6c757d;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

.stat-value {
  font-size: 1rem;
  font-weight: 600;
  color: #212529;
}

.timeline-error {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background-color: #f8d7da;
  border-left: 3px solid #dc3545;
  border-radius: 6px;
  font-size: 0.85rem;
  color: #721c24;
}

.view-details {
  white-space: nowrap;
  font-weight: 500;
  padding: 0.375rem 1rem;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.view-details:hover {
  background-color: #667eea;
  border-color: #667eea;
  color: white;
  transform: translateX(3px);
}

/* ========================================
   Search & Filter Controls
   ======================================== */

#searchInput,
#statusFilter {
  border: 2px solid #e9ecef;
  border-radius: 8px;
  transition: border-color 0.2s ease;
}

#searchInput:focus,
#statusFilter:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
  outline: none;
}

/* ========================================
   Scrollbar Styling
   ======================================== */

.timeline-container::-webkit-scrollbar {
  width: 8px;
}

.timeline-container::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
}

.timeline-container::-webkit-scrollbar-thumb {
  background: #667eea;
  border-radius: 10px;
}

.timeline-container::-webkit-scrollbar-thumb:hover {
  background: #5568d3;
}

/* ========================================
   Responsive Timeline
   ======================================== */

@media (max-width: 768px) {
  .timeline-item {
    flex-direction: column;
    gap: 1rem;
  }

  .timeline-date {
    width: 100%;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
    padding-bottom: 0.5rem;
  }

  .timeline-time {
    display: inline;
    margin-left: 0.5rem;
  }

  .timeline-stats {
    gap: 1rem;
  }

  .timeline-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .view-details {
    width: 100%;
  }
}

/* ========================================
   Loading State
   ======================================== */

.timeline-loading {
  text-align: center;
  padding: 3rem;
  color: #6c757d;
}

.timeline-loading::after {
  content: '';
  display: inline-block;
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-top: 1rem;
}

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

/* ========================================
   Detail Modal Styles
   ======================================== */

.detail-container {
  padding: 0.5rem;
}

.detail-header {
  padding-bottom: 1.5rem;
  border-bottom: 2px solid #e9ecef;
  margin-bottom: 1.5rem;
}

.detail-header h4 {
  color: #212529;
  font-weight: 600;
}

.detail-section {
  margin-bottom: 2rem;
}

.detail-section-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: #495057;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #f0f0f0;
}

/* Metrics Grid */
.detail-metric {
  background: #f8f9fa;
  border-radius: 10px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: transform 0.2s ease;
}

.detail-metric:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
}

.detail-metric-label {
  font-size: 0.75rem;
  color: #6c757d;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

.detail-metric-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #212529;
}

/* Info Cards */
.detail-info-card {
  background: white;
  border: 2px solid #e9ecef;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  transition: border-color 0.2s ease;
}

.detail-info-card:hover {
  border-color: #667eea;
}

.detail-info-label {
  font-size: 0.75rem;
  color: #6c757d;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.detail-info-value {
  font-size: 1.1rem;
  font-weight: 600;
  color: #212529;
}

/* Timeline */
.detail-timeline {
  background: #f8f9fa;
  border-left: 4px solid #667eea;
  border-radius: 8px;
  padding: 1rem 1.5rem;
}

.detail-timeline-item {
  padding: 0.5rem 0;
  font-size: 0.95rem;
  color: #495057;
}

.detail-timeline-item:not(:last-child) {
  border-bottom: 1px solid #dee2e6;
}

.detail-timeline-item strong {
  color: #212529;
  font-weight: 600;
}

/* IDs Section */
.detail-ids {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 1rem;
  font-size: 0.9rem;
}

.detail-ids div {
  padding: 0.5rem 0;
  color: #495057;
}

.detail-ids div:not(:last-child) {
  border-bottom: 1px solid #dee2e6;
}

.detail-ids strong {
  color: #212529;
  font-weight: 600;
  margin-right: 0.5rem;
}

.detail-ids code {
  background: white;
  color: #667eea;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.85rem;
  border: 1px solid #e9ecef;
}

/* Error Section */
.detail-section pre {
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: 'Courier New', monospace;
  font-size: 0.85rem;
  line-height: 1.6;
}

/* Modal Customization */
#detailModal .modal-content {
  border: none;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

#detailModal .modal-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 16px 16px 0 0;
  padding: 1.25rem 1.5rem;
}

#detailModal .modal-title {
  font-weight: 600;
}

#detailModal .btn-close {
  filter: brightness(0) invert(1);
}

#detailModal .modal-body {
  padding: 1.5rem;
  max-height: 70vh;
}

#detailModal .modal-footer {
  border-top: 2px solid #f0f0f0;
  padding: 1rem 1.5rem;
}

/* Responsive Detail Modal */
@media (max-width: 768px) {
  .detail-metric-value {
    font-size: 1.25rem;
  }

  .detail-info-value {
    font-size: 1rem;
  }

  #detailModal .modal-dialog {
    margin: 0.5rem;
  }
}

/* ========================================
   Compact Timeline Stats (Option A)
   ======================================== */

.timeline-stats-compact {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-top: 0.75rem;
  font-size: 0.9rem;
  color: #495057;
}

.stat-compact {
  white-space: nowrap;
}

.stat-compact strong {
  color: #212529;
  font-weight: 600;
  margin-right: 0.25rem;
}
