/**
 * Forms Component - Based on Original ProRank Unified Design
 * 
 * Premium form controls with focus states and smooth transitions
 * From the original prorank-unified.css design
 * 
 * @since 3.0.0
 */

/* ============================================
   FORM CONTROL GROUP
   ============================================ */

.prorank-control-group,
.prorank-form-group {
  margin-bottom: 20px;
}

.prorank-control-group label,
.prorank-form-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: var(--prorank-text);
  font-size: 14px;
}

.prorank-control-group .description,
.prorank-form-help {
  margin-top: 6px;
  font-size: 13px;
  color: var(--prorank-text-secondary);
  line-height: 1.5;
}

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

.prorank-control-group input[type="text"],
.prorank-control-group input[type="number"],
.prorank-control-group input[type="email"],
.prorank-control-group input[type="url"],
.prorank-control-group input[type="password"],
.prorank-control-group input[type="search"],
.prorank-control-group input[type="tel"],
.prorank-control-group input[type="date"],
.prorank-control-group input[type="time"],
.prorank-control-group input[type="datetime-local"],
.prorank-control-group textarea,
.prorank-control-group select,
.prorank-input,
.prorank-textarea,
.prorank-select {
  width: 100%;
  min-height: 36px; /* Match button height */
  padding: 8px 12px;
  border: 1px solid var(--prorank-border);
  border-radius: var(--prorank-radius-sm, 6px);
  font-size: 14px;
  font-family: inherit;
  background: white;
  color: var(--prorank-text);
  transition: all 0.2s ease;
  line-height: 1.5;
}

/* Focus states with brand color */
.prorank-control-group input:focus,
.prorank-control-group textarea:focus,
.prorank-control-group select:focus,
.prorank-input:focus,
.prorank-textarea:focus,
.prorank-select:focus {
  outline: none;
  border-color: var(--prorank-primary);
  box-shadow: 0 0 0 3px rgba(115, 102, 240, 0.1);
}

/* Hover states */
.prorank-control-group input:hover:not(:focus):not(:disabled),
.prorank-control-group textarea:hover:not(:focus):not(:disabled),
.prorank-control-group select:hover:not(:focus):not(:disabled) {
  border-color: #9ca3af;
}

/* Disabled state */
.prorank-control-group input:disabled,
.prorank-control-group textarea:disabled,
.prorank-control-group select:disabled,
.prorank-input:disabled,
.prorank-textarea:disabled,
.prorank-select:disabled {
  background-color: #f9fafb;
  color: #9ca3af;
  cursor: not-allowed;
  opacity: 0.7;
}

/* Error state */
.prorank-control-group.has-error input,
.prorank-control-group.has-error textarea,
.prorank-control-group.has-error select,
.prorank-input.error,
.prorank-textarea.error,
.prorank-select.error {
  border-color: var(--prorank-error);
}

.prorank-control-group.has-error input:focus,
.prorank-control-group.has-error textarea:focus,
.prorank-control-group.has-error select:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.prorank-control-group .error-message,
.prorank-form-error {
  color: var(--prorank-error);
  font-size: 13px;
  margin-top: 4px;
}

/* Success state */
.prorank-control-group.has-success input,
.prorank-control-group.has-success textarea,
.prorank-control-group.has-success select {
  border-color: var(--prorank-success);
}

.prorank-control-group.has-success input:focus,
.prorank-control-group.has-success textarea:focus,
.prorank-control-group.has-success select:focus {
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

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

.prorank-control-group textarea,
.prorank-textarea {
  min-height: 100px;
  resize: vertical;
  line-height: 1.5;
}

/* ============================================
   SELECT SPECIFIC
   ============================================ */

.prorank-control-group select,
.prorank-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M2 4L6 8L10 4' stroke='%236B7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* ============================================
   CHECKBOX & RADIO
   ============================================ */

.prorank-control-group input[type="checkbox"],
.prorank-control-group input[type="radio"],
.prorank-checkbox,
.prorank-radio {
  width: 18px;
  height: 18px;
  margin-right: 8px;
  cursor: pointer;
  vertical-align: middle;
}

.prorank-checkbox-label,
.prorank-radio-label {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  font-size: 14px;
  color: var(--prorank-text);
  margin-bottom: 8px;
}

.prorank-checkbox-label:hover input[type="checkbox"],
.prorank-radio-label:hover input[type="radio"] {
  border-color: var(--prorank-primary);
}

/* ============================================
   TOGGLE SWITCH
   ============================================ */

.prorank-toggle {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 24px;
}

.prorank-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

/* Button-based toggle slider - styles handled by React inline styles */
button.prorank-toggle-slider {
  /* Don't override inline styles */
}

/* Input-based toggle slider (legacy) */
.prorank-toggle .prorank-toggle-slider {
  position: relative;
  cursor: pointer;
  background-color: #cbd5e1;
  transition: 0.3s;
  border-radius: 24px;
}

/* Removed - React component handles the thumb via inline styles */

/* Legacy toggle styles - kept for backwards compatibility with input-based toggles */
.prorank-toggle input:checked + .prorank-toggle-slider {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
}

.prorank-toggle input:disabled + .prorank-toggle-slider {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============================================
   TOGGLE SWITCHES
   Toggle/switch controls
   ============================================ */

.prorank-toggle,
.components-toggle-control {
  display: flex;
  align-items: center;
  gap: 14px;
}

.prorank-toggle-switch,
.components-form-toggle {
  position: relative;
  display: inline-block;
  width: 56px;
  height: 32px;
  flex-shrink: 0;
}

.prorank-toggle-input,
.components-form-toggle__input {
  opacity: 0;
  width: 0;
  height: 0;
}

.prorank-toggle-track,
.components-form-toggle__track {
  position: relative;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(180deg, #dde4ee 0%, #c7d0dd 100%);
  transition: var(--prorank-transition);
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.55);
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.72),
    0 1px 2px rgba(15, 23, 42, 0.08);
}

.prorank-toggle-thumb,
.components-form-toggle__thumb {
  position: relative;
  cursor: pointer;
  height: 24px;
  width: 24px;
  left: 3px;
  bottom: 2px;
  background-color: white;
  transition: var(--prorank-transition);
  border-radius: 50%;
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.22), 0 1px 2px rgba(15, 23, 42, 0.12);
}

.prorank-toggle-input:checked + .prorank-toggle-track,
.components-form-toggle.is-checked .components-form-toggle__track {
  background: linear-gradient(135deg, #ff8a1a 0%, #ff6900 58%, #e25b00 100%);
  border-color: rgba(255, 105, 0, 0.55);
  box-shadow:
    0 0 0 4px rgba(255, 105, 0, 0.14),
    inset 0 1px 1px rgba(255, 255, 255, 0.18);
}

.prorank-toggle-input:checked + .prorank-toggle-track .prorank-toggle-thumb,
.components-form-toggle.is-checked .components-form-toggle__thumb {
  transform: translateX(26px);
}

.prorank-toggle-switch:hover .prorank-toggle-track,
.components-form-toggle:hover .components-form-toggle__track {
  filter: brightness(1.03);
}

.prorank-toggle-switch:focus-within .prorank-toggle-track,
.components-form-toggle:focus-within .components-form-toggle__track {
  box-shadow:
    0 0 0 4px rgba(31, 41, 55, 0.12),
    inset 0 1px 1px rgba(255, 255, 255, 0.18);
}

.prorank-toggle-label {
  font-size: 14px;
  color: var(--prorank-text);
  user-select: none;
}

/* ============================================
   FORM VALIDATION
   Error and success states
   ============================================ */

.prorank-form-error {
  color: var(--prorank-error);
  font-size: 13px;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.prorank-form-error::before {
  content: '⚠';
  font-size: 14px;
}

.prorank-form-success {
  color: var(--prorank-success);
  font-size: 13px;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.prorank-form-success::before {
  content: '✓';
  font-size: 14px;
}

/* ============================================
   FORM FIELDSETS
   Grouped form fields
   ============================================ */

.prorank-fieldset {
  border: 1px solid var(--prorank-border);
  border-radius: var(--prorank-radius-sm);
  padding: 20px;
  margin: 0 0 24px;
}

.prorank-fieldset-legend {
  font-size: 16px;
  font-weight: 600;
  color: var(--prorank-text);
  padding: 0 8px;
  margin-left: -8px;
  background: white;
}

/* ============================================
   FORM ACTIONS
   Form submit/cancel buttons area
   ============================================ */

.prorank-form-actions {
  display: flex;
  gap: 12px;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--prorank-border);
}

.prorank-form-actions--right {
  justify-content: flex-end;
}

.prorank-form-actions--center {
  justify-content: center;
}

/* ============================================
   INPUT ADDONS
   Input fields with icons or buttons
   ============================================ */

.prorank-input-group {
  display: flex;
  align-items: stretch;
}

.prorank-input-group .prorank-input {
  border-radius: 4px 0 0 4px;
  border-right: none;
}

.prorank-input-addon {
  display: flex;
  align-items: center;
  padding: 0 12px;
  background: var(--prorank-bg-tertiary);
  border: 1px solid var(--prorank-border);
  border-left: none;
  border-radius: 0 4px 4px 0;
  color: var(--prorank-text-secondary);
  font-size: 14px;
}

.prorank-input-group .prorank-button {
  border-radius: 0 4px 4px 0;
}

/* ============================================
   DIVIDERS
   Horizontal separators for form sections
   ============================================ */

.prorank-divider-spacing {
  margin: 20px 0;
}

/* ============================================
   UNIFIED FORM COMPONENTS
   Styles for ProrankInput, ProrankTextarea, ProrankSelect
   ============================================ */

/* Form field wrapper */
.prorank-form-field {
  margin-bottom: 20px;
}

/* Input wrapper for icons and suffixes */
.prorank-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

/* Input with icon styles */
.prorank-input--with-icon-left {
  padding-left: 38px;
}

.prorank-input--with-icon-right {
  padding-right: 38px;
}

.prorank-input-icon {
  position: absolute;
  color: var(--prorank-text-secondary);
  font-size: 16px;
  pointer-events: none;
}

.prorank-input-icon--left {
  left: 12px;
}

.prorank-input-icon--right {
  right: 12px;
}

/* ============================================
   INPUT SIZING - Content-appropriate widths
   ============================================ */

/* Extra Small - Numbers, ZIP codes, Years, Percentages */
.prorank-input-xs {
  width: 100px !important;
}

/* Small - Phone, Date, Time, Short codes */
.prorank-input-sm {
  width: 180px !important;
}

/* Medium - Name, Email, City, Username */
.prorank-input-md {
  width: 300px !important;
}

/* Large - URLs, File paths, Addresses */
.prorank-input-lg {
  width: 450px !important;
}

/* Extra Large - API keys, Tokens, Long descriptions */
.prorank-input-xl {
  width: 600px !important;
}

/* Full Width - Textareas, Long text, Meta descriptions */
.prorank-input-full {
  width: 100% !important;
  max-width: 800px;
}

/* Input with unit styling */
.prorank-input-with-unit {
  display: flex;
  align-items: center;
  gap: 8px;
}

.prorank-input-unit {
  font-size: 14px;
  color: var(--prorank-text-secondary);
  white-space: nowrap;
}

/* Premium input group styling */
.prorank-input-group {
  margin-bottom: 20px;
}

.prorank-input-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--prorank-text);
}

.prorank-input-help {
  font-size: 13px;
  color: var(--prorank-text-secondary);
  margin-top: 6px;
  line-height: 1.5;
}

/* Input prefix/suffix */
.prorank-input-prefix,
.prorank-input-suffix {
  color: var(--prorank-text-secondary);
  font-size: 14px;
  white-space: nowrap;
  padding: 0 8px;
}

.prorank-input--with-prefix {
  padding-left: 8px;
}

.prorank-input--with-suffix {
  padding-right: 8px;
}

/* Character counter */
.prorank-input-char-count,
.prorank-char-count {
  position: absolute;
  right: 12px;
  bottom: -20px;
  font-size: 12px;
  color: var(--prorank-text-secondary);
}

/* Size variations */
.prorank-input--small,
.prorank-textarea--small,
.prorank-select--small {
  padding: 6px 10px;
  font-size: 13px;
  min-height: 30px;
}

.prorank-input--large,
.prorank-textarea--large,
.prorank-select--large {
  padding: 12px 14px;
  font-size: 15px;
  min-height: 42px;
}

/* Content-appropriate width classes */
.prorank-input-xs {
  width: 100px !important;  /* For: Numbers, ZIP codes, Years, Percentages, Separators */
}

.prorank-input-sm {
  width: 180px !important;  /* For: Phone, Date, Time, Short codes, Home text */
}

.prorank-input-md {
  width: 300px !important;  /* For: Name, Email, City, Username, Select dropdowns */
}

.prorank-input-lg {
  width: 450px !important;  /* For: URLs, File paths, Addresses */
}

.prorank-input-xl {
  width: 600px !important;  /* For: API keys, Tokens, Long descriptions */
}

.prorank-input-full {
  width: 100% !important;
  max-width: 800px;  /* For: Textareas, Long text, Meta descriptions */
}

/* Textarea specific */
.prorank-textarea-container {
  position: relative;
}

.prorank-textarea {
  resize: vertical;
  min-height: 80px;
}

.prorank-textarea--auto-resize {
  resize: none;
  overflow: hidden;
}

.prorank-textarea-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}

/* Select specific */
.prorank-select-wrapper {
  position: relative;
  display: inline-block;
  width: 100%;
}

.prorank-select {
  padding-right: 30px;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: none;
}

.prorank-select-arrow {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--prorank-text-secondary);
  font-size: 14px;
}

/* Required indicator */
.prorank-required {
  color: var(--prorank-danger);
  margin-left: 4px;
}

/* Help and error messages */
.prorank-input-help,
.prorank-input-error {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.5;
}

.prorank-input-help {
  color: var(--prorank-text-secondary);
}

.prorank-input-error {
  color: var(--prorank-danger);
}

/* Error states */
.prorank-input--error,
.prorank-textarea--error,
.prorank-select--error {
  border-color: var(--prorank-danger);
}

.prorank-input--error:focus,
.prorank-textarea--error:focus,
.prorank-select--error:focus {
  border-color: var(--prorank-danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* Form actions */
.prorank-form-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--prorank-border);
}

.prorank-form-actions-left {
  display: flex;
  gap: 12px;
  align-items: center;
}

.prorank-import-button {
  display: inline-block;
}

/* Notice component styles */
.prorank-notice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--prorank-radius-sm);
  margin-bottom: 16px;
  position: relative;
}

.prorank-notice--info {
  background: #e0f2fe;
  border: 1px solid #7dd3fc;
  color: #075985;
}

.prorank-notice--success {
  background: #dcfce7;
  border: 1px solid #86efac;
  color: #166534;
}

.prorank-notice--warning {
  background: #fef3c7;
  border: 1px solid #fde047;
  color: #854d0e;
}

.prorank-notice--error {
  background: #fee2e2;
  border: 1px solid #fca5a5;
  color: #991b1b;
}

.prorank-notice-icon {
  flex-shrink: 0;
  font-size: 20px;
}

.prorank-notice-content {
  flex: 1;
  font-size: 14px;
  line-height: 1.5;
}

.prorank-notice-dismiss {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: inherit;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.prorank-notice-dismiss:hover {
  opacity: 1;
}

/* Divider component */
.prorank-divider {
  border: none;
  height: 1px;
  margin: 24px 0;
  background: linear-gradient(90deg, rgba(255, 107, 53, 0) 0%, rgba(255, 107, 53, 0.55) 16%, rgba(255, 209, 102, 0.72) 50%, rgba(255, 107, 53, 0.55) 84%, rgba(255, 107, 53, 0) 100%);
  box-shadow: 0 8px 20px -18px rgba(255, 107, 53, 0.72);
}

.prorank-divider--small {
  margin: 12px 0;
}

.prorank-divider--medium {
  margin: 20px 0;
}

.prorank-divider--large {
  margin: 32px 0;
}

/* Form stacks for vertical spacing */
.prorank-form-stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.prorank-form-stack--small {
  gap: 12px;
}

.prorank-form-stack--compact {
  gap: 16px;
}

.prorank-form-stack--large {
  gap: 28px;
}

/* Form section titles */
.prorank-form-section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--prorank-text);
  margin: 16px 0 12px;
  display: block;
}
