/* CSS Variables for Easy Maintenance */
:root {
  --primary-green: #28a745;
  --primary-green-hover: #218838;
  --primary-green-active: #1e7e34;
  --primary-green-light: #d4edda;
  --danger-red: #dc3545;
  --danger-red-hover: #c82333;
  --border-color: #ddd;
  --border-color-light: #e9ecef;
  --text-dark: #333;
  --text-medium: #555;
  --text-light: #777;
  --background-light: #f4f7f6;
  --white: #ffffff;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.2);
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s ease;
}

/* General Styles */
* {
  box-sizing: border-box;
}

body {
  background: linear-gradient(135deg, #f5f7fa 0%, #e9ecef 100%);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  margin: 0;
  padding: 20px;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-dark);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Form Container Styling */
.form-container {
  background-color: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 30px;
  max-width: 900px;
  width: 100%;
  margin: 20px auto;
}

/* Logo Container Styling */
.logo-container {
  text-align: center;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--border-color-light);
}

.logo-container img {
  max-width: 100%;
  height: auto;
  width: 320px;
}

h2 {
  text-align: center;
  color: var(--text-dark);
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 30px 0;
  letter-spacing: -0.5px;
}

/* Fieldset Styling */
fieldset {
  border: 2px solid var(--border-color-light);
  border-radius: var(--radius-md);
  padding: 24px;
  margin-bottom: 24px;
  background-color: #fafbfc;
  transition: border-color var(--transition-fast);
}

fieldset:focus-within {
  border-color: var(--primary-green);
  background-color: var(--white);
}

legend {
  font-weight: 700;
  font-size: 18px;
  padding: 0 12px;
  color: var(--text-dark);
  letter-spacing: -0.3px;
}

/* Labels */
label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-dark);
  font-size: 15px;
}

/* Form Row Layout */
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

/* Input, Select, and Button Styling */
input, select {
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border-color);
  font-size: 16px;
  font-family: inherit;
  background-color: var(--white);
  transition: all var(--transition-fast);
  -webkit-appearance: none;
  appearance: none;
  margin-bottom: 16px;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--primary-green);
  box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.1);
  background-color: var(--white);
}

input::placeholder {
  color: #999;
}

/* Select dropdown arrow */
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
  cursor: pointer;
}

/* Checkbox Container Styling */
.checkbox-container {
  margin: 24px 0;
  display: flex;
  align-items: center;
  gap: 12px;
  border-top: 2px solid var(--border-color-light);
  padding: 20px 0;
  background-color: var(--primary-green-light);
  padding: 16px;
  border-radius: var(--radius-sm);
}

.checkbox-container input[type="checkbox"] {
  width: 24px;
  height: 24px;
  cursor: pointer;
  margin: 0;
  flex-shrink: 0;
  -webkit-appearance: none;
  appearance: none;
  background-color: var(--white);
  border: 2px solid var(--primary-green);
  border-radius: 4px;
  position: relative;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.checkbox-container input[type="checkbox"]:hover {
  border-color: var(--primary-green-hover);
  box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.1);
}

.checkbox-container input[type="checkbox"]:checked {
  background-color: var(--primary-green);
  border-color: var(--primary-green);
}

.checkbox-container input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 7px;
  top: 3px;
  width: 6px;
  height: 12px;
  border: solid white;
  border-width: 0 3px 3px 0;
  transform: rotate(45deg);
}

.checkbox-container label {
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin: 0;
}

/* Hidden Class for Toggling */
.hidden {
  display: none !important;
}

/* Equipment Row Styling */
.equipment-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding: 16px;
  border-bottom: 2px solid var(--border-color-light);
  background-color: var(--white);
  border-radius: var(--radius-sm);
  transition: background-color var(--transition-fast);
}

.equipment-row:hover {
  background-color: #f8f9fa;
}

.equipment-row:last-of-type {
  border-bottom: none;
}

.equipment-row label {
  font-size: 20px;
  font-weight: 700;
  flex: 1;
  margin: 0;
  color: var(--text-dark);
}

/* Quantity Input Controls */
.quantity-input {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: #f1f3f5;
  border-radius: var(--radius-md);
  padding: 8px;
  min-width: 180px;
  box-shadow: var(--shadow-sm);
}

.quantity-btn {
  background-color: var(--primary-green);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 24px;
  font-weight: 700;
  min-width: 48px;
  min-height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.quantity-btn:hover {
  background-color: var(--primary-green-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.quantity-btn:active {
  background-color: var(--primary-green-active);
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

input[type="number"] {
  width: 70px;
  border: none;
  background: transparent;
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  outline: none;
  margin: 0;
  padding: 8px;
  color: var(--text-dark);
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Amount Label Styling */
.amount-label {
  font-size: 26px;
  text-align: center;
  margin-top: 24px;
  padding: 20px;
  font-weight: 700;
  color: var(--primary-green);
  background: linear-gradient(135deg, var(--primary-green-light) 0%, #e8f5e9 100%);
  border-radius: var(--radius-md);
  border: 2px solid var(--primary-green);
  box-shadow: var(--shadow-sm);
}

/* Generator Entry Cards */
.generator-entry {
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-md);
  transition: all var(--transition-normal);
}

.generator-entry:hover {
  border-color: var(--primary-green);
  box-shadow: var(--shadow-lg);
}

.generator-entry h4 {
  margin: 0 0 16px 0;
  color: var(--primary-green);
  font-size: 20px;
  font-weight: 700;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--border-color-light);
}

/* Information Icons */
.info-icon {
  cursor: pointer;
  font-size: 18px;
  font-weight: 700;
  color: var(--primary-green);
  margin-left: 8px;
  display: inline-block;
  padding: 4px 10px;
  background-color: var(--primary-green-light);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.info-icon:hover {
  background-color: var(--primary-green);
  color: white;
  transform: scale(1.05);
}

/* Modal Styling */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal img {
  display: block;
  max-width: 90%;
  max-height: 80vh;
  margin: 60px auto;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}

.close-button {
  position: absolute;
  top: 20px;
  right: 30px;
  font-size: 40px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  transition: all var(--transition-fast);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.close-button:hover {
  background-color: var(--danger-red);
  transform: rotate(90deg) scale(1.1);
}

/* Agreement Text Styling */
.agreement-text {
  margin: 24px 0;
  padding: 20px;
  font-size: 15px;
  line-height: 1.8;
  color: var(--text-medium);
  background-color: #f8f9fa;
  border-left: 4px solid var(--primary-green);
  border-radius: var(--radius-sm);
}

.agreement-text p {
  margin: 0 0 12px 0;
}

.agreement-text p:last-child {
  margin-bottom: 0;
}

#dynamicMonthlyAmount {
  font-weight: 700;
  color: var(--primary-green);
  font-size: 16px;
}

/* Signature Pad Styling */
#signature-pad {
  border: 3px dashed var(--border-color);
  border-radius: var(--radius-md);
  height: 200px;
  width: 100%;
  display: block;
  touch-action: none;
  background-color: #fafbfc;
  cursor: crosshair;
  margin-bottom: 12px;
  transition: border-color var(--transition-fast);
}

#signature-pad:focus {
  border-color: var(--primary-green);
  background-color: var(--white);
}

/* Button Styling */
button {
  font-family: inherit;
  font-weight: 700;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  box-shadow: var(--shadow-sm);
}

button[type="submit"] {
  background: linear-gradient(135deg, var(--primary-green) 0%, var(--primary-green-hover) 100%);
  color: white;
  font-size: 20px;
  padding: 18px 24px;
  min-height: 60px;
  width: 100%;
  margin-top: 16px;
  position: relative;
  overflow: hidden;
}

button[type="submit"]:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--primary-green-hover) 0%, var(--primary-green-active) 100%);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

button[type="submit"]:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

button[type="submit"]:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

button[type="button"] {
  background-color: var(--danger-red);
  color: white;
  font-size: 16px;
  padding: 14px 20px;
  min-height: 50px;
  width: 100%;
  margin-top: 8px;
}

button[type="button"]:hover {
  background-color: var(--danger-red-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

button[type="button"]:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

/* Spinner Animation */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 0.8s linear infinite;
  margin-left: 10px;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Tablet Landscape Optimizations (iPad) */
@media (min-width: 768px) and (max-width: 1024px) {
  .form-container {
    padding: 40px;
    max-width: 850px;
  }

  .form-row {
    grid-template-columns: repeat(3, 1fr);
  }

  .equipment-row label {
    font-size: 22px;
  }

  .quantity-input {
    min-width: 200px;
  }

  h2 {
    font-size: 32px;
  }
}

/* Mobile Portrait Optimizations */
@media (max-width: 767px) {
  body {
    padding: 10px;
  }

  .form-container {
    padding: 20px;
    border-radius: var(--radius-md);
  }

  .logo-container img {
    width: 240px;
  }

  h2 {
    font-size: 24px;
  }

  fieldset {
    padding: 16px;
  }

  .form-row {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .equipment-row {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 16px 12px;
  }

  .equipment-row label {
    text-align: center;
    font-size: 18px;
  }

  .quantity-input {
    width: 100%;
    justify-content: center;
  }

  .amount-label {
    font-size: 22px;
    padding: 16px;
  }

  .generator-entry {
    padding: 16px;
  }

  button[type="submit"] {
    font-size: 18px;
    padding: 16px 20px;
  }
}

/* Accessibility Enhancements */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Photo Button Styling */
.photo-btn {
  background-color: var(--primary-green);
  color: white;
  border: none;
  padding: 14px 16px;
  min-height: 50px;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
  font-family: inherit;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.photo-btn:hover {
  background-color: var(--primary-green-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.photo-btn:active {
  background-color: var(--primary-green-active);
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.photo-btn.bypass-btn {
  background-color: #6c757d;
}

.photo-btn.bypass-btn:hover {
  background-color: #5a6268;
}

.photo-btn.bypass-btn:active {
  background-color: #545b62;
}

.photo-remove-btn {
  background-color: var(--danger-red);
  color: white;
  border: none;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: inherit;
}

.photo-remove-btn:hover {
  background-color: var(--danger-red-hover);
}

.photo-preview {
  border: 2px solid var(--primary-green);
  border-radius: var(--radius-sm);
  padding: 10px;
  background-color: var(--white);
}

.photo-status {
  font-size: 14px;
  font-weight: 600;
  text-align: center;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  input, select {
    border-width: 3px;
  }

  fieldset {
    border-width: 3px;
  }

  .photo-btn {
    border-width: 2px;
    border-style: solid;
  }
}
