:root {
  --primary: #2c337c;
  --secondary: #4f4e8e;
  --tertiary: #716ca2;
  --light-bg: #f1f4f8;
  --dark-bg: #000000;
  --text-light: #000000;
  --text-dark: #ffffff;
  --header-bg: #1a1a1a;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  font-family: 'Gothic A1', sans-serif;
  background-color: var(--light-bg);
  color: var(--text-light);
  transition: background-color 0.3s, color 0.3s;
}

body.dark {
  background-color: var(--dark-bg);
  color: var(--text-dark);
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background-color: var(--header-bg);
  color: white;
}

.logo-link {
  display: flex;
  align-items: center;
}

.logo {
  height: 60px;
  object-fit: contain;
}

.header-buttons {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-label {
  color: white;
  font-size: 0.95rem;
  margin-right: 5px;
  font-weight: 500;
}

.header-btn {
  background-color: var(--secondary);
  color: white;
  padding: 8px 12px;
  border-radius: 4px;
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 600;
}

.header-btn:hover {
  background-color: var(--tertiary);
}

#toggleMode {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: white;
  cursor: pointer;
}

#toggleMode:focus {
  outline: 2px solid var(--secondary);
  outline-offset: 2px;
  border-radius: 4px;
}

.container {
  flex: 1;
  max-width: 900px;
  margin: 20px auto;
  padding: 0 20px;
}

.category-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}

.category-buttons button {
  padding: 10px 15px;
  border: none;
  background-color: var(--primary);
  color: white;
  border-radius: 4px;
  cursor: pointer;
}

.category-buttons button:hover {
  background-color: var(--tertiary);
}

.category-buttons button:focus {
  outline: 2px solid var(--secondary);
  outline-offset: 2px;
}

.service-card {
  background: white;
  padding: 15px;
  margin-top: 15px;
  border-radius: 5px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

body.dark .service-card {
  background-color: #1a1a1a;
  color: white;
}

.visit-btn {
  display: inline-block;
  padding: 8px 12px;
  background-color: var(--secondary);
  color: white;
  text-decoration: none;
  border-radius: 4px;
  margin-top: 5px;
  font-weight: 600;
}

.visit-btn:hover {
  background-color: var(--tertiary);
}

/* Header row: title wraps, buttons stay right */
.service-card > div {
  display: flex;
  align-items: flex-start;
}

.service-card > div h3 {
  flex: 1 1 auto;
  min-width: 0;
  word-break: break-word;
  margin: 0;
}

.service-card > div > div {
  flex: 0 0 auto;
  margin-left: auto;
  white-space: nowrap;
}

/* Service card structure */
.service-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.service-title {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
  word-break: break-word;
}

.service-buttons {
  display: flex;
  gap: 10px;
  flex: 0 0 auto;
  margin-left: auto;
  white-space: nowrap;
}

.service-description,
.service-address,
.service-directions {
  margin-top: 10px;
}

/* Footer styling */
footer {
  font-size: 0.75rem;
  text-align: center;
  padding: 10px 0;
  color: var(--secondary);
}

body.dark footer {
  color: var(--tertiary);
}

/* Loading spinner styles */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  padding: 40px 20px;
  text-align: center;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--light-bg);
  border-top: 4px solid var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

body.dark .loading-spinner {
  border: 4px solid #333;
  border-top: 4px solid var(--secondary);
}

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

.loading-text {
  font-size: 1.1rem;
  color: var(--secondary);
  font-weight: 500;
}

body.dark .loading-text {
  color: var(--tertiary);
}

/* Responsive design for small screens (under 768px) */
@media (max-width: 767px) {
  /* Header adjustments - stack vertically */
  header {
    padding: 12px 16px;
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }
  
  .logo {
    height: 50px;
  }
  
  .header-buttons {
    flex-direction: column;
    gap: 8px;
    width: 100%;
  }
  
  .header-label {
    font-size: 0.9rem;
    margin-right: 0;
    margin-bottom: 5px;
  }
  
  .header-btn {
    padding: 8px 12px;
    font-size: 0.9rem;
    width: 100%;
    text-align: center;
  }
  
  /* Main content adjustments */
  .container {
    margin: 15px auto;
    padding: 0 15px;
  }
  
  /* Keep original title sizes */
  .container h1 {
    text-align: center;
    line-height: 1.3;
  }
  
  .container h2 {
    text-align: center;
    line-height: 1.3;
  }
  
  /* Category buttons - better stacking */
  .category-buttons {
    gap: 8px;
    justify-content: center;
  }
  
  .category-buttons button {
    padding: 10px 15px;
    font-size: 0.9rem;
    flex: 1 1 calc(50% - 4px);
    min-width: 120px;
    text-align: center;
  }
  
  /* Override general service card rules to force vertical layout */
  .service-card > div {
    display: block !important;
  }
  
  .service-card > div h3 {
    flex: none !important;
    margin-left: 0 !important;
    margin-bottom: 12px;
    text-align: center;
  }
  
  .service-card > div > div {
    flex: none !important;
    margin-left: 0 !important;
    white-space: normal !important;
  }
  
  /* Service card layout for small screens */
  .service-card {
    padding: 15px;
    display: flex;
    flex-direction: column;
  }
  
  /* Override service header to stack vertically */
  .service-header {
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    margin-bottom: 15px;
  }
  
  .service-title {
    text-align: center;
    margin: 0 0 12px 0 !important;
    flex: none !important;
    min-width: auto !important;
  }
  
  .service-buttons {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    width: 100% !important;
    margin-left: 0 !important;
    white-space: normal !important;
    flex: none !important;
  }
  
  /* Smaller, responsive buttons */
  .visit-btn {
    padding: 8px 16px;
    font-size: 0.85rem;
    width: 100%;
    text-align: center;
    margin: 0;
    box-sizing: border-box;
  }
  
  .service-description {
    order: 3;
    margin-top: 15px;
    text-align: center;
  }
  
  .service-address {
    order: 4;
    margin-top: 10px;
    text-align: center;
  }
  
  .service-directions {
    order: 5;
    margin-top: 10px;
    text-align: center;
  }
  
  .directions-btn {
    max-width: 200px;
    margin: 0 auto;
    display: block;
  }
  
  /* Loading adjustments */
  .loading {
    padding: 30px 15px;
  }
  
  .loading-spinner {
    width: 35px;
    height: 35px;
  }
  
  /* Footer adjustments */
  footer {
    padding: 12px 15px;
    line-height: 1.4;
  }
  
  /* Theme toggle */
  #toggleMode {
    font-size: 1.3rem;
  }
}