/**
 * RK Spordikool Form Styles - Enhanced A11y & Feedback
 * Accessible forms with clear labels, focus states, and feedback
 */

/* Layout */
.contact-section { padding: 4rem 0; }
.contact__grid {
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  gap: 2rem;
  align-items: start;
}
@media (max-width: 960px) {
  .contact__grid { grid-template-columns: 1fr; }
}

/* Cards */
.rk-surface {
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 8px 24px rgba(15,23,42,.10);
}
.contact__form.rk-surface { padding: 2rem; }
.contact__info.rk-surface { padding: 1.5rem; }

/* Headings */
.contact__form h2, .contact__info h2 {
  margin: 0 0 1rem 0;
  letter-spacing: -.01em;
  color: var(--rk-text, #0f172a);
}

/* Labels & inputs */
.contact__form label {
  display: block;
  font-weight: 600;
  color: var(--rk-text, #0f172a);
  margin: .35rem 0 .35rem;
}
.contact__form label .req {
  color: #1e68ff;
  font-weight: 700;
}
.contact__form input[type=text],
.contact__form input[type=email],
.contact__form input[type=tel],
.contact__form select,
.contact__form textarea {
  width: 100%;
  background: #fff;
  color: var(--rk-text, #0f172a);
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: .9rem 1rem;
  box-shadow: 0 1px 2px rgba(15,23,42,.06);
  font-family: inherit;
}
.contact__form input:focus,
.contact__form select:focus,
.contact__form textarea:focus {
  outline: 0;
  border-color: #0066CC; /* Updated to match --rk-blue from style.css */
  box-shadow: 0 0 0 4px rgba(0, 102, 204, 0.12); /* Updated to match style.css blue */
}
.contact__form .help {
  font-size: .9rem;
  color: #64748b;
  margin-top: .25rem;
}

/* Submit - Updated to match unified color system */
.contact__form .btn-submit {
  width: 100%;
  border-radius: 999px;
  font-weight: 700;
  padding: .95rem 1.25rem;
  background: #FFD600; /* Updated to match --bright-yellow from style.css */
  color: #0f172a; /* Dark text on yellow background */
  border: none;
  cursor: pointer;
  transition: transform .16s cubic-bezier(.22,1,.36,1), box-shadow .16s;
}
.contact__form .btn-submit:hover {
  background: #e6c200; /* Darker yellow on hover to match style.css */
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(15,23,42,.18);
}

/* Info list inside the right card */
.info-list {
  display: grid;
  gap: .75rem;
  margin-top: .5rem;
}
.info-row {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: .75rem;
  align-items: center;
  padding: .5rem .25rem;
  border-radius: 12px;
}
.info-row .chip {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #e8f0ff;
  cursor: pointer;
  transition: background-color 0.2s ease;
}
.info-row .chip:hover {
  background: #dce7ff;
}
.info-row h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--rk-text, #0f172a);
}
.info-row p, .info-row a {
  margin: 0;
  color: #475569;
}
.info-row a:hover {
  color: #1e68ff;
  text-decoration: underline;
}

/* Map */
.contact__map {
  margin-top: 2rem;
  max-width: 100%;
}
.contact__map iframe {
  width: 100%;
  aspect-ratio: 16/9;
  border: 0;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(15,23,42,.10);
}
.map-caption {
  text-align: center;
  font-size: 0.9rem;
  color: #64748b;
  margin-top: 0.5rem;
  margin-bottom: 0;
}

/* Feedback */
.form-error {
  margin-top: .5rem;
  padding: .5rem .75rem;
  border-radius: 10px;
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}
.form-success {
  margin-top: 1rem;
  padding: .75rem 1rem;
  border-radius: 12px;
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

/* Small polish */
a[href^="mailto:"], a[href^="tel:"] {
  word-break: break-word;
}

/* Form Container */
.contact-form,
.form-container {
  background: var(--rk-surface);
  border-radius: var(--rk-radius-xl);
  padding: var(--rk-space-8);
  box-shadow: var(--rk-shadow-sm);
}

/* Form Groups */
.form-group {
  margin-bottom: var(--rk-space-6, 1.5rem);
  position: relative;
}

.form-group:last-child {
  margin-bottom: 0;
}

/* Enhanced Labels - Always Visible */
.form-label,
label {
  display: block;
  font-weight: 600;
  color: var(--rk-text);
  margin-bottom: var(--rk-space-2);
  font-size: 0.95rem;
  letter-spacing: 0.025em;
  line-height: 1.4;
}

.form-label.required::after,
label.required::after {
  content: ' *';
  color: #ef4444;
  font-weight: 700;
}

/* Input Fields - Enhanced A11y */
.input,
.form-input,
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="url"],
input[type="password"],
input[type="number"],
textarea,
select {
  width: 100%;
  background: var(--rk-surface);
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: 0.9rem 1rem;
  box-shadow: var(--rk-shadow-sm);
  font-family: inherit;
  font-size: 1rem;
  color: var(--rk-text);
  transition: all var(--rk-time-fast) var(--rk-ease);
  appearance: none;
  line-height: 1.5;
}

/* Remove placeholder dependency - use minimal placeholders */
.input::placeholder,
.form-input::placeholder,
input::placeholder,
textarea::placeholder {
  color: #9ca3af;
  opacity: 0.6;
  font-style: italic;
}

/* Enhanced Focus States */
.input:focus,
.form-input:focus,
input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: #0066CC; /* Updated to match --rk-blue from style.css */
  box-shadow: 0 0 0 4px rgba(0, 102, 204, 0.12); /* Updated to match style.css blue */
  background: var(--rk-surface);
  transform: translateY(-1px);
}

/* Error States with A11y */
.input[aria-invalid="true"],
.form-input[aria-invalid="true"],
input[aria-invalid="true"],
textarea[aria-invalid="true"],
select[aria-invalid="true"],
.form-group--error .input,
.form-group--error input,
.form-group--error textarea {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
  background-color: #fef2f2;
}

.form-group--error .form-label,
.form-group--error label {
  color: #dc2626;
}

/* Success States */
.input[aria-invalid="false"],
.form-input[aria-invalid="false"],
input[aria-invalid="false"],
textarea[aria-invalid="false"],
.form-group--success .input,
.form-group--success input,
.form-group--success textarea {
  border-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
  background-color: #f0fdf4;
}

/* Help Text */
.form__help,
.form-help {
  font-size: 0.85rem;
  color: #64748b;
  margin-top: 0.5rem;
  line-height: 1.4;
}

/* Error Messages */
.form__error,
.form-error {
  font-size: 0.85rem;
  color: #dc2626;
  margin-top: 0.5rem;
  line-height: 1.4;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.form__error::before,
.form-error::before {
  content: "⚠";
  color: #ef4444;
  font-weight: bold;
  flex-shrink: 0;
}

/* Success Toast - In-form feedback */
.form__success,
.form-success {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
  border-radius: 12px;
  padding: 0.75rem 1rem;
  margin-top: 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  font-size: 0.95rem;
  line-height: 1.4;
  animation: slideInSuccess 0.3s ease-out;
}

.form__success::before,
.form-success::before {
  content: "✓";
  color: #10b981;
  font-weight: bold;
  font-size: 1.1rem;
  flex-shrink: 0;
}

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

/* Input Groups with Icons */
.input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.input-group .input-icon {
  position: absolute;
  left: 1rem;
  color: var(--rk-text-soft);
  z-index: 2;
  pointer-events: none;
}

.input-group .input,
.input-group input {
  padding-left: 3rem;
}

.input-group .input:focus + .input-icon,
.input-group input:focus + .input-icon {
  color: var(--rk-blue);
}

/* Textarea Specific */
textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.6;
}

/* Select Styling */
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%236B7280'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z' clip-rule='evenodd'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1.25rem;
  padding-right: 3rem;
}

/* Button Styles */
.btn,
.button,
input[type="submit"],
button[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: all var(--rk-time-fast) var(--rk-ease);
  font-size: 1rem;
  line-height: 1;
  white-space: nowrap;
  border-radius: 12px;
  padding: 1rem 1.5rem;
}

.btn--primary,
.button--primary,
input[type="submit"],
button[type="submit"] {
  background: var(--rk-blue);
  color: #fff;
}

.btn:focus-visible,
.button:focus-visible,
input[type="submit"]:focus-visible,
button[type="submit"]:focus-visible {
  outline: 2px solid var(--rk-blue);
  outline-offset: 2px;
}

/* Contact Form 7 Specific Enhancements */
.wpcf7-form .wpcf7-form-control-wrap {
  display: block;
  position: relative;
}

.wpcf7-form label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--rk-text);
}

/* Contact Form 7 Validation */
.wpcf7-not-valid-tip {
  font-size: 0.85rem !important;
  color: #dc2626 !important;
  margin-top: 0.5rem !important;
  display: flex !important;
  align-items: flex-start !important;
  gap: 0.5rem !important;
  line-height: 1.4 !important;
}

.wpcf7-not-valid-tip::before {
  content: "⚠" !important;
  color: #ef4444 !important;
  font-weight: bold !important;
  flex-shrink: 0 !important;
}

.wpcf7-validation-errors {
  background: #fef2f2 !important;
  border: 1px solid #fecaca !important;
  color: #dc2626 !important;
  padding: 1rem !important;
  border-radius: 12px !important;
  margin-bottom: 1rem !important;
  font-size: 0.95rem !important;
}

.wpcf7-mail-sent-ok {
  background: #ecfdf5 !important;
  color: #065f46 !important;
  border: 1px solid #a7f3d0 !important;
  border-radius: 12px !important;
  padding: 0.75rem 1rem !important;
  margin-bottom: 1rem !important;
  display: flex !important;
  align-items: flex-start !important;
  gap: 0.75rem !important;
  font-size: 0.95rem !important;
  animation: slideInSuccess 0.3s ease-out !important;
}

.wpcf7-mail-sent-ok::before {
  content: "✓" !important;
  color: #10b981 !important;
  font-weight: bold !important;
  font-size: 1.1rem !important;
  flex-shrink: 0 !important;
}

/* Loading States */
.wpcf7-form.submitting .wpcf7-submit {
  opacity: 0.7;
  cursor: not-allowed;
  position: relative;
}

.wpcf7-form.submitting .wpcf7-submit::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  margin: auto;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  .input:focus,
  .form-input:focus,
  input:focus,
  textarea:focus,
  select:focus {
    border-width: 2px;
    box-shadow: 0 0 0 3px rgba(30, 104, 255, 0.3);
  }

  .form__error,
  .wpcf7-not-valid-tip {
    font-weight: 600 !important;
  }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  .form__success,
  .wpcf7-mail-sent-ok {
    animation: none !important;
  }

  .input:focus,
  .form-input:focus,
  input:focus,
  textarea:focus,
  select:focus {
    transform: none;
  }
}
