#ci-visual-search-button {
  position: fixed;
  z-index: 2147483000;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 9px 14px;
  border: 1px solid color-mix(in srgb, var(--color-primary, #f97316) 86%, #000 14%);
  border-radius: 999px;
  background: var(--color-primary, #f97316);
  color: #fff;
  font: 700 14px/1.2 inherit;
  cursor: pointer;
  box-shadow: 0 7px 20px rgb(0 0 0 / 16%);
  transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
}

#ci-visual-search-button:hover {
  filter: brightness(.96);
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgb(0 0 0 / 20%);
}

#ci-visual-search-button svg { width: 19px; height: 19px; }

#ci-visual-search-button.ci-floating {
  top: 38px;
  right: auto;
  bottom: auto;
  left: calc(18.5vw + 26px);
  width: 38px;
  min-height: 38px;
  padding: 8px;
  border-radius: 50%;
}

#ci-visual-search-button.ci-floating .ci-label,
#ci-visual-search-button.ci-search-attached .ci-label { display: none; }

#ci-visual-search-button.ci-search-attached {
  right: auto;
  bottom: auto;
  width: 36px;
  min-height: 36px;
  padding: 7px;
  border-radius: 50%;
}

#ci-visual-search-overlay {
  position: fixed;
  inset: 0;
  z-index: 2147483001;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgb(17 24 39 / 58%);
  backdrop-filter: blur(5px);
  direction: rtl;
}

#ci-visual-search-overlay.ci-open { display: flex; }

#ci-visual-search-dialog {
  width: min(900px, 100%);
  max-height: min(780px, 92vh);
  overflow: auto;
  border: 1px solid rgb(229 231 235 / 90%);
  border-radius: 22px;
  background: #fff;
  color: #172033;
  box-shadow: 0 28px 80px rgb(0 0 0 / 28%);
  font: 400 15px/1.65 inherit;
}

.ci-vs-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid #edf0f4;
  background: rgb(255 255 255 / 96%);
  backdrop-filter: blur(8px);
}

.ci-vs-header h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 800;
  color: #172033;
}

.ci-vs-close {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: #f3f5f7;
  color: #263142;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  transition: background .18s ease, transform .18s ease;
}

.ci-vs-close:hover { background: #e8ebef; transform: rotate(4deg); }
.ci-vs-body { padding: 22px; }

.ci-vs-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid color-mix(in srgb, var(--color-primary, #f97316) 18%, #fff 82%);
  border-radius: 16px;
  background: color-mix(in srgb, var(--color-primary, #f97316) 7%, #fff 93%);
}

.ci-vs-hero-icon {
  display: grid;
  place-items: center;
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: var(--color-primary, #f97316);
  color: #fff;
  box-shadow: 0 8px 20px color-mix(in srgb, var(--color-primary, #f97316) 28%, transparent 72%);
}

.ci-vs-hero-icon svg { width: 23px; height: 23px; }
.ci-vs-hero strong { display: block; margin-bottom: 2px; font-size: 16px; }
.ci-vs-hero span { display: block; color: #667085; font-size: 13px; }

.ci-vs-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.ci-vs-action {
  min-height: 48px;
  padding: 11px 16px;
  border: 1px solid var(--color-primary, #f97316);
  border-radius: 12px;
  background: var(--color-primary, #f97316);
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.2;
  cursor: pointer;
  transition: transform .18s ease, filter .18s ease, opacity .18s ease;
}

.ci-vs-action.ci-camera {
  background: #fff;
  color: var(--color-primary, #f97316);
}

.ci-vs-action:hover:not(:disabled) { filter: brightness(.97); transform: translateY(-1px); }
.ci-vs-action:disabled { cursor: wait; opacity: .48; }
.ci-vs-note { margin: 11px 2px 0; color: #7a8493; font-size: 12px; text-align: center; }

.ci-vs-loader {
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  min-height: 150px;
  margin-top: 18px;
  padding: 20px;
  border-radius: 16px;
  background: #f8fafc;
  color: #465165;
  text-align: center;
}

.ci-vs-loader.ci-visible { display: flex; }
.ci-vs-loader strong { font-size: 14px; font-weight: 700; }

.ci-vs-spinner {
  width: 42px;
  height: 42px;
  border: 4px solid #e8edf2;
  border-top-color: var(--color-primary, #f97316);
  border-radius: 50%;
  animation: ci-vs-spin .8s linear infinite;
}

@keyframes ci-vs-spin { to { transform: rotate(360deg); } }

.ci-vs-status {
  display: none;
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid #edf0f4;
  border-radius: 12px;
  background: #f8fafc;
  color: #526071;
  font-size: 13px;
  text-align: center;
}

.ci-vs-status.ci-visible { display: block; }

.ci-vs-query {
  display: none;
  align-items: center;
  gap: 13px;
  margin-top: 18px;
  padding: 12px;
  border: 1px solid #edf0f4;
  border-radius: 14px;
  background: #fbfcfd;
}

.ci-vs-query img {
  width: 82px;
  height: 82px;
  border: 1px solid #e5e9ee;
  border-radius: 12px;
  object-fit: cover;
  background: #fff;
}

.ci-vs-query strong { display: block; }
.ci-vs-query span { color: #7a8493; font-size: 13px; }

.ci-vs-results {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.ci-vs-product {
  display: block;
  min-width: 0;
  padding: 10px;
  border: 1px solid #edf0f4;
  border-radius: 15px;
  background: #fff;
  color: #172033;
  text-decoration: none;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.ci-vs-product:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--color-primary, #f97316) 35%, #e5e7eb 65%);
  box-shadow: 0 12px 26px rgb(0 0 0 / 9%);
}

.ci-vs-product img {
  width: 100%;
  aspect-ratio: 1;
  border: 0;
  border-radius: 11px;
  object-fit: contain;
  background: #f8fafc;
}

.ci-vs-product strong {
  display: -webkit-box;
  margin-top: 9px;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 13px;
  line-height: 1.5;
}

.ci-vs-product small { display: block; margin-top: 4px; color: var(--color-primary, #f97316); font-size: 11px; }

@media (max-width: 700px) {
  #ci-visual-search-overlay { align-items: flex-end; padding: 0; }
  #ci-visual-search-dialog {
    width: 100%;
    max-height: 92dvh;
    border-radius: 22px 22px 0 0;
  }
  .ci-vs-header { padding: 15px 17px; }
  .ci-vs-body { padding: 17px; }
  .ci-vs-hero { padding: 13px; }
  .ci-vs-actions { grid-template-columns: 1fr; }
  .ci-vs-results { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  #ci-visual-search-button.ci-floating {
    top: 53px;
    right: 58px;
    bottom: auto;
    left: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  #ci-visual-search-button,
  .ci-vs-action,
  .ci-vs-product,
  .ci-vs-close { transition: none; }
  .ci-vs-spinner { animation-duration: 1.4s; }
}

.ci-vs-retry {
  display: block;
  margin: 12px auto 0;
  border: 1px solid rgba(0,0,0,.12);
  border-radius: 10px;
  background: #fff;
  color: inherit;
  padding: 10px 16px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.ci-vs-retry[hidden] { display: none !important; }

/* تحسينات النسخة السريعة */
.ci-vs-dropzone,
.ci-vs-upload-hint,
.ci-vs-file-label,
.ci-vs-upload-area,
.ci-vs-selected-file { display: none !important; }

.ci-vs-hero-icon {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
}
.ci-vs-hero-icon svg {
  display: block !important;
  width: 24px !important;
  height: 24px !important;
  margin: 0 !important;
}
.ci-vs-action {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center !important;
}
.ci-vs-empty {
  grid-column: 1 / -1;
  margin: 12px 0 0;
  padding: 18px;
  border-radius: 14px;
  background: #f8fafc;
  color: #64748b;
  text-align: center;
}