/* Basic Reset */
@import url('https://fonts.googleapis.com/css2?family=Chakra+Petch:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400;1,500;1,600;1,700&family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap');

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* CSS Variables for Color Consistency */
:root {
  --primary-color: #003366;
  --primary-gradient: linear-gradient(135deg, #003366 0%, #004080 100%);
  --secondary-color: #0066cc;
  --accent-color: #00ccff;
  --text-light: #ffffff;
  --text-dark: #333333;
  --background-light: #f8f9fa;
  --shadow-light: rgba(0, 51, 102, 0.1);
  --shadow-medium: rgba(0, 51, 102, 0.2);
  --shadow-heavy: rgba(0, 51, 102, 0.3);
  --border-radius: 12px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Body Background with subtle pattern */
body {
  background: linear-gradient(45deg, #f8f9fa 25%, transparent 25%), 
              linear-gradient(-45deg, #f8f9fa 25%, transparent 25%), 
              linear-gradient(45deg, transparent 75%, #f8f9fa 75%), 
              linear-gradient(-45deg, transparent 75%, #f8f9fa 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
  min-height: 100vh;
}

/* Loading Animation */
@keyframes shimmer {
  0% { background-position: -200px 0; }
  100% { background-position: calc(200px + 100%) 0; }
}

.loading {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200px 100%;
  animation: shimmer 1.5s infinite;
}

/* Header Styling */
header {
  background: var(--primary-gradient);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  color: var(--text-light);
  flex-wrap: wrap;
  font-family: 'Chakra Petch', 'Courier New', Courier, monospace;
  box-shadow: 0 4px 20px var(--shadow-medium);
  position: relative;
  overflow: hidden;
}

/* Animated background for header */
header::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
  animation: slideHeader 3s infinite;
}

@keyframes slideHeader {
  0% { left: -100%; }
  100% { left: 100%; }
}

header h1 {
  text-align: center;
  flex-grow: 1;
  font-size: 1.6rem;
  font-weight: 600;
  margin: 10px 0;
  font-family: 'Chakra Petch', 'Courier New', Courier, monospace;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
  position: relative;
  z-index: 1;
}

header .logo img {
  height: 45px;
  filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.3));
  transition: var(--transition);
}

header .logo img:hover {
  transform: scale(1.05);
}

/* Body Styling */
main {
  padding: 30px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: 'Chakra Petch', 'Courier New', Courier, monospace;
}

/* Image Container Styling */
.image-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 30px;
  justify-content: center;
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 0;
}

.image-box {
  background: white;
  text-align: center;
  border-radius: var(--border-radius);
  box-shadow: 0 8px 25px var(--shadow-light);
  transition: var(--transition);
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(0, 51, 102, 0.1);
}

.image-box::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--primary-gradient);
  transform: scaleX(0);
  transition: var(--transition);
}

.image-box:hover::before {
  transform: scaleX(1);
}

.image-box:hover {
  transform: translateY(-10px) scale(1.02);
  box-shadow: 0 15px 40px var(--shadow-medium);
}

/* Image Styling */
.image {
  width: 100%;
  height: 250px;
  object-fit: cover;
  border-radius: var(--border-radius) var(--border-radius) 0 0;
  margin-bottom: 20px;
  transition: var(--transition);
}

.image-box:hover .image {
  transform: scale(1.05);
}

/* Route Name Styling */
.route-name {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--primary-color);
  text-transform: uppercase;
  margin: 20px 0 10px 0;
  font-family: 'Chakra Petch', 'Courier New', Courier, monospace;
  letter-spacing: 1px;
}

.image-box b1 {
  display: block;
  font-size: 1.1rem;
  color: var(--secondary-color);
  font-weight: 500;
  margin-bottom: 20px;
  font-family: 'Chakra Petch', 'Courier New', Courier, monospace;
}

/* Map Container */
#map {
  border-radius: var(--border-radius);
  box-shadow: 0 8px 25px var(--shadow-light);
  border: 2px solid var(--primary-color);
  overflow: hidden;
}

/* Zoom Button Styling */
#zoomButton {
  background: var(--primary-gradient);
  color: var(--text-light);
  border: none;
  padding: 12px 25px;
  border-radius: var(--border-radius);
  cursor: pointer;
  font-weight: 600;
  font-family: 'Chakra Petch', 'Courier New', Courier, monospace;
  margin: 20px 0;
  transition: var(--transition);
  box-shadow: 0 4px 15px var(--shadow-light);
  position: relative;
  overflow: hidden;
}

#zoomButton::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: var(--transition);
}

#zoomButton:hover::before {
  left: 100%;
}

#zoomButton:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px var(--shadow-medium);
}

/* Date Picker Container */
.date-picker-container {
  display: flex;
  gap: 15px;
  margin: 25px 0;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}

#dateSearch {
  padding: 12px 15px;
  border: 2px solid var(--primary-color);
  border-radius: var(--border-radius);
  font-family: 'Chakra Petch', 'Courier New', Courier, monospace;
  font-size: 1rem;
  transition: var(--transition);
  background: white;
}

#dateSearch:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(0, 204, 255, 0.1);
}

#fetchDateBtn {
  background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
  color: white;
  border: none;
  padding: 12px 20px;
  border-radius: var(--border-radius);
  cursor: pointer;
  font-weight: 600;
  font-family: 'Chakra Petch', 'Courier New', Courier, monospace;
  transition: var(--transition);
  box-shadow: 0 4px 15px rgba(220, 53, 69, 0.2);
}

#fetchDateBtn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(220, 53, 69, 0.3);
}

/* Student Table Styling */
.student-table-container {
  width: 100%;
  max-width: 1000px;
  overflow-x: auto;
  margin-top: 30px;
  font-family: 'Chakra Petch', 'Courier New', Courier, monospace;
  background: white;
  border-radius: var(--border-radius);
  box-shadow: 0 8px 25px var(--shadow-light);
  border: 1px solid rgba(0, 51, 102, 0.1);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: center;
  font-family: 'Chakra Petch', 'Courier New', Courier, monospace;
  background: white;
}

table th, table td {
  padding: 15px 10px;
  border-bottom: 1px solid #e9ecef;
  font-family: 'Chakra Petch', 'Courier New', Courier, monospace;
  transition: var(--transition);
}

table th {
  background: var(--primary-gradient);
  color: var(--text-light);
  font-family: 'Chakra Petch', 'Courier New', Courier, monospace;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  position: sticky;
  top: 0;
  z-index: 10;
}

table tr {
  transition: var(--transition);
}

table tr:nth-child(even) {
  background-color: #f8f9fa;
}

table tr:hover {
  background-color: rgba(0, 102, 204, 0.05);
  transform: scale(1.01);
}

table td {
  font-weight: 500;
}

/* Home Button Styling */
#homeBtn {
  background: white;
  color: var(--primary-color);
  border: 2px solid white;
  padding: 12px 25px;
  border-radius: var(--border-radius);
  cursor: pointer;
  position: relative;
  font-weight: 700;
  text-transform: uppercase;
  transition: var(--transition);
  font-family: 'Chakra Petch', 'Courier New', Courier, monospace;
  letter-spacing: 1px;
  box-shadow: 0 4px 15px rgba(255, 255, 255, 0.2);
  z-index: 1;
  overflow: hidden;
}

#homeBtn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: var(--accent-color);
  transition: var(--transition);
  z-index: -1;
}

#homeBtn:hover::before {
  left: 0;
}

#homeBtn:hover {
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(255, 255, 255, 0.3);
}

/* Enhanced Route Name on Map Pages */
.route-name {
  background: var(--primary-gradient);
  color: white;
  padding: 15px 25px;
  border-radius: var(--border-radius);
  margin: 20px 0;
  font-size: 1.2rem;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 4px 15px var(--shadow-light);
  position: relative;
  overflow: hidden;
}

.route-name::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
  animation: slideRoute 2s infinite;
}

@keyframes slideRoute {
  0% { left: -100%; }
  100% { left: 100%; }
}

/* Media Queries */
@media (max-width: 768px) {
  header {
    flex-direction: column;
    text-align: center;
    padding: 20px;
  }

  header h1 {
    font-size: 1.3rem;
  }

  .image-container {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    padding: 10px;
  }

  .image-box {
    margin: 0 10px;
  }

  .route-name {
    font-size: 1.1rem;
  }

  .date-picker-container {
    flex-direction: column;
    gap: 10px;
  }
}

@media (max-width: 480px) {
  main {
    padding: 20px 10px;
  }

  .image-container {
    grid-template-columns: 1fr;
    gap: 15px;
  }

  table {
    font-size: 0.85rem;
  }

  table th, table td {
    padding: 10px 8px;
  }

  #homeBtn, #zoomButton, #fetchDateBtn {
    padding: 10px 20px;
    font-size: 0.9rem;
  }

  header h1 {
    font-size: 1.1rem;
  }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  :root {
    --background-light: #1a1a1a;
    --text-dark: #ffffff;
  }
  
  body {
    background: #1a1a1a;
    color: white;
  }
  
  .image-box, .student-table-container, table {
    background: #2d2d2d;
    color: white;
  }
  
  table tr:nth-child(even) {
    background-color: #3a3a3a;
  }
  
  #dateSearch {
    background: #2d2d2d;
    color: white;
    border-color: var(--secondary-color);
  }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--primary-gradient);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--secondary-color);
}

/* SweetAlert 2 Font Custom */
.swal2-popup {
  font-size: 1.3rem !important;
  font-family: 'Chakra Petch', 'Poppins', 'Courier New', Courier, monospace;
  border-radius: var(--border-radius) !important;
  box-shadow: 0 20px 60px var(--shadow-heavy) !important;
}

.swal2-confirm {
  font-family: 'Chakra Petch', 'Poppins', 'Courier New', Courier, monospace;
  background: var(--primary-gradient) !important;
  border-radius: var(--border-radius) !important;
  font-weight: 600 !important;
  padding: 12px 25px !important;
  transition: var(--transition) !important;
}

.swal2-confirm:hover {
  transform: translateY(-2px) !important;
  box-shadow: 0 8px 25px var(--shadow-medium) !important;
}

/* Accessibility Improvements */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus styles for accessibility */
*:focus {
  outline: 3px solid var(--accent-color);
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --primary-color: #000000;
    --secondary-color: #000080;
    --shadow-light: rgba(0, 0, 0, 0.5);
    --shadow-medium: rgba(0, 0, 0, 0.7);
    --shadow-heavy: rgba(0, 0, 0, 0.9);
  }
}