/**
 * Custom Fields for WooCommerce - Frontend Styles
 * Modern, premium input styling with smooth animations
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

:root {
  /* Color Palette */
  --wcf-primary: hsl(220, 90%, 56%);
  --wcf-primary-light: hsl(220, 90%, 70%);
  --wcf-primary-dark: hsl(220, 90%, 40%);
  --wcf-danger: hsl(0, 84%, 60%);

  /* Neutrals */
  --wcf-neutral-50: hsl(210, 20%, 98%);
  --wcf-neutral-100: hsl(210, 20%, 95%);
  --wcf-neutral-200: hsl(210, 16%, 93%);
  --wcf-neutral-300: hsl(210, 14%, 89%);
  --wcf-neutral-400: hsl(210, 12%, 71%);
  --wcf-neutral-500: hsl(210, 10%, 53%);
  --wcf-neutral-600: hsl(210, 10%, 40%);
  --wcf-neutral-700: hsl(210, 10%, 23%);
  --wcf-neutral-800: hsl(210, 11%, 18%);
  --wcf-neutral-900: hsl(210, 11%, 15%);

  /* Spacing */
  --wcf-space-xs: 4px;
  --wcf-space-sm: 8px;
  --wcf-space-md: 16px;
  --wcf-space-lg: 24px;
  --wcf-space-xl: 32px;

  /* Border Radius */
  --wcf-radius-sm: 6px;
  --wcf-radius-md: 10px;

  /* Shadows */
  --wcf-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --wcf-shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);

  /* Transitions */
  --wcf-transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --wcf-transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== CUSTOM FIELDS WRAPPER ===== */

.wc-custom-fields-wrapper {
  margin-bottom: var(--wcf-space-xl);
  clear: both;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: linear-gradient(135deg, var(--wcf-neutral-50) 0%, white 100%);
  padding: var(--wcf-space-lg);
  border-radius: var(--wcf-radius-md);
  border: 1px solid var(--wcf-neutral-200);
  box-shadow: var(--wcf-shadow-sm);
}

/* ===== FIELD CONTAINER ===== */

.custom-field-container {
  margin-bottom: var(--wcf-space-lg);
  position: relative;
  animation: fadeIn var(--wcf-transition-normal);
}

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

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.custom-field-container:last-child {
  margin-bottom: 0;
}

/* ===== LABELS ===== */

.custom-field-container label {
  display: block;
  margin-bottom: var(--wcf-space-sm);
  font-weight: 600;
  font-size: 15px;
  color: var(--wcf-neutral-800);
  letter-spacing: -0.01em;
  transition: color var(--wcf-transition-fast);
}

.custom-field-container label .required {
  color: var(--wcf-danger);
  font-weight: 700;
  margin-left: 3px;
  font-size: 16px;
}

/* ===== INPUT FIELDS ===== */

.custom-product-field {
  width: 100%;
  max-width: 500px;
  border: 2px solid var(--wcf-neutral-200);
  padding: 14px 18px;
  background: white;
  border-radius: var(--wcf-radius-sm);
  font-size: 15px;
  font-family: 'Inter', sans-serif;
  color: var(--wcf-neutral-900);
  outline: none;
  transition: all var(--wcf-transition-normal);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.custom-product-field:hover {
  border-color: var(--wcf-neutral-300);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.custom-product-field:focus {
  border-color: var(--wcf-primary);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1), 0 4px 12px rgba(59, 130, 246, 0.15);
  transform: translateY(-1px);
}

.custom-product-field::placeholder {
  color: var(--wcf-neutral-400);
  opacity: 1;
  font-style: italic;
}

/* Focus effect for label */
.custom-field-container:focus-within label {
  color: var(--wcf-primary);
}

/* ===== TEXTAREA ===== */

textarea.custom-product-field {
  min-height: 120px;
  resize: vertical;
  line-height: 1.6;
}

/* ===== VALIDATION STATES ===== */

.custom-product-field:invalid:not(:placeholder-shown) {
  border-color: var(--wcf-danger);
}

.custom-product-field:invalid:not(:placeholder-shown):focus {
  box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.1), 0 4px 12px rgba(220, 38, 38, 0.15);
}

.custom-product-field:valid:not(:placeholder-shown) {
  border-color: hsl(142, 71%, 45%);
}

/* ===== RESPONSIVE ===== */

@media (max-width: 768px) {
  .wc-custom-fields-wrapper {
    padding: var(--wcf-space-md);
    margin-bottom: var(--wcf-space-lg);
  }

  .custom-product-field {
    max-width: 100%;
    font-size: 16px;
    /* Prevent zoom on iOS */
  }

  .custom-field-container label {
    font-size: 14px;
  }
}

/* ===== ACCESSIBILITY ===== */

@media (prefers-reduced-motion: reduce) {

  .custom-product-field,
  .custom-field-container,
  .custom-field-container label {
    transition: none;
    animation: none;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .custom-product-field {
    border-width: 3px;
  }

  .custom-product-field:focus {
    outline: 3px solid var(--wcf-primary);
    outline-offset: 2px;
  }
}