/* CSS Custom Properties for Theming */
:root {
  --primary-color: #6cac44;
  --primary-hover: #5a9338;
  --primary-light: #f0f7eb;
  --primary-focus: rgba(108, 172, 68, 0.1);
}

/* Base Styles */
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: white;
  color: #333;
  /* FIXED: Remove flexbox centering that causes top cutoff */
  /* display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh; */
  
  /* NEW: Simple top-aligned layout */
  padding: 1rem;
  box-sizing: border-box;
  overflow-y: auto;
}

/* Loading Spinner */
#loading {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 999;
}

#loading::after {
  content: "";
  width: 40px;
  height: 40px;
  border: 5px solid #ccc;
  border-top: 5px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Form Container */
form {
  width: 100%;
  max-width: 1000px; /* Set a reasonable max width */
  background: white;
  padding: 2rem;
  border-radius: 12px;
  box-sizing: border-box;
  margin: 0 auto; /* Center horizontally only */
}

/* Typography */
h2 {
  text-align: center;
  margin-bottom: 1.5rem;
  color: #2c3e50;
}

.subtitle {
  text-align: center;
  color: #7f8c8d;
  margin-bottom: 2rem;
  font-size: 0.9rem;
}

label {
  display: block;
  margin-top: 1rem;
  font-weight: 600;
  color: #34495e;
}

/* Form Layout */
.name-row {
  display: flex;
  gap: 1rem;
}

.name-row .field {
  flex: 1;
}

/* Input Styles */
input[type="text"], input[type="email"], input[type="number"] {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid #e1e8ed;
  border-radius: 8px;
  margin-top: 0.25rem;
  box-sizing: border-box;
  font-size: 1rem;
  transition: border-color 0.2s ease;
}

input[type="text"]:focus, input[type="email"]:focus, input[type="number"]:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px var(--primary-focus);
}

/* Amount Selection */
.amount-section {
  margin-top: 1rem;
}

.amount-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-top: 0.5rem;
  margin-bottom: 1rem;
}

.amount-btn {
  padding: 0.75rem;
  border: 2px solid #e1e8ed;
  background: white;
  border-radius: 8px;
  cursor: pointer;
  text-align: center;
  font-weight: 600;
  transition: all 0.2s ease;
}

.amount-btn:hover {
  border-color: var(--primary-color);
  background-color: var(--primary-light);
}

.amount-btn.selected {
  border-color: var(--primary-color);
  background-color: var(--primary-color);
  color: white;
}

.custom-amount {
  display: none;
}

.custom-amount.show {
  display: block;
}

/* Frequency Selection */
.frequency-section {
  margin-top: 1.5rem;
}

.frequency-buttons {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.frequency-btn {
  flex: 1;
  padding: 0.75rem;
  border: 2px solid #e1e8ed;
  background: white;
  border-radius: 8px;
  cursor: pointer;
  text-align: center;
  font-weight: 600;
  transition: all 0.2s ease;
}

.frequency-btn:hover {
  border-color: var(--primary-color);
  background-color: var(--primary-light);
}

.frequency-btn.selected {
  border-color: var(--primary-color);
  background-color: var(--primary-color);
  color: white;
}

/* Checkbox Styles */
input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid #e1e8ed;
  border-radius: 4px;
  margin-right: 0.75rem;
  position: relative;
  cursor: pointer;
  background: white;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

input[type="checkbox"]:hover {
  border-color: var(--primary-color);
}

input[type="checkbox"]:checked {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
}

input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 1px;
  width: 5px;
  height: 9px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

input[type="checkbox"]:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--primary-focus);
}

.checkbox-group {
  margin-top: 1rem;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  font-weight: normal;
  cursor: pointer;
  margin-top: 0.75rem;
}

#company-name-group {
  display: none;
}

/* Impact Message */
.impact-message {
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  padding: 1rem;
  margin-top: 1rem;
  font-size: 0.9rem;
  color: #495057;
  display: none;
}

.impact-message.show {
  display: block;
}

/* Legal Disclaimer */
.legal-disclaimer {
  font-size: 0.8rem;
  color: #7f8c8d;
  text-align: center;
  margin-top: 1.5rem;
  line-height: 1.4;
}

.legal-disclaimer a {
  color: var(--primary-color);
  text-decoration: none;
}

.legal-disclaimer a:hover {
  text-decoration: underline;
}

/* Submit Button */
button {
  margin-top: 2rem;
  width: 100%;
  padding: 1rem;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease;
  position: relative;
}

button:hover {
  background-color: var(--primary-hover);
}

button:disabled {
  background-color: #bdc3c7;
  cursor: not-allowed;
}

.processing {
  opacity: 0.7;
  pointer-events: none;
}

/* Footer */
.footer {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  line-height: 30px;
  margin-top: 20px;
  color: #7f8c8d;
  margin-bottom: 20px;
}

.footer-image {
  max-width: 150px;
  max-height: 30px;
  display: inline-block;
  margin-left: 5px;
}

/* Success/Error Messages */
.message {
  padding: 1rem;
  border-radius: 8px;
  margin-top: 1rem;
  display: none;
}

.message.success {
  background: #d4edda;
  border: 1px solid #c3e6cb;
  color: #155724;
}

.message.error {
  background: #f8d7da;
  border: 1px solid #f5c6cb;
  color: #721c24;
}

.message.show {
  display: block;
}

/* Dark Theme Support */
.dark-theme {
  background-color: #2d2d2d;
  color: #e0e0e0;
}

.dark-theme form {
  background-color: #2d2d2d;
  color: #e0e0e0;
}

.dark-theme h2 {
  color: #f0f0f0;
}

.dark-theme .subtitle {
  color: #b0b0b0;
}

.dark-theme label {
  color: #e0e0e0;
}

.dark-theme input[type="text"], 
.dark-theme input[type="email"], 
.dark-theme input[type="number"] {
  background-color: #3a3a3a;
  border-color: #555;
  color: #e0e0e0;
}

.dark-theme input[type="text"]:focus,
.dark-theme input[type="email"]:focus,
.dark-theme input[type="number"]:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px var(--primary-focus);
}

.dark-theme input::placeholder {
  color: #999;
}

.dark-theme .amount-btn,
.dark-theme .frequency-btn {
  background-color: #3a3a3a;
  border-color: #555;
  color: #e0e0e0;
}

.dark-theme .amount-btn:hover,
.dark-theme .frequency-btn:hover {
  border-color: var(--primary-color);
  background-color: var(--primary-light);
  color: #e0e0e0;
}

.dark-theme .amount-btn.selected,
.dark-theme .frequency-btn.selected {
  border-color: var(--primary-color);
  background-color: var(--primary-color);
  color: white;
}

.dark-theme .impact-message {
  background-color: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
  color: #e0e0e0;
}

.dark-theme input[type="checkbox"] {
  background-color: #3a3a3a;
  border-color: #555;
}

.dark-theme input[type="checkbox"]:hover {
  border-color: var(--primary-color);
}

.dark-theme input[type="checkbox"]:checked {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
}

.dark-theme .checkbox-group label {
  color: #e0e0e0;
}

.dark-theme .message.success {
  background-color: rgba(76, 175, 80, 0.2);
  border-color: #4caf50;
  color: #c8e6c9;
}

.dark-theme .message.error {
  background-color: rgba(244, 67, 54, 0.2);
  border-color: #f44336;
  color: #ffcdd2;
}

.dark-theme .legal-disclaimer {
  color: #b0b0b0;
}

.dark-theme .legal-disclaimer a {
  color: var(--primary-color);
}

.dark-theme .footer {
  color: #999;
}

/* Payment Form Styles */

.payment-header {
  text-align: center;
  margin-bottom: 2rem;
  border-bottom: 1px solid #e1e8ed;
  padding: 2rem;
}

.payment-header h3 {
  margin: 0 0 0.5rem 0;
  color: #2c3e50;
}

.payment-header p {
  margin: 0 0 1rem 0;
  color: #7f8c8d;
}

.back-button {
  background: none;
  border: 1px solid #e1e8ed;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  color: #666;
  font-size: 0.9rem;
  margin-top: 1rem;
  transition: all 0.2s ease;
}

.back-button:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

/* Force Stripe Payment Element to use full width */
#payment-element {
  width: 100% !important;
  max-width: 100% !important;
  margin-bottom: 2rem;
}

#payment-element > * {
  width: 100% !important;
  max-width: 100% !important;
}

/* Ensure payment form uses full width */
#payment-form {
  width: 100%;
  max-width: 100%;
  margin-top: 0;
}

#payment-container {
  width: 100%;
  margin: 0 auto; /* Center horizontally */
}

.payment-submit-btn {
  width: 100%;
  padding: 1rem;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease;
  margin-top: 1rem;
}

.payment-submit-btn:hover {
  background-color: var(--primary-hover);
}

.payment-submit-btn:disabled {
  background-color: #bdc3c7;
  cursor: not-allowed;
}

.payment-message {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 6px;
  display: none;
}

.payment-message.error {
  background-color: #f8d7da;
  border: 1px solid #f5c6cb;
  color: #721c24;
  display: block;
}

.payment-success {
  text-align: center;
  padding: 2rem;
  background: #d4edda;
  border: 1px solid #c3e6cb;
  border-radius: 8px;
  color: #155724;
}

.payment-success h3 {
  margin: 0 0 1rem 0;
  color: #155724;
}

.donate-again-btn {
  margin-top: 1.5rem;
  padding: 0.75rem 2rem;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.donate-again-btn:hover {
  background-color: var(--primary-hover);
}

/* Dark Theme Payment Styles */
.dark-theme .payment-header {
  border-bottom-color: #555;
}

.dark-theme .payment-header h3 {
  color: #f0f0f0;
}

.dark-theme .payment-header p {
  color: #b0b0b0;
}

.dark-theme .back-button {
  border-color: #555;
  color: #e0e0e0;
  background-color: #3a3a3a;
}

.dark-theme .back-button:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.dark-theme .payment-success {
  background-color: rgba(76, 175, 80, 0.2);
  border-color: #4caf50;
  color: #c8e6c9;
}

.dark-theme .payment-success h3 {
  color: #c8e6c9;
}

.dark-theme .donate-again-btn {
  background-color: var(--primary-color);
}

.dark-theme .donate-again-btn:hover {
  background-color: var(--primary-hover);
}

.payment-section {
  margin-top: 2rem;
  border-top: 1px solid #e0e0e0;
  padding-top: 2rem;
}

.payment-section h3 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text-color, #333);
}

#payment-element {
  margin-bottom: 1rem;
  /* Stripe Elements will handle their own styling */
}

/* Dark theme support for payment section */
.dark-theme .payment-section {
  border-top-color: #444;
}

.dark-theme .payment-section h3 {
  color: var(--text-color-dark, #fff);
}

@media (max-width: 600px) {
  body {
    padding: 0.5rem;
  }
  
  form {
    margin: 0 auto;
    padding: 1.5rem;
  }
  
  .amount-buttons {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .name-row {
    flex-direction: column;
    gap: 0;
  }
  
  .frequency-buttons {
    flex-direction: column;
  }
}