/* SizeExplorer Popup Styles */

.se-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 6vh;
}

.se-overlay[hidden] {
    display: none;
}

.se-popup {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.22);
    width: min(720px, 95vw);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.97);
    opacity: 0;
    transition: transform 150ms ease-out, opacity 150ms ease-out;
}

.se-overlay.se-open .se-popup {
    transform: scale(1);
    opacity: 1;
}

/* ── Zone A: Search bar ── */
.se-search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid #d4d4d4;
    flex-shrink: 0;
}

.se-search-icon {
    font-size: 1.1rem;
    color: #888;
    flex-shrink: 0;
}

#seSearchInput {
    flex: 1;
    border: none;
    outline: none;
    font-size: 1.05rem;
    color: #222;
    background: transparent;
    min-width: 0;
}

#seSearchInput::placeholder {
    color: #aaa;
}

.se-clear-btn,
.se-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    color: #888;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1;
    flex-shrink: 0;
}

.se-clear-btn:hover,
.se-close-btn:hover {
    background: #f0f0f0;
    color: #333;
}

/* ── Zone B: Content ── */
.se-content {
    overflow-y: auto;
    padding: 16px;
    flex: 1;
    overscroll-behavior: contain;
}

/* ── Section headers ── */
.se-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    margin-top: 4px;
}

.se-section-title {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: #888;
}

.se-section + .se-section {
    margin-top: 20px;
}


.se-scroll-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding-bottom: 8px;
}

/* ── Item card sm (thumbnail) ── */
.se-card-sm {
    flex: 0 0 110px;
    height: 150px;
    border-radius: 8px;
    box-shadow: var(--shadow, 0 0 5px rgba(0,0,0,.2));
    cursor: pointer;
    transition: transform 150ms ease, box-shadow 150ms ease;
    overflow: visible;
    display: flex;
    flex-direction: column;
    background: #f7fbff;
    border: 1px solid #d9e8f7;
    position: relative;
}

.se-card-sm:hover {
    transform: scale(1.04);
    box-shadow: 0 4px 16px rgba(0, 123, 255, 0.18);
}

.se-card-sm-thumb {
    flex: 1;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #eef4fb;
    border-radius: 8px 8px 0 0;
    position: relative;
}

.se-card-sm-thumb img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.se-card-sm-thumb.se-no-img {
    font-size: 2rem;
    color: #c3d8f0;
}

.se-card-sm-info {
    padding: 5px 6px 6px;
    background: #fff;
    flex-shrink: 0;
    overflow: hidden;
    border-radius: 0 0 8px 8px;
}

/* ── SM card image-count badge ── */
.se-card-sm-img-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    border: none;
    border-radius: 4px;
    padding: 2px 5px;
    cursor: pointer;
    z-index: 1;
    line-height: 1.3;
    backdrop-filter: blur(2px);
    transition: background 100ms;
}

.se-card-sm-img-badge:hover {
    background: rgba(0, 123, 255, 0.85);
}

/* ── SM card image picker popover (appended to body, positioned via JS) ── */
.se-sm-picker {
    background: #fff;
    border: 1px solid #d0e8ff;
    border-radius: 8px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 6px;
    z-index: 9999;
    min-width: 100px;
    max-width: 220px;
}

.se-sm-picker-img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: 5px;
    cursor: pointer;
    border: 2px solid transparent;
    background: #eef4fb;
    transition: border-color 100ms, transform 100ms;
    display: block;
}

.se-sm-picker-img:hover {
    border-color: #007bff;
    transform: scale(1.08);
}

.se-card-sm-name {
    font-size: 0.73rem;
    font-weight: 600;
    color: #222;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.se-card-sm-size {
    font-size: 0.68rem;
    color: #007bff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Item card md (list row) ── */
.se-card-md {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 120ms;
    border: 1px solid transparent;
}

.se-card-md:hover {
    background: #f0f7ff;
    border-color: #d0e8ff;
}

.se-card-md-thumb {
    flex: 0 0 52px;
    height: 52px;
    border-radius: 6px;
    overflow: hidden;
    background: #eef4fb;
    display: flex;
    align-items: center;
    justify-content: center;
}

.se-card-md-thumb img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.se-card-md-thumb.se-no-img {
    font-size: 1.4rem;
    color: #c3d8f0;
}

/* Multiple-image grid in md card */
.se-card-md-thumbs {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 3px;
    flex-shrink: 0;
    max-width: 160px; /* ~3 per row; wraps to additional rows for more */
    align-content: flex-start;
}

.se-card-md-img {
    width: 50px;
    height: 50px;
    object-fit: contain;
    border-radius: 5px;
    cursor: pointer;
    border: 2px solid transparent;
    background: #eef4fb;
    flex-shrink: 0;
    transition: border-color 120ms, transform 120ms;
}

.se-card-md-img:hover {
    border-color: #007bff;
    transform: scale(1.08);
}

.se-card-md-body {
    flex: 1;
    min-width: 0;
}

.se-card-md-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: #222;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.se-card-md-meta {
    font-size: 0.78rem;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.se-card-md-add {
    flex-shrink: 0;
    padding: 5px 12px;
    background: #007bff;
    color: #fff;
    border: none;
    border-radius: 5px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 120ms;
}

.se-card-md-add:hover {
    background: #0056b3;
}

/* ── Share card ── */
.se-share-card-wrap {
    border: 1px solid transparent;
    border-radius: 8px;
    transition: border-color 120ms;
}

.se-share-card-wrap:hover {
    border-color: #d0e8ff;
}

.se-share-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    border-radius: 8px 8px 0 0;
    transition: background 120ms;
    text-decoration: none;
    color: inherit;
}

.se-share-card:hover {
    background: #f0f7ff;
}

.se-share-items {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding: 6px 10px 8px;
    border-top: 1px solid #eef4fb;
}

.se-share-item-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #eef4fb;
    border: 1px solid #c8dff5;
    border-radius: 4px;
    padding: 2px 8px 2px 2px;
    font-size: 0.75rem;
    color: #2255aa;
    cursor: pointer;
    transition: background 120ms, border-color 120ms;
    white-space: nowrap;
}

.se-share-item-chip:hover {
    background: #007bff;
    border-color: #007bff;
    color: #fff;
}

.se-share-item-tn {
    width: 28px;
    height: 28px;
    object-fit: contain;
    border-radius: 3px;
    background: #d8eaf8;
    flex-shrink: 0;
    display: block;
}

.se-share-item-tn-empty {
    background: #d8eaf8;
}

.se-share-thumb-strip {
    display: flex;
    gap: 3px;
    flex-shrink: 0;
}

.se-share-thumb {
    width: 38px;
    height: 38px;
    border-radius: 5px;
    object-fit: contain;
    background: #eef4fb;
    border: 1px solid #d9e8f7;
}

.se-share-thumb.se-no-img {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: #c3d8f0;
}

.se-share-body {
    flex: 1;
    min-width: 0;
}

.se-share-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: #222;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-transform: capitalize;
}

.se-share-meta {
    font-size: 0.75rem;
    color: #888;
}

.se-share-open {
    flex-shrink: 0;
    padding: 5px 10px;
    background: none;
    border: 1px solid #007bff;
    color: #007bff;
    border-radius: 5px;
    font-size: 0.78rem;
    cursor: pointer;
    white-space: nowrap;
    transition: background 120ms, color 120ms;
    text-decoration: none;
}

.se-share-open:hover {
    background: #007bff;
    color: #fff;
}

/* ── Skeleton loading ── */
.se-skeleton {
    background: linear-gradient(90deg, #eee 25%, #f8f8f8 50%, #eee 75%);
    background-size: 200% 100%;
    animation: se-shimmer 1.4s infinite;
    border-radius: 6px;
}

@keyframes se-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.se-card-sm.se-skeleton-card {
    background: #f0f0f0;
    box-shadow: none;
    border-color: transparent;
    cursor: default;
}

.se-card-sm.se-skeleton-card .se-card-sm-thumb {
    background: linear-gradient(90deg, #e0e0e0 25%, #eee 50%, #e0e0e0 75%);
    background-size: 200% 100%;
    animation: se-shimmer 1.4s infinite;
}

.se-card-sm.se-skeleton-card .se-card-sm-name,
.se-card-sm.se-skeleton-card .se-card-sm-size {
    height: 10px;
    border-radius: 4px;
    margin-bottom: 3px;
    background: linear-gradient(90deg, #e0e0e0 25%, #eee 50%, #e0e0e0 75%);
    background-size: 200% 100%;
    animation: se-shimmer 1.4s infinite;
    color: transparent;
}

/* ── Empty state ── */
.se-empty {
    text-align: center;
    padding: 40px 20px;
    color: #888;
}

.se-empty-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.se-empty-text {
    font-size: 0.95rem;
    margin-bottom: 14px;
}

.se-empty-cta {
    display: inline-block;
    padding: 7px 18px;
    background: #007bff;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    text-decoration: none;
    transition: background 120ms;
}

.se-empty-cta:hover {
    background: #0056b3;
}

/* ── Proximity ruler ── */
.se-proximity-header {
    font-size: 0.9rem;
    color: #555;
    margin-bottom: 14px;
}

.se-proximity-header strong {
    color: #007bff;
}

.se-ruler-wrap {
    position: relative;
    height: 32px;
    margin-bottom: 20px;
    padding: 0 8px;
}

.se-ruler-track {
    position: absolute;
    left: 8px;
    right: 8px;
    top: 50%;
    height: 3px;
    background: #d9e8f7;
    border-radius: 2px;
    transform: translateY(-50%);
}

.se-ruler-target {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #007bff;
    box-shadow: 0 0 0 3px rgba(0,123,255,.25);
    z-index: 2;
}

.se-ruler-dot {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #33a1ff;
    opacity: 0.6;
}

.se-proximity-results {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.se-proximity-delta {
    font-size: 0.75rem;
    color: #007bff;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 56px;
    text-align: right;
}

/* ── Toolbar search button ── */
#searchOpenBtn {
    /* font-size: 1.15rem; */
    padding: 4px 8px;
    cursor: pointer;
}

/* ── infoPanel value/tag chips ── */
.se-value-chip,
.se-tag-chip {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font: inherit;
    color: inherit;
    display: inline;
    text-decoration: underline dotted;
    text-underline-offset: 2px;
}

.se-value-chip:hover,
.se-tag-chip:hover {
    color: #007bff;
    text-decoration: underline;
}

/* ── Mobile bottom sheet ── */
@media (max-width: 640px) {
    .se-overlay {
        align-items: flex-end;
        padding-top: 0;
    }

    .se-popup {
        width: 100%;
        max-height: 90vh;
        border-radius: 14px 14px 0 0;
        padding-bottom: env(safe-area-inset-bottom, 0);
    }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
    .se-popup {
        transition: opacity 150ms ease-out;
        transform: none !important;
    }

    .se-overlay.se-open .se-popup {
        transform: none;
    }

    .se-skeleton,
    .se-card-sm.se-skeleton-card .se-card-sm-thumb,
    .se-card-sm.se-skeleton-card .se-card-sm-name,
    .se-card-sm.se-skeleton-card .se-card-sm-size {
        animation: none;
    }
}
