/* Modern Colorful UI Design */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap");

:root {
  /* Bangladesh National Flag Palette */
  --bd-green: #006a4e;
  --bd-red: #f42a41;
  --bd-yellow: #fffbe7;
  --main-bg: #e5f4e9;

  --primary-gradient: linear-gradient(135deg, #006a4e 0%, #008a5a 100%);
  --secondary-gradient: linear-gradient(135deg, #f42a41 0%, #c81d25 100%);
  --accent-gradient: linear-gradient(135deg, #f42a41 0%, #006a4e 100%);
  --success-gradient: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
  --warning-gradient: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
  --error-gradient: linear-gradient(135deg, #f42a41 0%, #c81d25 100%);

  --primary: #006a4e;
  --secondary: #f42a41;
  --accent: #f42a41;
  --success: #43e97b;
  --warning: #fa709a;
  --error: #f42a41;

  --bg-primary: var(--main-bg);
  --bg-secondary: var(--main-bg);
  --bg-card: #ffffff;
  --bg-glass: rgba(0, 106, 78, 0.08);

  --text-primary: #003820;
  --text-secondary: #006a4e;
  --text-muted: #b2b2b2;
  --text-white: #fffbe7;

  --border-light: #b2d8c5;
  --border-medium: #006a4e;

  --shadow-sm: 0 1px 2px 0 rgba(0, 106, 78, 0.05);
  --shadow-md:
    0 4px 6px -1px rgba(0, 106, 78, 0.1), 0 2px 4px -1px rgba(0, 106, 78, 0.06);
  --shadow-lg:
    0 10px 15px -3px rgba(0, 106, 78, 0.1),
    0 4px 6px -2px rgba(0, 106, 78, 0.05);
  --shadow-xl:
    0 20px 25px -5px rgba(0, 106, 78, 0.1),
    0 10px 10px -5px rgba(0, 106, 78, 0.04);
  --shadow-glow: 0 0 20px rgba(0, 106, 78, 0.15);

  --header-height: 80px;
  --footer-height: 60px;
  --border-radius: 16px;
  --border-radius-sm: 8px;
  --border-radius-lg: 24px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Inter", sans-serif;
  background: var(--main-bg);
  color: var(--text-primary);
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Animated Background */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(
      circle at 20% 80%,
      rgba(0, 106, 78, 0.12) 0%,
      transparent 50%
    ),
    radial-gradient(
      circle at 80% 20%,
      rgba(244, 42, 65, 0.1) 0%,
      transparent 50%
    ),
    radial-gradient(
      circle at 40% 40%,
      rgba(0, 106, 78, 0.08) 0%,
      transparent 50%
    );
  z-index: -1;
  animation: backgroundShift 20s ease-in-out infinite;
}

@keyframes backgroundShift {
  0%,
  100% {
    transform: scale(1) rotate(0deg);
  }
  50% {
    transform: scale(1.1) rotate(1deg);
  }
}

/* Header */
header {
  background: var(--primary-gradient);
  color: var(--text-white);
  padding: 1rem 0;
  text-align: center;
  box-shadow: var(--shadow-lg);
  position: sticky;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1000;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  position: sticky;
  transition: top 0.2s;
}

header::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(
      circle at 20% 80%,
      rgba(244, 42, 65, 0.08) 0%,
      transparent 50%
    ),
    radial-gradient(
      circle at 80% 20%,
      rgba(255, 255, 255, 0.08) 0%,
      transparent 50%
    );
  z-index: 1;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
  position: relative;
  z-index: 2;
  width: 100%;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.notification-bell {
  position: relative;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 50%;
  transition: all 0.3s ease;
  background: rgba(255, 255, 255, 0.1);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.notification-bell:hover,
.notification-bell:focus-visible {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
  outline: 2px solid var(--text-white);
  outline-offset: 2px;
}

.bell-icon {
  font-size: 1.5rem;
  display: block;
}

.notification-count {
  position: absolute;
  top: -5px;
  right: -5px;
  background: var(--error);
  color: white;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: bold;
  animation: pulse 2s infinite;
}

.notification-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  width: 350px;
  max-height: 400px;
  background: white;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-xl);
  z-index: 1001;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.3s ease;
  margin-top: 0.5rem;
}

.notification-dropdown.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-primary);
  border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.dropdown-header h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--text-primary);
}

.clear-notifications {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--border-radius-sm);
  transition: all 0.3s ease;
}

.clear-notifications:hover {
  background: var(--primary);
  color: white;
}

.notification-list {
  max-height: 300px;
  overflow-y: auto;
}

.no-notifications {
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
}

.notification-item {
  padding: 1rem;
  border-bottom: 1px solid var(--border-light);
  transition: background 0.3s ease;
}

.notification-item:hover {
  background: var(--bg-primary);
}

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

.notification-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.notification-item-title {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.9rem;
}

.notification-item-time {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.notification-item-message {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.logo-section {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  min-width: 0;
}

.logo-text h1 {
  margin: 0;
  font-size: 2.2rem;
  font-weight: 600;
  font-family: "Poppins", sans-serif;
  animation: slideInDown 1s ease-out;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.logo-text p {
  font-size: 1rem;
  margin: 0.1rem 0 0 0;
  opacity: 0.85;
  font-family: "Inter", sans-serif;
  color: #e0e0e0;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Main Content */
main {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: calc(var(--header-height) + 1rem) 1rem
    calc(var(--footer-height) + 1rem) 1rem;
  width: 100%;
  box-sizing: border-box;
  background: var(--bg-secondary);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-xl);
}

/* Search Section */
#search-section {
  background: var(--bg-card);
  padding: 3rem;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-xl);
  text-align: center;
  margin-bottom: 1.5rem;
  animation: slideInUp 0.8s ease-out;
  border: 2px solid var(--bd-green);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  position: relative;
  overflow: hidden;
}

#search-section::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--accent-gradient);
}

#search-section h2 {
  margin-top: 0;
  margin-bottom: 2rem;
  background: var(--secondary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-size: 2.5rem;
  font-weight: 600;
  font-family: "Poppins", sans-serif;
}

.search-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  position: relative;
}

#trainIdInput {
  padding: 1rem 1.5rem;
  font-size: 1.1rem;
  border: 2px solid var(--border-light);
  border-radius: var(--border-radius);
  width: 70%;
  max-width: 400px;
  transition: all 0.3s ease;
  box-sizing: border-box;
  background: var(--bg-secondary);
  font-family: "Inter", sans-serif;
}

#trainIdInput:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(0, 106, 78, 0.1);
  outline: none;
  transform: translateY(-2px);
}

#searchButton {
  padding: 1rem 2rem;
  font-size: 1.1rem;
  font-weight: 600;
  background: var(--primary-gradient);
  color: var(--text-white);
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-family: "Inter", sans-serif;
  position: relative;
  overflow: hidden;
}

#searchButton::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: left 0.5s;
}

#searchButton:hover::before {
  left: 100%;
}

#searchButton:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-glow);
}

/* Search Animation */
.search-animation {
  position: relative;
  height: 80px;
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-train {
  font-size: 3rem;
  animation: searchTrainMove 4s ease-in-out infinite;
  position: relative;
  z-index: 2;
}

.search-track {
  position: absolute;
  bottom: 15px;
  left: 50%;
  transform: translateX(-50%);
  width: 200px;
  height: 4px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--border-medium) 10%,
    var(--border-medium) 90%,
    transparent 100%
  );
  border-radius: 2px;
  z-index: 1;
}

.search-track::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 0;
  width: 100%;
  height: 16px;
  background: repeating-linear-gradient(
    90deg,
    transparent 0px,
    transparent 12px,
    var(--border-light) 12px,
    var(--border-light) 16px
  );
  border-radius: 1px;
}

@keyframes searchTrainMove {
  0%,
  100% {
    transform: translateX(60px) scale(0.9);
    opacity: 0.7;
  }
  25% {
    transform: translateX(20px) scale(1);
    opacity: 1;
  }
  75% {
    transform: translateX(-20px) scale(1);
    opacity: 1;
  }
  100% {
    transform: translateX(-60px) scale(0.9);
    opacity: 0.7;
  }
}

/* Results Section */
#results-section {
  display: none;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem 2rem;
  gap: 2rem;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr;
  grid-template-areas: "map info";
}

#results-section.visible {
  display: grid;
  animation: slideInUp 0.5s ease-out;
}

#map {
  grid-area: map;
  height: 500px;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-md);
  background: var(--bg-secondary);
  overflow: hidden;
  position: sticky;
  top: calc(var(--header-height) + 1rem);
  z-index: 10;
}

#train-info {
  grid-area: info;
  background: var(--bg-secondary);
  padding: 1.5rem;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-md);
  max-height: 500px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--primary) var(--border-light);
}

#train-info h3 {
  margin-top: 0;
  margin-bottom: 2rem;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  border-bottom: 2px solid var(--border-light);
  padding-bottom: 1rem;
  font-size: 1.8rem;
  font-weight: 600;
  font-family: "Poppins", sans-serif;
}

#train-info p {
  margin-bottom: 1rem;
  font-size: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-light);
}

#train-info p:last-child {
  border-bottom: none;
}

#train-info p strong {
  color: var(--text-primary);
  font-weight: 600;
  flex: 1;
}

#train-info span {
  color: var(--text-secondary);
  font-weight: 500;
  text-align: right;
  flex: 1;
}

#train-info hr {
  border: none;
  border-top: 2px solid var(--border-light);
  margin: 1.5rem 0;
  border-radius: 1px;
}

/* Status Messages */
#statusMessage {
  padding: 1.5rem;
  margin-bottom: 2rem;
  border-radius: var(--border-radius);
  font-weight: 600;
  text-align: center;
  display: none;
  font-size: 1.1rem;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

#statusMessage.info {
  background: var(--success-gradient);
  color: var(--text-white);
  box-shadow: var(--shadow-md);
}

#statusMessage.error {
  background: var(--error-gradient);
  color: var(--text-white);
  box-shadow: var(--shadow-md);
}

/* Google Maps Link */
#gmapsLink {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  background: var(--accent-gradient);
  color: var(--text-white);
  text-decoration: none;
  border-radius: var(--border-radius);
  font-weight: 600;
  transition: all 0.3s ease;
  margin-top: 1rem;
}

#gmapsLink:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

/* Footer */
footer {
  background: var(--primary-gradient);
  color: var(--text-white);
  text-align: center;
  padding: 1.5rem 0;
  margin-top: auto;
  position: relative;
  overflow: hidden;
}

footer::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--secondary-gradient);
}

footer p {
  margin: 0.5rem 0;
  font-size: 0.9rem;
  opacity: 0.9;
}

footer a {
  color: var(--bd-yellow);
  text-decoration: none;
  transition: opacity 0.3s ease;
}

footer a:hover {
  opacity: 0.7;
}

/* Loading Animation */
.loader {
  display: inline-block;
  width: 50px;
  height: 50px;
  border: 4px solid var(--border-light);
  border-radius: 50%;
  border-top-color: var(--primary);
  animation: spin 1s ease-in-out infinite;
  margin: 2rem auto;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Error Message */
#errorMessage {
  display: block;
  background: linear-gradient(90deg, #ffecd2 0%, #fcb69f 100%);
  color: #b71c1c;
  border: 1.5px solid #ffb199;
  border-radius: 8px;
  padding: 1.2rem 1.5rem;
  margin: 1.5rem auto 1.5rem auto;
  max-width: 600px;
  font-size: 1.1rem;
  font-weight: 500;
  box-shadow: 0 2px 12px 0 rgba(252, 182, 159, 0.08);
  display: flex;
  align-items: center;
  gap: 1rem;
  animation: fadeIn 0.5s;
  position: relative;
}

#errorMessage .error-icon {
  font-size: 1.7rem;
  flex-shrink: 0;
  margin-right: 0.5rem;
}

#errorMessage .error-close {
  background: none;
  border: none;
  color: #b71c1c;
  font-size: 1.5rem;
  font-weight: bold;
  margin-left: auto;
  cursor: pointer;
  padding: 0 0.5rem;
  border-radius: 50%;
  transition:
    background 0.2s,
    color 0.2s;
  line-height: 1;
  opacity: 0.7;
  align-self: flex-start;
}

#errorMessage .error-close:hover,
#errorMessage .error-close:focus {
  background: #ffb19933;
  color: #d32f2f;
  opacity: 1;
  outline: none;
}

/* Animations */
@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Responsive Design */
@media (max-width: 1024px) {
  .header-content {
    flex-direction: column;
    gap: 1rem;
    padding: 0 1rem;
    align-items: stretch;
  }
  .header-controls {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
  }
  .logo-text h1 {
    font-size: 1.5rem;
  }
  .logo-text p {
    font-size: 0.85rem;
  }
  .header-animation .train-icon {
    font-size: 1.2rem;
  }
  .header-animation .track-line {
    width: 60px;
  }
  #results-section {
    padding: 0.5rem;
    gap: 0.5rem;
  }
  #map {
    height: 250px;
  }
  #train-info {
    padding: 1rem;
    max-height: 350px;
  }
  .modal-content {
    width: 98%;
    max-width: 350px;
  }
}

@media (max-width: 768px) {
  header {
    height: auto;
    min-height: 60px;
    padding: 0.5rem 0;
  }

  .header-content {
    flex-direction: column;
    gap: 0.5rem;
    padding: 0 0.5rem;
    align-items: stretch;
  }

  .logo-text h1 {
    font-size: 1.2rem;
    line-height: 1.2;
  }

  .logo-text p {
    font-size: 0.8rem;
    line-height: 1.2;
  }

  .header-controls {
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
  }
  .notification-bell,
  .history-toggle,
  .server-status-container {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
  }

  .notification-bell,
  .history-toggle {
    font-size: 1rem;
    padding: 0.75rem;
    min-width: 48px;
    min-height: 48px;
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
  }

  .server-status-container {
    min-width: 48px;
    min-height: 48px;
    padding: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--border-radius-sm);
    background: rgba(255, 255, 255, 0.1);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
  }

  .server-status-text {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-white);
    white-space: nowrap;
  }

  .notification-bell:active,
.history-toggle:active,
.server-status-container:active {
  transform: scale(0.95);
  background: rgba(255, 255, 255, 0.2);
  transition: all 0.1s ease;
}

  .notification-dropdown {
    width: 95vw;
    max-width: 350px;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 0.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-xl);
  }

  #search-section {
    margin: 0.5rem;
    padding: 1.5rem 1rem;
    border-radius: var(--border-radius);
  }

  #search-section h2 {
    font-size: 1.3rem;
    margin-bottom: 1rem;
    text-align: center;
  }

  .search-container {
    flex-direction: column;
    gap: 1rem;
    width: 100%;
  }

  #trainIdInput {
    width: 100%;
    font-size: 1rem;
    min-height: 50px;
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius-sm);
    border: 2px solid var(--border-light);
    transition: all 0.3s ease;
  }

  #trainIdInput:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 106, 78, 0.1);
    outline: none;
  }

  #searchButton {
    width: 100%;
    font-size: 1rem;
    min-height: 50px;
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
  }

  #searchButton:active {
    transform: scale(0.98);
  }

  .autocomplete-list {
    width: 100%;
    max-height: 200px;
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow-lg);
  }

  .autocomplete-item {
    padding: 0.75rem 1rem;
    min-height: 48px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }

  #results-section {
    padding: 0.5rem;
    gap: 1rem;
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "map"
      "info";
  }

  #map {
    height: 250px;
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow-md);
  }

  #train-info {
    padding: 1rem;
    max-height: 60vh;
    overflow-y: auto;
    border-radius: var(--border-radius-sm);
    background: var(--bg-card);
    box-shadow: var(--shadow-md);
  }

  #train-info h3 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    text-align: center;
    color: var(--text-primary);
  }

  #train-info p {
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
    line-height: 1.5;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-light);
  }

  #train-info p:last-child {
    border-bottom: none;
  }

  #train-info strong {
    color: var(--text-primary);
    font-weight: 600;
  }

  #train-info span {
    color: var(--text-secondary);
    font-weight: 500;
  }

  #gmapsLink {
    display: inline-block;
    margin-top: 1rem;
    padding: 0.75rem 1.5rem;
    background: var(--primary-gradient);
    color: white;
    text-decoration: none;
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    text-align: center;
    transition: all 0.3s ease;
  }

  #gmapsLink:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
  }
}

/* Glass Morphism Effects */
.glass {
  background: var(--bg-glass);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Hover Effects */
.hover-lift {
  transition:
    transform 0.3s ease,
    box-shadow 0.3s ease;
}

.hover-lift:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-xl);
}

/* Pulse Animation */
@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

.pulse {
  animation: pulse 2s infinite;
}

/* Train Loader Animation */
.train-loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.train-loader.show {
  opacity: 1;
  visibility: visible;
}

.loader-container {
  position: relative;
  width: 300px;
  height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.loader-train {
  font-size: 4rem;
  animation: trainMoveRightToLeft 2s ease-in-out infinite;
  position: relative;
  z-index: 2;
}

.loader-track {
  position: absolute;
  bottom: 60px;
  width: 100%;
  height: 6px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--border-medium) 10%,
    var(--border-medium) 90%,
    transparent 100%
  );
  border-radius: 3px;
  z-index: 1;
}

.loader-track::before {
  content: "";
  position: absolute;
  top: -8px;
  left: 0;
  width: 100%;
  height: 22px;
  background: repeating-linear-gradient(
    90deg,
    transparent 0px,
    transparent 15px,
    var(--border-light) 15px,
    var(--border-light) 20px
  );
  border-radius: 2px;
}

.loader-text {
  margin-top: 2rem;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-primary);
  font-family: "Inter", sans-serif;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes trainMoveRightToLeft {
  0% {
    transform: translateX(120px) scale(0.8);
    opacity: 0;
  }
  20% {
    transform: translateX(80px) scale(1);
    opacity: 1;
  }
  80% {
    transform: translateX(-80px) scale(1);
    opacity: 1;
  }
  100% {
    transform: translateX(-120px) scale(0.8);
    opacity: 0;
  }
}

/* Responsive loader */
@media (max-width: 768px) {
  .loader-container {
    width: 250px;
    height: 150px;
  }

  .loader-train {
    font-size: 3rem;
  }

  .loader-track {
    bottom: 40px;
    height: 4px;
  }

  .loader-track::before {
    top: -6px;
    height: 16px;
  }

  .loader-text {
    font-size: 1rem;
    margin-top: 1.5rem;
  }
}

/* API Status Notification */
.api-status {
  background: linear-gradient(135deg, #006a4e 0%, #008a5a 100%);
  color: white;
  padding: 1rem;
  margin-bottom: 2rem;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-md);
  animation: slideInDown 0.8s ease-out;
}

.status-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: var(--max-width);
  margin: 0 auto;
  gap: 1rem;
}

.status-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

.status-text {
  flex: 1;
  font-size: 0.95rem;
  font-weight: 500;
  font-family: "Inter", sans-serif;
}

.status-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  font-size: 1.5rem;
  font-weight: bold;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.status-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

/* Responsive API status */
@media (max-width: 768px) {
  .api-status {
    margin: 0.5rem;
    border-radius: var(--border-radius);
  }

  .status-content {
    padding: 1rem;
    flex-direction: column;
    gap: 0.75rem;
    text-align: center;
  }

  .status-text {
    font-size: 0.9rem;
    line-height: 1.4;
  }

  .status-close {
    width: 32px;
    height: 32px;
    font-size: 1.2rem;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.1);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
  }
}

/* Notification System */
.notification-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 400px;
}

.notification {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 1rem 1.5rem;
  box-shadow: var(--shadow-xl);
  border-left: 4px solid var(--primary);
  transform: translateX(100%);
  opacity: 0;
  animation: slideInNotification 0.3s ease-out forwards;
  position: relative;
  overflow: hidden;
}

.notification::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--primary-gradient);
  opacity: 0.05;
  z-index: -1;
}

.notification.success {
  border-left-color: var(--success);
}

.notification.error {
  border-left-color: var(--error);
}

.notification.warning {
  border-left-color: var(--warning);
}

.notification.info {
  border-left-color: var(--accent);
}

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

.notification-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.notification-message {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.notification-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.notification-close:hover {
  background: var(--bg-primary);
  color: var(--text-primary);
}

.notification-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: var(--primary);
  animation: notificationProgress 5s linear forwards;
}

.notification.success .notification-progress {
  background: var(--success);
}

.notification.error .notification-progress {
  background: var(--error);
}

.notification.warning .notification-progress {
  background: var(--warning);
}

.notification.info .notification-progress {
  background: var(--accent);
}

@keyframes slideInNotification {
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOutNotification {
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

@keyframes notificationProgress {
  from {
    width: 100%;
  }
  to {
    width: 0%;
  }
}

/* Search History Styles */
.history-toggle {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--text-white);
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.3s ease;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  white-space: nowrap;
}

.history-toggle:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}

.history-toggle.active {
  background: linear-gradient(90deg, #006a4e 0%, #008a5a 100%);
  color: #fff;
  box-shadow: 0 2px 12px 0 rgba(0, 106, 78, 0.15);
  border: 2px solid #006a4e;
  font-weight: 700;
  transform: translateY(-2px) scale(1.04);
  transition: all 0.2s cubic-bezier(0.4, 2, 0.6, 1);
}

.history-section {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  margin: 2rem auto;
  max-width: 1200px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: translateY(20px);
  opacity: 0;
  transition: all 0.3s ease;
  position: relative;
}

.history-section::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--primary-gradient);
  opacity: 0.02;
  z-index: -1;
}

.history-section.show {
  transform: translateY(0);
  opacity: 1;
}

.history-header {
  background: var(--primary-gradient);
  color: var(--text-white);
  padding: 1.5rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
}

.history-header::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(
      circle at 20% 80%,
      rgba(255, 255, 255, 0.1) 0%,
      transparent 50%
    ),
    radial-gradient(
      circle at 80% 20%,
      rgba(255, 255, 255, 0.1) 0%,
      transparent 50%
    );
  z-index: -1;
}

.history-header h3 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.clear-history {
  background: rgba(255, 255, 255, 0.2);
  color: var(--text-white);
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s ease;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.clear-history:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.history-list {
  padding: 1.5rem 2rem;
  max-height: 400px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.history-item {
  background: var(--bg-primary);
  border-radius: var(--border-radius-sm);
  padding: 1rem;
  border-left: 4px solid var(--primary);
  transition: all 0.2s ease;
  cursor: pointer;
  position: relative;
  overflow: auto;
  margin-bottom: 0.5rem;
  min-width: 100%;
  box-sizing: border-box;
  min-height: 80px;
  max-height: 180px;
  word-break: break-word;
}

.history-item::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--primary-gradient);
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: -1;
}

.history-item:hover {
  transform: translateX(5px);
  box-shadow: var(--shadow-md);
}

.history-item:hover::before {
  opacity: 0.05;
}

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

.history-train-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
}

.history-train-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-train-number {
  color: var(--text-secondary);
  font-size: 0.9rem;
  white-space: nowrap;
}

.history-timestamp {
  color: var(--text-muted);
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.history-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.history-detail {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  min-width: 0;
}

.history-detail-label {
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}

.history-detail-value {
  color: var(--text-primary);
  overflow: auto;
  text-overflow: ellipsis;
  white-space: normal;
  word-break: break-word;
}

.history-empty {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--text-muted);
}

.history-empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.history-empty-text {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

.history-empty-subtext {
  font-size: 0.9rem;
  opacity: 0.7;
}

/* Responsive styles for history */
@media (max-width: 768px) {
  .history-section {
    margin: 0.5rem;
    padding: 1rem;
    border-radius: var(--border-radius);
  }

  .history-header {
    padding: 1rem;
    margin-bottom: 1rem;
  }

  .history-header h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
  }

  .clear-history {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    min-height: 40px;
  }

  .history-item {
    padding: 1rem;
    margin-bottom: 0.75rem;
    border-radius: var(--border-radius-sm);
  }

  .history-item-header {
    margin-bottom: 0.75rem;
  }

  .history-train-name {
    font-size: 1rem;
    font-weight: 600;
  }

  .history-train-number {
    font-size: 0.9rem;
  }

  .history-timestamp {
    font-size: 0.8rem;
  }

  .history-details {
    gap: 0.5rem;
  }

  .history-detail {
    padding: 0.5rem;
    border-radius: var(--border-radius-sm);
  }

  .history-detail-label {
    font-size: 0.8rem;
  }

  .history-detail-value {
    font-size: 0.9rem;
  }
}

/* Modal Styles */
.modal {
  display: none;
  position: fixed;
  z-index: 10000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  animation: fadeIn 0.3s ease-out;
}

.modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-xl);
  width: 90%;
  max-width: 400px;
  animation: slideInModal 0.3s ease-out;
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-primary);
}

.modal-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-header-actions .clear-notifications,
.modal-header-actions .clear-history {
  background: var(--primary);
  color: #fff;
  font-weight: bold;
  border: none;
  border-radius: var(--border-radius-sm);
  padding: 0.5rem 1rem;
  cursor: pointer;
  transition:
    background 0.2s,
    color 0.2s;
  font-size: 0.9rem;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-header-actions .clear-notifications:hover,
.modal-header-actions .clear-history:hover {
  background: var(--error);
  color: #fff;
}

.modal-header h3 {
  margin: 0;
  color: var(--text-primary);
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1;
  display: flex;
  align-items: center;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.3s ease;
  line-height: 1;
}

.modal-close:hover {
  background: var(--border-light);
  color: var(--text-primary);
}

.modal-body {
  padding: 1.5rem;
}

.modal-body p {
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.6;
}

.modal-footer {
  display: flex;
  gap: 1rem;
  padding: 1.5rem;
  border-top: 1px solid var(--border-light);
  background: var(--bg-primary);
}

.modal-btn {
  flex: 1;
  padding: 0.75rem 1rem;
  border: none;
  border-radius: var(--border-radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
}

.modal-btn-cancel {
  background: var(--border-light);
  color: var(--text-secondary);
}

.modal-btn-cancel:hover {
  background: var(--border-medium);
  color: var(--text-primary);
}

.modal-btn-confirm {
  background: var(--error-gradient);
  color: white;
}

.modal-btn-confirm:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

@keyframes slideInModal {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@media (max-width: 768px) {
  .modal-content {
    width: 95vw;
    max-width: 95vw;
    margin: 1rem auto;
    border-radius: var(--border-radius);
    max-height: 90vh;
    overflow-y: auto;
  }

  .modal-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-light);
  }

  .modal-header-actions {
    gap: 0.25rem;
  }

  .modal-header-actions .clear-notifications,
  .modal-header-actions .clear-history {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    height: 32px;
  }

  .modal-header h3 {
    font-size: 1.2rem;
    line-height: 1;
  }

  .modal-close {
    width: 32px;
    height: 32px;
    font-size: 1.5rem;
    border-radius: 50%;
    background: var(--bg-secondary);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    line-height: 1;
  }

  .modal-body {
    padding: 1rem;
  }

  .modal-body p {
    font-size: 0.95rem;
    line-height: 1.5;
  }

  .modal-footer {
    padding: 1rem;
    flex-direction: column;
    gap: 0.75rem;
    border-top: 1px solid var(--border-light);
  }

  .modal-btn {
    width: 100%;
    min-height: 48px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--border-radius-sm);
    transition: all 0.3s ease;
  }

  .modal-btn:active {
    transform: scale(0.98);
  }
}

/* Autocomplete styles for train search */
.autocomplete-list {
  position: absolute;
  z-index: 1000;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  max-height: 260px;
  overflow-y: auto;
  width: 100%;
  min-width: 220px;
  display: none;
  margin-top: 2px;
}
.autocomplete-list.active {
  display: block;
}
.autocomplete-item {
  padding: 12px 16px;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  transition: background 0.15s;
}
.autocomplete-item:hover,
.autocomplete-item.selected {
  background: #f0f4ff;
  color: #1a237e;
}
.autocomplete-item .train-no {
  font-weight: bold;
  margin-right: 10px;
  color: #1976d2;
  min-width: 60px;
}
.autocomplete-item .train-name {
  flex: 1;
  color: #333;
}
@media (max-width: 600px) {
  .autocomplete-list {
    font-size: 0.95rem;
    min-width: 160px;
    max-height: 180px;
  }
  .autocomplete-item {
    padding: 10px 12px;
  }
}

.server-status-icon {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 8px;
  animation: status-blink 1.5s ease-in-out infinite;
  box-shadow: 0 0 8px currentColor;
}

.server-status-online {
  background-color: #4ade80;
  color: #4ade80;
  animation: status-blink-online 1.2s ease-in-out infinite;
  box-shadow:
    0 0 12px #4ade80,
    0 0 20px rgba(74, 222, 128, 0.3);
}

.server-status-offline {
  background-color: #f87171;
  color: #f87171;
  animation: status-blink-offline 1.2s ease-in-out infinite;
  box-shadow:
    0 0 12px #f87171,
    0 0 20px rgba(248, 113, 113, 0.3);
}

@keyframes status-blink-online {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
    box-shadow:
      0 0 12px #4ade80,
      0 0 20px rgba(74, 222, 128, 0.3);
  }
  50% {
    opacity: 0.3;
    transform: scale(0.8);
    box-shadow:
      0 0 6px #4ade80,
      0 0 10px rgba(74, 222, 128, 0.2);
  }
}

@keyframes status-blink-offline {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
    box-shadow:
      0 0 12px #f87171,
      0 0 20px rgba(248, 113, 113, 0.3);
  }
  50% {
    opacity: 0.3;
    transform: scale(0.8);
    box-shadow:
      0 0 6px #f87171,
      0 0 10px rgba(248, 113, 113, 0.2);
  }
}

/* Train name inside search bar */
.search-container {
  position: relative;
}

/* Remove external train name styling since we're showing it inside the input */
.selected-train-name {
  display: none !important;
}

#trainIdInput.with-train-name {
  padding-left: 1rem !important;
}

@media (max-width: 600px) {
  .server-status-icon {
    width: 14px;
    height: 14px;
    margin: 0 0.5rem;
  }
  #trainIdInput.with-train-name {
    padding-left: 1rem !important;
  }
}

/* Remove header-animation styles */
.header-animation,
.header-animation .train-icon,
.header-animation .track-line {
  display: none !important;
}

/* Fullpage Train Loader Animation */
.fullpage-loader {
  position: relative;
  width: 300px;
  height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.fullpage-track {
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  height: 6px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--border-medium) 10%,
    var(--border-medium) 90%,
    transparent 100%
  );
  border-radius: 3px;
  z-index: 1;
}

.fullpage-track::before {
  content: "";
  position: absolute;
  top: -8px;
  left: 0;
  width: 100%;
  height: 22px;
  background: repeating-linear-gradient(
    90deg,
    transparent 0px,
    transparent 15px,
    var(--border-light) 15px,
    var(--border-light) 20px
  );
  border-radius: 2px;
}

.fullpage-train {
  font-size: 4rem;
  animation: fullTrainMove 2s ease-in-out infinite;
  position: relative;
  z-index: 2;
  margin-bottom: 20px;
}

.fullpage-loader .loader-text {
  margin-top: 2rem;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-primary);
  font-family: "Inter", sans-serif;
  animation: pulse 1.5s ease-in-out infinite;
  text-align: center;
}

@keyframes fullTrainMove {
  0% {
    transform: translateX(120px) scale(0.8);
    opacity: 0;
  }
  20% {
    transform: translateX(80px) scale(1);
    opacity: 1;
  }
  80% {
    transform: translateX(-80px) scale(1);
    opacity: 1;
  }
  100% {
    transform: translateX(-120px) scale(0.8);
    opacity: 0;
  }
}

@media (max-width: 600px) {
  .fullpage-loader {
    width: 250px;
    height: 150px;
  }

  .fullpage-train {
    font-size: 3rem;
    margin-bottom: 15px;
  }

  .fullpage-track {
    bottom: 40px;
    height: 4px;
  }

  .fullpage-track::before {
    top: -6px;
    height: 16px;
  }

  .fullpage-loader .loader-text {
    font-size: 1rem;
    margin-top: 1.5rem;
  }
}

.bd-flag-text {
  display: inline-block;
  position: relative;
  padding: 0.3em 1.2em 0.3em 2.2em;
  background: #006a4e; /* Bangladesh green */
  color: #fffbe7; /* Off-white/yellowish for contrast */
  border-radius: 0.7em;
  font-weight: 700;
  font-size: 2.2rem;
  font-family: "Poppins", sans-serif;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  overflow: visible;
}
.bd-flag-text::before {
  content: "";
  position: absolute;
  left: 0.5em;
  top: 50%;
  transform: translateY(-50%);
  width: 1.2em;
  height: 1.2em;
  background: #f42a41; /* Bangladesh red */
  border-radius: 50%;
  box-shadow: 0 0 0 2px #fffbe7;
  z-index: 1;
}
@media (max-width: 600px) {
  .bd-flag-text {
    font-size: 1.6rem;
    padding: 0.3em 1em 0.3em 1.8em;
  }
  .bd-flag-text::before {
    width: 1em;
    height: 1em;
    left: 0.4em;
  }

  .loading {
    text-align: center;
    justify-content: center;
  }
}

/* Notification Modal Tweaks */
#notificationModal .modal-content {
  max-width: 400px;
  width: 95vw;
}
#notificationModal .modal-header {
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-primary);
}
#notificationModal .modal-body {
  padding: 1rem;
  max-height: 350px;
  overflow-y: auto;
}
#notificationModal .notification-list {
  max-height: 250px;
  overflow-y: auto;
}
#notificationModal .clear-notifications {
  margin-bottom: 1rem;
  float: right;
}

/* History Modal Tweaks */
#historyModal .modal-content {
  max-height: 95vh;
  min-height: 600px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-width: 900px;
  width: 98vw;
}

#historyModal .modal-header {
  flex-shrink: 0;
}

#historyModal .modal-body {
  flex: 1;
  overflow: hidden;
  padding: 0;
}

#historyModal .history-list {
  max-height: 80vh;
  min-height: 400px;
  overflow-y: auto;
  padding: 2rem 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border-medium) transparent;
}

#historyModal .history-list::-webkit-scrollbar {
  width: 6px;
}

#historyModal .history-list::-webkit-scrollbar-track {
  background: transparent;
}

#historyModal .history-list::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: 3px;
}

#historyModal .history-list::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

#historyModal .clear-history {
  margin: 0 2rem 1.5rem 2rem;
}

/* Ensure history items are properly visible */
#historyModal .history-item {
  background: var(--bg-primary);
  border-radius: var(--border-radius-sm);
  padding: 1.5rem;
  border-left: 4px solid var(--primary);
  transition: all 0.2s ease;
  cursor: pointer;
  position: relative;
  overflow: visible;
  margin-bottom: 0.75rem;
  min-width: 100%;
  box-sizing: border-box;
  min-height: 120px;
  max-height: none;
  word-break: break-word;
}

#historyModal .history-item:last-child {
  margin-bottom: 0;
}

#historyModal .history-item:hover {
  transform: translateX(5px);
  box-shadow: var(--shadow-md);
  background: var(--bg-card);
}

#historyModal .history-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}

#historyModal .history-train-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
}

#historyModal .history-train-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#historyModal .history-train-number {
  color: var(--text-secondary);
  font-size: 0.9rem;
  white-space: nowrap;
}

#historyModal .history-timestamp {
  color: var(--text-muted);
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  white-space: nowrap;
  flex-shrink: 0;
}

#historyModal .history-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.5rem;
  margin-top: 0.5rem;
}

#historyModal .history-detail {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  min-width: 0;
}

#historyModal .history-detail-label {
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}

#historyModal .history-detail-value {
  color: var(--text-primary);
  overflow: auto;
  text-overflow: ellipsis;
  white-space: normal;
  word-break: break-word;
}

/* Responsive history modal */
@media (max-width: 900px) {
  #historyModal .modal-content {
    min-height: 400px;
    max-width: 99vw;
  }
  #historyModal .history-list {
    min-height: 200px;
    max-height: 60vh;
    padding: 1rem;
  }
}

@media (max-width: 600px) {
  #historyModal .modal-content {
    min-height: unset;
    max-height: 95vh;
  }
  #historyModal .history-list {
    min-height: unset;
    max-height: 60vh;
    padding: 0.75rem;
  }
}

/* Additional mobile fixes for very small screens */
@media (max-width: 480px) {
  #historyModal .modal-content {
    margin: 0.5rem;
    max-height: 95vh;
  }

  #historyModal .history-list {
    padding: 0.75rem;
    max-height: 75vh;
  }

  #historyModal .history-item {
    padding: 0.75rem;
    margin-bottom: 0.75rem;
  }

  #historyModal .history-train-name {
    font-size: 0.9rem;
    max-width: none;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    word-break: break-word;
  }

  #historyModal .history-train-number {
    font-size: 0.8rem;
    max-width: none;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
  }

  #historyModal .history-timestamp {
    font-size: 0.7rem;
  }

  #historyModal .history-detail {
    padding: 0.4rem;
  }

  #historyModal .history-detail-label {
    font-size: 0.75rem;
  }

  #historyModal .history-detail-value {
    font-size: 0.85rem;
  }
}

@media (max-width: 360px) {
  #historyModal .modal-content {
    margin: 0.25rem;
  }

  #historyModal .history-list {
    padding: 0.5rem;
  }

  #historyModal .history-item {
    padding: 0.5rem;
    margin-bottom: 0.5rem;
  }

  #historyModal .history-train-name {
    font-size: 0.85rem;
    max-width: none;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    word-break: break-word;
  }

  #historyModal .history-train-number {
    font-size: 0.75rem;
    max-width: none;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
  }

  #historyModal .history-timestamp {
    font-size: 0.65rem;
  }

  #historyModal .history-detail {
    padding: 0.3rem;
  }

  #historyModal .history-detail-label {
    font-size: 0.7rem;
  }

  #historyModal .history-detail-value {
    font-size: 0.8rem;
  }
}

/* Improve Clear All button visibility in modals */
#notificationModal .clear-notifications,
#historyModal .clear-history {
  background: var(--primary);
  color: #fff;
  font-weight: bold;
  border: none;
  border-radius: var(--border-radius-sm);
  padding: 0.5rem 1rem;
  margin-bottom: 1rem;
  float: right;
  cursor: pointer;
  transition:
    background 0.2s,
    color 0.2s;
}
#notificationModal .clear-notifications:hover,
#historyModal .clear-history:hover {
  background: var(--error);
  color: #fff;
}

/* Terms and Privacy Pages Mobile Responsive Styles */
.terms-content {
  max-width: 700px;
  margin: 2.5rem auto;
  background: var(--bg-card, #fff);
  border-radius: var(--border-radius-lg);
  box-shadow:
    0 8px 32px rgba(0, 106, 78, 0.1),
    0 1.5px 4px rgba(0, 0, 0, 0.04);
  padding: 2.5rem 2.5rem 2rem 2.5rem;
  line-height: 1.8;
  border: 1.5px solid var(--border-light);
  transition: box-shadow 0.3s;
}
.terms-content:hover {
  box-shadow:
    0 16px 40px rgba(0, 106, 78, 0.13),
    0 2px 8px rgba(0, 0, 0, 0.06);
}
.terms-content h2 {
  color: var(--primary);
  margin-bottom: 2rem;
  font-size: 2.2rem;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.01em;
}
.terms-content section {
  margin-bottom: 2.2rem;
  padding-bottom: 1.2rem;
  border-bottom: 1px solid var(--border-light);
}
.terms-content section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}
.terms-content h3 {
  color: var(--secondary);
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.7rem;
  margin-top: 0.5rem;
  letter-spacing: 0.01em;
}
.terms-content ul {
  margin-bottom: 1.2rem;
  padding-left: 1.5rem;
}
.terms-content li {
  margin-bottom: 0.7rem;
  color: var(--text-primary);
  font-size: 1.05rem;
  line-height: 1.7;
  border-left: 3px solid var(--bd-green);
  padding-left: 0.7rem;
  background: rgba(0, 106, 78, 0.03);
  border-radius: 6px;
  margin-top: 0.2rem;
  transition: background 0.2s;
}
.terms-content li:hover {
  background: rgba(0, 106, 78, 0.07);
}
.terms-content p.hero-desc {
  font-size: 1.15rem;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 2.2rem;
  font-weight: 500;
}
.terms-content .modern-meta {
  margin-top: 2.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.98rem;
}
.terms-content .modern-meta a {
  color: var(--secondary);
  text-decoration: underline;
  font-weight: 500;
}
@media (max-width: 768px) {
  .terms-content {
    margin: 1rem;
    padding: 1.2rem 0.7rem 1.2rem 0.7rem;
    border-radius: var(--border-radius-sm);
  }
  .terms-content h2 {
    font-size: 1.5rem;
    margin-bottom: 1.2rem;
  }
  .terms-content h3 {
    font-size: 1.1rem;
  }
  .terms-content ul {
    padding-left: 1rem;
  }
  .terms-content li {
    font-size: 0.97rem;
    padding-left: 0.5rem;
  }
  .terms-content p.hero-desc {
    font-size: 1rem;
    margin-bottom: 1.2rem;
  }
}
@media (max-width: 480px) {
  .terms-content {
    margin: 0.5rem;
    padding: 0.7rem 0.2rem 0.7rem 0.2rem;
  }
  .terms-content h2 {
    font-size: 1.2rem;
  }
  .terms-content h3 {
    font-size: 1rem;
  }
  .terms-content li {
    font-size: 0.9rem;
    padding-left: 0.3rem;
  }
  .terms-content p.hero-desc {
    font-size: 0.95rem;
  }
}

/* Mobile Responsive Adjustments */
@media (max-width: 768px) {
  .terms-content {
    margin: 1rem;
    padding: 1.5rem;
    border-radius: var(--border-radius-sm);
  }

  .terms-content h2 {
    font-size: 1.5rem;
    margin-bottom: 1.2rem;
  }

  .terms-content ul {
    padding-left: 1.2rem;
  }

  .terms-content li {
    margin-bottom: 0.7rem;
    font-size: 0.95rem;
  }

  .terms-content p {
    font-size: 0.95rem;
  }
}

@media (max-width: 480px) {
  .terms-content {
    margin: 0.5rem;
    padding: 1rem;
    border-radius: var(--border-radius-sm);
  }

  .terms-content h2 {
    font-size: 1.3rem;
    margin-bottom: 1rem;
  }

  .terms-content ul {
    padding-left: 1rem;
  }

  .terms-content li {
    margin-bottom: 0.6rem;
    font-size: 0.9rem;
    line-height: 1.6;
  }

  .terms-content p {
    font-size: 0.9rem;
    line-height: 1.6;
  }
}

@media (max-width: 360px) {
  .terms-content {
    margin: 0.25rem;
    padding: 0.75rem;
  }

  .terms-content h2 {
    font-size: 1.2rem;
  }

  .terms-content li,
  .terms-content p {
    font-size: 0.85rem;
  }
}

/* Additional Mobile Responsive Footer Improvements */
@media (max-width: 480px) {
  footer {
    padding: 1rem 0.5rem;
    text-align: center;
  }

  footer p {
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
    line-height: 1.4;
  }

  footer .footer-link {
    font-size: 0.85rem;
    padding: 0.2rem 0.4rem;
    margin: 0 0.2rem;
    display: inline-block;
    min-width: 80px;
  }

  footer a {
    font-size: 0.85rem;
    word-break: break-word;
  }
}

@media (max-width: 360px) {
  footer {
    padding: 0.75rem 0.25rem;
  }

  footer p {
    font-size: 0.8rem;
    margin-bottom: 0.4rem;
  }

  footer .footer-link {
    font-size: 0.8rem;
    padding: 0.15rem 0.3rem;
    margin: 0 0.15rem;
    min-width: 70px;
  }

  footer a {
    font-size: 0.8rem;
  }
}

/* Touch-friendly improvements for mobile */
@media (max-width: 768px) {
  .footer-link,
  footer a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0.75rem;
    margin: 0.25rem;
    border-radius: var(--border-radius-sm);
    transition: all 0.3s ease;
  }

  .footer-link:hover,
  footer a:hover {
    background: rgba(0, 106, 78, 0.1);
    transform: translateY(-1px);
  }

  .footer-link:active,
  footer a:active {
    transform: translateY(0);
    background: rgba(0, 106, 78, 0.2);
  }
}

/* ===== COMPREHENSIVE MOBILE RESPONSIVENESS IMPROVEMENTS ===== */

/* Enhanced Mobile History Section */
@media (max-width: 768px) {
  .history-section {
    margin: 0.5rem;
    padding: 1rem;
    border-radius: var(--border-radius);
  }

  .history-header {
    padding: 1rem;
    margin-bottom: 1rem;
  }

  .history-header h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
  }

  .clear-history {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    min-height: 40px;
  }

  .history-item {
    padding: 1rem;
    margin-bottom: 0.75rem;
    border-radius: var(--border-radius-sm);
  }

  .history-item-header {
    margin-bottom: 0.75rem;
  }

  .history-train-name {
    font-size: 1rem;
    font-weight: 600;
  }

  .history-train-number {
    font-size: 0.9rem;
  }

  .history-timestamp {
    font-size: 0.8rem;
  }

  .history-details {
    gap: 0.5rem;
  }

  .history-detail {
    padding: 0.5rem;
    border-radius: var(--border-radius-sm);
  }

  .history-detail-label {
    font-size: 0.8rem;
  }

  .history-detail-value {
    font-size: 0.9rem;
  }
}

/* Enhanced Mobile Modals */
@media (max-width: 768px) {
  .modal-content {
    width: 95vw;
    max-width: 95vw;
    margin: 1rem auto;
    border-radius: var(--border-radius);
    max-height: 90vh;
    overflow-y: auto;
  }

  .modal-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-light);
  }

  .modal-header-actions {
    gap: 0.25rem;
  }

  .modal-header-actions .clear-notifications,
  .modal-header-actions .clear-history {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    height: 32px;
  }

  .modal-header h3 {
    font-size: 1.2rem;
    line-height: 1;
  }

  .modal-close {
    width: 32px;
    height: 32px;
    font-size: 1.5rem;
    border-radius: 50%;
    background: var(--bg-secondary);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    line-height: 1;
  }

  .modal-body {
    padding: 1rem;
  }

  .modal-body p {
    font-size: 0.95rem;
    line-height: 1.5;
  }

  .modal-footer {
    padding: 1rem;
    flex-direction: column;
    gap: 0.75rem;
    border-top: 1px solid var(--border-light);
  }

  .modal-btn {
    width: 100%;
    min-height: 48px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--border-radius-sm);
    transition: all 0.3s ease;
  }

  .modal-btn:active {
    transform: scale(0.98);
  }
}

/* Enhanced Mobile Notifications */
@media (max-width: 768px) {
  .notification {
    width: 95vw;
    max-width: 95vw;
    left: 2.5vw;
    right: 2.5vw;
    font-size: 0.95rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-xl);
  }

  .notification-header {
    padding: 0.75rem 1rem;
  }

  .notification-title {
    font-size: 1rem;
    font-weight: 600;
  }

  .notification-message {
    font-size: 0.9rem;
    line-height: 1.4;
  }

  .notification-close {
    width: 32px;
    height: 32px;
    font-size: 1.2rem;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.1);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
  }
}

/* Enhanced Mobile Footer */
@media (max-width: 768px) {
  footer {
    padding: 1.5rem 1rem;
    text-align: center;
    background: var(--primary-gradient);
    color: var(--text-white);
  }

  footer p {
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
    line-height: 1.4;
  }

  footer a {
    color: var(--text-white);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
    padding: 0.5rem 0.75rem;
    border-radius: var(--border-radius-sm);
    display: inline-block;
    margin: 0.25rem;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  footer a:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
  }

  footer a:active {
    transform: translateY(0);
    background: rgba(255, 255, 255, 0.2);
  }
}

/* Extra Small Mobile Devices (320px - 480px) */
@media (max-width: 480px) {
  header {
    padding: 0.75rem 0;
  }

  .logo-text h1 {
    font-size: 1.2rem;
  }

  .logo-text p {
    font-size: 0.8rem;
  }

  .notification-bell,
  .history-toggle,
  .server-status-container {
    min-width: 44px;
    min-height: 44px;
    padding: 0.6rem;
    font-size: 0.9rem;
  }

  .server-status-text {
    font-size: 0.75rem;
  }

  #search-section {
    margin: 0.25rem;
    padding: 1rem 0.75rem;
  }

  #search-section h2 {
    font-size: 1.1rem;
  }

  #trainIdInput,
  #searchButton {
    min-height: 45px;
    font-size: 0.95rem;
  }

  #map {
    height: 200px;
  }

  #train-info {
    padding: 0.75rem;
    max-height: 50vh;
  }

  #train-info h3 {
    font-size: 1.1rem;
  }

  #train-info p {
    font-size: 0.9rem;
  }

  .modal-content {
    margin: 0.5rem;
    padding: 1rem;
  }

  .notification {
    margin: 0.5rem;
    padding: 0.75rem;
    font-size: 0.9rem;
  }

  footer {
    padding: 0.75rem 0.25rem;
  }

  footer p {
    font-size: 0.8rem;
  }

  footer a {
    font-size: 0.8rem;
  }
}

@media (max-width: 360px) {
  .header-content {
    padding: 0 0.5rem;
  }

  .logo-text h1 {
    font-size: 1.1rem;
  }

  .logo-text p {
    font-size: 0.75rem;
  }

  .notification-bell,
  .history-toggle,
  .server-status-container {
    min-width: 40px;
    min-height: 40px;
    padding: 0.5rem;
    font-size: 0.85rem;
  }

  .server-status-text {
    font-size: 0.7rem;
  }

  #search-section {
    margin: 0.2rem;
    padding: 0.75rem 0.5rem;
  }

  #search-section h2 {
    font-size: 1rem;
  }

  #trainIdInput,
  #searchButton {
    min-height: 40px;
    font-size: 0.9rem;
  }

  #map {
    height: 180px;
  }

  #train-info {
    padding: 0.5rem;
    max-height: 45vh;
  }

  #train-info h3 {
    font-size: 1rem;
  }

  #train-info p {
    font-size: 0.85rem;
  }

  .modal-content {
    margin: 0.25rem;
    padding: 0.75rem;
  }

  .modal-header,
  .modal-body,
  .modal-footer {
    padding: 0.5rem;
  }

  .modal-btn {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
  }

  .notification {
    margin: 0.25rem;
    padding: 0.5rem;
    font-size: 0.85rem;
  }

  footer {
    padding: 0.5rem 0.2rem;
  }

  footer p {
    font-size: 0.75rem;
  }

  footer a {
    font-size: 0.75rem;
  }
}

/* Touch-friendly improvements for all interactive elements */
@media (max-width: 768px) {
  button,
  .notification-bell,
  .history-toggle,
  .clear-history,
  .modal-close,
  .notification-close,
  .status-close {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  input,
  button,
  select,
  textarea {
    font-size: 16px; /* Prevents zoom on iOS */
  }

  /* Prevent horizontal scrolling */
  body {
    overflow-x: hidden;
    width: 100%;
  }

  /* Improve scrolling performance */
  * {
    -webkit-overflow-scrolling: touch;
  }
}

/* Landscape orientation improvements */
@media (max-width: 768px) and (orientation: landscape) {
  header {
    min-height: 40px;
    padding: 0.25rem 0;
  }

  .header-content {
    flex-direction: row;
    gap: 0.5rem;
  }

  #map {
    height: 150px;
  }

  #train-info {
    max-height: 40vh;
  }

  .modal-content {
    max-height: 80vh;
  }
}

/* Server Status Container and Text */
.server-status-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--border-radius-sm);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  transition: all 0.3s ease;
}

.server-status-text {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-white);
  white-space: nowrap;
}

.server-status-container.online .server-status-text {
  color: var(--text-white);
}

.server-status-container.online .server-status-text::after {
  content: " Up";
  color: #4ade80;
}

.server-status-container.offline .server-status-text {
  color: var(--text-white);
}

.server-status-container.offline .server-status-text::after {
  content: " Down";
  color: #f87171;
}

@media (max-width: 768px) {
  .server-status-container {
    padding: 0.4rem 0.6rem;
    gap: 0.4rem;
  }

  .server-status-text {
    font-size: 0.8rem;
  }
}

@media (max-width: 480px) {
  .server-status-container {
    padding: 0.3rem 0.5rem;
    gap: 0.3rem;
    min-width: 0;
    flex-shrink: 1;
    max-width: 100vw;
  }

  .server-status-text {
    font-size: 0.68rem;
    max-width: 120px;
    overflow: visible;
    text-overflow: unset;
    white-space: normal;
    word-break: break-word;
    display: inline-block;
  }
}

@media (max-width: 360px) {
  .server-status-text {
    font-size: 0.62rem;
    max-width: 100px;
  }
}

/* Search input placeholder animation */
@keyframes placeholder-marquee {
  0% {
    transform: translateX(100%);
  }
  100% {
    transform: translateX(-100%);
  }
}

#trainIdInput::placeholder {
  animation: placeholder-marquee 8s linear infinite;
  white-space: nowrap;
  overflow: hidden;
}

/* Pause animation on focus */
#trainIdInput:focus::placeholder {
  animation-play-state: paused;
}

/* Hide scrollbar if there are no history items */
#historyModal .history-list:empty,
#historyModal .history-list:has(.history-empty) {
  overflow-y: hidden !important;
}

@media (max-width: 1080px) and (min-width: 769px) {
  .header-content {
    flex-direction: column;
    gap: 0.75rem;
    padding: 0 1.5rem;
    align-items: stretch;
  }
  .header-controls {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
  }
  .logo-text h1 {
    font-size: 1.4rem;
  }
  .logo-text p {
    font-size: 0.9rem;
  }
}

/* Train Animation Container */
#trainAnimationContainer {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 1rem auto 0 auto;
  min-height: 120px;
  position: relative;
}

.train-animation-container {
  position: relative;
  width: 200px;
  height: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.train-animation-train {
  font-size: 2.5rem;
  animation: trainAnimationMove 3s ease-in-out infinite;
  position: relative;
  z-index: 2;
}

.train-animation-track {
  position: absolute;
  bottom: 20px;
  width: 100%;
  height: 4px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--border-medium) 10%,
    var(--border-medium) 90%,
    transparent 100%
  );
  border-radius: 2px;
  z-index: 1;
}

.train-animation-track::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 0;
  width: 100%;
  height: 16px;
  background: repeating-linear-gradient(
    90deg,
    transparent 0px,
    transparent 12px,
    var(--border-light) 12px,
    var(--border-light) 16px
  );
  border-radius: 1px;
}

.train-animation-text {
  margin-top: 1rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  font-family: "Inter", sans-serif;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes trainAnimationMove {
  0% {
    transform: translateX(-100px) scale(0.8);
    opacity: 0;
  }
  20% {
    transform: translateX(-60px) scale(1);
    opacity: 1;
  }
  80% {
    transform: translateX(60px) scale(1);
    opacity: 1;
  }
  100% {
    transform: translateX(100px) scale(0.8);
    opacity: 0;
  }
}

/* Responsive train animation */
@media (max-width: 768px) {
  .train-animation-container {
    width: 150px;
    height: 60px;
  }

  .train-animation-train {
    font-size: 2rem;
  }

  .train-animation-track {
    bottom: 15px;
    height: 3px;
  }

  .train-animation-track::before {
    top: -4px;
    height: 12px;
  }

  .train-animation-text {
    font-size: 0.9rem;
    margin-top: 0.75rem;
  }
}

#historyModal .history-item {
  min-height: 80px;
  max-height: 180px;
  overflow: auto;
  word-break: break-word;
}
#historyModal .history-detail-value {
  white-space: normal;
  word-break: break-word;
  overflow: auto;
}

.notification-item.unread {
  background: #f0f8ff;
  border-left: 4px solid var(--primary);
}
.notification-item.unread .notification-item-title {
  font-weight: bold;
  color: var(--primary);
}

@media (max-width: 768px) {
  #historyModal .modal-content {
    max-height: 90vh;
    margin: 1rem;
  }

  #historyModal .history-list {
    max-height: 70vh;
    padding: 1rem;
  }

  #historyModal .history-item {
    padding: 1.25rem;
    min-height: 100px;
    margin-bottom: 0.75rem;
  }

  #historyModal .history-item-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  #historyModal .history-train-info {
    width: 100%;
    justify-content: space-between;
  }

  #historyModal .history-train-name {
    font-size: 0.95rem;
    max-width: none;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    word-break: break-word;
  }

  #historyModal .history-train-number {
    font-size: 0.85rem;
    max-width: none;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
  }

  #historyModal .history-timestamp {
    width: 100%;
    justify-content: flex-end;
    font-size: 0.75rem;
  }

  #historyModal .history-details {
    grid-template-columns: 1fr;
    gap: 0.75rem;
    margin-top: 0.75rem;
  }

  #historyModal .history-detail {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
    padding: 0.5rem;
    background: rgba(0, 106, 78, 0.05);
    border-radius: var(--border-radius-sm);
  }

  #historyModal .history-detail-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 600;
  }

  #historyModal .history-detail-value {
    font-size: 0.9rem;
    color: var(--text-primary);
    word-break: break-word;
    white-space: normal;
    line-height: 1.4;
  }
}

/* Network Status Indicator */
.network-status {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10000;
  background: linear-gradient(90deg, #ff6b6b 0%, #ee5a52 100%);
  color: white;
  padding: 0.75rem 1rem;
  text-align: center;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transform: translateY(-100%);
  transition: transform 0.3s ease;
}

.network-status.show {
  transform: translateY(0);
}

.network-offline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.network-icon {
  font-size: 1.2rem;
  animation: pulse 2s infinite;
}

.network-text {
  font-size: 0.9rem;
}

/* Offline Mode Styles */
.offline-mode {
  background: rgba(255, 107, 107, 0.1);
  border: 1px solid rgba(255, 107, 107, 0.3);
  border-radius: var(--border-radius-sm);
  padding: 0.5rem;
  margin: 0.5rem 0;
  font-size: 0.85rem;
  color: #d63031;
}

.offline-mode .offline-icon {
  margin-right: 0.5rem;
  font-size: 1rem;
}

/* Low Bandwidth Optimizations */
@media (max-width: 480px) {
  .network-status {
    padding: 0.5rem;
  }

  .network-text {
    font-size: 0.8rem;
  }
}

/* Connection Speed Detection */
.connection-slow {
  opacity: 0.8;
}

.connection-slow .network-text::after {
  content: " (Slow Connection)";
  font-size: 0.8rem;
  opacity: 0.8;
}

/* Progressive Enhancement */
@supports not (display: grid) {
  .history-details {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }
}

/* Fallback for older browsers */
.no-serviceworker .offline-features {
  display: none;
}

/* Loading States for Different Network Speeds */
.loading-slow {
  animation: loadingSlow 3s ease-in-out infinite;
}

.loading-medium {
  animation: loadingMedium 2s ease-in-out infinite;
}

.loading-fast {
  animation: loadingFast 1s ease-in-out infinite;
}

@keyframes loadingSlow {
  0%,
  100% {
    opacity: 0.3;
  }
  50% {
    opacity: 1;
  }
}

@keyframes loadingMedium {
  0%,
  100% {
    opacity: 0.5;
  }
  50% {
    opacity: 1;
  }
}

@keyframes loadingFast {
  0%,
  100% {
    opacity: 0.7;
  }
  50% {
    opacity: 1;
  }
}

/* Connection Quality Indicator */
.connection-indicator {
  /* Removed: display: flex; ... all styles ... */
  display: none !important;
}
.connection-indicator.connection-fast,
.connection-indicator.connection-medium,
.connection-indicator.connection-slow,
.connection-indicator.connection-offline {
  display: none !important;
}

/* Mobile responsive for connection indicator */
@media (max-width: 768px) {
  .connection-indicator {
    min-width: 40px;
    min-height: 40px;
    padding: 0.4rem;
  }

  .connection-text {
    display: none;
  }

  .connection-icon {
    font-size: 0.9rem;
  }
}

@media (max-width: 480px) {
  .connection-indicator {
    min-width: 36px;
    min-height: 36px;
    padding: 0.3rem;
  }

  .connection-icon {
    font-size: 0.8rem;
  }
}

/* Ensure header modal-btns have spacing */
.header-controls .modal-btn {
  margin-left: 0.5rem;
}

/* Mobile/touch and accessibility improvements */
button, .modal-btn, .notification-bell, .history-toggle, .clear-notifications, .clear-history {
  min-width: 44px;
  min-height: 44px;
  touch-action: manipulation;
  font-size: 1rem;
}
button:active, .modal-btn:active, .notification-bell:active, .history-toggle:active, .clear-notifications:active, .clear-history:active,
button:focus-visible, .modal-btn:focus-visible, .notification-bell:focus-visible, .history-toggle:focus-visible, .clear-notifications:focus-visible, .clear-history:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  filter: brightness(0.95);
}
@media (max-width: 600px) {
  .header-controls {
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    gap: 0.5rem;
    align-items: center;
    justify-content: center;
    width: 100%;
  }
  button, .modal-btn, .notification-bell, .history-toggle, .clear-notifications, .clear-history {
    font-size: 1.1rem;
    min-width: 48px;
    min-height: 48px;
    padding: 0.75rem;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
  .notification-bell {
    position: relative;
    z-index: 1002;
  }
  input, select, textarea {
    font-size: 1.05rem;
    min-height: 44px;
  }
  .search-container {
    flex-direction: column;
    gap: 0.7rem;
  }
  .modal-content {
    box-shadow: 0 2px 8px rgba(0,0,0,0.10);
  }
}
