/* Background remover styles */
.bg-remove-open-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 10px 16px;
    border-radius: 14px;
    border: 0;
    background: #0f9f7f;
    color: #ffffff;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 10px 22px rgba(15,159,127,.18);
}

.bg-remove-open-btn:hover {
    background: #0c7f66;
}

.bg-remove-open-btn:disabled {
    opacity: .65;
    cursor: wait;
}

.bg-remove-modal[hidden],
.bg-remove-placeholder[hidden],
#bg-remove-result[hidden],
#bg-remove-download[hidden],
#bg-remove-open-result[hidden] {
    display: none !important;
}

.bg-remove-modal {
    position: fixed;
    inset: 0;
    z-index: 21000;
    display: block;
    padding: 4vh 16px;
    background: rgba(15, 23, 42, 0.42);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    overflow: auto;
}

.bg-remove-modal__panel {
    width: min(1120px, 96vw);
    margin: 0 auto;
    overflow: hidden;
    border-radius: 26px;
    background: rgba(255,255,255,.96);
    border: 1px solid rgba(255,255,255,.82);
    box-shadow: 0 30px 90px rgba(15, 23, 42, 0.32);
}

.bg-remove-modal__bar {
    min-height: 62px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: linear-gradient(135deg, #ecfdf5 0%, #ffffff 100%);
    border-bottom: 1px solid #dbe7e5;
}

.bg-remove-modal__bar strong {
    display: block;
    color: #365f46;
    font-size: 16px;
}

#bg-remove-status {
    display: block;
    margin-top: 2px;
    color: #667085;
    font-size: 13px;
}

.bg-remove-close,
.bg-remove-download {
    min-height: 38px;
    padding: 9px 14px;
    border-radius: 12px;
    border: 1px solid #dbe7e5;
    background: #ffffff;
    color: #365f46 !important;
    font-weight: 700;
    text-decoration: none !important;
    box-shadow: 0 8px 18px rgba(16,24,40,.06);
}

.bg-remove-modal__body {
    padding: 18px;
}

.bg-remove-preview {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.bg-remove-preview__box {
    min-height: 340px;
    padding: 14px;
    border-radius: 22px;
    background: #f8fafc;
    border: 1px solid #dbe7e5;
    text-align: center;
}

.bg-remove-preview__box--result {
    background:
        linear-gradient(45deg, #eef2f7 25%, transparent 25%),
        linear-gradient(-45deg, #eef2f7 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #eef2f7 75%),
        linear-gradient(-45deg, transparent 75%, #eef2f7 75%);
    background-size: 24px 24px;
    background-position: 0 0, 0 12px, 12px -12px, -12px 0;
    background-color: #ffffff;
}

.bg-remove-preview__title {
    margin-bottom: 12px;
    color: #365f46;
    font-weight: 700;
}

.bg-remove-preview img {
    display: block;
    max-width: 100%;
    max-height: 520px;
    margin: 0 auto;
    object-fit: contain;
    border-radius: 16px;
}

.bg-remove-placeholder {
    min-height: 260px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #667085;
}

.bg-remove-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 16px;
}

.bg-remove-download {
    background: #0f9f7f;
    border-color: #0f9f7f;
    color: #ffffff !important;
}

.bg-remove-download--soft {
    background: #ffffff;
    border-color: #dbe7e5;
    color: #365f46 !important;
}

/* Photopea modal hard fix */
.photopea-modal[hidden],
#photopea-modal[hidden] {
    display: none !important;
}

.photopea-modal,
#photopea-modal {
    position: fixed !important;
    inset: 0 !important;
    z-index: 20500 !important;
    display: block !important;
    width: 100vw !important;
    height: 100vh !important;
    padding: 3vh 16px !important;
    margin: 0 !important;
    overflow: auto !important;
    background: rgba(15, 23, 42, 0.42) !important;
    backdrop-filter: blur(6px) !important;
    -webkit-backdrop-filter: blur(6px) !important;
}

.photopea-modal__panel {
    width: min(1480px, 96vw) !important;
    height: min(92vh, 980px) !important;
    margin: 0 auto !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    border-radius: 24px !important;
    background: rgba(255,255,255,.96) !important;
    border: 1px solid rgba(255,255,255,.82) !important;
    box-shadow: 0 30px 90px rgba(15, 23, 42, 0.32) !important;
}

.photopea-modal__bar {
    flex: 0 0 auto !important;
    min-height: 62px !important;
    padding: 12px 16px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 16px !important;
    background: linear-gradient(135deg, #ecfdf5 0%, #ffffff 100%) !important;
    border-bottom: 1px solid #dbe7e5 !important;
}

.photopea-modal__bar strong {
    display: block !important;
    color: #365f46 !important;
    font-size: 16px !important;
}

#photopea-status {
    display: block !important;
    margin-top: 2px !important;
    color: #667085 !important;
    font-size: 13px !important;
}

.photopea-modal__actions {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    flex-wrap: wrap !important;
}

.photopea-frame,
#photopea-frame {
    width: 100% !important;
    height: auto !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    border: 0 !important;
    display: block !important;
    background: #202020 !important;
}

.photopea-save,
.photopea-close,
.photopea-download-result {
    min-height: 38px !important;
    padding: 9px 14px !important;
    border-radius: 12px !important;
    border: 1px solid #dbe7e5 !important;
    background: #ffffff !important;
    color: #365f46 !important;
    font-weight: 700 !important;
    text-decoration: none !important;
    box-shadow: 0 8px 18px rgba(16,24,40,.06) !important;
}

.photopea-save {
    background: #0f9f7f !important;
    border-color: #0f9f7f !important;
    color: #ffffff !important;
}

.photopea-save:disabled {
    opacity: .55 !important;
    cursor: not-allowed !important;
}

.photopea-saved {
    flex: 0 0 auto !important;
    padding: 10px 16px !important;
    border-top: 1px solid #dbe7e5 !important;
    background: rgba(255,255,255,.94) !important;
    color: #667085 !important;
    font-size: 13px !important;
}

@media (max-width: 760px) {
    .bg-remove-preview {
        grid-template-columns: 1fr;
    }

    .photopea-modal,
    #photopea-modal {
        padding: 8px !important;
    }

    .photopea-modal__panel {
        width: calc(100vw - 16px) !important;
        height: calc(100vh - 16px) !important;
        border-radius: 18px !important;
    }

    .photopea-modal__bar {
        align-items: flex-start !important;
        flex-direction: column !important;
    }

    .photopea-modal__actions {
        width: 100% !important;
    }

    .photopea-save,
    .photopea-close,
    .photopea-download-result {
        flex: 1 1 auto !important;
    }
}
