/**
 * Form Validation Styles — Balloon tooltip errors + invalid input states
 *
 * Always loaded on pages with forms. Uses hardcoded colors so it works
 * regardless of theme or whether form-client.css is loaded.
 */

/* ═══════════════════════════════════════════════════════════════════════════
   BALLOON TOOLTIP ERROR
   ═══════════════════════════════════════════════════════════════════════════ */

.gcms-field-error {
  display: none;
  position: absolute;
  left: 0;
  z-index: 10;
  min-width: 200px;
  max-width: calc(100% - 1rem);
  margin-top: 6px;
  padding: 8px 12px;
  background-color: #b91c1c;
  border-radius: 0.375rem;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05),
    0 0 0 1px rgba(185, 28, 28, 0.3);
  font-size: 0.875rem;
  line-height: 1.5;
  color: #fff;
  pointer-events: none;
}

/* Arrow pointing up */
.gcms-field-error::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 16px;
  width: 12px;
  height: 12px;
  background-color: #b91c1c;
  transform: rotate(45deg);
  border-radius: 2px 0 0 0;
}

.gcms-field-error--visible {
  display: block;
  animation: gcms-balloon-in 200ms ease-out;
}

.gcms-field-error__item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.gcms-field-error__item + .gcms-field-error__item {
  margin-top: 4px;
}

.gcms-field-error__icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 1px;
  color: #fff;
}

.gcms-field-error__text {
  flex: 1;
}

/* ═══════════════════════════════════════════════════════════════════════════
   INVALID INPUT STATE
   ═══════════════════════════════════════════════════════════════════════════ */

input[aria-invalid="true"],
select[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: #dc2626;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15);
}

input[aria-invalid="true"]:focus,
select[aria-invalid="true"]:focus,
textarea[aria-invalid="true"]:focus {
  border-color: #dc2626;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.25);
}

/* ═══════════════════════════════════════════════════════════════════════════
   GLOBAL ERRORS
   ═══════════════════════════════════════════════════════════════════════════ */

.gcms-global-errors {
  margin-bottom: 1.5rem;
}

.gcms-global-errors__inner {
  padding: 1rem;
  background-color: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 0.375rem;
}

.gcms-global-errors__item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.5rem 0;
  font-size: 0.875rem;
  color: #dc2626;
}

.gcms-global-errors__item:first-child {
  padding-top: 0;
}

.gcms-global-errors__item:last-child {
  padding-bottom: 0;
}

.gcms-global-errors__item::before {
  content: '';
  display: inline-block;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23dc2626' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 8v4'/%3E%3Cpath d='M12 16h.01'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
}

/* ═══════════════════════════════════════════════════════════════════════════
   ANIMATION
   ═══════════════════════════════════════════════════════════════════════════ */

@keyframes gcms-balloon-in {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   REDUCED MOTION
   ═══════════════════════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
  .gcms-field-error--visible {
    animation: none;
  }
}
