/* ==========================================================================
   GawangPinas Buyer Marketplace — Google Cloud Vision Visual Search
   Styles for Modal, Camera Stream, Dropzone, Product Results & Dark Theme
   ========================================================================== */

/* Header Search Trigger Button */
.search-vision-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 6px 10px;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.search-vision-btn:hover {
  color: var(--primary);
  background: var(--primary-soft);
  transform: scale(1.08);
}

.search-vision-btn .material-symbols-outlined {
  font-size: 21px;
}

/* Modal Backdrop */
.vsearch-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 2500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.vsearch-modal-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

/* Modal Container */
.vsearch-modal {
  background: var(--bg-card);
  border-radius: var(--gp-radius-modal, 16px);
  width: min(780px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--gp-shadow-modal, 0 20px 40px -12px rgba(15, 23, 42, 0.18));
  border: 1px solid var(--line);
  transform: scale(0.96) translateY(12px);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.vsearch-modal-backdrop.is-open .vsearch-modal {
  transform: scale(1) translateY(0);
}

/* Header */
.vsearch-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--line-soft);
  flex-shrink: 0;
}

.vsearch-header__title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.vsearch-header__icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.vsearch-header h3 {
  font-size: 17px;
  font-weight: 800;
  color: var(--navy);
  margin: 0 0 2px;
  line-height: 1.2;
}

.vsearch-ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 700;
  color: #0d9488;
  background: rgba(13, 148, 136, 0.1);
  padding: 2px 8px;
  border-radius: 9999px;
}

.vsearch-ai-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #0d9488;
  animation: vsearch-pulse 1.8s infinite ease-in-out;
}

@keyframes vsearch-pulse {
  0%, 100% { transform: scale(0.85); opacity: 0.6; }
  50% { transform: scale(1.3); opacity: 1; }
}

.vsearch-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  transition: all 0.2s ease;
}

.vsearch-close:hover {
  background: var(--bg-soft);
  color: var(--navy);
}

/* Modal Body */
.vsearch-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

/* Step 1: Input View */
.vsearch-intro__text {
  font-size: 14px;
  color: var(--body);
  margin-bottom: 18px;
  line-height: 1.55;
}

.vsearch-dropzone {
  border: 2px dashed var(--line);
  border-radius: 16px;
  padding: 36px 20px;
  text-align: center;
  background: var(--bg-soft);
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
}

.vsearch-dropzone:hover,
.vsearch-dropzone.is-dragover,
.vsearch-dropzone:focus-visible {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.vsearch-dropzone__icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--bg-card);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  transition: transform 0.2s ease;
}

.vsearch-dropzone:hover .vsearch-dropzone__icon {
  transform: translateY(-3px);
}

.vsearch-dropzone__heading {
  font-size: 16px;
  font-weight: 700;
  color: var(--navy);
  margin: 0 0 4px;
}

.vsearch-dropzone__sub {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 18px;
}

.vsearch-input-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Camera Stream Panel */
.vsearch-camera-panel {
  background: #0f172a;
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 18px;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15);
}

.vsearch-camera-view {
  position: relative;
  width: 100%;
  max-width: 480px;
  aspect-ratio: 4/3;
  margin: 0 auto;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
}

.vsearch-camera-view video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.vsearch-camera-target-box {
  position: absolute;
  inset: 15%;
  border: 2px dashed rgba(255, 255, 255, 0.7);
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.vsearch-camera-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
}

/* Samples Chips */
.vsearch-samples {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
}

.vsearch-samples__title {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}

.vsearch-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.vsearch-chip {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  padding: 6px 14px;
  border-radius: 9999px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--body);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.vsearch-chip:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary-dark);
  transform: translateY(-1px);
}

/* Step 2: Image Preview & Processing */
.vsearch-preview-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 18px;
  padding: 20px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 16px;
  margin-bottom: 18px;
}

.vsearch-preview-media {
  width: 180px;
  height: 180px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
  background: var(--bg-card);
  border: 2px solid var(--bg-card);
}

.vsearch-preview-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.vsearch-preview-status {
  max-width: 400px;
}

.vsearch-spinner {
  width: 42px;
  height: 42px;
  margin: 0 auto 12px;
  color: var(--primary);
  animation: vsearch-spin 1s linear infinite;
}

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

.vsearch-preview-status h4 {
  font-size: 16px;
  font-weight: 700;
  color: var(--navy);
  margin: 0 0 4px;
}

.vsearch-preview-status p {
  font-size: 13.5px;
  color: var(--muted);
  margin: 0;
}

.vsearch-preview-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

/* Step 3: Results View */
.vsearch-results-summary {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 16px;
}

.vsearch-summary-thumb {
  width: 52px;
  height: 52px;
  min-width: 52px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--bg-card);
}

.vsearch-summary-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.vsearch-summary-info {
  flex: 1;
  min-width: 0;
}

.vsearch-summary-headline {
  display: flex;
  align-items: center;
  gap: 8px;
}

.vsearch-summary-headline h4 {
  font-size: 15px;
  font-weight: 800;
  color: var(--navy);
  margin: 0;
}

.vsearch-time-badge {
  font-size: 11px;
  font-weight: 700;
  color: #0d9488;
  background: rgba(13, 148, 136, 0.12);
  padding: 2px 6px;
  border-radius: 4px;
}

.vsearch-summary-labels {
  font-size: 12.5px;
  color: var(--muted);
  margin: 2px 0 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Multi-Product Object Filters */
.vsearch-detected-objects {
  margin-bottom: 14px;
}

.vsearch-objects-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.vsearch-object-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.vsearch-obj-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1.5px solid var(--line);
  padding: 5px 12px;
  border-radius: 9999px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--body);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.vsearch-obj-pill:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.vsearch-obj-pill.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.vsearch-obj-pill__score {
  font-size: 10.5px;
  opacity: 0.85;
}

/* Toolbar & Sorting */
.vsearch-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.vsearch-sort {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.vsearch-select {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-card);
  font-size: 13px;
  font-family: inherit;
  color: var(--navy);
  outline: none;
  cursor: pointer;
}

.vsearch-select:focus {
  border-color: var(--primary);
}

.vsearch-cat-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.vsearch-cat-chip {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--body);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.vsearch-cat-chip.is-active,
.vsearch-cat-chip:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary-dark);
}

/* Results Product Grid */
.vsearch-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

@media(max-width: 640px) {
  .vsearch-grid {
    grid-template-columns: 1fr;
  }
}

.vsearch-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--gp-radius-card, 12px);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
  transition: all 0.2s ease;
}

.vsearch-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.1);
}

.vsearch-card__media {
  position: relative;
  width: 100%;
  height: 160px;
  background: var(--bg-soft);
  overflow: hidden;
}

.vsearch-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.vsearch-card:hover .vsearch-card__media img {
  transform: scale(1.04);
}

.vsearch-match-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 9999px;
  font-size: 11.5px;
  font-weight: 800;
  color: #ffffff;
  backdrop-filter: blur(4px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.vsearch-match-badge--high {
  background: linear-gradient(135deg, #059669, #10b981);
}

.vsearch-match-badge--medium {
  background: linear-gradient(135deg, #0284c7, #38bdf8);
}

.vsearch-match-badge--low {
  background: linear-gradient(135deg, #d97706, #f59e0b);
}

.vsearch-card__body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.vsearch-card__cat {
  font-size: 11.5px;
  font-weight: 700;
  color: #0d9488;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.vsearch-card__title {
  font-size: 15px;
  font-weight: 800;
  color: var(--navy);
  line-height: 1.25;
  margin: 0 0 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.vsearch-card__supplier {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 10px;
}

.vsearch-card__supplier svg {
  color: #10b981;
  flex-shrink: 0;
}

.vsearch-card__features {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 12px;
}

.vsearch-tag {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  font-size: 11px;
  font-weight: 600;
  color: var(--slate);
  padding: 2px 6px;
  border-radius: 4px;
}

.vsearch-card__footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.vsearch-card__price-box {
  min-width: 0;
}

.vsearch-card__price {
  font-size: 16px;
  font-weight: 800;
  color: var(--navy);
  line-height: 1;
}

.vsearch-card__price small {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.vsearch-card__moq {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}

.vsearch-card__btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 700;
  border-radius: 8px;
  background: var(--primary);
  color: #ffffff;
  text-decoration: none;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.vsearch-card__btn:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

/* Empty State */
.vsearch-empty {
  text-align: center;
  padding: 40px 20px;
  background: var(--bg-soft);
  border-radius: 16px;
  border: 1px dashed var(--line);
}

.vsearch-empty__icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--bg-card);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.06);
}

.vsearch-empty h4 {
  font-size: 17px;
  font-weight: 800;
  color: var(--navy);
  margin: 0 0 6px;
}

.vsearch-empty p {
  font-size: 14px;
  color: var(--muted);
  max-width: 420px;
  margin: 0 auto 20px;
  line-height: 1.5;
}

.vsearch-empty__actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* ---------- Dark Theme Overrides ---------- */
[data-theme="dark"] .vsearch-modal {
  background: #1e293b;
  border-color: #334155;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.7);
}

[data-theme="dark"] .vsearch-header {
  background: #1e293b;
  border-bottom-color: #334155;
}

[data-theme="dark"] .vsearch-header h3,
[data-theme="dark"] .vsearch-dropzone__heading,
[data-theme="dark"] .vsearch-preview-status h4,
[data-theme="dark"] .vsearch-summary-headline h4,
[data-theme="dark"] .vsearch-card__title,
[data-theme="dark"] .vsearch-card__price,
[data-theme="dark"] .vsearch-empty h4 {
  color: #f1f5f9;
}

[data-theme="dark"] .vsearch-close:hover {
  background: #334155;
  color: #f8fafc;
}

[data-theme="dark"] .vsearch-dropzone,
[data-theme="dark"] .vsearch-preview-box,
[data-theme="dark"] .vsearch-results-summary,
[data-theme="dark"] .vsearch-empty,
[data-theme="dark"] .vsearch-card__media {
  background: #0f172a;
  border-color: #334155;
}

[data-theme="dark"] .vsearch-dropzone:hover,
[data-theme="dark"] .vsearch-dropzone.is-dragover {
  background: rgba(2, 132, 199, 0.15);
  border-color: #38bdf8;
}

[data-theme="dark"] .vsearch-dropzone__icon,
[data-theme="dark"] .vsearch-preview-media,
[data-theme="dark"] .vsearch-empty__icon {
  background: #1e293b;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .vsearch-chip,
[data-theme="dark"] .vsearch-cat-chip,
[data-theme="dark"] .vsearch-obj-pill {
  background: #0f172a;
  border-color: #334155;
  color: #cbd5e1;
}

[data-theme="dark"] .vsearch-chip:hover,
[data-theme="dark"] .vsearch-cat-chip.is-active,
[data-theme="dark"] .vsearch-cat-chip:hover {
  background: rgba(2, 132, 199, 0.2);
  border-color: #0284c7;
  color: #38bdf8;
}

[data-theme="dark"] .vsearch-card {
  background: #1e293b;
  border-color: #334155;
}

[data-theme="dark"] .vsearch-card:hover {
  border-color: #0284c7;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .vsearch-card__footer {
  border-top-color: #334155;
}

[data-theme="dark"] .vsearch-tag {
  background: #0f172a;
  border-color: #334155;
  color: #94a3b8;
}

[data-theme="dark"] .vsearch-select {
  background: #0f172a;
  border-color: #334155;
  color: #f1f5f9;
}
