/* Global styles, variables, layout, and overlays */
html, body {
  max-width: 100%;
  overflow-x: hidden; /* Prevent horizontal scroll */
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

:root {
  --critical-red: #dc2626;
  --critical-red-bg: #fef2f2;
  --warning-amber: #f59e0b;
  --warning-amber-bg: #fffbeb;
  --info-blue: #3b82f6;
  --info-blue-bg: #eff6ff;
  --success-green: #10b981;
  --success-green-bg: #ecfdf5;
  --shadow-critical: 0 4px 20px rgba(220, 38, 38, 0.15);
  --shadow-warning: 0 4px 20px rgba(245, 158, 11, 0.15);
  --shadow-elevated: 0 8px 32px rgba(0, 0, 0, 0.08);
  --mobile-section-gap: 16px;
  --mobile-card-gap: 10px;
  --mobile-padding: 12px;
}

/* FIXED: Reusable styled section class - prevents horizontal overflow */
.styled-section {
  background: linear-gradient(135deg, var(--surface-primary, #ffffff) 0%, var(--surface-secondary, #f8f9fa) 100%);
  border-radius: 16px;
  margin: 8px auto; /* Changed from 8px 12px to auto centering */
  padding: 16px;
  border: 2px solid var(--card-border, #dee2e6);
  width: 100%;
  max-width: calc(100vw - 24px); /* Ensures section never exceeds viewport width */
  box-sizing: border-box;
  word-wrap: break-word;
  overflow-wrap: break-word;
  min-width: 0; /* Important for flex/grid children */
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary, #212529);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.title-icon {
  font-size: 18px;
  flex-shrink: 0; /* Prevent icon from shrinking */
}

.section-summary {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-secondary, #6c757d);
  font-weight: 500;
  flex-shrink: 0; /* Prevent summary from being squeezed out */
  white-space: nowrap;
}

.no-conditions, .no-insights {
  text-align: center;
  color: var(--text-secondary, #6c757d);
  font-size: 12px;
  padding: 20px;
  background: var(--surface-secondary, #f8f9fa);
  border-radius: 12px;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* ADDED: Container wrapper for better control (optional) */
.page-container {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  padding: 0;
  margin: 0;
}

/* ADDED: Mobile-specific improvements */
@media (max-width: 768px) {
  .styled-section {
    margin: 8px 8px; /* Smaller margins on mobile */
    max-width: calc(100vw - 16px);
    padding: 12px;
  }
  
  .section-title {
    font-size: 14px;
    flex-wrap: wrap; /* Allow wrapping on very small screens */
  }
  
  .section-summary {
    font-size: 10px;
  }
}

/* ADDED: Extra small screen adjustments */
@media (max-width: 480px) {
  .styled-section {
    margin: 8px 4px;
    max-width: calc(100vw - 8px);
    padding: 10px;
  }
  
  .section-title {
    gap: 6px;
  }
}

/* Modern, sharp message text */
/* Full-screen overlay */
.overlay.loading {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #f7f9fc, #ffffff);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  font-family: "Inter", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  text-align: center;
  color: #333;
  padding: 1rem;
  box-sizing: border-box;
}

/* Container to align spinner and message */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Spinner animation */
.spinner {
  animation: rotate 1s linear infinite;
  width: 64px;
  height: 64px;
  margin-bottom: 1rem;
}

.spinner .path {
  stroke-linecap: round;
  animation: dash 1.5s ease-in-out infinite;
}

/* Spinner keyframes */
@keyframes rotate {
  100% { transform: rotate(360deg); }
}

@keyframes dash {
  0% { stroke-dasharray: 1, 150; stroke-dashoffset: 0; }
  50% { stroke-dasharray: 90, 150; stroke-dashoffset: -35; }
  100% { stroke-dasharray: 90, 150; stroke-dashoffset: -124; }
}

/* Loading message styling */
.overlay.loading .msg {
  font-size: 1.1rem;
  font-weight: 500;
  color: #555;
  line-height: 1.4;
  max-width: 280px;
  letter-spacing: 0.3px;
}


/* Simplified fadeIn animation */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Container to center content */
.empty-container {
  max-width: 400px;
}

/* Icon at the top */
.empty-icon {
  font-size: 5rem;
  color: #6c63ff;
  margin-bottom: 1rem;
  animation: float 2s ease-in-out infinite;
}

/* Loading / info message container */
.overlay {
  position: fixed;       /* Cover entire screen */
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.95); /* subtle light overlay */
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  text-align: center;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

/* Spinner */
.overlay .spinner {
  width: 60px;
  height: 60px;
  border: 6px solid #f3f3f3;  /* light gray */
  border-top: 6px solid #6c63ff; /* purple highlight */
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Message text */
.overlay .msg {
  font-size: 1.4rem;
  font-weight: 500;
  color: #333;
  max-width: 400px;
  background: #f0f4ff;
  padding: 1rem 1.5rem;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  animation: fadeInUp 0.8s ease forwards;
}

/* Subtle floating animation */
@keyframes fadeInUp {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}
/* Retry / Refresh button */
#retry-button {
  background-color: #6c63ff;       /* Primary purple */
  color: #fff;                     /* White text */
  font-size: 1rem;                 /* Comfortable reading size */
  font-weight: 600;
  padding: 0.75rem 1.5rem;         /* Top-bottom, left-right spacing */
  border: none;                    /* Remove default border */
  border-radius: 12px;             /* Rounded corners */
  cursor: pointer;                 /* Pointer on hover */
  box-shadow: 0 4px 12px rgba(0,0,0,0.15); /* Soft shadow */
  transition: all 0.3s ease;       /* Smooth hover animation */
}

/* Hover state */
#retry-button:hover {
  background-color: #574fd6;       /* Slightly darker purple */
  transform: translateY(-2px);     /* Subtle lift effect */
  box-shadow: 0 6px 14px rgba(0,0,0,0.2);
}

/* Active / click state */
#retry-button:active {
  transform: translateY(0);
  box-shadow: 0 3px 8px rgba(0,0,0,0.15);
}

/* Focus state (keyboard navigation) */
#retry-button:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(108,99,255,0.4);
}


