/* Visual Search Plugin v10 */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600&family=DM+Serif+Display&display=swap');

:root {
    --vs-primary:      #1a1a2e;
    --vs-accent:       #e94560;
    --vs-accent-hover: #c73652;
    --vs-bg:           #f8f7f4;
    --vs-surface:      #ffffff;
    --vs-border:       #e5e2db;
    --vs-text:         #1a1a2e;
    --vs-muted:        #6b6868;
    --vs-radius:       12px;
    --vs-shadow-hover: 0 8px 32px rgba(26,26,46,0.14);
    --vs-font:         'DM Sans', sans-serif;
    --vs-font-display: 'DM Serif Display', serif;
}

.vs-wrapper { font-family: var(--vs-font); color: var(--vs-text); max-width: 900px; margin: 0 auto; padding: 40px 20px 60px; }

/* Hero */
.vs-hero { text-align: center; margin-bottom: 36px; }
.vs-hero-icon { width: 56px; height: 56px; background: var(--vs-accent); border-radius: 16px; display: inline-flex; align-items: center; justify-content: center; margin-bottom: 16px; color: #fff; }
.vs-hero h2 { font-family: var(--vs-font-display); font-size: clamp(24px, 4vw, 36px); margin: 0 0 8px; color: var(--vs-primary); }
.vs-hero p  { font-size: 16px; color: var(--vs-muted); margin: 0; }

/* Upload area */
.vs-upload-area {
    border: 2px dashed var(--vs-border);
    border-radius: var(--vs-radius);
    background: var(--vs-bg);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    position: relative;
    min-height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.vs-upload-area:hover, .vs-upload-area.vs-drag-over { border-color: var(--vs-accent); background: #fff5f6; }
.vs-file-input { display: none; }

/* Empty state */
#vs-drop-content { text-align: center; padding: 40px 24px; pointer-events: none; }
.vs-upload-icon { width: 48px; height: 48px; margin: 0 auto 16px; color: var(--vs-muted); }
.vs-upload-icon svg { width: 100%; height: 100%; }
.vs-drop-primary  { font-size: 17px; font-weight: 600; margin: 0 0 6px; color: var(--vs-text); }
.vs-drop-secondary { font-size: 14px; color: var(--vs-muted); margin: 0 0 8px; }
.vs-browse-link { color: var(--vs-accent); font-weight: 600; cursor: pointer; pointer-events: all; text-decoration: underline; }
.vs-drop-hint { font-size: 12px; color: #aaa; margin: 0; }

/* CropperJS container — standalone outside upload area, no height limits */
#vs-cropper-wrap {
    width: 100%;
    background: #fff;
    border-radius: var(--vs-radius);
    border: 1px solid var(--vs-border);
    overflow: hidden;
}
#vs-cropper-img {
    display: block;
    max-width: 100%;
    height: auto;
}

/* CropperJS theme overrides */
.cropper-view-box, .cropper-face { border-radius: 0; }
.cropper-view-box { outline: 2px solid var(--vs-accent); }
.cropper-line { background-color: var(--vs-accent); }
.cropper-point { background-color: var(--vs-accent); width: 8px; height: 8px; border-radius: 2px; }
.cropper-point.point-se { width: 10px; height: 10px; }
.cropper-bg { background-image: none; background-color: rgba(26,26,46,0.45); }

/* Crop toolbar */
.vs-crop-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
    padding: 10px 14px;
    background: #f0f0f8;
    border-radius: 8px;
    border: 1px solid #dddde8;
}
.vs-crop-hint-text { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--vs-primary); font-weight: 500; }
.vs-crop-hint-text svg { flex-shrink: 0; color: var(--vs-accent); }
.vs-crop-actions { display: flex; gap: 8px; }
.vs-crop-btn {
    display: inline-flex; align-items: center; gap: 5px;
    background: #fff; border: 1px solid var(--vs-border); border-radius: 6px;
    padding: 6px 12px; font-size: 12px; font-weight: 600; color: var(--vs-primary);
    cursor: pointer; font-family: var(--vs-font); transition: border-color 0.15s, color 0.15s;
}
.vs-crop-btn:hover { border-color: var(--vs-accent); color: var(--vs-accent); }

/* Search button */
.vs-btn {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    width: 100%; margin-top: 20px; padding: 16px 28px;
    background: var(--vs-accent); color: #fff; border: none;
    border-radius: var(--vs-radius); font-family: var(--vs-font);
    font-size: 16px; font-weight: 600; cursor: pointer;
    transition: background 0.2s, transform 0.1s, opacity 0.2s;
}
.vs-btn:hover:not(:disabled)  { background: var(--vs-accent-hover); transform: translateY(-1px); }
.vs-btn:active:not(:disabled) { transform: translateY(0); }
.vs-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.vs-btn-icon, .vs-btn-spinner { width: 20px; height: 20px; flex-shrink: 0; }
.vs-btn-spinner { display: inline-flex; align-items: center; justify-content: center; }
.vs-spin { animation: vs-rotate 0.8s linear infinite; }
@keyframes vs-rotate { to { transform: rotate(360deg); } }

/* Status */
.vs-status { margin-top: 20px; background: var(--vs-bg); border-radius: 8px; padding: 14px 16px; }
.vs-status-bar { height: 4px; background: var(--vs-border); border-radius: 2px; overflow: hidden; margin-bottom: 10px; }
.vs-status-fill { height: 100%; background: var(--vs-accent); border-radius: 2px; width: 0%; transition: width 0.4s ease; }
.vs-status-text { font-size: 13px; color: var(--vs-muted); margin: 0; text-align: center; }

/* Error */
.vs-error { margin-top: 16px; display: flex; align-items: center; gap: 10px; background: #fff0f2; border: 1px solid #fbc8ce; border-radius: 8px; padding: 12px 16px; color: #c0293e; font-size: 14px; }
.vs-error svg { width: 18px; height: 18px; flex-shrink: 0; }

/* Results */
.vs-results-header { display: flex; align-items: baseline; gap: 12px; margin: 40px 0 20px; border-bottom: 1px solid var(--vs-border); padding-bottom: 14px; }
.vs-results-header h3 { font-family: var(--vs-font-display); font-size: 22px; margin: 0; color: var(--vs-primary); }
.vs-results-count { font-size: 13px; color: var(--vs-muted); background: var(--vs-bg); padding: 3px 10px; border-radius: 20px; }
.vs-results-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 20px; }
.vs-product-card { background: var(--vs-surface); border: 1px solid var(--vs-border); border-radius: var(--vs-radius); overflow: hidden; transition: box-shadow 0.2s, transform 0.2s; animation: vs-card-in 0.35s ease both; }
@keyframes vs-card-in { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
.vs-product-card:hover { box-shadow: var(--vs-shadow-hover); transform: translateY(-3px); }
.vs-card-link { text-decoration: none; color: inherit; display: block; }
.vs-card-image { position: relative; background: var(--vs-bg); aspect-ratio: 1; overflow: hidden; }
.vs-card-image img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.3s; }
.vs-product-card:hover .vs-card-image img { transform: scale(1.04); }
.vs-match-badge { position: absolute; top: 8px; left: 8px; background: var(--vs-primary); color: #fff; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 20px; }
.vs-out-of-stock { position: absolute; bottom: 0; left: 0; right: 0; background: rgba(26,26,46,0.7); color: #fff; font-size: 12px; font-weight: 600; text-align: center; padding: 6px; }
.vs-card-body { padding: 14px 14px 16px; }
.vs-card-category { font-size: 11px; color: var(--vs-muted); text-transform: uppercase; letter-spacing: 0.8px; margin: 0 0 4px; }
.vs-card-name { font-size: 14px; font-weight: 600; margin: 0 0 12px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.vs-card-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.vs-price-row { display: flex; align-items: baseline; gap: 6px; }
.vs-price { font-size: 15px; font-weight: 700; color: var(--vs-primary); }
.vs-price-sale { color: var(--vs-accent); }
.vs-price-old { font-size: 12px; font-weight: 400; color: var(--vs-muted); text-decoration: line-through; }
.vs-view-btn { font-size: 12px; font-weight: 600; color: var(--vs-accent); white-space: nowrap; }
.vs-no-results { grid-column: 1/-1; text-align: center; padding: 48px 24px; color: var(--vs-muted); }
.vs-no-results svg { width: 48px; height: 48px; margin: 0 auto 16px; display: block; opacity: 0.4; }
.vs-no-results p { margin: 0; font-size: 15px; }

/* Homepage camera */
.vs-camera-trigger { display: inline-flex !important; align-items: center; justify-content: center; cursor: pointer; padding: 6px; border-radius: 6px; transition: background 0.2s, color 0.2s; color: #888; flex-shrink: 0; margin: 0 2px; }
.vs-camera-trigger:hover { color: #e94560; background: rgba(233,69,96,0.08); }
.vs-camera-icon { width: 20px !important; height: 20px !important; display: block !important; }
.vs-camera-loading .vs-camera-icon { animation: vs-rotate 0.8s linear infinite; color: #e94560; }
.vs-home-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; margin-top: 12px; }
.vs-home-title { font-size: 18px; font-weight: 600; margin: 24px 0 4px; color: #1a1a2e; }
.vs-home-card { display: block; text-decoration: none; color: inherit; border: 1px solid #e5e2db; border-radius: 10px; overflow: hidden; transition: box-shadow 0.2s, transform 0.2s; }
.vs-home-card:hover { box-shadow: 0 6px 20px rgba(0,0,0,0.1); transform: translateY(-2px); }
.vs-home-card img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.vs-home-name { font-size: 13px; font-weight: 600; padding: 8px 10px 2px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vs-home-price { font-size: 13px; color: #e94560; font-weight: 700; padding: 0 10px 10px; margin: 0; }
.vs-home-error { color: #c0293e; font-size: 14px; margin: 12px 0; }

/* Loading overlay */
.vs-upload-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 99999; display: flex; align-items: center; justify-content: center; }
.vs-upload-modal { background: #fff; border-radius: 16px; padding: 40px 48px; text-align: center; max-width: 340px; width: 90%; box-shadow: 0 20px 60px rgba(0,0,0,0.2); }
.vs-upload-modal-icon { width: 56px; height: 56px; background: #fff0f2; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 20px; color: #e94560; }
.vs-upload-modal-title { font-size: 18px; font-weight: 700; margin: 0 0 6px; color: #1a1a2e; }
.vs-upload-modal-sub   { font-size: 14px; color: #888; margin: 0 0 20px; }
.vs-upload-modal-bar   { height: 4px; background: #f0ede8; border-radius: 2px; overflow: hidden; }
.vs-upload-modal-fill  { height: 100%; background: #e94560; border-radius: 2px; width: 5%; transition: width 0.3s ease; }

/* Responsive */
@media (max-width: 600px) {
    .vs-wrapper { padding: 24px 16px 40px; }
    .vs-results-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    #vs-cropper-wrap { max-height: 320px; }
    .vs-crop-toolbar { flex-direction: column; align-items: flex-start; }
}
