/* =========================================================
   AUCTIONIQ - EBAY RESEARCH
   Page-specific styles
   ========================================================= */


/* ---------------------------------------------------------
   Search / research header
   --------------------------------------------------------- */

.ebay-back-auction {
    display: inline-block;
    margin-bottom: 16px;
}

.ebay-research-lot-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 8px;
}

.ebay-research-lot-thumb {
    display: block;
    flex: 0 0 72px;
    width: 72px;
    height: 72px;
}

.ebay-research-lot-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #fff;
}

.ebay-research-lot-summary {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.ebay-research-search,
.ebay-research-run {
    margin-bottom: 20px;
}

.ebay-search-form {
    margin-top: 16px;
}

.ebay-search-query input {
    width: 100%;
}

.ebay-research-run-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
}

.ebay-research-summary {
    margin-top: 12px;
}

.ebay-research-waiting {
    margin-top: 16px;
}


/* ---------------------------------------------------------
   Research status
   --------------------------------------------------------- */

.ebay-research-status {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    padding: 7px 11px;
    border-radius: 999px;
    font-size: 0.84rem;
    font-weight: 700;
}

.ebay-research-status-pending {
    background: #f1f5f9;
}

.ebay-research-status-claimed,
.ebay-research-status-processing {
    background: #dbeafe;
}

.ebay-research-status-completed {
    background: #dcfce7;
}

.ebay-research-status-failed,
.ebay-research-status-needs_attention {
    background: #fee2e2;
}


/* ---------------------------------------------------------
   Evidence selector / summary
   --------------------------------------------------------- */

.ebay-evidence-selector {
    margin-bottom: 20px;
}

.ebay-evidence-view-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.ebay-comparable-summary {
    margin-bottom: 22px;
}

.ebay-comparable-summary-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
}

.ebay-comparable-counts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ebay-comparable-counts span {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
}

.ebay-count-primary {
    background: #dcfce7;
}

.ebay-count-secondary {
    background: #fef3c7;
}

.ebay-count-rejected {
    background: #f1f5f9;
}

.ebay-comparable-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 18px;
}

.ebay-comparable-toolbar label {
    font-weight: 600;
}

.ebay-comparable-toolbar select {
    width: auto;
    min-width: 180px;
}

.ebay-comparable-rerun {
    margin-top: 12px;
}


/* ---------------------------------------------------------
   Group headings
   --------------------------------------------------------- */

.ebay-comparable-group,
.ebay-results-section {
    margin-top: 26px;
}

.ebay-results-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 20px;
    margin-bottom: 14px;
}

.ebay-results-heading h2 {
    margin-bottom: 3px;
}

.ebay-results-heading p {
    margin: 0;
}

.ebay-results-heading > span {
    flex: 0 0 auto;
    font-weight: 700;
}


/* =========================================================
   RESULT GRID
   ========================================================= */

.ebay-results-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
    align-items: stretch;
}


/* =========================================================
   RESULT CARD
   ========================================================= */

.ebay-results-grid .ebay-result-card {
    display: flex;
    flex-direction: column;

    min-width: 0;
    height: 100%;

    margin: 0;
    padding: 0;

    overflow: hidden;

    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
}


/*
 * Primary / Secondary / Rejected cards have this wrapper.
 * It MUST be vertical.
 */

.ebay-results-grid .ebay-result-card-body {
    display: flex;
    flex-direction: column;

    width: 100%;
    min-width: 0;

    flex: 1 1 auto;
}


/* =========================================================
   RESULT IMAGE
   ========================================================= */

/*
 * Give every result a proper photographic area.
 *
 * Desktop cards are roughly 300px wide, so a square area
 * gives auction photographs room to breathe without
 * cropping portrait or landscape images.
 */

.ebay-results-grid .ebay-comparable-image {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 100%;
    min-width: 100%;
    max-width: 100%;

    aspect-ratio: 1 / 1;

    margin: 0;
    padding: 10px;

    box-sizing: border-box;
    overflow: hidden;

    background: #f8fafc;
    border: 0;
    border-bottom: 1px solid #e2e8f0;
    border-radius: 0;
}


/*
 * The eBay listing link fills the entire image area.
 */

.ebay-results-grid .ebay-comparable-image > a {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 100%;
    height: 100%;

    margin: 0;
    padding: 0;
}


/*
 * Full s-l1600 image.
 *
 * object-fit: contain means NO auction photograph is
 * deliberately cropped.
 */

.ebay-results-grid .ebay-comparable-image img {
    display: block;

    width: 100%;
    height: 100%;

    min-width: 0;
    max-width: 100%;
    max-height: 100%;

    margin: 0;
    padding: 0;

    object-fit: contain;

    border: 0;
    border-radius: 0;
    background: transparent;
}


/* =========================================================
   RESULT CONTENT
   ========================================================= */

.ebay-results-grid .ebay-comparable-content {
    display: block;

    width: 100%;
    min-width: 0;

    padding: 16px;

    box-sizing: border-box;
}

.ebay-results-grid .ebay-comparable-content h3 {
    margin: 8px 0 10px;
    line-height: 1.35;
}

.ebay-comparable-badge {
    display: inline-flex;
    align-items: center;

    padding: 5px 9px;

    border-radius: 999px;

    font-size: 0.72rem;
    font-weight: 800;
    line-height: 1;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.ebay-comparable-primary .ebay-comparable-badge {
    background: #dcfce7;
}

.ebay-comparable-secondary .ebay-comparable-badge {
    background: #fef3c7;
}

.ebay-comparable-rejected .ebay-comparable-badge {
    background: #f1f5f9;
}

.ebay-result-price {
    margin: 8px 0;
    font-size: 1.15rem;
    font-weight: 800;
}

.ebay-result-item-id {
    margin-top: 8px;
    font-size: 0.82rem;
    color: #64748b;
}

.ebay-comparable-reason {
    margin: 12px 0 0;
    padding-top: 12px;

    border-top: 1px solid #e2e8f0;

    line-height: 1.55;
}


/* ---------------------------------------------------------
   Match indication
   --------------------------------------------------------- */

.ebay-comparable-primary {
    border-left: 4px solid #22c55e !important;
}

.ebay-comparable-secondary {
    border-left: 4px solid #f59e0b !important;
}

.ebay-comparable-rejected {
    border-left: 4px solid #94a3b8 !important;
}


/* =========================================================
   CARD FOOTER
   ========================================================= */

.ebay-results-grid .ebay-result-card-footer {
    margin-top: auto;
    padding: 12px 16px;

    border-top: 1px solid #e2e8f0;
}

.ebay-results-grid .ebay-result-card-footer .button {
    margin: 0;
}


/* ---------------------------------------------------------
   Rejected group
   --------------------------------------------------------- */

.ebay-rejected-details {
    margin-top: 28px;
}

.ebay-rejected-details > summary {
    cursor: pointer;
    font-weight: 700;
}

.ebay-rejected-details[open] > summary {
    margin-bottom: 12px;
}


/* ---------------------------------------------------------
   Analyse comparables
   --------------------------------------------------------- */

.ebay-comparable-action {
    margin-bottom: 20px;
}

.ebay-comparable-action-content {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.ebay-comparable-action-icon {
    display: flex;
    align-items: center;
    justify-content: center;

    flex: 0 0 44px;
    width: 44px;
    height: 44px;

    border-radius: 10px;
    background: #eef2ff;

    font-weight: 800;
}

.ebay-comparable-action-text {
    flex: 1;
    min-width: 0;
}

.ebay-comparable-hint {
    margin-bottom: 0;
}

.ebay-comparable-action-form {
    margin-top: 16px;
}

.ebay-analyse-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.ebay-analyse-spinner {
    width: 16px;
    height: 16px;

    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;

    animation: ebay-spin 0.7s linear infinite;
}

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


/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 640px) {

    .ebay-research-run-header,
    .ebay-comparable-summary-header,
    .ebay-results-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .ebay-evidence-view-actions {
        flex-direction: column;
    }

    .ebay-evidence-view-actions .button {
        width: 100%;
        text-align: center;
    }

    .ebay-comparable-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .ebay-comparable-toolbar select {
        width: 100%;
    }


    /*
     * One large result per row.
     */

    .ebay-results-grid {
        grid-template-columns: 1fr;
        gap: 18px;
    }


    /*
     * Same catalogue-style large image presentation.
     */

    .ebay-results-grid .ebay-comparable-image {
        width: 100%;
        min-width: 100%;
        aspect-ratio: 1 / 1;
        padding: 8px;
    }

    .ebay-results-grid .ebay-comparable-image img {
        width: 100%;
        height: 100%;
        object-fit: contain;
    }

    .ebay-results-grid .ebay-comparable-content {
        padding: 14px;
    }

    .ebay-results-grid .ebay-result-card-footer {
        padding: 12px 14px;
    }

    .ebay-comparable-action-content {
        flex-direction: column;
    }
}