/* ================================
   WORLD-CLASS INPUT COMPONENT
   Apple / Stripe / Linear Quality
=================================== */

.input-container {
  position: relative;
  width: 100%;
  margin-bottom: var(--space-4);
}

.input-group {
  position: relative;
  display: flex;
  align-items: center;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.9) 0%,
    rgba(248, 250, 252, 0.8) 100%
  );
  border: 2px solid var(--border-primary);
  border-radius: var(--radius-xl);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transform: translateZ(0);
  will-change: transform, border-color, box-shadow;
}

.input-group::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.6),
    transparent
  );
}

/* ================================
   Input Field Container
=================================== */

.input-field-container {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
}

.input-field {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  color: var(--text-primary);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.input-field::placeholder {
  color: var(--text-tertiary);
  opacity: 1;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.input-field:focus::placeholder {
  opacity: 0;
  transform: translateY(-4px);
}

/* ================================
   Floating Label
=================================== */

.input-label {
  position: absolute;
  left: 0;
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  color: var(--text-tertiary);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
  transform-origin: left top;
  z-index: 1;
}

.input-required {
  color: var(--error-500);
  margin-left: 2px;
}

/* ================================
   Focus Ring
=================================== */

.input-focus-ring {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  background: var(--primary-500);
  transform-origin: center;
  border-radius: 1px;
  width: 100%;
}

/* ================================
   Input States
=================================== */

.input-focused {
  border-color: rgba(37, 99, 235, 0.45);
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.95) 0%,
    rgba(251, 252, 254, 0.9) 100%
  );
  box-shadow: 
    0 0 0 4px rgba(37, 99, 235, 0.12),
    0 8px 24px rgba(var(--primary-rgb), 0.08),
    0 2px 8px rgba(var(--primary-rgb), 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

/* Enhanced mobile keyboard support */
input[type="email"] {
  caret-color: var(--primary-600);
}

input[type="tel"] {
  -webkit-text-size-adjust: 100%;
}

.input-error {
  border-color: rgba(239, 68, 68, 0.3);
  background: linear-gradient(
    135deg,
    rgba(254, 242, 242, 0.9) 0%,
    rgba(255, 255, 255, 0.8) 100%
  );
}

.input-error.input-focused {
  box-shadow: 
    0 8px 24px rgba(239, 68, 68, 0.08),
    0 2px 8px rgba(239, 68, 68, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.input-disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: linear-gradient(
    135deg,
    rgba(248, 250, 252, 0.6) 0%,
    rgba(241, 245, 249, 0.5) 100%
  );
}

.input-disabled .input-field {
  cursor: not-allowed;
}

/* ================================
   Input Sizes
=================================== */

.input-sm {
  min-height: 40px;
  border-radius: var(--radius-lg);
}

.input-sm .input-field {
  padding: var(--space-2) var(--space-4);
  font-size: var(--font-size-sm);
}

.input-sm .input-label {
  font-size: var(--font-size-sm);
}

.input-md {
  min-height: 48px;
  border-radius: var(--radius-xl);
}

.input-md .input-field {
  padding: var(--space-3) var(--space-4);
  font-size: var(--font-size-base);
}

.input-lg {
  min-height: 56px;
  border-radius: var(--radius-xl);
}

.input-lg .input-field {
  padding: var(--space-4) var(--space-6);
  font-size: var(--font-size-lg);
}

.input-lg .input-label {
  font-size: var(--font-size-lg);
}

/* ================================
   Input Variants
=================================== */

.input-outline {
  background: transparent;
  border: 2px solid var(--border-primary);
}

.input-outline.input-focused {
  background: rgba(var(--primary-rgb), 0.02);
  border-color: var(--primary-300);
}

.input-filled {
  background: var(--bg-secondary);
  border: 2px solid transparent;
}

.input-filled.input-focused {
  background: var(--bg-primary);
  border-color: var(--primary-300);
}

.input-underline {
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--border-primary);
  border-radius: 0;
}

.input-underline.input-focused {
  border-bottom-color: var(--primary-500);
}

.input-underline .input-focus-ring {
  bottom: -2px;
  height: 2px;
}

/* ================================
   Input Icons
=================================== */

.input-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  flex-shrink: 0;
}

.input-icon-left {
  padding-left: var(--space-4);
  padding-right: var(--space-2);
}

.input-icon-right {
  padding-left: var(--space-2);
  padding-right: var(--space-4);
}

.input-icon svg {
  width: 20px;
  height: 20px;
}

/* ================================
   Clear Button
=================================== */

.input-clear {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  background: rgba(var(--gray-500), 0.1);
  color: var(--gray-500);
  border-radius: var(--radius-full);
  margin-right: var(--space-3);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  font-size: 12px;
  flex-shrink: 0;
}

.input-clear:hover {
  background: rgba(var(--gray-500), 0.2);
  color: var(--gray-700);
}

/* ================================
   Loading Spinner
=================================== */

.input-loading-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top: 2px solid var(--primary-500);
  border-radius: 50%;
  margin-right: var(--space-3);
  flex-shrink: 0;
}

/* ================================
   Error and Hint Messages
=================================== */

.input-error-message {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-2);
  color: var(--error-600);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-normal);
}

.input-error-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  background: var(--error-100);
  color: var(--error-600);
  border-radius: var(--radius-full);
  font-size: 10px;
  flex-shrink: 0;
}

.input-hint {
  margin-top: var(--space-2);
  color: var(--text-tertiary);
  font-size: var(--font-size-sm);
  line-height: var(--line-height-normal);
}

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

.textarea-group {
  align-items: flex-start;
}

.textarea-field {
  resize: vertical;
  min-height: 120px;
  line-height: var(--line-height-relaxed);
  padding-top: var(--space-6);
  padding-bottom: var(--space-3);
}

.textarea-label {
  top: var(--space-4);
  transform: translateY(0);
}

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

.select-group {
  position: relative;
}

.select-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
  border: none;
  outline: none;
  cursor: pointer;
  font-family: inherit;
  font-size: var(--font-size-base);
  color: var(--text-primary);
  text-align: left;
  padding: var(--space-3) var(--space-4);
}

.select-trigger:disabled {
  cursor: not-allowed;
}

.select-value {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.select-arrow {
  margin-left: var(--space-2);
  color: var(--text-tertiary);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  font-size: 12px;
}

.select-open .select-arrow {
  color: var(--primary-600);
}

.select-label {
  left: var(--space-4);
}

/* Select Dropdown */
.select-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.98) 0%,
    rgba(251, 252, 254, 0.95) 100%
  );
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(var(--primary-rgb), 0.1);
  border-radius: var(--radius-2xl);
  box-shadow: 
    0 20px 40px rgba(0, 0, 0, 0.08),
    0 8px 16px rgba(0, 0, 0, 0.04),
    0 2px 4px rgba(0, 0, 0, 0.02),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
  z-index: var(--z-dropdown);
  overflow: hidden;
  max-height: 240px;
  transform: translateZ(0);
}

.select-search {
  padding: var(--space-3);
  border-bottom: 1px solid var(--border-primary);
}

.select-search-input {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  background: var(--bg-primary);
  font-size: var(--font-size-sm);
  outline: none;
}

.select-search-input:focus {
  border-color: var(--primary-300);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.08);
}

.select-options {
  max-height: 200px;
  overflow-y: auto;
  padding: var(--space-2) 0;
}

.select-option {
  width: 100%;
  display: flex;
  align-items: center;
  padding: var(--space-3) var(--space-4);
  background: transparent;
  border: none;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  font-size: var(--font-size-base);
  color: var(--text-primary);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  border-bottom: 1px solid rgba(var(--border-primary), 0.5);
}

.select-option:last-child {
  border-bottom: none;
}

.select-option:hover {
  background: linear-gradient(
    135deg,
    rgba(var(--primary-rgb), 0.04) 0%,
    rgba(var(--primary-rgb), 0.02) 100%
  );
  color: var(--primary-600);
}

.select-option-selected {
  background: linear-gradient(
    135deg,
    var(--primary-500) 0%,
    var(--primary-600) 100%
  );
  color: white;
  font-weight: var(--font-weight-medium);
}

.select-option-selected:hover {
  background: linear-gradient(
    135deg,
    var(--primary-600) 0%,
    var(--primary-700) 100%
  );
  color: white;
}

.select-no-options {
  padding: var(--space-6) var(--space-4);
  text-align: center;
  color: var(--text-tertiary);
  font-size: var(--font-size-sm);
  font-style: italic;
}

/* ================================
   Input Groups
=================================== */

.input-group-container {
  display: flex;
  gap: var(--space-3);
}

.input-group-container .input-container {
  flex: 1;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

.input-row.cols-2 {
  grid-template-columns: repeat(2, 1fr);
}

.input-row.cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

/* ================================
   Checkbox and Radio Inputs
=================================== */

.checkbox-container,
.radio-container {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  cursor: pointer;
}

.checkbox-input,
.radio-input {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-primary);
  background: var(--bg-primary);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 2px;
}

.checkbox-input {
  border-radius: var(--radius-base);
}

.radio-input {
  border-radius: var(--radius-full);
}

.checkbox-input:checked,
.radio-input:checked {
  background: linear-gradient(
    135deg,
    var(--primary-500) 0%,
    var(--primary-600) 100%
  );
  border-color: var(--primary-600);
}

.checkbox-input:checked::after {
  content: '✓';
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 12px;
  font-weight: bold;
}

.radio-input:checked::after {
  content: '';
  display: block;
  width: 8px;
  height: 8px;
  background: white;
  border-radius: var(--radius-full);
  margin: 4px auto;
}

.checkbox-label,
.radio-label {
  flex: 1;
  font-size: var(--font-size-base);
  color: var(--text-primary);
  line-height: var(--line-height-relaxed);
  cursor: pointer;
}

.checkbox-container:hover .checkbox-input,
.radio-container:hover .radio-input {
  border-color: var(--primary-300);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.08);
}

/* ================================
   File Input
=================================== */

.file-input-container {
  position: relative;
  display: inline-block;
  cursor: pointer;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.file-input-label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.9) 0%,
    rgba(248, 250, 252, 0.8) 100%
  );
  border: 2px solid var(--border-primary);
  border-radius: var(--radius-xl);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.file-input-label:hover {
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.95) 0%,
    rgba(251, 252, 254, 0.9) 100%
  );
  border-color: var(--primary-300);
  color: var(--primary-600);
  transform: translateY(-1px);
  box-shadow: 
    0 8px 24px rgba(0, 0, 0, 0.06),
    0 2px 8px rgba(0, 0, 0, 0.04);
}

.file-input-text {
  flex: 1;
}

.file-input-icon {
  width: 20px;
  height: 20px;
  color: currentColor;
}

/* ================================
   Responsive Design
=================================== */

@media (max-width: 768px) {
  .input-row.cols-2,
  .input-row.cols-3 {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }

  .input-group-container {
    flex-direction: column;
    gap: var(--space-3);
  }

  .input-lg {
    min-height: 52px;
  }

  .input-lg .input-field {
    font-size: var(--font-size-base);
  }

  .select-dropdown {
    position: fixed;
    top: auto;
    bottom: var(--space-4);
    left: var(--space-4);
    right: var(--space-4);
    max-height: 60vh;
  }
}

@media (max-width: 480px) {
  .input-container {
    margin-bottom: var(--space-3);
  }

  .input-md {
    min-height: 44px;
  }

  .input-lg {
    min-height: 48px;
  }

  .input-field {
    font-size: var(--font-size-base);
  }

  .input-lg .input-field {
    padding: var(--space-3) var(--space-4);
  }

  .checkbox-container,
  .radio-container {
    gap: var(--space-2);
  }

  .file-input-label {
    padding: var(--space-3) var(--space-4);
    font-size: var(--font-size-sm);
  }
}

/* ================================
   Accessibility & Performance
=================================== */

@media (prefers-reduced-motion: reduce) {
  .input-group,
  .input-field,
  .input-label,
  .input-focus-ring,
  .select-arrow,
  .input-icon {
    transition: none !important;
    animation: none !important;
  }
}

@media (prefers-contrast: high) {
  .input-group {
    border-width: 3px;
    border-color: var(--gray-600);
  }

  .input-focused {
    border-color: var(--primary-600);
  }

  .input-error {
    border-color: var(--error-600);
  }

  .checkbox-input,
  .radio-input {
    border-width: 3px;
  }
}

/* Focus visible for better keyboard navigation */
.input-field:focus-visible,
.select-trigger:focus-visible,
.checkbox-input:focus-visible,
.radio-input:focus-visible {
  outline: 3px solid rgba(var(--primary-rgb), 0.5);
  outline-offset: 2px;
}

/* Performance optimizations */
.input-group,
.select-dropdown {
  transform: translateZ(0);
}

.input-group *,
.select-dropdown * {
  transform: translateZ(0);
}