/* Direct uploader — "+"-tile hybrid: square file tiles with hover
   Replace/Remove actions + one trailing add tile. */

.du-uploader .du-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-start;
}

.du-uploader .du-tile {
    position: relative;
    width: 104px;
    height: 104px;
    border: 1px solid #e2e5ec;
    border-radius: 6px;
    overflow: hidden;
    background: #f7f8fa;
}

.du-uploader .du-thumb {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: #6c757d;
}

.du-uploader .du-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.du-uploader .du-thumb i {
    font-size: 1.75rem;
}

.du-uploader .du-ext {
    font-size: 10px;
    color: #6c757d;
}

/* hover overlay with the two actions */
.du-uploader .du-actions {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(20, 24, 31, 0.45);
    opacity: 0;
    transition: opacity 0.12s ease;
}

.du-uploader .du-tile:hover .du-actions,
.du-uploader .du-tile:focus-within .du-actions {
    opacity: 1;
}

/* touch devices have no hover — keep the actions visible in a corner strip */
@media (hover: none) {
    .du-uploader .du-actions {
        opacity: 1;
        inset: auto 0 0 0;
        padding: 3px 0;
        background: rgba(20, 24, 31, 0.55);
    }
}

.du-uploader .du-act {
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 50%;
    background: #fff;
    color: #14181f;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0;
}

.du-uploader .du-act:hover {
    background: var(--primary, #377dff);
    color: #fff;
}

.du-uploader .du-remove:hover {
    background: #dc3545;
    color: #fff;
}

/* tagged image indicator (a small dot on the tile corner) */
.du-uploader .du-tile.du-tagged::after {
    content: "";
    position: absolute;
    top: 5px;
    left: 5px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #28a745;
    box-shadow: 0 0 0 2px #fff;
}

/* the "+" add tile */
.du-uploader .du-add {
    width: 104px;
    height: 104px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px;
    border: 2px dashed #d0d5dd;
    border-radius: 6px;
    background: #fafbfc;
    color: #6c757d;
    cursor: pointer;
    text-align: center;
    transition: border-color 0.15s ease, background 0.15s ease;
    -webkit-user-select: none;
    user-select: none;
}

.du-uploader .du-add:hover,
.du-uploader .du-add:focus,
.du-uploader .du-add.du-dragover {
    border-color: var(--primary, #377dff);
    background: rgba(55, 125, 255, 0.04);
    color: var(--primary, #377dff);
    outline: none;
}

/* the "Library" browse tile (admin) — sits next to the "+" tile */
.du-uploader .du-browse {
    width: 104px;
    height: 104px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px;
    border: 2px dashed #d0d5dd;
    border-radius: 6px;
    background: #fafbfc;
    color: #6c757d;
    cursor: pointer;
    text-align: center;
    transition: border-color 0.15s ease, background 0.15s ease;
    -webkit-user-select: none;
    user-select: none;
}

.du-uploader .du-browse:hover,
.du-uploader .du-browse:focus {
    border-color: var(--primary, #377dff);
    background: rgba(55, 125, 255, 0.04);
    color: var(--primary, #377dff);
    outline: none;
}

/* ---- library modal ---- */
.du-lib-overlay {
    position: fixed;
    inset: 0;
    z-index: 1080;
    background: rgba(20, 24, 31, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.du-lib-modal {
    background: #fff;
    border-radius: 8px;
    width: 100%;
    max-width: 760px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.du-lib-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #e9ecef;
}

.du-lib-close {
    border: 0;
    background: transparent;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    color: #6c757d;
}

.du-lib-toolbar {
    display: flex;
    gap: 8px;
    padding: 10px 16px;
    border-bottom: 1px solid #f1f2f4;
    flex-wrap: wrap;
}

.du-lib-toolbar .du-lib-search {
    flex: 1 1 180px;
}

.du-lib-body {
    padding: 14px 16px;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 160px;
}

.du-lib-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 10px;
}

.du-lib-card {
    position: relative;
    border: 2px solid #e2e5ec;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    background: #f7f8fa;
}

.du-lib-card.selected {
    border-color: var(--primary, #377dff);
    box-shadow: 0 0 0 2px rgba(55, 125, 255, 0.25);
}

.du-lib-thumb {
    height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    color: #6c757d;
}

.du-lib-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.du-lib-thumb i {
    font-size: 1.9rem;
}

.du-lib-card.selected::after {
    content: "\2713";
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary, #377dff);
    color: #fff;
    font-size: 12px;
    line-height: 20px;
    text-align: center;
}

.du-lib-card.du-tagged .du-lib-thumb::before {
    content: "";
    position: absolute;
    top: 5px;
    left: 5px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #28a745;
    box-shadow: 0 0 0 2px #fff;
    z-index: 1;
}

.du-lib-name {
    font-size: 11px;
    padding: 4px 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.du-lib-loading,
.du-lib-empty {
    padding: 40px 0;
    text-align: center;
    color: #6c757d;
}

.du-lib-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 16px;
    border-top: 1px solid #e9ecef;
    flex-wrap: wrap;
}

.du-lib-page {
    font-size: 12px;
    color: #6c757d;
    margin: 0 4px;
}

.du-lib-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.du-lib-count {
    font-size: 12px;
    color: #6c757d;
}

.du-uploader .du-icon {
    font-size: 1.5rem;
    line-height: 1;
}

.du-uploader .du-label {
    font-size: 11px;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* the real input is triggered programmatically */
.du-uploader .du-file {
    display: none;
}

.du-uploader .du-error {
    margin-top: 4px;
}

/* upload-in-progress tile */
.du-uploader .du-uploading .du-thumb i {
    font-size: 1.5rem;
    opacity: 0.6;
}

.du-uploader .du-progress {
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: 8px;
    height: 6px;
    background: #e9ecef;
    border-radius: 3px;
    overflow: hidden;
}

.du-uploader .du-progress-bar {
    height: 100%;
    width: 0;
    background: var(--primary, #377dff);
    border-radius: 3px;
    transition: width 0.15s linear;
}

/* Profile photo variant --------------------------------------------------
   One shared uploader runtime; only the single-image profile presentation
   changes. Storefront theme tokens remain the source of color and focus. */
.du-uploader--profile {
    --du-profile-ink: var(--st-ink, #1b1712);
    --du-profile-muted: var(--st-muted, #8b8479);
    --du-profile-surface: var(--st-surface, #f7f5f0);
    --du-profile-field: #faf8f3;
    --du-profile-line: var(--st-line-2, rgba(27, 23, 18, 0.14));
    --du-profile-gold: var(--st-gold, #a9743f);
    --du-profile-gold-soft: rgba(169, 116, 63, 0.12);
    max-width: 680px;
}

.du-uploader--profile .du-grid {
    display: block;
    width: 100%;
}

.du-uploader--profile .du-add,
.du-uploader--profile .du-tile {
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr) auto;
    align-items: center;
    width: 100%;
    height: auto;
    min-height: 126px;
    gap: 18px;
    overflow: visible;
    border: 1px solid var(--du-profile-line);
    border-radius: 20px;
    background: var(--du-profile-field);
    padding: 18px;
    color: var(--du-profile-ink);
    text-align: left;
    transition: border-color 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease;
}

.du-uploader--profile .du-add:hover,
.du-uploader--profile .du-add.du-dragover {
    border-color: var(--du-profile-gold);
    background: var(--du-profile-surface);
    color: var(--du-profile-ink);
    box-shadow: 0 16px 35px -30px rgba(70, 42, 14, 0.8);
}

.du-uploader--profile .du-add:focus-visible,
.du-uploader--profile .du-act:focus-visible {
    outline: 3px solid var(--st-focus, #075dcc);
    outline-offset: 3px;
}

.du-uploader--profile .du-profile-avatar,
.du-uploader--profile .du-profile-photo {
    position: relative;
    display: grid;
    place-items: center;
    width: 88px;
    height: 88px;
}

.du-uploader--profile .du-profile-avatar,
.du-uploader--profile .du-profile-photo .du-thumb {
    overflow: hidden;
    border: 1px solid rgba(169, 116, 63, 0.22);
    border-radius: 24px;
    background: var(--du-profile-gold-soft);
    color: var(--du-profile-gold);
}

.du-uploader--profile .du-profile-avatar > .la,
.du-uploader--profile .du-profile-photo .du-thumb > .la {
    font-size: 30px;
    line-height: 1;
}

.du-uploader--profile .du-profile-photo .du-thumb,
.du-uploader--profile .du-profile-photo .du-thumb img {
    width: 100%;
    height: 100%;
}

.du-uploader--profile .du-profile-camera {
    position: absolute;
    right: -3px;
    bottom: -3px;
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border: 3px solid var(--du-profile-field);
    border-radius: 50%;
    background: var(--du-profile-ink);
    color: #fff;
    font-size: 13px;
    line-height: 1;
}

.du-uploader--profile .du-profile-copy {
    min-width: 0;
}

.du-uploader--profile .du-profile-copy strong,
.du-uploader--profile .du-profile-copy > span,
.du-uploader--profile .du-profile-copy small {
    display: block;
}

.du-uploader--profile .du-profile-copy strong {
    margin-bottom: 5px;
    color: var(--du-profile-ink);
    font-size: 15px;
    font-weight: 750;
    letter-spacing: -0.012em;
}

.du-uploader--profile .du-profile-copy > span,
.du-uploader--profile .du-profile-copy small {
    color: var(--du-profile-muted);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.55;
}

.du-uploader--profile .du-profile-copy .du-profile-filename {
    max-width: 310px;
    overflow: hidden;
    color: var(--du-profile-gold);
    font-size: 11.5px;
    font-weight: 750;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.du-uploader--profile .du-profile-choose,
.du-uploader--profile .du-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.du-uploader--profile .du-profile-choose {
    min-height: 44px;
    border: 1px solid var(--du-profile-ink);
    border-radius: 999px;
    background: var(--du-profile-ink);
    padding: 0 17px;
    color: #fff;
    font-size: 12.5px;
    font-weight: 800;
    line-height: 1;
}

.du-uploader--profile .du-profile-choose .la {
    font-size: 16px;
}

.du-uploader--profile .du-actions {
    position: static;
    inset: auto;
    padding: 0;
    background: transparent;
    opacity: 1;
}

.du-uploader--profile .du-act {
    min-width: 44px;
    height: 44px;
    border-radius: 999px;
    transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease;
    touch-action: manipulation;
}

.du-uploader--profile .du-replace {
    width: auto;
    gap: 7px;
    border: 1px solid var(--du-profile-ink);
    background: var(--du-profile-ink);
    padding: 0 17px;
    color: #fff;
}

.du-uploader--profile .du-replace:hover {
    background: #000;
    color: #fff;
}

.du-uploader--profile .du-remove {
    width: 44px;
    border: 1px solid rgba(176, 68, 50, 0.28);
    background: transparent;
    color: #b04432;
}

.du-uploader--profile .du-remove:hover {
    border-color: rgba(176, 68, 50, 0.5);
    background: rgba(176, 68, 50, 0.07);
    color: #a23727;
}

.du-uploader--profile .du-act-label {
    font-size: 12.5px;
    font-weight: 800;
    line-height: 1;
}

.du-uploader--profile .du-uploading {
    grid-template-columns: 88px minmax(0, 1fr);
}

.du-uploader--profile .du-replacing {
    display: none;
}

.du-uploader--profile .du-uploading .du-progress {
    position: relative;
    inset: auto;
    width: min(310px, 100%);
    height: 5px;
    margin-top: 10px;
    background: rgba(27, 23, 18, 0.1);
}

.du-uploader--profile .du-uploading .du-progress-bar {
    background: var(--du-profile-gold);
}

.du-uploader--profile .du-error {
    margin-top: 8px;
    font-weight: 650;
}

@media (max-width: 620px) {
    .du-uploader--profile .du-add,
    .du-uploader--profile .du-tile {
        grid-template-columns: 72px minmax(0, 1fr);
        min-height: 0;
        gap: 14px;
        border-radius: 18px;
        padding: 15px;
    }

    .du-uploader--profile .du-profile-avatar,
    .du-uploader--profile .du-profile-photo {
        width: 72px;
        height: 72px;
    }

    .du-uploader--profile .du-profile-avatar,
    .du-uploader--profile .du-profile-photo .du-thumb {
        border-radius: 20px;
    }

    .du-uploader--profile .du-profile-choose,
    .du-uploader--profile .du-actions {
        grid-column: 1 / -1;
        width: 100%;
    }

    .du-uploader--profile .du-profile-choose,
    .du-uploader--profile .du-replace {
        flex: 1 1 auto;
        justify-content: center;
    }

    .du-uploader--profile .du-uploading {
        grid-template-columns: 72px minmax(0, 1fr);
    }
}

@media (prefers-reduced-motion: reduce) {
    .du-uploader--profile .du-add,
    .du-uploader--profile .du-tile,
    .du-uploader--profile .du-act,
    .du-uploader--profile .du-progress-bar {
        transition-duration: 0.01ms;
    }
}
