.compare-wrap { 
    max-width: 900px; 
}

.compare-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    gap: 1rem;
}

.compare-slots {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 0.5rem;
}
@media (max-width: 640px) {
    .compare-slots { grid-template-columns: 1fr; }
}

/* ── Slot card ── */
.slot-card {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    height: fit-content; 

    contain: layout style; /* Isolates internal layout shifts from triggering full page reflows */
    
}

.slot-header {
    padding: 10px 14px;
    border-bottom: 1px solid #f1f5f9;
    background: #f8fafc;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.slot-label { font-size: 11px; font-weight: 600; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.06em; }
.slot-body { padding: 14px; }
.slot-product-name { font-weight: 500; color: #0f172a; margin-bottom: 2px; }
.slot-product-brand {  color: #94a3b8; font-weight: 500; margin-bottom: 10px; }

/* ── 3-tab workflow ── */
.slot-workflow { display: flex; flex-direction: column; }

.workflow-tabs {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 6px 8px 6px 16px;
    border-bottom: 1px solid #f1f5f9;
    background: #f8fafc;
    font-size: 0.8rem;
}

.workflow-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 5px 10px;
    border-radius: 6px;
    border: none;
    background: transparent;
    cursor: pointer;
    
    font-weight: 500;
    color: #94a3b8;
    transition: background 0.12s, color 0.12s;
    white-space: nowrap;
}

.workflow-tab i { font-size: 14px; line-height: 1; }
.workflow-tab:hover { background: #f1f5f9; color: #475569; }
.workflow-tab.active { background: #fff; color: #0F172A; box-shadow: 0 0 0 1px #e2e8f0; }

.workflow-body {
    padding: 12px 14px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.workflow-pane { display: none; flex-direction: column; gap: 10px; flex: 1; }
.workflow-pane.active { display: flex; }

/* ── Search pane ── */
.slot-search {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.875rem;
    font-family: inherit;
    color: #0f172a;
}

.slot-search:focus { outline: none; border-color: #cbd5e1; }
.slot-search::placeholder {
    color: #94a3b8;
}
.search-results-box { display: none; max-height: 180px; overflow-y: auto; border-radius: 8px; }
.search-result-item {
    display: block;
    padding: 8px 10px;
    border-radius: 6px;
   
    color: #334155;
    text-decoration: none;
    transition: background 0.12s;
}
.search-result-item:hover { background: #f1f5f9; }
.search-result-brand {  font-weight: 600; }

/* ── Snap/Paste pane ── */
.product-title-input {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-family: inherit;
    color: #0f172a;
    margin-bottom: 8px;
}
.product-title-input:focus { outline: none; border-color: #cbd5e1; }
.product-title-input::placeholder { color: #94a3b8; }

/* Upload zone — matches your original Tailwind styling */
.scan-upload-label {
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 12px;
    background: #f8fafc;
    border: 2px dashed #e2e8f0;
    border-radius: 12px;
    text-align: center;
    transition: background 0.15s, border-color 0.15s;
}
.scan-upload-label:hover { background: #f1f5f9; border-color: #cbd5e1; }

.scan-icon-circle {
    width: 48px; 
    height: 48px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border: 1px solid #f1f5f9;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 10px;
    transition: transform 0.15s;
}
.scan-upload-label:hover .scan-icon-circle { transform: scale(1.05); }
.scan-icon-circle svg { width: 22px; height: 22px; stroke: #475569; }

.scan-prompt-title { font-weight: 600; color: #1e293b; }
.scan-prompt-sub { font-size: 11px; color: #94a3b8; margin-top: 2px; }

/* Preview state */
.scan-preview-inner {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: fadeIn 0.25s ease;
}
.scan-preview-label-text {
    font-size: 10px; font-weight: 700; color: #94a3b8;
    letter-spacing: 0.07em; text-transform: uppercase; margin-bottom: 6px;
}
.scan-preview-img-wrap {
    position: relative; width: 100%; max-width: 400px;
    border-radius: 8px; overflow: hidden;
    box-shadow: 0 2px 12px rgba(0,0,0,0.12);
    background: #000; border: 1px solid #e2e8f0;
    cursor: pointer; transition: transform 0.15s;
}
.scan-preview-img-wrap:hover { transform: scale(1.01); }
.scan-preview-img-wrap img { width: 100%; height: auto; display: block; opacity: 0.95; }

/* OCR status */
.ocr-status {
    font-size: 11px; font-weight: 600;
    margin-top: 6px; padding: 6px 10px;
    border-radius: 6px;
    background: rgba(239,246,255,0.6);
    color: #003595;
    text-align: center; width: 100%;
}
.ocr-status-error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

/* Divider */
.paste-divider {
    display: flex; align-items: center; gap: 12px;
    margin: 4px 0;
}
.paste-divider-line { flex: 1; height: 1px; background: #e2e8f0; }
.paste-divider-text { font-size: 11px; font-weight: 500; color: #94a3b8; white-space: nowrap; }

/* Textarea */
.analyze-box {
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    background: #fff;
    padding: 12px;
    width: 100%;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.ingredient-textarea {
    width: 100%;
    background: transparent;
    resize: none;
    
    line-height: 1.6;
    font-family: inherit;
    color: #0f172a;
    outline: none;
    border: none;
    min-height: 80px;
}
.ingredient-textarea::placeholder { color: #94a3b8; }

/* OK button */
.ok-btn {
    width: 100%;
    padding: 8px;
    background: #003595;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    cursor: pointer;
    transition: opacity 0.12s;
    margin-top: auto;
}
.ok-btn:hover { opacity: 0.88; }

/* ── Stats chips ── */
.stats-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.stat-chip { font-size: 14px; padding: 2px 8px; border-radius: 99px; border: 0.5px solid; }
.chip-warn  { background: #fef9ec; color: #92400e; border-color: #fde68a; }
.chip-good  { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.chip-muted { background: #f8fafc; color: #64748b; border-color: #e2e8f0; }

/* ── Export button ── */
.export-btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 20px; background: #003595; color: #fff;
    border: none; border-radius: 8px; font-size: 13px; font-weight: 600;
    cursor: pointer; text-decoration: none; margin-top: 1.5rem;
    transition: opacity 0.12s;
}
.export-btn:hover { opacity: 0.9; }
.export-btn:disabled { background: #94a3b8; cursor: not-allowed; }

/* ── Slot redo button (shown after snap/paste confirms) ── */
.slot-redo-btn {
    margin-top: 8px;
    font-size: 11px;
    color: #94a3b8;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
}
.slot-redo-btn:hover { color: #475569; }

/* ── Crop modal — ONE shared instance ── */
#cropModal {
    display: none;
    position: fixed; inset: 0; z-index: 50;
    flex-direction: column; align-items: center; justify-content: center;
    background: rgba(0,0,0,0.8);
    padding: 1rem;
    backdrop-filter: blur(4px);
}
#cropModal.open { display: flex; }

.crop-modal-inner {
    background: #fff;
    width: 100%; max-width: 28rem;
    border-radius: 16px; padding: 1rem;
    display: flex; flex-direction: column;
    max-height: 90vh;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.crop-modal-title { font-size: 13px; font-weight: 600; color: #1e293b; margin-bottom: 8px; }
.crop-img-wrap {
    position: relative; overflow: hidden;
    background: #f1f5f9; flex: 1;
    min-height: 200px; max-height: 50vh;
    border-radius: 10px; border: 1px solid #e2e8f0;
}
.crop-img-wrap img { max-width: 100%; display: block; }
.crop-actions { display: flex; align-items: center; gap: 10px; width: 100%; padding: 0 4px; margin-top: 14px; }
.crop-btn {
    flex: 1; padding: 10px;
    font-size: 12px; font-weight: 600;
    border-radius: 10px; border: none;
    cursor: pointer;
    transition: background 0.12s, transform 0.1s;
    text-align: center;
}
.crop-btn:active { transform: scale(0.98); }
.crop-btn-cancel { background: #f1f5f9; color: #64748b; }
.crop-btn-cancel:hover { background: #e2e8f0; }
.crop-btn-confirm { background: #1e293b; color: #fff; }
.crop-btn-confirm:hover { background: #0f172a; }

/* selection view */

/* Container overlay that dims the selected slot area */
.slot-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.85); /* Frosty translucent background */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    border-radius: 8px; /* Match your card border rounding */
    animation: fadeInSlot 0.2s ease-in-out;
}

/* Base styling for the active compare button */
#main-analyze-btn {
    padding: 6px 16px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    background-color: #003595; /* Default brand blue */
    color: #ffffff;
    transition: background 0.2s ease;
    font-size: var(--button-font-size);
}

/* Hover and focus styles for when the button is active */
#main-analyze-btn:not(:disabled):hover {
    background-color: #002566; /* Slightly darker shade on hover */
    transform: translateY(0);
}

#main-analyze-btn:not(:disabled):active {
    transform: translateY(0);
}

/* Disabled state styling overrides */
#main-analyze-btn:disabled,
#main-analyze-btn.btn-disabled {
    background-color: #cbd5e1;
    color: #64748b;
    cursor: not-allowed;
    transform: none;
}

/* Container positioning offsets */
.compare-actions-wrapper {
    text-align: center;
    margin: 30px 0;
}

/* --- THE RESPONSIVE FIX --- */
/* Mobile Viewports (Default Layout stack) */
.selected-badges-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    width: 100%;
}

/* Individual choice item tracking frame styles */
.selected-badge-card {
    padding: 10px;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 6px;
    width: 100%;
    max-width: 280px;
    box-sizing: border-box;
}


/* Container wrapper to center the image column */
.product-image-compare-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    /* margin-bottom: 20px; */
}

/* Image behavior rule */
.product-image-compare-wrap img {
    max-height: 180px;
    max-width: 100%;
    object-fit: contain;
    border-radius: 4px;
    display: block;
    margin: 1rem 0;
}

/* Mode 1: Default View */
.slot-card .slot-search-view {
    display: none;
}
.slot-card .slot-details-view {
    display: block;
}

/* Mode 2: Active Editing View */
.slot-card.is-editing .slot-search-view {
    display: block;
}
.slot-card.is-editing .slot-details-view {
    display: none;
}



/* The locked, disabled state */
#main-analyze-btn.btn-disabled {
    background: #cbd5e1;
    color: #64748b;
    cursor: not-allowed;
    pointer-events: none; /* ◄ Natively stops user clicks without breaking HTML event pipelines */
}

@keyframes spinTrack {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes fadeInSlot {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.compare-card-image-wrapper {
  width: 100%;
  aspect-ratio: 1 / 1;
  background-color: #f3f4f6;
  contain: strict; /* Prevents image loading from shifting surrounding DOM elements */
}

/* Reserve height for search preview dropdowns to prevent layout jumps */
.slot-search-results {
  min-height: 200px;
  contain: layout;
}

/* Ensure comparison cards maintain intrinsic size before data finishes rendering */
.comparison-card-slot {
  min-height: 320px;
  contain: layout style;
}
