/* CODSHIPX_AI_R139_R5_R4_MEDIA_BUNDLE_UI */

#cx-r132-template-modal .cx-r132-modal-card {
    width: min(980px, calc(100vw - 36px));
}

.cx-r139-media-badge {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 2px 8px;
    border: 1px solid #dbe5ee;
    border-radius: 999px;
    background: #f8fafc;
    color: #5e6e82;
    font-size: 9.5px;
    font-weight: 800;
    white-space: nowrap;
}

.cx-r139-media-section {
    margin: 14px 0 4px;
    padding: 14px;
    border: 1px solid #dce6ee;
    border-radius: 14px;
    background: #fff;
}

.cx-r139-media-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 11px;
}

.cx-r139-media-head > div {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.cx-r139-media-head strong {
    color: #1a2d45;
    font-size: 12px;
}

.cx-r139-media-head small {
    color: #8190a2;
    font-size: 10px;
    line-height: 1.4;
}

.cx-r139-media-head > b {
    color: #668b1e;
    font-size: 10px;
    white-space: nowrap;
}

.cx-r139-dropzone {
    position: relative;
    min-height: 76px;
    display: flex !important;
    align-items: center;
    justify-content: center;
    flex-direction: column !important;
    gap: 3px !important;
    margin: 0 !important;
    padding: 12px;
    border: 1px dashed #bdcad6;
    border-radius: 12px;
    background: #f9fbfc;
    text-align: center;
    cursor: pointer;
}

.cx-r139-dropzone.dragging {
    border-color: #91be35;
    background: #f5faec;
}

.cx-r139-dropzone input {
    position: absolute;
    width: 1px !important;
    height: 1px !important;
    opacity: 0;
    pointer-events: none;
}

.cx-r139-dropzone strong {
    color: #334a63;
    font-size: 11px;
}

.cx-r139-dropzone span {
    color: #8492a4;
    font-size: 9.5px;
}

.cx-r139-media-preview {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 8px;
    margin-top: 11px;
}

.cx-r139-media-card {
    position: relative;
    min-width: 0;
    overflow: hidden;
    border: 1px solid #dfe7ee;
    border-radius: 11px;
    background: #fff;
}

.cx-r139-media-card.staged {
    border-style: dashed;
}

.cx-r139-media-card img {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    background: #eef2f5;
}

.cx-r139-media-card > span {
    position: absolute;
    top: 5px;
    left: 5px;
    min-width: 20px;
    min-height: 20px;
    display: grid;
    place-items: center;
    padding: 0 5px;
    border-radius: 999px;
    background: rgba(17, 31, 49, .82);
    color: #fff;
    font-size: 8.5px;
    font-weight: 850;
}

.cx-r139-media-card > div {
    display: flex;
    gap: 3px;
    padding: 5px;
}

.cx-r139-media-card button {
    flex: 1;
    min-width: 0;
    height: 28px;
    border: 1px solid #dce4eb;
    border-radius: 7px;
    background: #fff;
    color: #56677a;
    cursor: pointer;
}

.cx-r139-media-card button:disabled {
    opacity: .35;
    cursor: default;
}

.cx-r139-media-card button.danger {
    color: #b63345;
    border-color: #f0d1d6;
    background: #fff9fa;
}

.cx-r139-media-empty {
    grid-column: 1 / -1;
    padding: 17px;
    border: 1px dashed #dce4eb;
    border-radius: 10px;
    color: #8492a4;
    font-size: 10px;
    text-align: center;
}

.cx-r139-picker-media {
    display: block;
    margin-top: 5px;
    color: #668b1e;
    font-size: 9.5px;
    font-style: normal;
    font-weight: 800;
}

.cx-r139-bundle-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 7px;
    padding: 9px 10px;
    border: 1px solid #d9e8c4;
    border-radius: 11px;
    background: #f8fbf3;
}

.cx-r139-bundle-bar > div {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cx-r139-bundle-bar strong {
    color: #2d465f;
    font-size: 10.5px;
}

.cx-r139-bundle-bar span {
    color: #718196;
    font-size: 9.5px;
}

.cx-r139-bundle-bar button {
    min-height: 34px;
    padding: 0 12px;
    border: 0;
    border-radius: 9px;
    background: #83ad2d;
    color: #fff;
    font-size: 10px;
    font-weight: 850;
    white-space: nowrap;
    cursor: pointer;
}

.cx-r139-bundle-bar button:disabled {
    opacity: .6;
    cursor: wait;
}

.cx-r139-bundle-bar.error {
    border-color: #f0d0d5;
    background: #fff8f9;
}

.cx-r139-bundle-bar.error span {
    color: #b23c4d;
}

.cx-r139-bundle-bar.success {
    border-color: #cfe2af;
    background: #f5faec;
}

@media (max-width: 900px) {
    .cx-r139-media-preview {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 700px) {
    #cx-r132-template-modal .cx-r132-modal-card {
        width: calc(100vw - 20px);
    }

    .cx-r139-media-preview {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .cx-r139-media-head {
        flex-direction: column;
    }

    .cx-r139-bundle-bar {
        align-items: stretch;
        flex-direction: column;
    }

    .cx-r139-bundle-bar button {
        width: 100%;
        min-height: 40px;
    }
}

@media (max-width: 430px) {
    .cx-r139-media-preview {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/*
 * CODSHIPX_AI_R139_R6_R8_TEMPLATE_MODAL_SCROLL_OWNERSHIP
 *
 * Scope: Message Templates modal only.
 * The canonical R132 card has a bounded max-height and
 * overflow:hidden. Media templates can exceed that height,
 * so the card itself becomes the vertical scroll owner.
 *
 * Inbox/message-canvas scroll ownership is untouched.
 */
#cx-r132-template-modal .cx-r132-modal-card {
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scrollbar-gutter: stable;
    -webkit-overflow-scrolling: touch;
}

