/**
 * TA Search Box Component Styles
 * React-like search box with multiple variants
 *
 * @package Flavor_Starter
 */

/* ========================================
   CSS Variables
   ======================================== */
.ta-search {
  --ta-search-font: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  --ta-search-bg: #f8fafc;
  --ta-search-bg-focus: #ffffff;
  --ta-search-border: #e2e8f0;
  --ta-search-border-focus: #94a3b8;
  --ta-search-text: #1e293b;
  --ta-search-placeholder: #94a3b8;
  --ta-search-icon: #64748b;
  --ta-search-accent: #f5a623;
  --ta-search-accent-hover: #e09612;
  --ta-search-radius: 0.5rem;
  --ta-search-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  --ta-search-shadow-focus: 0 4px 12px rgba(0, 0, 0, 0.1);
  --ta-search-transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   Base Styles
   ======================================== */
.ta-search {
  width: 100%;
  font-family: var(--ta-search-font);
}

.ta-search__form {
  display: flex;
  align-items: stretch;
  gap: 0;
  width: 100%;
  background-color: #ffffff;
  margin-bottom: 0px;
}

.ta-search__input-wrapper {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
}

/* Icon */
.ta-search__icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ta-search-icon);
  pointer-events: none;
  flex-shrink: 0;
  transition: var(--ta-search-transition);
}

/* Input */
.ta-search__input {
  width: 100%;
  padding: 0.875rem 2.75rem 0.875rem 3rem;
  border: 1px solid var(--ta-search-border);
  border-radius: var(--ta-search-radius);
  background: var(--ta-search-bg);
  color: var(--ta-search-text);
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 450;
  line-height: 1.5;
  outline: none;
  box-shadow: var(--ta-search-shadow);
  transition: var(--ta-search-transition);
  -webkit-appearance: none;
  appearance: none;
}

.ta-search__input::placeholder {
  color: var(--ta-search-placeholder);
  font-weight: 400;
}

.ta-search__input:focus {
  background: var(--ta-search-bg-focus);
  border-color: var(--ta-search-border-focus);
  box-shadow: var(--ta-search-shadow-focus);
}

.ta-search__input:focus + .ta-search__icon,
.ta-search__input-wrapper:focus-within .ta-search__icon {
  color: var(--ta-search-accent);
}

/* Remove default search cancel button */
.ta-search__input::-webkit-search-cancel-button,
.ta-search__input::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}

/* Clear button */
.ta-search__clear {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--ta-search-placeholder);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: var(--ta-search-transition);
}

.ta-search__clear:hover {
  background: var(--ta-search-border);
  color: var(--ta-search-text);
}

.ta-search__input:not(:placeholder-shown) ~ .ta-search__clear,
.ta-search--has-value .ta-search__clear {
  opacity: 1;
  visibility: visible;
}

/* Submit button */
.ta-search__button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  min-width: 48px;
  height: auto;
  border: none;
  border-radius: 0 var(--ta-search-radius) var(--ta-search-radius) 0;
  background: var(--ta-search-accent);
  color: #ffffff;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--ta-search-transition);
  margin-left: -1px;
}

.ta-search__button:hover {
  background: var(--ta-search-accent-hover);
}

.ta-search__button:active {
  transform: scale(0.98);
}

.ta-search__button svg {
  flex-shrink: 0;
}

.ta-search__button-text {
  padding: 0 1rem;
  white-space: nowrap;
}

/* When button is shown, adjust input border radius */
.ta-search:has(.ta-search__button) .ta-search__input {
  border-radius: var(--ta-search-radius) 0 0 var(--ta-search-radius);
  border-right: none;
}

/* ========================================
   Size Variants
   ======================================== */

/* Small */
.ta-search--sm .ta-search__input {
  padding: 0.625rem 2.5rem 0.625rem 2.5rem;
  font-size: 0.8125rem;
}

.ta-search--sm .ta-search__icon {
  left: 0.75rem;
  width: 16px;
  height: 16px;
}

.ta-search--sm .ta-search__clear {
  right: 0.5rem;
  width: 20px;
  height: 20px;
}

.ta-search--sm .ta-search__clear svg {
  width: 12px;
  height: 12px;
}

.ta-search--sm .ta-search__button {
  min-width: 40px;
}

.ta-search--sm .ta-search__button svg {
  width: 16px;
  height: 16px;
}

/* Large */
.ta-search--lg .ta-search__input {
  padding: 1.125rem 3rem 1.125rem 3.5rem !important;
  font-size: 1.0625rem;
  margin-bottom: 0px;
  min-height: 44px;
  height: auto !important;
}

.ta-search--lg .ta-search__icon {
  left: 1.25rem;
  width: 24px;
  height: 24px;
}

.ta-search--lg .ta-search__clear {
  right: 1rem;
  width: 28px;
  height: 28px;
}

.ta-search--lg .ta-search__button {
  min-width: 56px;
  padding: 0 1.25rem;
}

/* ========================================
   Style Variants
   ======================================== */

/* Minimal - no border, subtle background */
.ta-search--minimal .ta-search__input {
  border: none;
  background: var(--ta-search-bg);
  box-shadow: none;
  margin: 0px;
  border-radius: 0.25rem;
}

.ta-search--minimal .ta-search__input:focus {
  background: #f1f5f9;
  box-shadow: none;
}

.ta-search--minimal .ta-search__button {
  border-radius: var(--ta-search-radius);
  margin-left: 0.5rem;
}

.ta-search--minimal:has(.ta-search__button) .ta-search__input {
  border-radius: var(--ta-search-radius);
}

/* Bordered - prominent border */
.ta-search--bordered .ta-search__input {
  background: transparent;
  border-width: 2px;
  border-color: var(--ta-search-border);
}

.ta-search--bordered .ta-search__input:focus {
  border-color: var(--ta-search-accent);
  box-shadow: 0 0 0 3px rgba(245, 166, 35, 0.15);
}

/* Filled - solid background, no border */
.ta-search--filled .ta-search__input {
  border: none;
  background: #1e293b;
  color: #ffffff;
}

.ta-search--filled .ta-search__input::placeholder {
  color: #94a3b8;
}

.ta-search--filled .ta-search__icon {
  color: #94a3b8;
}

.ta-search--filled .ta-search__input:focus {
  background: #0f172a;
  box-shadow: 0 0 0 3px rgba(245, 166, 35, 0.25);
}

.ta-search--filled .ta-search__input:focus ~ .ta-search__icon,
.ta-search--filled .ta-search__input-wrapper:focus-within .ta-search__icon {
  color: var(--ta-search-accent);
}

.ta-search--filled .ta-search__clear {
  color: #64748b;
}

.ta-search--filled .ta-search__clear:hover {
  background: #334155;
  color: #ffffff;
}

/* ========================================
   Focus States & Accessibility
   ======================================== */
.ta-search__input:focus-visible {
  outline: 2px solid var(--ta-search-accent);
  outline-offset: 2px;
}

.ta-search__button:focus-visible {
  outline: 2px solid var(--ta-search-accent);
  outline-offset: 2px;
}

.ta-search__clear:focus-visible {
  outline: 2px solid var(--ta-search-accent);
  outline-offset: 1px;
  opacity: 1;
  visibility: visible;
}

/* ========================================
   Loading State
   ======================================== */
.ta-search--loading .ta-search__icon {
  animation: ta-search-spin 1s linear infinite;
}

@keyframes ta-search-spin {
  from {
    transform: translateY(-50%) rotate(0deg);
  }
  to {
    transform: translateY(-50%) rotate(360deg);
  }
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 640px) {
  .ta-search__input {
    font-size: 16px; /* Prevent zoom on iOS */
  }

  .ta-search__button-text {
    display: none;
  }

  .ta-search__button {
    min-width: 44px;
    padding: 0;
  }
}
