/* --- Crop & Share Button in DFlip toolbar --- */

.hp-crop-share-btn {
    display: inline-flex !important;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    font-size: 12px !important;
    line-height: 1.2 !important;
    text-indent: 0 !important;
    overflow: visible !important;
    width: auto !important;
    min-width: auto !important;
    max-width: none !important;
    height: auto !important;
    padding: 8px 14px !important;
    margin: 0 4px !important;
}

.hp-crop-share-btn .hp-crop-icon {
    font-style: normal;
    font-size: 14px !important;
    line-height: 1.2 !important;
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.hp-crop-share-btn .hp-crop-label {
    font-size: 12px !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-weight: 600;
    color: #333 !important;
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    line-height: 1.2 !important;
    text-indent: 0 !important;
    width: auto !important;
    height: auto !important;
    overflow: visible !important;
    white-space: nowrap !important;
}

.hp-crop-share-btn:hover .hp-crop-label,
.hp-crop-share-btn.df-active .hp-crop-label {
    color: #ff9800;
}

.hp-crop-share-btn.df-active {
    color: #ff9800;
}

/* --- Crop Overlay (fixed on body, not inside DFlip DOM) --- */

#hp-crop-overlay {
    display: none;
    position: fixed;
    z-index: 2147483640;
    cursor: crosshair;
    background: rgba(0, 0, 0, 0.15);
}

#hp-crop-box {
    position: absolute;
    display: none;
    border: 2px solid #ff9800;
    background: rgba(255, 152, 0, 0.08);
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45);
    cursor: move;
    z-index: 1;
}

/* Resize handles */
.hp-ch {
    position: absolute;
    width: 14px;
    height: 14px;
    background: #ff9800;
    border: 2px solid #fff;
    border-radius: 2px;
    z-index: 2;
}
.hp-tl { top: -8px; left: -8px; cursor: nw-resize; }
.hp-tr { top: -8px; right: -8px; cursor: ne-resize; }
.hp-bl { bottom: -8px; left: -8px; cursor: sw-resize; }
.hp-br { bottom: -8px; right: -8px; cursor: se-resize; }

/* --- Share Modal --- */

#hp-share-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 2147483647;
    align-items: center;
    justify-content: center;
}

.hp-share-wrap {
    background: #fff;
    border-radius: 12px;
    width: 90%;
    max-width: 480px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    max-height: 90vh;
    overflow-y: auto;
}

.hp-share-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
}
.hp-share-head h3 {
    margin: 0;
    font-size: 18px;
    color: #333;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
#hp-share-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #999;
    padding: 0 5px;
    line-height: 1;
}
#hp-share-close:hover { color: #333; }

.hp-share-preview {
    padding: 20px;
    text-align: center;
    background: #222;
    max-height: 350px;
    overflow: auto;
}
.hp-share-preview img {
    max-width: 100%;
    max-height: 300px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.hp-share-btns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 20px;
}

.hsb {
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    color: #fff;
    transition: background 0.2s;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.hsb.dl { background: #0073aa; }
.hsb.dl:hover { background: #005f8d; }
.hsb.wa { background: #25D366; }
.hsb.wa:hover { background: #1da851; }
.hsb.tw { background: #1da1f2; }
.hsb.tw:hover { background: #0d8ecf; }
.hsb.fb { background: #4267B2; }
.hsb.fb:hover { background: #365899; }
.hsb.cp { background: #666; }
.hsb.cp:hover { background: #555; }

#hp-crop-cancel-wrap {
    padding: 0 20px 20px;
    text-align: center;
}
#hp-crop-cancel-btn {
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 10px 30px;
    font-size: 14px;
    cursor: pointer;
    color: #555;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
#hp-crop-cancel-btn:hover { background: #e0e0e0; }

/* --- Loading spinner --- */

.hp-crop-loading {
    padding: 40px 20px;
    text-align: center;
    color: #666;
    font-size: 14px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.hp-crop-loading::before {
    content: '';
    display: block;
    width: 30px;
    height: 30px;
    margin: 0 auto 12px;
    border: 3px solid #eee;
    border-top-color: #ff9800;
    border-radius: 50%;
    animation: hp-spin 0.8s linear infinite;
}
@keyframes hp-spin { to { transform: rotate(360deg); } }

/* --- Toast --- */

.hp-toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #333;
    color: #fff;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 2147483647;
    opacity: 0;
    transition: all 0.3s;
    pointer-events: none;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.hp-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* --- Mobile --- */

@media (max-width: 768px) {
    .hp-crop-share-btn .hp-crop-label {
        display: none;
    }
    .hp-crop-icon {
        font-size: 16px;
    }
    .hp-share-btns {
        grid-template-columns: 1fr;
    }
    #hp-crop-box {
        min-width: 40px;
        min-height: 40px;
    }
}
