/**
 * Kosmetix Input Component
 * Reusable input styling with design system
 *
 * @package Kosmetix
 */

/* ============================================
   BASE WRAPPER
   ============================================ */

.kosmetix-input {
  display: flex;
  flex-direction: column;
  gap: var(--wp--preset--spacing--2xs);
  width: 100%;
}

/* ============================================
   LABEL
   ============================================ */

.kosmetix-input__label {
  font-size: var(--wp--preset--font-size--sm);
  font-weight: 500;
  color: var(--wp--preset--color--charcoal);
  letter-spacing: var(--wp--custom--letter-spacing--wide);
}

.kosmetix-input__required {
  color: var(--wp--preset--color--rose-gold);
  margin-left: 2px;
}

/* ============================================
   INPUT WRAPPER (for icon positioning)
   ============================================ */

.kosmetix-input__wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

/* ============================================
   INPUT FIELD - BASE
   ============================================ */

.kosmetix-input__field {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  font-family: var(--wp--preset--font-family--body);
  font-size: var(--wp--preset--font-size--base);
  color: var(--wp--preset--color--charcoal);
  transition: all var(--wp--custom--transition--fast);
  outline: none; /* Remove default browser outline that creates double border */
  box-sizing: border-box;
}

.kosmetix-input__field:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

.kosmetix-input__field::placeholder {
  color: var(--wp--preset--color--slate);
  opacity: 0.7;
}

/* Remove default browser styling */
.kosmetix-input__field::-webkit-outer-spin-button,
.kosmetix-input__field::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.kosmetix-input__field[type='number'] {
  -moz-appearance: textfield;
  appearance: textfield;
}

.kosmetix-input__field[type='search']::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

/* ============================================
   SIZE VARIANTS
   ============================================ */

/* Small - 32px */
.kosmetix-input--sm .kosmetix-input__field {
  height: 32px;
  padding: 0 var(--wp--preset--spacing--xs);
  font-size: 13px;
  border-radius: var(--wp--custom--radius--sm);
}

.kosmetix-input--sm.kosmetix-input--icon-left .kosmetix-input__field {
  padding-left: 32px;
}

.kosmetix-input--sm.kosmetix-input--icon-right .kosmetix-input__field {
  padding-right: 32px;
}

.kosmetix-input--sm .kosmetix-input__icon {
  width: 32px;
  font-size: 16px;
}

/* Medium - 40px (default) */
.kosmetix-input--md .kosmetix-input__field {
  height: 40px;
  padding: 0 var(--wp--preset--spacing--sm);
  font-size: var(--wp--preset--font-size--sm);
  border-radius: var(--wp--custom--radius--md);
}

.kosmetix-input--md.kosmetix-input--icon-left .kosmetix-input__field {
  padding-left: 40px;
}

.kosmetix-input--md.kosmetix-input--icon-right .kosmetix-input__field {
  padding-right: 40px;
}

.kosmetix-input--md .kosmetix-input__icon {
  width: 40px;
  font-size: 20px;
}

/* Large - 48px */
.kosmetix-input--lg .kosmetix-input__field {
  height: 48px;
  padding: 0 var(--wp--preset--spacing--md);
  font-size: var(--wp--preset--font-size--base);
}

.kosmetix-input--lg.kosmetix-input--icon-left .kosmetix-input__field {
  padding-left: 48px;
}

.kosmetix-input--lg.kosmetix-input--icon-right .kosmetix-input__field {
  padding-right: 48px;
}

.kosmetix-input--lg .kosmetix-input__icon {
  width: 48px;
  font-size: 24px;
}

/* ============================================
   STYLE VARIANTS
   ============================================ */

/* Default - White bg with ultra-subtle border */
.kosmetix-input--default .kosmetix-input__field {
  background: var(--wp--preset--color--white);
  border: 1px solid transparent;
  box-shadow: inset 0 0 0 1px var(--wp--preset--color--blush-light);
}

.kosmetix-input--default .kosmetix-input__field:hover {
  box-shadow: inset 0 0 0 1px var(--wp--preset--color--rose-gold-light);
}

.kosmetix-input--default .kosmetix-input__field:focus {
  box-shadow: inset 0 0 0 1px var(--wp--preset--color--rose-gold),
    0 0 0 1px rgba(193, 124, 116, 0.1);
  outline: none; /* Override Storefront parent theme */
}

/* Filled - Very light cream background, no visible border */
.kosmetix-input--filled .kosmetix-input__field {
  background: var(--wp--preset--color--cream);
  border: 1px solid transparent;
  box-shadow: none;
}

.kosmetix-input--filled .kosmetix-input__field:hover {
  background: var(--wp--preset--color--white);
  box-shadow: inset 0 0 0 1px var(--wp--preset--color--blush-light);
}

.kosmetix-input--filled .kosmetix-input__field:focus {
  background: var(--wp--preset--color--white);
  box-shadow: inset 0 0 0 1px var(--wp--preset--color--rose-gold),
    0 0 0 1px rgba(193, 124, 116, 0.1);
  outline: none; /* Override Storefront parent theme */
}

/* Outlined - Transparent with delicate border */
.kosmetix-input--outlined .kosmetix-input__field {
  background: transparent;
  border: 1px solid transparent;
  box-shadow: inset 0 0 0 1px var(--wp--preset--color--blush-light);
}

.kosmetix-input--outlined .kosmetix-input__field:hover {
  box-shadow: inset 0 0 0 1px var(--wp--preset--color--rose-gold-light);
}

.kosmetix-input--outlined .kosmetix-input__field:focus {
  box-shadow: inset 0 0 0 1px var(--wp--preset--color--rose-gold),
    0 0 0 1px rgba(193, 124, 116, 0.1);
  outline: none; /* Override Storefront parent theme */
}

/* Chromeless - No border/bg, for use in other wrappers */
.kosmetix-input--chromeless .kosmetix-input__field {
  background: transparent;
  border: none;
  box-shadow: none;
  padding-left: 0;
  padding-right: 0;
}

.kosmetix-input--chromeless .kosmetix-input__field:focus {
  outline: none;
  box-shadow: none;
}

/* Override padding for chromeless when icon is present */
.kosmetix-input--chromeless.kosmetix-input--icon-left .kosmetix-input__field {
  padding-left: 32px; /* Restore icon space */
}

.kosmetix-input--chromeless.kosmetix-input--icon-right .kosmetix-input__field {
  padding-right: 32px;
}

.kosmetix-input--chromeless.kosmetix-input--lg.kosmetix-input--icon-left
  .kosmetix-input__field {
  padding-left: 48px;
}

/* ============================================
   ICON
   ============================================ */

.kosmetix-input__icon {
  position: absolute;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--wp--preset--color--slate);
  pointer-events: none;
  transition: color var(--wp--custom--transition--fast);
}

.kosmetix-input--icon-left .kosmetix-input__icon {
  left: 0;
}

.kosmetix-input--icon-right .kosmetix-input__icon {
  right: 0;
}

/* Icon color on focus */
.kosmetix-input__field:focus ~ .kosmetix-input__icon,
.kosmetix-input__wrapper:focus-within .kosmetix-input__icon {
  color: var(--wp--preset--color--rose-gold);
}

/* ============================================
   ERROR STATE
   ============================================ */

.kosmetix-input--error .kosmetix-input__field {
  border-color: var(--wp--preset--color--error) !important;
  background-color: var(--wp--preset--color--error-light);
}

.kosmetix-input--error .kosmetix-input__field:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.kosmetix-input__error {
  display: flex;
  align-items: center;
  gap: var(--wp--preset--spacing--3xs);
  font-size: var(--wp--preset--font-size--xs);
  color: var(--wp--preset--color--error);
}

.kosmetix-input__error .material-symbols-outlined {
  font-size: 16px;
}

/* ============================================
   DISABLED STATE
   ============================================ */

.kosmetix-input--disabled .kosmetix-input__field {
  background-color: var(--wp--preset--color--mist);
  color: var(--wp--preset--color--slate);
  cursor: not-allowed;
  opacity: 0.7;
}

.kosmetix-input--disabled .kosmetix-input__icon {
  opacity: 0.5;
}

/* ============================================
   HINT TEXT
   ============================================ */

.kosmetix-input__hint {
  font-size: var(--wp--preset--font-size--xs);
  color: var(--wp--preset--color--slate);
}

/* ============================================
   COMPACT MODE (for inline filters)
   ============================================ */

.kosmetix-input--compact {
  width: auto;
}

.kosmetix-input--compact .kosmetix-input__field {
  text-align: center;
}

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

@media (max-width: 767px) {
  .kosmetix-input--md .kosmetix-input__field {
    height: 44px; /* Better touch target */
  }

  .kosmetix-input--lg .kosmetix-input__field {
    height: 52px;
  }
}
