/* Expandable Search Bar Styles */
.zignature-expandable-search {
  position: relative;
  display: inline-block;
  z-index: 1000;
}

.expandable-search-container {
  position: relative;
  display: flex;
  align-items: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  width: 50px; /* Default width (button size) */
  height: 50px;
  border-radius: 25px;
  background: transparent;
  overflow: hidden;
}

.expandable-search-container.expanded {
  background-color: #ffffff;
  border: 1px solid #e0e0e0;
  box-shadow: none;
}

.expandable-search-trigger {
  position: relative;
  z-index: 2;
  width: 50px;
  height: 50px;
  border: none !important;
  border-radius: 50%;
  background-color: #333333;
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  flex-shrink: 0;
  outline: none !important;
  box-shadow: none !important;
}

/* More specific targeting for stubborn borders */
.zignature-expandable-search input,
.zignature-expandable-search input[type="search"],
.zignature-expandable-search input[type="text"] {
  border: none !important;
  border-width: 0 !important;
  border-style: none !important;
  border-color: transparent !important;
  outline: none !important;
  outline-width: 0 !important;
  outline-style: none !important;
  outline-color: transparent !important;
  box-shadow: none !important;
  -webkit-box-shadow: none !important;
  -moz-box-shadow: none !important;
}

.zignature-expandable-search button,
.zignature-expandable-search .expandable-search-trigger {
  border: none !important;
  border-width: 0 !important;
  border-style: none !important;
  border-color: transparent !important;
  outline: none !important;
  outline-width: 0 !important;
  outline-style: none !important;
  outline-color: transparent !important;
  box-shadow: none !important;
  -webkit-box-shadow: none !important;
  -moz-box-shadow: none !important;
}

.expandable-search-trigger:focus,
.expandable-search-trigger:active,
.expandable-search-trigger:hover:focus {
  outline: none !important;
  box-shadow: none !important;
  border: none !important;
}

.expandable-search-trigger:hover {
  background-color: #555555;
  transform: scale(1.05);
}

.expandable-search-trigger i,
.expandable-search-trigger svg {
  font-size: 18px;
  transition: all 0.3s ease;
  display: inline-block;
  line-height: 1;
}

.expandable-search-container.expanded .expandable-search-trigger {
  background-color: transparent;
  color: #000000;
  position: absolute;
  right: 0;
  top: 0;
  border-radius: 0 25px 25px 0;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  z-index: 3;
}

.expandable-search-container.expanded .expandable-search-trigger:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

/* Ensure close icon is black */
.expandable-search-container.expanded .expandable-search-trigger i.fa-times {
  color: #000000;
}

/* Ensure search icon is always visible */
.expandable-search-trigger i.fa-search {
  color: #ffffff;
  width: auto;
  height: auto;
  min-width: 18px;
  min-height: 18px;
}

.expandable-search-input {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  border: none !important;
  background: transparent;
  padding: 0 60px 0 20px; /* Right padding for the button */
  font-size: 16px;
  color: #333333;
  outline: none !important;
  opacity: 0;
  transform: translateX(-20px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 25px;
  box-shadow: none !important;
  z-index: 1;
}

.expandable-search-input:focus,
.expandable-search-input:active,
.expandable-search-input:hover {
  outline: none !important;
  border: none !important;
  box-shadow: none !important;
}

.expandable-search-container.expanded .expandable-search-input {
  opacity: 1;
  transform: translateX(0);
}

.expandable-search-input::placeholder {
  color: #999999;
  opacity: 0.7;
}

/* Animation states */
.expandable-search-container.expanding {
  animation: expandSearch 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.expandable-search-container.collapsing {
  animation: collapseSearch 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes expandSearch {
  0% {
    width: 50px;
  }
  100% {
    width: 300px;
  }
}

@keyframes collapseSearch {
  0% {
    width: 300px;
  }
  100% {
    width: 50px;
  }
}

/* Responsive Design */
@media (max-width: 768px) {
  .expandable-search-container.expanded {
    width: 280px !important;
  }

  @keyframes expandSearch {
    100% {
      width: 280px;
    }
  }

  @keyframes collapseSearch {
    0% {
      width: 280px;
    }
  }
}

@media (max-width: 480px) {
  .expandable-search-container.expanded {
    width: 250px !important;
  }

  .expandable-search-input {
    font-size: 14px;
    padding: 0 55px 0 15px;
  }

  .expandable-search-trigger {
    width: 45px;
    height: 45px;
    background: transparent !important;
    border: none !important;
  }

  .expandable-search-container {
    width: 45px;
    height: 45px;
  }

  @keyframes expandSearch {
    100% {
      width: 250px;
    }
  }

  @keyframes collapseSearch {
    0% {
      width: 250px;
    }
  }
}

/* Smooth transitions for specific elements only */
.expandable-search-container {
  transition: all 0.3s ease;
}

.expandable-search-trigger {
  transition: all 0.3s ease;
}

.expandable-search-input {
  transition: all 0.3s ease;
}

/* Override any theme or browser default borders */
.zignature-expandable-search *,
.zignature-expandable-search *:before,
.zignature-expandable-search *:after {
  box-sizing: border-box;
}

.zignature-expandable-search button,
.zignature-expandable-search input[type="search"] {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
}

.zignature-expandable-search button:focus,
.zignature-expandable-search button:active,
.zignature-expandable-search input[type="search"]:focus,
.zignature-expandable-search input[type="search"]:active {
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
}

/* Overlay for mobile click-outside detection */
.search-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: transparent;
  z-index: 999;
  display: none;
}

.search-overlay.active {
  display: block;
}

/* RTL Support */
[dir="rtl"] .expandable-search-input {
  padding: 0 20px 0 60px;
}

[dir="rtl"] .expandable-search-container.expanded .expandable-search-trigger {
  right: auto;
  left: 0;
  border-radius: 25px 0 0 25px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .expandable-search-trigger {
    border: 2px solid #000000;
  }

  .expandable-search-container.expanded {
    border: 2px solid #000000;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .expandable-search-container,
  .expandable-search-trigger,
  .expandable-search-input,
  .expandable-search-container * {
    transition: none;
    animation: none;
  }
}
