/* Custom Color Variables */
:root {
  /* Light Mode Colors */
  --primary-color: #27638a;
  --on-primary-color: #ffffff;
  --background-color: #f7f9ff;
  --on-background-color: #181c20;
  --surface-color: #ffffff;
  --on-surface-color: #181c20;
  --secondary-color: #50606e;
  --on-secondary-color: #ffffff;
  --error-color: #ba1a1a;
  --on-error-color: #ffffff;
}

/* Dark Mode Colors */
@media (prefers-color-scheme: dark) {
  :root {
    --primary-color: #96cdf8;
    --on-primary-color: #001e30;
    --background-color: #181c20;
    --on-background-color: #f7f9ff;
    --surface-color: #2d3135;
    --on-surface-color: #eef1f6;
    --secondary-color: #b7c9d9;
    --on-secondary-color: #0c1d29;
    --error-color: #ffb4ab;
    --on-error-color: #690005;
  }
}

/* Base Styles */
body {
  background-color: var(--background-color);
  color: var(--on-background-color);
  line-height: 1.6;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

/* Override Bootstrap Colors */
.navbar,
.footer,
.card,
.header,
.bg-primary,
.bg-light,
.bg-white {
  background-color: var(--surface-color) !important;
  color: var(--on-surface-color) !important;
}

.navbar .navbar-brand,
.navbar .nav-link,
.footer a,
.header h1,
.header p,
.card-title,
.card-text {
  color: var(--on-surface-color) !important;
}

.bg-primary {
  background-color: var(--primary-color) !important;
  color: var(--on-primary-color) !important;
}

.text-primary {
  color: var(--primary-color) !important;
}

.text-secondary {
  color: var(--secondary-color) !important;
}

/* Primary Actions */
.btn-primary {
  background-color: var(--primary-color);
  color: var(--on-primary-color);
  border-color: var(--primary-color);
}

.btn-primary:hover {
  background-color: var(--secondary-color);
  color: var(--on-secondary-color);
}

/* Secondary and Tertiary Styles */
.btn-donation-amount,
.btn-donation-period {
  background-color: var(--surface-color);
  color: var(--on-surface-color);
  border: 2px solid var(--primary-color);
  flex: 1;
  font-size: 1rem;
  padding: 0.75rem;
  margin-right: -2px; /* Overlap borders slightly */
  transition: background-color 0.3s, color 0.3s, border-color 0.3s;
  cursor: pointer;
}

.btn-donation-period {
  font-size: 0.8rem;
  padding: 0.5rem;
}

.btn-donation-amount:first-child,
.btn-donation-period:first-child {
  border-top-left-radius: 0.5rem;
  border-bottom-left-radius: 0.5rem;
}

.btn-donation-amount:last-child,
.btn-donation-period:last-child {
  border-top-right-radius: 0.5rem;
  border-bottom-right-radius: 0.5rem;
  margin-right: 0;
}

.btn-donation-amount:hover,
.btn-donation-amount:focus,
.btn-donation-amount.active,
.btn-donation-period:hover,
.btn-donation-period:focus,
.btn-donation-period.active {
  background-color: var(--primary-color);
  color: var(--on-primary-color);
  border-color: var(--primary-color);
}

/* Hero Section */
.header {
  background-color: var(--primary-color) !important;
  color: var(--on-primary-color) !important;
}

.header h1,
.header p {
  color: var(--on-primary-color) !important;
}

/* Features Section */
.features {
  background-color: var(--background-color);
  color: var(--on-background-color);
}

.card {
  background-color: var(--surface-color) !important;
  color: var(--on-surface-color) !important;
}

.card-title {
  color: var(--primary-color) !important;
}

/* Donation Section */
.donate {
  background-color: var(--surface-color);
  color: var(--on-surface-color);
}

.donation-form {
  background-color: var(--background-color);
  color: var(--on-background-color);
  border: 1px solid var(--primary-color);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--primary-color);
  box-shadow: none;
}

.form-control,
.form-select {
  background-color: var(--surface-color);
  color: var(--on-surface-color);
  border: 1px solid var(--primary-color);
  transition: border-color 0.3s, background-color 0.3s;
}

.form-control:focus,
.form-select:focus {
  background-color: var(
    --surface-color
  ); /* Ensure background stays consistent */
  color: var(--on-surface-color);
  border-color: var(--secondary-color) !important; /* Thicker border on focus */
  border-width: 2px;
  box-shadow: none;
  outline: none; /* Remove default browser outline */
}

.border-focus {
  border-color: var(--secondary-color) !important;
  border-width: 2px;
}

.border-error {
  border-color: var(--error-color) !important;
}

.form-control::placeholder,
.form-select::placeholder {
  color: var(--on-surface-color);
  opacity: 0.6;
}

.form-label {
  color: var(--on-surface-color);
}

.btn-block {
  display: block;
  width: 100%;
}

/* Footer */
/* Footer */
.footer {
  background-color: var(--primary-color) !important;
  color: var(--on-primary-color) !important;
  width: 100%;
  text-align: center;
}

.footer a {
  color: var(--on-primary-color) !important;
}

.footer a:hover {
  text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 768px) {
  .navbar .nav-links {
    flex-direction: column;
    align-items: center;
  }

  .navbar .nav-links li {
    margin-bottom: 0.5rem;
  }
}

/* Donation Form Styling */
.donation-form .btn-group .btn {
  font-size: 1rem;
}

.donation-form .btn-group .btn-check:checked + .btn,
.donation-form .btn-group .btn:hover {
  background-color: var(--primary-color);
  color: var(--on-primary-color);
}

.donation-form .form-control:focus {
  border-color: var(--primary-color);
  box-shadow: none;
}

/* Adjust input[type="radio"] visibility */
.btn-check {
  position: absolute;
  clip: rect(0, 0, 0, 0);
}

.btn-group.donation-amount-group {
  display: flex;
}

/* Form Validation */
.border-error {
  border-color: var(--error-color) !important;
}

/* Popup Styles */
.popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.popup-content {
  background-color: var(--surface-color);
  color: var(--on-surface-color);
  padding: 20px;
  border-radius: 10px;
  text-align: center;
  position: relative;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.popup-content h2 {
  margin-top: 0;
}

.popup-content p {
  margin-bottom: 20px;
}

/* Form Title and Call to Action */
.form-title {
  font-size: 1.5rem;
  font-weight: bold;
}

.call-to-action {
  font-size: 1rem;
  font-style: italic;
  color: var(--secondary-color);
}

/* Input Focus and Validation Styles */
.border-focus {
  border-color: var(--secondary-color) !important;
  border-width: 2px;
}

/* Adjust width and alignment */
.d-flex select {
  margin-right: 0.5rem;
  flex: 1;
}

/* Recurring Period Button Group */
.btn-group-sm .btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
}

/* Thank You Page Styling */
.thankyou-card {
  max-width: 600px;
  background-color: var(--surface-color);
  color: var(--on-surface-color);
  border: 1px solid var(--primary-color);
  padding: 2rem;
}

.thank-you-icon {
  margin: 1.5rem 0;
}

/* Reuse existing styles */
.form-title {
  font-size: 1.5rem;
  font-weight: bold;
}

.call-to-action {
  font-size: 1rem;
  font-style: italic;
  color: var(--secondary-color);
}

.btn-primary {
  background-color: var(--primary-color);
  color: var(--on-primary-color);
  border-color: var(--primary-color);
}

.btn-primary:hover {
  background-color: var(--secondary-color);
  color: var(--on-secondary-color);
}

/* Lottie Background */
.lottie-background {
  position: fixed; /* Fixed to viewport */
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden; /* Ensure animation doesn't overflow */
  z-index: 3; /* Place above the content */
  pointer-events: none; /* Make the background not interfere with clicks */
}

/* Thank You Page Content */
.container {
  position: relative; /* Make sure content is above the Lottie animation */
  z-index: 1; /* Ensure it is below the background */
}

/* Style for Recurring Donation Period Buttons */
.btn-donation-period {
  background-color: var(--surface-color);
  color: var(--on-surface-color);
  border: 2px solid var(--primary-color);
  margin-right: -2px;
  transition: background-color 0.3s, color 0.3s, border-color 0.3s;
  cursor: pointer;
}

.btn-donation-period:first-child {
  border-top-left-radius: 0.5rem;
  border-bottom-left-radius: 0.5rem;
}

.btn-donation-period:last-child {
  border-top-right-radius: 0.5rem;
  border-bottom-right-radius: 0.5rem;
  margin-right: 0;
}

.btn-donation-period:hover,
.btn-donation-period:focus,
.btn-donation-period.active {
  background-color: var(--primary-color);
  color: var(--on-primary-color);
  border-color: var(--primary-color);
}

/* Style for the Recurring Donation Checkbox */
.form-check-input:checked {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
}

/* Ensures the variant color for all selections */
.btn-donation-amount.active,
.btn-donation-period.active,
.btn-donation-amount:focus,
.btn-donation-period:focus {
  background-color: var(--secondary-color);
  color: var(--on-secondary-color);
  border-color: var(--secondary-color);
}

/* Fix autofill background and text color */
input:-webkit-autofill,
textarea:-webkit-autofill,
select:-webkit-autofill {
  background-color: var(--surface-color) !important;
  color: var(--on-surface-color) !important;
  transition: background-color 5000s ease-in-out 0s;
}

input:-webkit-autofill:focus,
textarea:-webkit-autofill:focus,
select:-webkit-autofill:focus {
  background-color: var(--surface-color) !important;
  color: var(--on-surface-color) !important;
}

input:-webkit-autofill::first-line {
  color: var(--on-surface-color) !important;
}

/* Fix autofill background and text color for select inputs */
select:-webkit-autofill {
  background-color: var(--surface-color) !important;
  color: var(--on-surface-color) !important;
  transition: background-color 5000s ease-in-out 0s, color 5000s ease-in-out 0s;
}

/* Ensure text color stays consistent even when autofilled */
select:-webkit-autofill::first-line {
  color: var(--on-surface-color) !important;
}

/* Donation Form Styling */
.donation-form .btn-group {
  display: flex;
  flex-wrap: wrap; /* Allow wrapping when space is insufficient */
  justify-content: space-between;
}

.btn-donation-amount {
  flex: 1 1 45%; /* Allow buttons to take up at least 45% of the row, wrapping if necessary */
  margin-bottom: 10px; /* Add margin for better spacing between rows */
}

.btn-donation-amount:last-child {
  margin-right: 0; /* Remove margin on the last button in the row */
}

/* Add a media query to further adjust for very narrow screens */
@media (max-width: 576px) {
  .btn-donation-amount {
    flex: 1 1 100%; /* On very small screens, each button takes up 100% width */
    margin-right: 0;
  }
}
