/* Emergency Plumbing Guide Styles */
/* BEM naming convention with epg prefix */

/* CSS Reset and Base Styles */
.epg *,
.epg *::before,
.epg *::after {
  box-sizing: border-box;
}

.epg {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  line-height: 1.5;
  color: #333333;
  background-color: #f5f5f5;
  margin: 0;
  padding: 0;
}

/* Container */
.epg__container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
}

/* Header */
.epg__header {
  text-align: center;
  margin-bottom: 32px;
}

.epg__title {
  font-size: 2.5rem;
  font-weight: 700;
  color: #2c5aa0;
  margin: 0 0 16px 0;
  line-height: 1.2;
}

.epg__subtitle {
  font-size: 1.125rem;
  color: #666666;
  margin: 0;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

/* Card Grid */
.epg__card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 32px;
}

/* Individual Cards */
.epg__card {
  background: #ffffff;
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  padding: 24px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
  overflow: hidden;
}

.epg__card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: #388e3c;
  transition: all 0.3s ease;
}

.epg__card--high-urgency::before {
  background: #d32f2f;
}

.epg__card--medium-urgency::before {
  background: #f57c00;
}

.epg__card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
  border-color: #2c5aa0;
}

.epg__card:focus {
  outline: 3px solid #2c5aa0;
  outline-offset: 2px;
}

.epg__card-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  display: block;
}

.epg__card-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #333333;
  margin: 0 0 8px 0;
  line-height: 1.3;
}

.epg__card-urgency {
  font-size: 0.875rem;
  font-weight: 500;
  color: #666666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Checklist Styles */
.epg__checklist {
  background: #ffffff;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  display: none;
}

.epg__checklist--active {
  display: block;
  animation: fadeIn 0.3s ease-in-out;
}

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

/* Navigation */
.epg__navigation {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.epg__back-btn,
.epg__print-btn {
  background: #2c5aa0;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  min-height: 44px;
  min-width: 44px;
}

.epg__back-btn:hover,
.epg__print-btn:hover {
  background: #1e3f73;
  transform: translateY(-2px);
}

.epg__back-btn:focus,
.epg__print-btn:focus {
  outline: 3px solid #2c5aa0;
  outline-offset: 2px;
}

.epg__print-btn {
  background: #388e3c;
}

.epg__print-btn:hover {
  background: #2e7d32;
}

/* Checklist Header */
.epg__checklist-header {
  margin-bottom: 32px;
  text-align: center;
}

.epg__checklist-title {
  font-size: 2rem;
  font-weight: 700;
  color: #2c5aa0;
  margin: 0 0 16px 0;
  line-height: 1.2;
}

/* Progress Bar */
.epg__progress-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 16px;
}

.epg__progress-bar {
  width: 200px;
  height: 8px;
  background: #e0e0e0;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.epg__progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #4caf50, #388e3c);
  width: 0%;
  transition: width 0.3s ease;
  border-radius: 4px;
}

.epg__progress-text {
  font-size: 0.875rem;
  font-weight: 500;
  color: #666666;
  min-width: 80px;
}

/* Safety Warning */
.epg__safety-warning {
  background: #fff3cd;
  border: 1px solid #ffeaa7;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 24px;
  color: #856404;
  font-weight: 500;
}

.epg__safety-warning::before {
  content: '⚠️ ';
  font-size: 1.2em;
}

/* Tools Section */
.epg__tools-section {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 32px;
}

.epg__tools-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #2c5aa0;
  margin: 0 0 16px 0;
}

.epg__tools-category {
  margin-bottom: 16px;
}

.epg__tools-category:last-child {
  margin-bottom: 0;
}

.epg__tools-category-title {
  font-size: 1rem;
  font-weight: 600;
  color: #333333;
  margin: 0 0 8px 0;
}

.epg__tools-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.epg__tools-item {
  padding: 4px 0;
  color: #555555;
  font-size: 0.9rem;
}

.epg__tools-item::before {
  content: '• ';
  color: #2c5aa0;
  font-weight: bold;
}

/* Checklist Items */
.epg__checklist-items {
  border: none;
  padding: 0;
  margin: 0 0 32px 0;
}

/* Print Section */
.epg__print-section {
  text-align: center;
  padding: 24px 0;
  border-top: 2px solid #e0e0e0;
  margin-top: 32px;
}

.epg__checklist-legend {
  font-size: 1.25rem;
  font-weight: 600;
  color: #2c5aa0;
  margin: 0 0 20px 0;
  padding: 0;
}

.epg__checklist-item {
  display: flex;
  align-items: flex-start;
  padding: 12px 0;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  transition: background-color 0.2s ease;
  min-width: 0; /* Prevents flex items from overflowing */
  width: 100%; /* Ensures full width */
}

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

.epg__checklist-item:hover {
  background-color: #f8f9fa;
  border-radius: 6px;
  margin: 0 -8px;
  padding: 12px 8px;
}

.epg__checklist-item--checked {
  opacity: 0.7;
}

.epg__checklist-item--checked .epg__checklist-text {
  text-decoration: line-through;
  color: #888888;
}

/* Custom Checkbox */
.epg__checkbox {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

.epg__checkbox-custom {
  display: inline-block;
  width: 20px;
  height: 20px;
  background: #ffffff;
  border: 2px solid #e0e0e0;
  border-radius: 4px;
  margin-right: 12px;
  margin-top: 2px;
  flex-shrink: 0;
  flex-grow: 0; /* Prevents growing */
  position: relative;
  transition: all 0.2s ease;
  min-width: 20px; /* Ensures minimum width */
}

.epg__checkbox:checked + .epg__checkbox-custom {
  background: #4caf50;
  border-color: #4caf50;
}

.epg__checkbox:checked + .epg__checkbox-custom::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #ffffff;
  font-size: 14px;
  font-weight: bold;
}

.epg__checkbox:focus + .epg__checkbox-custom {
  outline: 3px solid #2c5aa0;
  outline-offset: 2px;
}

.epg__checklist-text {
  flex: 1;
  font-size: 1rem;
  line-height: 1.5;
  color: #333333;
  margin: 0;
  min-width: 0; /* Allows text to wrap properly */
  word-wrap: break-word; /* Handles long words */
  overflow-wrap: break-word; /* Modern property for word wrapping */
}

/* Loading State */
.epg__loading {
  text-align: center;
  padding: 40px 20px;
}

.epg__loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #2c5aa0;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}

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

/* Error State */
.epg__error {
  text-align: center;
  padding: 40px 20px;
  background: #f8d7da;
  border: 1px solid #f5c6cb;
  border-radius: 8px;
  color: #721c24;
}

.epg__error h2 {
  margin: 0 0 16px 0;
  color: #721c24;
}

.epg__retry-btn {
  background: #dc3545;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-top: 16px;
}

.epg__retry-btn:hover {
  background: #c82333;
  transform: translateY(-2px);
}

/* Responsive Design */
@media (min-width: 768px) {
  .epg__card-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
  }
  
  .epg__container {
    padding: 24px;
  }
  
  .epg__title {
    font-size: 3rem;
  }
  
  .epg__checklist {
    padding: 32px;
  }
  
  .epg__navigation {
    flex-wrap: nowrap;
  }
}

@media (min-width: 1024px) {
  .epg__card-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
  }
  
  .epg__container {
    padding: 32px;
  }
  
  .epg__title {
    font-size: 3.5rem;
  }
  
  .epg__checklist {
    padding: 40px;
  }
}

/* Mobile Optimizations */
@media (max-width: 767px) {
  .epg__container {
    padding: 12px;
  }
  
  .epg__title {
    font-size: 2rem;
  }
  
  .epg__subtitle {
    font-size: 1rem;
  }
  
  .epg__card {
    padding: 20px;
    min-height: 100px;
  }
  
  .epg__card-icon {
    font-size: 2rem;
  }
  
  .epg__card-title {
    font-size: 1.125rem;
  }
  
  .epg__checklist {
    padding: 16px;
    margin: 0 -4px; /* Extends slightly beyond container for better touch targets */
  }
  
  .epg__navigation {
    flex-direction: column;
    align-items: stretch;
  }
  
  .epg__back-btn,
  .epg__print-btn {
    width: 100%;
    margin-bottom: 8px;
  }
  
  .epg__progress-container {
    flex-direction: column;
    gap: 8px;
  }
  
  .epg__progress-bar {
    width: 100%;
    max-width: 300px;
  }
  
  /* Mobile checklist item improvements */
  .epg__checklist-item {
    padding: 16px 8px; /* More padding for better touch targets */
    margin: 0 -8px; /* Extends to edges for better touch area */
  }
  
  .epg__checkbox-custom {
    width: 24px; /* Slightly larger on mobile */
    height: 24px;
    margin-right: 16px; /* More space between checkbox and text */
  }
  
  .epg__checklist-text {
    font-size: 1.1rem; /* Slightly larger text on mobile */
    line-height: 1.6; /* Better line spacing */
  }
  
  /* Mobile print section */
  .epg__print-section {
    padding: 20px 0;
    margin-top: 24px;
  }
  
  .epg__print-btn {
    width: 100%;
    max-width: 300px;
    padding: 16px 24px;
    font-size: 1.1rem;
  }
}

/* Accessibility Improvements */
@media (prefers-reduced-motion: reduce) {
  .epg__card,
  .epg__back-btn,
  .epg__print-btn,
  .epg__retry-btn,
  .epg__checklist-item,
  .epg__checkbox-custom,
  .epg__progress-fill {
    transition: none;
  }
  
  .epg__loading-spinner {
    animation: none;
  }
  
  .epg__checklist--active {
    animation: none;
  }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
  .epg__card {
    border-width: 3px;
  }
  
  .epg__card--high-urgency {
    border-color: #d32f2f;
  }
  
  .epg__card--medium-urgency {
    border-color: #f57c00;
  }
  
  .epg__checkbox-custom {
    border-width: 3px;
  }
}

/* Print Styles */
@media print {
  .epg__navigation,
  .epg__back-btn,
  .epg__print-btn,
  .epg__progress-container {
    display: none;
  }
  
  .epg__checklist {
    box-shadow: none;
    border: 1px solid #000;
  }
  
  .epg__checklist-item {
    break-inside: avoid;
  }
  
  .epg__checkbox-custom {
    -webkit-print-color-adjust: exact;
    color-adjust: exact;
  }
}
