/* CSS Variables for consistent theming */
:root {
  --primary-color: #2E7D32;
  --primary-light: #4CAF50;
  --primary-dark: #1B5E20;
  --secondary-color: #FFC107;
  --accent-color: #FF5722;
  --background-color: #F5F5F5;
  --surface-color: #FFFFFF;
  --text-primary: #212121;
  --text-secondary: #757575;
  --text-light: #FFFFFF;
  --border-color: #E0E0E0;
  --shadow-light: 0 2px 4px rgba(0,0,0,0.1);
  --shadow-medium: 0 4px 8px rgba(0,0,0,0.15);
  --shadow-heavy: 0 8px 16px rgba(0,0,0,0.2);
  --border-radius: 8px;
  --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, Oxygen, Ubuntu, Cantarell, sans-serif;
  background-color: var(--background-color);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* App container */
#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
  color: var(--text-light);
  padding: 1rem 0;
  box-shadow: var(--shadow-medium);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.app-header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0;
}

.header-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* Buttons */
.btn-primary {
  background-color: var(--primary-color);
  color: var(--text-light);
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: var(--border-radius);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-light);
}

.btn-primary:hover {
  background-color: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-medium);
}

.btn-secondary {
  background-color: rgba(255, 255, 255, 0.2);
  color: var(--text-light);
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  backdrop-filter: blur(10px);
}

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.btn-icon {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 50%;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

/* Search */
.search-container {
  background-color: var(--surface-color);
  padding: 1rem;
  box-shadow: var(--shadow-light);
  display: flex;
  align-items: center;
  gap: 1rem;
  max-width: 1200px;
  margin: 0 auto;
}

.search-container.hidden {
  display: none;
}

#search-input {
  flex: 1;
  padding: 0.75rem;
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 1rem;
  transition: var(--transition);
}

#search-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.1);
}

/* Main content */
.main-content {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem;
  width: 100%;
}

/* Mode toggle */
.mode-toggle {
  display: flex;
  background-color: var(--surface-color);
  border-radius: var(--border-radius);
  padding: 0.25rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-light);
  max-width: 300px;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 2rem;
}

.mode-btn {
  flex: 1;
  padding: 0.75rem 1rem;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: calc(var(--border-radius) - 2px);
  font-weight: 500;
  transition: var(--transition);
  color: var(--text-secondary);
}

.mode-btn.active {
  background-color: var(--primary-color);
  color: var(--text-light);
  box-shadow: var(--shadow-light);
}

.mode-btn:not(.active):hover {
  background-color: var(--background-color);
}

/* Situations grid */
.situations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.situation-card {
  background-color: var(--surface-color);
  border-radius: var(--border-radius);
  overflow: hidden;
  box-shadow: var(--shadow-light);
  transition: var(--transition);
  cursor: pointer;
  position: relative;
}

.situation-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-heavy);
}

.situation-image {
  width: 100%;
  height: 200px;
  background: linear-gradient(135deg, var(--primary-light), var(--primary-color));
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.situation-icon {
  font-size: 4rem;
  color: var(--text-light);
  opacity: 0.9;
}

.situation-content {
  padding: 1.5rem;
}

.situation-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.situation-description {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 1rem;
  line-height: 1.5;
}

.severity-indicator {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.severity-warning {
  background-color: #FFF3E0;
  color: #E65100;
}

.severity-penalty {
  background-color: #FFEBEE;
  color: #C62828;
}

.severity-info {
  background-color: #E3F2FD;
  color: #1565C0;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  backdrop-filter: blur(4px);
}

.modal.hidden {
  display: none;
}

.modal-content {
  background-color: var(--surface-color);
  border-radius: var(--border-radius);
  max-width: 600px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-heavy);
  animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
  color: var(--text-light);
}

.modal-title-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-right: 1rem;
}

.modal-title-container h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  flex: 1;
}

.modal-navigation-indicator {
  background-color: rgba(255, 255, 255, 0.2);
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.modal-header h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
}

.modal-body {
  padding: 2rem;
}

.rule-section {
  margin-bottom: 2rem;
}

.rule-section:last-child {
  margin-bottom: 0;
}

.rule-section h3 {
  color: var(--primary-color);
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.rule-list {
  list-style: none;
  padding: 0;
}

.rule-item {
  background-color: var(--background-color);
  padding: 1rem;
  margin-bottom: 0.75rem;
  border-radius: var(--border-radius);
  border-left: 4px solid var(--primary-color);
}

.rule-item:last-child {
  margin-bottom: 0;
}

.rule-number {
  font-weight: 600;
  color: var(--primary-color);
  margin-bottom: 0.5rem;
}

.rule-text {
  line-height: 1.6;
}

.penalty-box {
  background: linear-gradient(135deg, #FFEBEE, #FCE4EC);
  border: 1px solid #E91E63;
  border-radius: var(--border-radius);
  padding: 1rem;
  margin: 1rem 0;
}

.penalty-title {
  font-weight: 600;
  color: #C2185B;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Footer */
.app-footer {
  background-color: var(--surface-color);
  padding: 1rem;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
  border-top: 1px solid var(--border-color);
  margin-top: auto;
}

/* Loading screen */
.loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--surface-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid var(--border-color);
  border-top: 4px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Utility classes */
.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

/* Notifications and prompts */
.error-notification,
.offline-notification,
.install-prompt,
.update-notification {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 1rem;
}

.error-content,
.install-content,
.update-content {
  background-color: var(--surface-color);
  border-radius: var(--border-radius);
  padding: 2rem;
  max-width: 400px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-heavy);
  animation: modalSlideIn 0.3s ease-out;
}

.error-content h3,
.install-content h3,
.update-content h3 {
  color: var(--primary-color);
  margin-bottom: 1rem;
}

.error-content p,
.install-content p,
.update-content p {
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.install-buttons,
.update-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

.offline-notification {
  top: auto;
  bottom: 0;
  height: auto;
  background: none;
  padding: 1rem;
  align-items: flex-end;
}

.offline-content {
  background: linear-gradient(135deg, var(--accent-color), #D84315);
  color: var(--text-light);
  padding: 1rem 1.5rem;
  border-radius: var(--border-radius);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: var(--shadow-medium);
  animation: slideInUp 0.3s ease-out;
}

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(100%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* No results styling */
.no-results {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-secondary);
  grid-column: 1 / -1;
}

.no-results h3 {
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

/* Enhanced focus styles for better accessibility */
.situation-card:focus-visible {
  outline: 3px solid var(--primary-color);
  outline-offset: 2px;
  transform: translateY(-2px);
}

.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.btn-icon:focus-visible,
.mode-btn:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --border-color: #000000;
    --text-secondary: #000000;
    --shadow-light: 0 2px 4px rgba(0,0,0,0.3);
    --shadow-medium: 0 4px 8px rgba(0,0,0,0.4);
    --shadow-heavy: 0 8px 16px rgba(0,0,0,0.5);
  }
  
  .situation-card {
    border: 2px solid var(--border-color);
  }
  
  .severity-indicator {
    border: 1px solid currentColor;
  }
}

/* Animation for situation cards */
.situation-card {
  animation: fadeInUp 0.3s ease-out;
}

.situation-card:nth-child(1) { animation-delay: 0.1s; }
.situation-card:nth-child(2) { animation-delay: 0.2s; }
.situation-card:nth-child(3) { animation-delay: 0.3s; }
.situation-card:nth-child(4) { animation-delay: 0.4s; }
.situation-card:nth-child(5) { animation-delay: 0.5s; }
.situation-card:nth-child(6) { animation-delay: 0.6s; }

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Loading animation improvements */
.loading-screen {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
  color: var(--text-light);
}

.loading-spinner {
  border-color: rgba(255, 255, 255, 0.3);
  border-top-color: var(--text-light);
}

/* Search enhancements */
.search-container {
  border-bottom: 1px solid var(--border-color);
}

#search-input {
  font-size: 1rem;
}

#search-input::placeholder {
  color: var(--text-secondary);
}

/* Modal improvements */
.modal {
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-header {
  border-radius: var(--border-radius) var(--border-radius) 0 0;
}

/* Severity indicator improvements */
.severity-warning {
  background: linear-gradient(135deg, #FFF3E0, #FFE0B2);
  border: 1px solid #FF8F00;
}

.severity-penalty {
  background: linear-gradient(135deg, #FFEBEE, #FFCDD2);
  border: 1px solid #D32F2F;
}

.severity-info {
  background: linear-gradient(135deg, #E3F2FD, #BBDEFB);
  border: 1px solid #1976D2;
}
