/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu",
    "Cantarell", sans-serif;
  line-height: 1.6;
  color: #333;
  background: #f8fafc;
  padding: 20px;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

/* Header Styles */
header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 40px 30px;
  text-align: center;
  position: relative;
}

.header-navigation {
  position: absolute;
  top: 20px;
  left: 30px;
}

.back-to-home-btn {
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 400;
  transition: color 0.2s ease;
}

.back-to-home-btn:hover {
  color: white;
  text-decoration: underline;
}

header img {
  max-width: 200px;
  margin-bottom: 15px;
}

header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 10px;
  letter-spacing: -0.02em;
}

header h2 {
  font-size: 1.5rem;
  font-weight: 400;
  margin-bottom: 10px;
  opacity: 0.95;
}

header p {
  font-size: 1.1rem;
  opacity: 0.95;
  margin-bottom: 0;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.4;
}

/* Form Sections */
.form-section {
  padding: 40px 30px;
  border-bottom: 1px solid #e2e8f0;
}

.form-section:last-child {
  border-bottom: none;
}

.form-section h3 {
  font-size: 1.5rem;
  font-weight: 600;
  color: #2d3748;
  margin-bottom: 25px;
  padding-bottom: 10px;
  border-bottom: 2px solid #e2e8f0;
}

/* Form Groups */
.form-group {
  margin-bottom: 20px;
}

.form-row {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
}

.form-row .form-group {
  flex: 1;
  margin-bottom: 0;
}

/* Labels */
label {
  display: block;
  font-weight: 500;
  color: #374151;
  margin-bottom: 6px;
  font-size: 0.95rem;
}

/* Input Styles */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="url"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-size: 1rem;
  transition: all 0.2s ease;
  background: white;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

input:hover,
select:hover {
  border-color: #cbd5e0;
}

/* Radio Groups */
.radio-group {
  display: flex;
  gap: 20px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.radio-group label {
  display: flex;
  align-items: center;
  font-weight: normal;
  margin-bottom: 0;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 6px;
  transition: background-color 0.2s ease;
}

.radio-group label:hover {
  background-color: #f7fafc;
}

.radio-group input[type="radio"] {
  width: auto;
  margin-right: 8px;
  margin-bottom: 0;
}

/* Checkbox Groups */
.checkbox-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 12px;
  margin-top: 8px;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  font-weight: normal;
  margin-bottom: 0;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 6px;
  transition: background-color 0.2s ease;
}

.checkbox-group label:hover {
  background-color: #f7fafc;
}

.checkbox-group input[type="checkbox"] {
  width: auto;
  margin-right: 8px;
  margin-bottom: 0;
}

/* Sales Type Grid */
.sales-type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 15px;
  margin-top: 10px;
}

.sales-input {
  display: flex;
  flex-direction: column;
}

.sales-input label {
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.sales-input input {
  padding: 10px 12px;
}

/* Total Display */
.total-display {
  margin-top: 15px;
  padding: 12px 16px;
  background: #f7fafc;
  border-radius: 8px;
  font-weight: 600;
  text-align: center;
  border: 2px solid #e2e8f0;
}

.total-display.valid {
  background: #f0fff4;
  border-color: #9ae6b4;
  color: #276749;
}

.total-display.invalid {
  background: #fed7d7;
  border-color: #feb2b2;
  color: #c53030;
}

/* Owner Block Styles */
.owner-block {
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  padding: 25px;
  margin-bottom: 20px;
  background: #f8fafc;
  position: relative;
}

.owner-block h4 {
  font-size: 1.2rem;
  font-weight: 600;
  color: #2d3748;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e2e8f0;
}

.owner-block .remove-owner {
  position: absolute;
  top: 15px;
  right: 15px;
  background: #e53e3e;
  color: white;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.owner-block .remove-owner:hover {
  background: #c53030;
}

/* Button Styles */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}

.btn-primary {
  background: #667eea;
  color: white;
}

.btn-primary:hover {
  background: #5a67d8;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
  background: #718096;
  color: white;
  margin-top: 15px;
}

.btn-secondary:hover {
  background: #4a5568;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(113, 128, 150, 0.3);
}

.btn-large {
  padding: 16px 32px;
  font-size: 1.1rem;
  width: 100%;
  margin-top: 20px;
}

/* Form actions at bottom */
.form-actions-bottom {
  text-align: center;
  margin: 20px 0 10px 0;
}

.clear-form-link {
  color: #6c757d;
  text-decoration: none;
  font-size: 0.85rem;
  transition: color 0.2s ease;
}

.clear-form-link:hover {
  color: #dc3545;
  text-decoration: underline;
}

/* Welcome Section */
.welcome-section {
  background-color: #f8f9fa;
  border-bottom: 1px solid #dee2e6;
  padding: 20px 30px;
  text-align: center;
}

.welcome-content p {
  color: #495057;
  font-size: 1rem;
  margin: 0;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

/* Success Message */
#successMessage {
  padding: 60px 40px;
  text-align: center;
  background: #f0fff4;
  border: 2px solid #9ae6b4;
  border-radius: 12px;
  margin: 20px;
}

#successMessage h2 {
  color: #276749;
  font-size: 2rem;
  margin-bottom: 15px;
}

#successMessage p {
  font-size: 1.1rem;
  color: #2f855a;
  margin-bottom: 10px;
}

#successMessage button {
  margin-top: 20px;
  background: #38a169;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 12px 24px;
  font-size: 1rem;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

#applicationId {
  font-family: "Monaco", "Menlo", "Ubuntu Mono", monospace;
  background: #e6fffa;
  padding: 4px 8px;
  border-radius: 4px;
  font-weight: bold;
  color: #234e52;
}

/* Responsive Design */
@media (max-width: 768px) {
  body {
    padding: 10px;
  }

  .container {
    border-radius: 0;
    margin: 0;
  }

  header {
    padding: 30px 20px;
  }

  .header-navigation {
    top: 15px;
    left: 20px;
  }

  .back-to-home-btn {
    padding: 8px 16px;
    font-size: 0.8rem;
  }

  .welcome-section {
    padding: 15px 20px;
  }

  header h1 {
    font-size: 2rem;
  }

  header h2 {
    font-size: 1.3rem;
  }

  .form-section {
    padding: 30px 20px;
  }

  .form-row {
    flex-direction: column;
    gap: 0;
  }

  .radio-group {
    flex-direction: column;
    gap: 8px;
  }

  .sales-type-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .checkbox-group {
    grid-template-columns: 1fr;
  }

  .owner-block {
    padding: 20px;
  }

  .owner-block .remove-owner {
    position: static;
    margin-bottom: 15px;
    width: 100%;
  }
}

@media (max-width: 480px) {
  header {
    padding: 20px 15px;
  }

  .header-navigation {
    position: static;
    margin-bottom: 15px;
  }

  .back-to-home-btn {
    padding: 8px 16px;
    font-size: 0.8rem;
    border-radius: 20px;
  }

  .welcome-section {
    padding: 15px;
  }

  header h1 {
    font-size: 1.8rem;
  }

  .form-section {
    padding: 25px 15px;
  }

  .btn {
    padding: 14px 20px;
  }

  .btn-large {
    padding: 16px 24px;
  }
}

/* Form Validation States */
/* Only show validation styles when field has error-state class */
input.error-state,
select.error-state {
  border-color: #e53e3e;
  background-color: #fff5f5;
}

input.error-state:focus,
select.error-state:focus {
  border-color: #e53e3e;
  box-shadow: 0 0 0 3px rgba(229, 62, 62, 0.1);
}

/* Special styling for routing number */
#routingNumber:invalid:not(:placeholder-shown) {
  border-width: 2px;
}

#routingNumber:invalid:not(:placeholder-shown) ~ .error-message {
  display: block;
}

.error-message {
  display: none;
  color: #e53e3e;
  font-size: 0.875rem;
  margin-top: 5px;
  animation: fadeIn 0.2s ease-in;
}

/* Loading States */
.loading {
  opacity: 0.7;
  pointer-events: none;
}

.btn.loading {
  position: relative;
  color: transparent;
}

.btn.loading::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  top: 50%;
  left: 50%;
  margin-left: -10px;
  margin-top: -10px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  border-top-color: transparent;
  animation: spin 1s ease-in-out infinite;
}

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

/* Focus indicators for accessibility */
.btn:focus {
  outline: 3px solid rgba(102, 126, 234, 0.3);
  outline-offset: 2px;
}

input:focus,
select:focus {
  outline: none;
}

/* Hidden elements */
.hidden {
  display: none;
}

.fade-in {
  animation: fadeIn 0.3s ease-in;
}

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