/* AP Headless CMS - Frontend Styles */

:root {
  --ap-primary: #2271b1;
  --ap-success: #00a32a;
  --ap-error: #d63638;
  --ap-warning: #dba617;
  --ap-border: #ddd;
  --ap-text: #333;
  --ap-bg: #f9f9f9;
  --ap-white: #fff;
  --ap-shadow: 0 2px 4px rgba(0,0,0,0.1);
  --ap-radius: 4px;
  --ap-transition: all 0.3s ease;
}

/* Contact Form Styles */
.ap-contact-form {
  max-width: 600px;
  margin: 0 auto;
  padding: 30px;
  background: var(--ap-white);
  border-radius: var(--ap-radius);
  box-shadow: var(--ap-shadow);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.ap-contact-form h2 {
  margin: 0 0 20px 0;
  color: var(--ap-text);
  font-size: 1.5em;
  text-align: center;
}

.ap-form-group {
  margin-bottom: 20px;
}

.ap-form-label {
  display: block;
  margin-bottom: 5px;
  font-weight: 600;
  color: var(--ap-text);
}

.ap-form-label.required::after {
  content: ' *';
  color: var(--ap-error);
}

.ap-form-input,
.ap-form-textarea,
.ap-form-select {
  width: 100%;
  padding: 12px 15px;
  border: 2px solid var(--ap-border);
  border-radius: var(--ap-radius);
  font-size: 16px;
  font-family: inherit;
  transition: var(--ap-transition);
  background: var(--ap-white);
  box-sizing: border-box;
}

.ap-form-input:focus,
.ap-form-textarea:focus,
.ap-form-select:focus {
  outline: none;
  border-color: var(--ap-primary);
  box-shadow: 0 0 0 3px rgba(34, 113, 177, 0.1);
}

.ap-form-textarea {
  min-height: 120px;
  resize: vertical;
}

.ap-form-submit {
  width: 100%;
  padding: 15px 30px;
  background: var(--ap-primary);
  color: var(--ap-white);
  border: none;
  border-radius: var(--ap-radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--ap-transition);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ap-form-submit:hover {
  background: #135e96;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.ap-form-submit:disabled {
  background: #ccc;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.ap-form-submit.loading {
  position: relative;
  color: transparent;
}

.ap-form-submit.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  border: 2px solid transparent;
  border-top: 2px solid var(--ap-white);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Form Validation */
.ap-form-group.error .ap-form-input,
.ap-form-group.error .ap-form-textarea,
.ap-form-group.error .ap-form-select {
  border-color: var(--ap-error);
}

.ap-form-group.success .ap-form-input,
.ap-form-group.success .ap-form-textarea,
.ap-form-group.success .ap-form-select {
  border-color: var(--ap-success);
}

.ap-form-error {
  color: var(--ap-error);
  font-size: 14px;
  margin-top: 5px;
  display: none;
}

.ap-form-group.error .ap-form-error {
  display: block;
}

/* Success/Error Messages */
.ap-form-message {
  padding: 15px 20px;
  border-radius: var(--ap-radius);
  margin-bottom: 20px;
  font-weight: 500;
}

.ap-form-message.success {
  background: rgba(0, 163, 42, 0.1);
  color: var(--ap-success);
  border: 1px solid rgba(0, 163, 42, 0.3);
}

.ap-form-message.error {
  background: rgba(214, 54, 56, 0.1);
  color: var(--ap-error);
  border: 1px solid rgba(214, 54, 56, 0.3);
}

.ap-form-message.warning {
  background: rgba(219, 166, 23, 0.1);
  color: var(--ap-warning);
  border: 1px solid rgba(219, 166, 23, 0.3);
}

/* Honeypot (Hidden Anti-Spam Field) */
.ap-honeypot {
  position: absolute !important;
  left: -9999px !important;
  top: -9999px !important;
  visibility: hidden !important;
}

/* Loading Overlay */
.ap-form-loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--ap-radius);
  z-index: 10;
}

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

/* Responsive Design */
@media (max-width: 768px) {
  .ap-contact-form {
    padding: 20px;
    margin: 10px;
  }
  
  .ap-form-input,
  .ap-form-textarea,
  .ap-form-select,
  .ap-form-submit {
    font-size: 16px; /* Prevent iOS zoom */
  }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  .ap-contact-form {
    background: #1e1e1e;
    color: #e0e0e0;
  }
  
  .ap-form-input,
  .ap-form-textarea,
  .ap-form-select {
    background: #2a2a2a;
    border-color: #444;
    color: #e0e0e0;
  }
  
  .ap-form-input:focus,
  .ap-form-textarea:focus,
  .ap-form-select:focus {
    border-color: #72aee6;
  }
  
  .ap-form-label {
    color: #e0e0e0;
  }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
  .ap-form-input,
  .ap-form-textarea,
  .ap-form-select {
    border-width: 3px;
  }
  
  .ap-form-submit {
    border: 3px solid transparent;
  }
  
  .ap-form-submit:focus {
    border-color: var(--ap-white);
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Print Styles */
@media print {
  .ap-contact-form {
    box-shadow: none;
    border: 1px solid #000;
  }
  
  .ap-form-submit {
    display: none;
  }
}

/* Focus Indicators for Accessibility */
.ap-form-input:focus-visible,
.ap-form-textarea:focus-visible,
.ap-form-select:focus-visible,
.ap-form-submit:focus-visible {
  outline: 2px solid var(--ap-primary);
  outline-offset: 2px;
}

/* Custom Checkbox/Radio Styles */
.ap-form-checkbox,
.ap-form-radio {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: 10px;
  cursor: pointer;
}

.ap-form-checkbox input,
.ap-form-radio input {
  width: auto;
  margin-right: 10px;
}

/* Form Grid Layout */
.ap-form-row {
  display: flex;
  gap: 15px;
  margin-bottom: 20px;
}

.ap-form-col {
  flex: 1;
}

@media (max-width: 600px) {
  .ap-form-row {
    flex-direction: column;
    gap: 0;
  }
}

/* Character Counter */
.ap-form-counter {
  font-size: 12px;
  color: #666;
  text-align: right;
  margin-top: 5px;
}

.ap-form-counter.warning {
  color: var(--ap-warning);
}

.ap-form-counter.error {
  color: var(--ap-error);
}

/* Progress Bar for Multi-Step Forms */
.ap-form-progress {
  width: 100%;
  height: 4px;
  background: var(--ap-border);
  border-radius: 2px;
  margin-bottom: 30px;
  overflow: hidden;
}

.ap-form-progress-bar {
  height: 100%;
  background: var(--ap-primary);
  transition: width 0.3s ease;
  border-radius: 2px;
}

/* Tooltip Styles */
.ap-form-tooltip {
  position: relative;
  display: inline-block;
  margin-left: 5px;
  cursor: help;
}

.ap-form-tooltip::before {
  content: '?';
  display: inline-block;
  width: 16px;
  height: 16px;
  line-height: 16px;
  text-align: center;
  background: var(--ap-primary);
  color: white;
  border-radius: 50%;
  font-size: 12px;
}

.ap-form-tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 14px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
  z-index: 1000;
}

.ap-form-tooltip:hover::after {
  opacity: 1;
  visibility: visible;
}
