/* ================================================================
   RIZA Visual Search — Premium AI Image Search Dialog
   RTL-first · matches RIZA design system (black / gold / beige)
   ================================================================ */

/* ── Header trigger button ── */
.hdr-btn.js-vsearch-trigger {
  position: relative;
}
.vsearch-ai-badge {
  position: absolute;
  top: -5px;
  left: -5px;
  background: linear-gradient(135deg, #c9a96e 0%, #e8c98a 100%);
  color: #111;
  font-size: 7px;
  font-weight: 900;
  font-family: 'Tajawal', sans-serif;
  padding: 2px 4px;
  border-radius: 5px;
  line-height: 1;
  letter-spacing: .2px;
  pointer-events: none;
}

/* ── Overlay ── */
.vsearch-overlay {
  position: fixed;
  inset: 0;
  z-index: 99998;
  background: rgba(0, 0, 0, .72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity .35s ease, visibility .35s ease;
}
.vsearch-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

/* ── Dialog ── */
.vsearch-dialog {
  background: #fff;
  border-radius: 28px;
  width: 100%;
  max-width: 800px;
  max-height: 88vh;
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow:
    0 40px 100px rgba(0, 0, 0, .45),
    0 0 0 1px rgba(255, 255, 255, .08);
  transform: translateY(50px) scale(.95);
  transition: transform .45s cubic-bezier(.34, 1.56, .64, 1);
  scrollbar-width: thin;
  scrollbar-color: #e0d5c5 transparent;
}
.vsearch-dialog::-webkit-scrollbar { width: 4px; }
.vsearch-dialog::-webkit-scrollbar-track { background: transparent; }
.vsearch-dialog::-webkit-scrollbar-thumb { background: #e0d5c5; border-radius: 4px; }
.vsearch-overlay.is-open .vsearch-dialog {
  transform: translateY(0) scale(1);
}

/* ── Header ── */
.vsearch-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 32px 24px;
  background: linear-gradient(135deg, #0d0d0d 0%, #1c1c1c 50%, #141414 100%);
  border-radius: 28px 28px 0 0;
  position: relative;
  overflow: hidden;
  gap: 16px;
}
.vsearch-head::before {
  content: '';
  position: absolute;
  width: 260px;
  height: 260px;
  background: radial-gradient(circle, rgba(201, 169, 110, .22) 0%, transparent 70%);
  top: -80px;
  left: -60px;
  pointer-events: none;
}
.vsearch-head::after {
  content: '';
  position: absolute;
  width: 150px;
  height: 150px;
  background: radial-gradient(circle, rgba(201, 169, 110, .1) 0%, transparent 70%);
  bottom: -40px;
  right: 40px;
  pointer-events: none;
}
.vsearch-head-info {
  display: flex;
  align-items: center;
  gap: 18px;
  position: relative;
  z-index: 1;
}
.vsearch-head-icon {
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, #c9a96e 0%, #e8c98a 100%);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: #111;
  flex-shrink: 0;
  box-shadow: 0 6px 20px rgba(201, 169, 110, .45);
}
.vsearch-head-text h2 {
  font-family: 'Tajawal', sans-serif;
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  margin: 0 0 4px;
  line-height: 1.2;
}
.vsearch-head-text p {
  font-family: 'Tajawal', sans-serif;
  font-size: 13px;
  color: rgba(255, 255, 255, .5);
  margin: 0;
}
.vsearch-close {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .14);
  color: rgba(255, 255, 255, .75);
  font-size: 16px;
  cursor: pointer;
  transition: all .2s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}
.vsearch-close:hover {
  background: rgba(255, 255, 255, .18);
  color: #fff;
  transform: scale(1.08);
}

/* ── Upload area ── */
.vsearch-upload-wrap {
  padding: 40px 40px 36px;
  border-bottom: 1px solid #f0ebe2;
}
.vsearch-dropzone {
  border: 2px dashed #d8cfc2;
  border-radius: 20px;
  padding: 48px 32px 40px;
  text-align: center;
  transition: all .25s;
  cursor: pointer;
  background: #faf8f5;
  position: relative;
}
.vsearch-dropzone.drag-over {
  border-color: #c9a96e;
  background: rgba(201, 169, 110, .06);
}
.vsearch-dropzone.drag-over .vsearch-drop-icon {
  transform: scale(1.12);
}
.vsearch-file-input { display: none; }

/* spinning ring + camera icon */
.vsearch-drop-icon {
  position: relative;
  width: 110px;
  height: 110px;
  margin: 0 auto 28px;
  transition: transform .35s cubic-bezier(.34, 1.56, .64, 1);
}
.vsearch-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px dashed #c9a96e;
  opacity: .7;
  animation: vsearch-spin 9s linear infinite;
}
@keyframes vsearch-spin { to { transform: rotate(360deg); } }
.vsearch-ring-2 {
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  border: 1px dashed rgba(201, 169, 110, .35);
  animation: vsearch-spin 6s linear infinite reverse;
}
.vsearch-drop-inner {
  position: absolute;
  inset: 16px;
  background: linear-gradient(145deg, #f5f0e8, #ede6d8);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: #c9a96e;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .08);
}
.vsearch-drop-title {
  font-family: 'Tajawal', sans-serif;
  font-size: 19px;
  font-weight: 700;
  color: #111;
  margin: 0 0 8px;
}
.vsearch-drop-sub {
  font-family: 'Tajawal', sans-serif;
  font-size: 14px;
  color: #888;
  margin: 0 0 28px;
}
.vsearch-drop-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.vsearch-btn {
  font-family: 'Tajawal', sans-serif;
  font-size: 14px;
  font-weight: 700;
  padding: 12px 24px;
  border-radius: 12px;
  cursor: pointer;
  transition: all .22s;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  line-height: 1;
}
.vsearch-btn-dark {
  background: #111;
  color: #fff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .2);
}
.vsearch-btn-dark:hover {
  background: #2a2a2a;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
}
.vsearch-btn-outline {
  background: transparent;
  color: #444;
  border: 1.5px solid #ddd;
}
.vsearch-btn-outline:hover {
  border-color: #c9a96e;
  color: #c9a96e;
  background: rgba(201, 169, 110, .06);
}
.vsearch-drop-hint {
  font-family: 'Tajawal', sans-serif;
  font-size: 12px;
  color: #bbb;
  margin: 0;
}

/* ── Preview ── */
.vsearch-preview-wrap {
  padding: 28px 40px;
  border-bottom: 1px solid #f0ebe2;
  display: none;
}
.vsearch-preview-inner {
  position: relative;
  display: inline-block;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .15);
  max-width: 100%;
}
#vsearch-preview-img {
  display: block;
  max-width: 100%;
  max-height: 300px;
  width: auto;
  height: auto;
  border-radius: 18px;
}
.vsearch-retake-btn {
  position: absolute;
  bottom: 14px;
  left: 14px;
  background: rgba(0, 0, 0, .75);
  backdrop-filter: blur(6px);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 9px 16px;
  font-family: 'Tajawal', sans-serif;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  transition: background .2s;
}
.vsearch-retake-btn:hover { background: rgba(0, 0, 0, .9); }

/* ── Analyzing ── */
.vsearch-analyzing-wrap {
  padding: 44px 40px;
  text-align: center;
  border-bottom: 1px solid #f0ebe2;
  display: none;
}
.vsearch-scan-anim {
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
  position: relative;
}
.vsearch-scan-anim::before,
.vsearch-scan-anim::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid #c9a96e;
  animation: vsearch-pulse 1.8s ease-out infinite;
}
.vsearch-scan-anim::after { animation-delay: .6s; }
@keyframes vsearch-pulse {
  0%   { transform: scale(.5); opacity: 1; }
  100% { transform: scale(1.6); opacity: 0; }
}
.vsearch-scan-icon {
  position: absolute;
  inset: 18px;
  background: linear-gradient(135deg, #c9a96e, #e8c98a);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #111;
  font-size: 18px;
}
.vsearch-analyzing-title {
  font-family: 'Tajawal', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: #111;
  margin: 0 0 6px;
}
.vsearch-analyzing-sub {
  font-family: 'Tajawal', sans-serif;
  font-size: 13px;
  color: #999;
  margin: 0;
}
.vsearch-dots {
  display: inline-flex;
  gap: 5px;
  vertical-align: middle;
  margin-right: 2px;
}
.vsearch-dots span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #c9a96e;
  animation: vsearch-blink 1.2s ease-in-out infinite;
}
.vsearch-dots span:nth-child(2) { animation-delay: .2s; }
.vsearch-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes vsearch-blink {
  0%, 80%, 100% { opacity: .2; transform: scale(.7); }
  40%           { opacity: 1;  transform: scale(1);   }
}

/* ── Detected items chips ── */
.vsearch-items-wrap {
  padding: 22px 40px 18px;
  border-bottom: 1px solid #f0ebe2;
  display: none;
}
.vsearch-items-label {
  font-family: 'Tajawal', sans-serif;
  font-size: 12px;
  font-weight: 700;
  color: #aaa;
  letter-spacing: .8px;
  text-transform: uppercase;
  margin: 0 0 14px;
}
.vsearch-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.vsearch-chip {
  font-family: 'Tajawal', sans-serif;
  font-size: 14px;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: 50px;
  border: 1.5px solid #e0d8cf;
  background: #faf8f5;
  color: #555;
  cursor: pointer;
  transition: all .22s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  line-height: 1;
}
.vsearch-chip i { font-size: 12px; color: #bbb; transition: color .22s; }
.vsearch-chip:hover {
  border-color: #c9a96e;
  color: #9a7840;
  background: rgba(201, 169, 110, .08);
}
.vsearch-chip:hover i { color: #c9a96e; }
.vsearch-chip.is-active {
  background: #111;
  border-color: #111;
  color: #fff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .2);
}
.vsearch-chip.is-active i { color: #c9a96e; }
.vsearch-chip .vsearch-chip-star {
  font-size: 10px;
  background: #c9a96e;
  color: #111;
  border-radius: 4px;
  padding: 1px 5px;
  font-weight: 800;
  letter-spacing: .2px;
}

/* ── Results ── */
.vsearch-results-wrap {
  padding: 24px 40px 40px;
  display: none;
}
.vsearch-results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
}
.vsearch-results-title {
  font-family: 'Tajawal', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: #111;
  margin: 0;
}
.vsearch-view-all {
  font-family: 'Tajawal', sans-serif;
  font-size: 13px;
  color: #c9a96e;
  text-decoration: none;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  transition: opacity .2s;
}
.vsearch-view-all:hover { opacity: .7; }

/* Products grid */
.vsearch-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.vsearch-product-card {
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid #f0ebe2;
  background: #fff;
  text-decoration: none;
  display: block;
  transition: all .28s;
  position: relative;
}
.vsearch-product-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .12);
  border-color: #e4d6bf;
}
.vsearch-product-img {
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #f5f0e8;
  position: relative;
}
.vsearch-product-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .45s ease;
}
.vsearch-product-card:hover .vsearch-product-img img {
  transform: scale(1.08);
}
.vsearch-sale-tag {
  position: absolute;
  top: 10px;
  right: 10px;
  background: #e53935;
  color: #fff;
  font-family: 'Tajawal', sans-serif;
  font-size: 10px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 6px;
  line-height: 1.4;
}
.vsearch-out-tag {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .35);
  display: flex;
  align-items: center;
  justify-content: center;
}
.vsearch-out-tag span {
  background: rgba(0, 0, 0, .8);
  color: #fff;
  font-family: 'Tajawal', sans-serif;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 8px;
}
.vsearch-product-body {
  padding: 13px 14px 14px;
}
.vsearch-product-name {
  font-family: 'Tajawal', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: #222;
  margin: 0 0 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.vsearch-product-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.vsearch-product-price {
  font-family: 'Tajawal', sans-serif;
  font-size: 14px;
  font-weight: 800;
  color: #111;
  line-height: 1;
}
.vsearch-product-price ins {
  text-decoration: none;
  color: #e53935;
}
.vsearch-product-price del {
  font-size: 11px;
  color: #bbb;
  font-weight: 400;
  display: block;
  margin-bottom: 1px;
}
.vsearch-cart-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #111;
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  transition: all .22s;
}
.vsearch-cart-btn:hover {
  background: #c9a96e;
  transform: scale(1.12);
}
.vsearch-cart-btn.added {
  background: #22c55e;
  animation: vsearch-pop .3s ease;
}
@keyframes vsearch-pop {
  0%   { transform: scale(1.3); }
  100% { transform: scale(1);   }
}

/* Grid loading skeleton */
.vsearch-skeleton-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.vsearch-skeleton-card {
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid #f0ebe2;
}
.vsearch-skeleton-img {
  aspect-ratio: 4 / 3;
  background: linear-gradient(90deg, #f0ebe2 25%, #e8e0d4 50%, #f0ebe2 75%);
  background-size: 200% 100%;
  animation: vsearch-shimmer 1.4s ease-in-out infinite;
}
.vsearch-skeleton-body {
  padding: 13px 14px;
}
.vsearch-skeleton-line {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, #f0ebe2 25%, #e8e0d4 50%, #f0ebe2 75%);
  background-size: 200% 100%;
  animation: vsearch-shimmer 1.4s ease-in-out infinite;
  margin-bottom: 8px;
}
.vsearch-skeleton-line.short { width: 55%; }
@keyframes vsearch-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* No results */
.vsearch-empty {
  text-align: center;
  padding: 48px 20px;
  display: none;
}
.vsearch-empty-icon {
  width: 70px;
  height: 70px;
  background: #f5f0e8;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: #c9a96e;
  margin: 0 auto 18px;
}
.vsearch-empty h4 {
  font-family: 'Tajawal', sans-serif;
  font-size: 17px;
  font-weight: 700;
  color: #222;
  margin: 0 0 8px;
}
.vsearch-empty p {
  font-family: 'Tajawal', sans-serif;
  font-size: 14px;
  color: #999;
  margin: 0;
}

/* ── Camera button inside header search field ── */
.hsearch-field-wrap {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
}
.hsearch-field {
  padding-left: 82px !important;
  width: 100%;
  box-sizing: border-box;
}
.hsearch-cam-btn {
  position: absolute;
  left: 7px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: linear-gradient(135deg, #0d0d0d 0%, #222 100%);
  border: 1px solid rgba(201, 169, 110, .25);
  border-radius: 10px;
  padding: 5px 10px 5px 8px;
  cursor: pointer;
  color: #fff;
  font-size: 13px;
  line-height: 1;
  white-space: nowrap;
  z-index: 2;
  transition: all .22s cubic-bezier(.34, 1.56, .64, 1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
}
.hsearch-cam-btn:hover {
  background: linear-gradient(135deg, #c9a96e 0%, #e8c98a 100%);
  border-color: transparent;
  color: #111;
  transform: translateY(-50%) scale(1.06);
  box-shadow: 0 6px 18px rgba(201, 169, 110, .4);
}
.hsearch-cam-btn:hover .hsearch-cam-ai {
  background: #111;
  color: #c9a96e;
}
.hsearch-cam-btn:active { transform: translateY(-50%) scale(.97); }
.hsearch-cam-ai {
  font-family: 'Tajawal', sans-serif;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: .4px;
  background: linear-gradient(135deg, #c9a96e, #e8c98a);
  color: #111;
  padding: 2px 5px;
  border-radius: 4px;
  line-height: 1.1;
  display: inline-block;
  transition: all .2s;
}

/* ── Bounding box overlay ── */
.vsearch-bbox-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 18px;
  z-index: 10;
}
.vsearch-bbox {
  position: absolute;
  border: 2px solid rgba(201, 169, 110, .75);
  border-radius: 8px;
  background: rgba(201, 169, 110, .07);
  cursor: pointer;
  pointer-events: all;
  transition: border-color .2s, background .2s, box-shadow .2s;
  animation: vsearch-bbox-in .35s cubic-bezier(.34, 1.56, .64, 1) both;
}
@keyframes vsearch-bbox-in {
  from { opacity: 0; transform: scale(.88); }
  to   { opacity: 1; transform: scale(1); }
}
.vsearch-bbox:hover {
  border-color: #c9a96e;
  background: rgba(201, 169, 110, .16);
  box-shadow: 0 0 0 3px rgba(201, 169, 110, .25), inset 0 0 24px rgba(201, 169, 110, .08);
}
.vsearch-bbox.is-active {
  border-color: #c9a96e;
  border-width: 2.5px;
  background: rgba(201, 169, 110, .14);
  box-shadow: 0 0 0 3px rgba(201, 169, 110, .35), 0 6px 28px rgba(201, 169, 110, .28);
}
.vsearch-bbox-lbl {
  position: absolute;
  bottom: 0;
  right: 0;
  background: linear-gradient(135deg, #0d0d0d 0%, #1c1c1c 100%);
  color: #c9a96e;
  font-family: 'Tajawal', sans-serif;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 9px 4px 7px;
  border-radius: 6px 0 6px 0;
  line-height: 1.3;
  white-space: nowrap;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0;
  transform: translateY(3px);
  transition: opacity .18s, transform .18s;
}
.vsearch-bbox:hover .vsearch-bbox-lbl,
.vsearch-bbox.is-active .vsearch-bbox-lbl {
  opacity: 1;
  transform: translateY(0);
}

/* ── Responsive ── */
@media (max-width: 650px) {
  .vsearch-overlay { padding: 0; align-items: flex-end; }
  .vsearch-dialog {
    border-radius: 24px 24px 0 0;
    max-height: 92vh;
  }
  .vsearch-head { border-radius: 24px 24px 0 0; padding: 22px 20px 18px; }
  .vsearch-upload-wrap,
  .vsearch-preview-wrap,
  .vsearch-analyzing-wrap,
  .vsearch-items-wrap,
  .vsearch-results-wrap { padding-right: 20px; padding-left: 20px; }
  .vsearch-dropzone { padding: 36px 20px 28px; }
  .vsearch-drop-actions { flex-direction: column; align-items: center; }
  .vsearch-btn { width: 100%; max-width: 240px; justify-content: center; }
  .vsearch-grid,
  .vsearch-skeleton-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
}
@media (max-width: 360px) {
  .vsearch-grid,
  .vsearch-skeleton-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .hsearch-field { padding-left: 52px !important; }
  .hsearch-cam-ai { display: none; }
  .hsearch-cam-btn { padding: 5px 9px; gap: 0; }
}
