/* Smart Search Dropdown */
.ss-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  background: #fff;
  border-radius: 0 0 10px 10px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
  z-index: 9999;
  overflow: hidden;
}

.ss-dropdown-inner {
  max-height: 85vh;
  overflow-y: auto;
  overflow-x: hidden;
}

/* When dropdown is open: remove bottom rounding from search bar */
.ss-dropdown-open .is-input-wrap {
  border-radius: 8px 0 0 0 !important;
}

.ss-dropdown-open .sAll button[type="submit"] {
  border-radius: 0 8px 0 0 !important;
}

/* Chips */
.ss-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 16px;
  border-bottom: 1px solid #eee;
}

.ss-chip {
  display: inline-block;
  padding: 4px 12px;
  background: #f0f0f0;
  border-radius: 16px;
  font-size: 13px;
  color: #333;
  cursor: pointer;
  transition: background 0.15s;
}

.ss-chip:hover,
.ss-chip.ss-item-active {
  background: #e0e0e0;
}

/* Sections */
.ss-section {
  padding: 4px 0;
}

.ss-section-border {
  border-top: 1px solid #eee;
}

/* Items */
.ss-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 16px;
  cursor: pointer;
  transition: background 0.1s;
}

.ss-item:hover,
.ss-item-active {
  background: #f5f5f5;
}

/* Search icon for terms */
.ss-icon-search {
  flex-shrink: 0;
  color: #999;
}

.ss-item-term span {
  font-size: 14px;
  font-weight: 400;
  color: #222;
}

.ss-item-term span b {
  font-weight: 500;
  color: #222;
}

/* Two-column layout: categories left, brands right */
.ss-columns {
  display: flex;
  border-top: 1px solid #eee;
}

.ss-col {
  flex: 1;
  min-width: 0;
  padding: 4px 0;
}

.ss-col + .ss-col {
  border-left: 1px solid #eee;
}

.ss-col-label {
  padding: 6px 14px 4px;
  font-size: 11px;
  font-weight: 600;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ss-col .ss-item {
  padding: 5px 14px;
  gap: 8px;
}

/* Inline icon for categories/brands */
.ss-icon-inline {
  flex-shrink: 0;
  color: #bbb;
}

/* Image icons for categories/brands */
.ss-icon-img {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  object-fit: contain;
  border-radius: 6px;
}

/* Letter avatar fallback */
.ss-avatar {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
}

/* Text block */
.ss-item-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.ss-item-name {
  font-size: 13px;
  color: #222;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ss-item-sub {
  font-size: 11px;
  color: #aaa;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Hide old autocomplete globally */
.ac_results.search {
  display: none !important;
}

/* Hide old typeahead dropdown inside mobile search */
#search > ul > ul.nav {
  display: none !important;
}

/* Mobile: hide old suggestions when smart search is active */
.ss-dropdown-open ~ #searchSuggests {
  display: none !important;
}

/* Mobile styles */
@media (max-width: 768px) {
  .ss-dropdown {
    position: fixed;
    bottom: 0;
    border-radius: 0 0 10px 10px;
    box-shadow: none;
    z-index: 10000;
  }

  .ss-dropdown-inner {
    max-height: 100%;
    overflow-y: auto;
  }

  /* Single column for categories/brands on mobile */
  .ss-columns {
    flex-direction: column;
  }

  .ss-col + .ss-col {
    border-left: none;
    border-top: 1px solid #eee;
  }

  .ss-chip {
    font-size: 14px;
    padding: 6px 14px;
  }

  .ss-item {
    padding: 10px 16px;
  }

  .ss-item-name {
    font-size: 14px;
  }

  .ss-col .ss-item {
    padding: 8px 14px;
  }
}

/* Dark theme (mobile only) */
@media (max-width: 768px) and (prefers-color-scheme: dark) {
  .ss-dropdown {
    background: #1D1B26;
  }

  .ss-chips {
    border-bottom-color: #333;
  }

  .ss-chip {
    background: #2a2838;
    color: #ddd;
  }

  .ss-chip:hover,
  .ss-chip.ss-item-active {
    background: #3a3848;
  }

  .ss-item:hover,
  .ss-item-active {
    background: #2a2838;
  }

  .ss-icon-search {
    color: #666;
  }

  .ss-item-term span {
    color: #ddd;
  }

  .ss-item-term span b {
    color: #ddd;
  }

  .ss-columns {
    border-top-color: #333;
  }

  .ss-col + .ss-col {
    border-left-color: #333;
  }

  .ss-col-label {
    color: #777;
  }

  .ss-icon-inline {
    color: #555;
  }

  .ss-item-name {
    color: #ddd;
  }

  .ss-item-sub {
    color: #777;
  }
}

/* ===== Image Search ===== */

/* Hide original favorite label */
.is-action-bar ~ input[name="favorite"] + label,
input[name="favorite"] + label.is-hidden {
  display: none !important;
}

/* Product page action buttons */
.is-action-bar {
  display: flex;
  gap: 8px;
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 5;
}

.is-action-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #666;
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .12);
  transition: all .2s;
}

.is-action-btn:hover {
  color: #282828;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
}

.is-action-btn svg {
  width: 20px;
  height: 20px;
}

.is-action-btn.is-loading {
  pointer-events: none;
}

/* Spinners */
.is-spinner-sm {
  display: block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(0, 0, 0, .1);
  border-radius: 50%;
  border-top-color: #282828;
  animation: isSpin .7s linear infinite;
}

.is-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(0, 0, 0, .1);
  border-radius: 50%;
  border-top-color: #282828;
  animation: isSpin .7s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}

.is-spinner-lg {
  display: block;
  width: 36px;
  height: 36px;
  border: 3px solid rgba(0, 0, 0, .08);
  border-radius: 50%;
  border-top-color: #febd01;
  animation: isSpin .7s linear infinite;
}

@keyframes isSpin {
  to { transform: rotate(360deg); }
}

/* Search input wrapper (desktop) */
header .sAll .is-input-wrap {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  min-width: 0;
  background: #fff;
  border-radius: 8px 0 0 8px;
  overflow: visible;
}

header .sAll .is-input-wrap input[type="search"] {
  background: transparent !important;
  border-radius: 0 !important;
  border: none !important;
  outline: none !important;
  flex: 1;
  min-width: 0;
  width: 100%;
}

/* Camera button */
.is-cam-btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  padding: 0 !important;
  margin: 0 !important;
  background: none !important;
  border: none !important;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #555;
  transition: color .15s;
  z-index: 2;
  font-size: 0 !important;
  line-height: 0 !important;
}

.is-cam-btn:hover {
  color: #333;
}

.is-cam-btn svg {
  width: 18px;
  height: 18px;
  display: block;
}

/* Image chip in search bar */
.is-chip {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 10px;
  flex-shrink: 0;
  height: 28px;
}

.is-chip img {
  width: 26px;
  height: 26px;
  object-fit: cover;
  border-radius: 4px;
  display: block;
}

.is-chip-x {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  color: #999;
  cursor: pointer;
  transition: color .15s, background .15s;
  flex-shrink: 0;
}

.is-chip-x:hover {
  color: #282828;
  background: rgba(0, 0, 0, .06);
}

/* Modal */
.is-modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, .5);
  z-index: 10000;
  justify-content: center;
  align-items: center;
}

.is-modal-overlay.active {
  display: flex;
}

.is-modal {
  background: #fff;
  border-radius: 12px;
  position: relative;
  max-width: 400px;
  width: 92%;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .25);
  animation: isSlideIn .2s ease-out;
}

@keyframes isSlideIn {
  from { opacity: 0; transform: translateY(-16px); }
  to { opacity: 1; transform: translateY(0); }
}

.is-modal-header {
  padding: 20px 20px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.is-modal-header h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  color: #282828;
}

.is-modal-close {
  position: absolute;
  top: -18px;
  right: -18px;
  width: 44px;
  height: 44px;
  background: #fff;
  border: none;
  border-radius: 50%;
  font-size: 24px;
  cursor: pointer;
  color: #666;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .15);
  transition: all .15s;
  z-index: 1;
}

.is-modal-close:hover {
  background: #f0f0f0;
  color: #333;
}

.is-modal-body {
  padding: 16px 20px 20px;
}

.is-upload-area {
  border: 2px dashed #ddd;
  border-radius: 10px;
  padding: 32px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
}

.is-upload-area:hover,
.is-upload-area.dragover {
  border-color: #febd01;
  background: #fffcf0;
}

.is-upload-area.is-loading {
  border-style: solid;
  border-color: #eee;
  cursor: default;
  background: #fafafa;
}

.is-upload-area.is-loading:hover {
  border-color: #eee;
  background: #fafafa;
}

.is-upload-area p {
  margin: 0;
  color: #282828;
  font-size: 14px;
  font-weight: 500;
}

.is-upload-area span {
  color: #999;
  font-size: 12px;
}

.is-btn-select {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid #eee;
  background: #fff;
  color: #282828;
  transition: border-color .15s, background .15s;
}

.is-btn-select:hover:not(:disabled) {
  border-color: #febd01;
  background: #fffcf0;
}

.is-btn-select:disabled {
  opacity: .5;
  cursor: default;
}

/* Toast */
.is-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: #282828;
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 10001;
  opacity: 0;
  transition: all .25s;
  max-width: 90%;
  text-align: center;
}

.is-toast-error {
  background: #d32f2f;
}

.is-toast-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
