/* ==========================================================================
   Euzhan - Social Preview Module (Instagram Preview & Cropping)
   ========================================================================== */

/* Social Preview Container */
.insta-preview-wrapper {
    width: 100%;
    max-width: 320px;
    margin: 10px auto 0;
}

.insta-preview-container {
    position: relative;
    width: 100%;
    padding-bottom: 133.33%;
    /* Aspect Ratio 3:4 (1080x1440) */
    background-color: #f0f0f0;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    border-radius: 4px;
    cursor: pointer;
    /* Clickable for upload */
    transition: transform 0.2s ease;
}

.insta-preview-container:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

.insta-bg-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 1;
}

.insta-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Default to Transparent -> Theme Color Gradient */
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 40%, var(--theme-overlay-color, rgba(32, 223, 198, 0.8)) 100%);
    z-index: 2;
}

.insta-text-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    pointer-events: none;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.insta-territory {
    position: absolute;
    /* PHP Calcs Baseline Corrected */
    top: 53.9%;
    right: 5.2%;
    color: #fff;
    font-size: 12px;
    font-weight: bold;
    text-align: right;
    text-transform: uppercase;
}

.insta-category {
    position: absolute;
    /* PHP Calcs Baseline Corrected */
    top: 64.4%;
    left: 3.9%;
    color: var(--theme-color, #20dfc6);
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
}

.insta-title {
    position: absolute;
    /* PHP Calcs */
    top: 70.4%;
    left: 3.7%;
    width: 92.49%;
    color: #fff;
    font-size: 21px;
    font-weight: bold;
    line-height: 1.02;
    letter-spacing: -0.047em;
    text-transform: uppercase;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ========================================
   PREVIEW ACTIONS OVERLAY (Hover/Tap)
   ======================================== */

.preview-actions-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

/* Hide overlay if no media is loaded */
.insta-preview-container:not(.has-media) .preview-actions-overlay {
    display: none !important;
}

/* Show overlay on hover (desktop only — pointer:fine excludes touch devices) */
@media (hover: hover) and (pointer: fine) {
    .insta-preview-container:hover .preview-actions-overlay {
        opacity: 1;
        pointer-events: auto;
    }
}

/* Show overlay when tapped (mobile) */
.preview-actions-overlay.is-visible {
    opacity: 1;
    pointer-events: auto;
}

/* Pill Buttons */
.preview-action-btn {
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 10px 0;
    width: 200px;
    display: flex;
    justify-content: center;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    border: none;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

/* Filled white */
.preview-action-btn--filled {
    background: var(--resca-white);
    color: var(--resca-dark);
    border: 2px solid var(--resca-white);
}

.preview-action-btn--filled:hover {
    background: var(--resca-accent);
    border-color: var(--resca-accent);
}

/* Outline white */
.preview-action-btn--outline {
    background: transparent;
    color: var(--resca-white);
    border: 2px solid var(--resca-white);
}

.preview-action-btn--outline:hover {
    background: rgba(255, 255, 255, 0.15);
}


/* Hide overlay and text layers when cropping is active */
.insta-preview-container.cropping-active .insta-overlay,
.insta-preview-container.cropping-active .insta-text-layer,
.insta-preview-container.cropping-active .preview-actions-overlay {
    display: none !important;
}

/* During cropping: remove the padding-based height trick so Cropper.js
   can measure real dimensions. The image becomes static in the flow. */
/* Restore fixed 3:4 Aspect Ratio (Instagram Portrait) */
.insta-preview-container.cropping-active {
    padding-bottom: 133.33% !important;
    height: 0 !important;
    overflow: hidden;
    /* Hide anything outside the 3:4 box */
    cursor: default;
    background: #000;
    /* Black background for the "mask" effect */
}

/* Force Cropper.js to fill the 3:4 container exactly */
.insta-preview-container.cropping-active .cropper-container {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
}

/* Make image static so Cropper can initialize, but it will be hidden/wrapped by Cropper */
.insta-preview-container.cropping-active .insta-bg-img {
    display: block;
    /* Let Cropper handle visibility */
}

/* "Mask" everything outside the crop box (the "modal" layer) */
.cropper-modal {
    background-color: var(--resca-bg-light) !important;
    /* Match page background color */
    opacity: 1 !important;
    /* Fully hide outside area */
}

/* Crop actions bar — sits OUTSIDE the card (in the DOM flow) */
.crop-actions-bar {
    display: flex;
    justify-content: space-between;
    /* Spread buttons */
    gap: 15px;
    margin-top: 15px;
    padding: 0;
    width: 100%;
    background: transparent;
}

.crop-actions-bar .preview-action-btn {
    padding: 12px 0;
    flex: 1;
    font-size: 13px;
    font-weight: 800;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

#btn-crop-confirm {
    background: var(--resca-accent) !important;
    color: var(--resca-dark) !important;
    border: none !important;
}

#btn-crop-confirm:hover {
    background: var(--resca-dark) !important;
    color: var(--resca-accent) !important;
}

#btn-crop-cancel {
    background: transparent !important;
    color: var(--resca-dark) !important;
    border: 2px solid var(--resca-dark) !important;
}

#btn-crop-cancel:hover {
    background: var(--resca-dark) !important;
    color: var(--resca-white) !important;
}

.cropper-container {
    max-width: 100% !important;
}

.insta-preview-container:has(.preview-actions-overlay) {
    cursor: default;
}

.disclaimer-text {
    font-size: 11px;
    color: var(--resca-text-muted);
    font-style: italic;
    margin-top: 5px;
    text-align: center;
}
