/**
 * SE-Builder Popup Component Styles
 */

/* Popup Container */
.se-popup {
    position: relative;
}

/* Popup Overlay */
.se-popup-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.se-popup-overlay.se-popup-overlay-visible {
    opacity: 1;
    visibility: visible;
}

.se-popup-overlay.hidden {
    display: none;
}

.se-popup-overlay.hidden-overlay {
    background-color: transparent;
}

/* Popup Panel Base */
.se-popup-panel {
    position: fixed;
    background-color: #fff;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    border-radius: 0.75rem;
}

.se-popup-panel.se-popup-open {
    opacity: 1;
    visibility: visible;
}

/* ============ POSITION CLASSES ============ */

/* Center (default) */
.se-popup-panel.popup-position-center {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.se-popup-panel.popup-position-center.se-popup-open {
    transform: translate(-50%, -50%);
}

/* Top Center */
.se-popup-panel.popup-position-top {
    top: 2rem;
    left: 50%;
    transform: translate(-50%, -20px);
}

.se-popup-panel.popup-position-top.se-popup-open {
    transform: translate(-50%, 0);
}

/* Bottom Center */
.se-popup-panel.popup-position-bottom {
    bottom: 2rem;
    left: 50%;
    transform: translate(-50%, 20px);
}

.se-popup-panel.popup-position-bottom.se-popup-open {
    transform: translate(-50%, 0);
}

/* Top Left */
.se-popup-panel.popup-position-top-left {
    top: 2rem;
    left: 2rem;
    transform: translate(-20px, -20px);
}

.se-popup-panel.popup-position-top-left.se-popup-open {
    transform: translate(0, 0);
}

/* Top Right */
.se-popup-panel.popup-position-top-right {
    top: 2rem;
    right: 2rem;
    transform: translate(20px, -20px);
}

.se-popup-panel.popup-position-top-right.se-popup-open {
    transform: translate(0, 0);
}

/* Bottom Left */
.se-popup-panel.popup-position-bottom-left {
    bottom: 2rem;
    left: 2rem;
    transform: translate(-20px, 20px);
}

.se-popup-panel.popup-position-bottom-left.se-popup-open {
    transform: translate(0, 0);
}

/* Bottom Right */
.se-popup-panel.popup-position-bottom-right {
    bottom: 2rem;
    right: 2rem;
    transform: translate(20px, 20px);
}

.se-popup-panel.popup-position-bottom-right.se-popup-open {
    transform: translate(0, 0);
}

/* ============ SIZE CLASSES ============ */

.se-popup-panel.popup-size-small {
    width: 320px;
    max-width: 90vw;
}

.se-popup-panel.popup-size-medium {
    width: 480px;
    max-width: 90vw;
}

.se-popup-panel.popup-size-large {
    width: 640px;
    max-width: 90vw;
}

.se-popup-panel.popup-size-xl {
    width: 800px;
    max-width: 90vw;
}

.se-popup-panel.popup-size-full {
    width: calc(100vw - 4rem);
    height: calc(100vh - 4rem);
    max-width: none;
    max-height: none;
    border-radius: 0;
}

/* ============ ANIMATION CLASSES ============ */

/* Fade (default) */
.se-popup-panel.popup-animation-fade {
    opacity: 0;
}

.se-popup-panel.popup-animation-fade.se-popup-open {
    opacity: 1;
}

/* Zoom */
.se-popup-panel.popup-animation-zoom {
    transform: translate(-50%, -50%) scale(0.8);
}

.se-popup-panel.popup-animation-zoom.se-popup-open {
    transform: translate(-50%, -50%) scale(1);
}

/* Slide Down */
.se-popup-panel.popup-animation-slide-down {
    transform: translate(-50%, -100%);
}

.se-popup-panel.popup-animation-slide-down.se-popup-open {
    transform: translate(-50%, -50%);
}

/* Slide Up */
.se-popup-panel.popup-animation-slide-up {
    transform: translate(-50%, 100%);
}

.se-popup-panel.popup-animation-slide-up.se-popup-open {
    transform: translate(-50%, -50%);
}

/* Slide Left */
.se-popup-panel.popup-animation-slide-left {
    transform: translate(100%, -50%);
}

.se-popup-panel.popup-animation-slide-left.se-popup-open {
    transform: translate(-50%, -50%);
}

/* Slide Right */
.se-popup-panel.popup-animation-slide-right {
    transform: translate(-200%, -50%);
}

.se-popup-panel.popup-animation-slide-right.se-popup-open {
    transform: translate(-50%, -50%);
}

/* Bounce */
.se-popup-panel.popup-animation-bounce {
    transform: translate(-50%, -50%) scale(0);
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.se-popup-panel.popup-animation-bounce.se-popup-open {
    transform: translate(-50%, -50%) scale(1);
}

/* ============ POPUP COMPONENTS ============ */

/* Popup Header */
.se-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.se-popup-header h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: #111827;
}

/* Close Button */
.se-popup-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    background: transparent;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background-color 0.15s ease;
    color: #6b7280;
}

.se-popup-close:hover {
    background-color: #f3f4f6;
    color: #111827;
}

/* Popup Body */
.se-popup-body {
    padding: 1.5rem;
    flex: 1;
    overflow-y: auto;
}

/* Popup Footer */
.se-popup-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
}

/* Trigger Button */
.se-popup-trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    background-color: var(--primary-color, #3b82f6);
    color: #fff;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background-color 0.15s ease, transform 0.15s ease;
}

.se-popup-trigger:hover {
    background-color: var(--primary-color-dark, #2563eb);
}

.se-popup-trigger:active {
    transform: scale(0.98);
}

/* ============ RESPONSIVE ============ */

@media (max-width: 640px) {
    .se-popup-panel.popup-size-large,
    .se-popup-panel.popup-size-xl {
        width: calc(100vw - 2rem);
    }
    
    .se-popup-panel.popup-position-top,
    .se-popup-panel.popup-position-bottom,
    .se-popup-panel.popup-position-center {
        left: 50%;
    }
    
    .se-popup-panel.popup-position-top-left,
    .se-popup-panel.popup-position-top-right,
    .se-popup-panel.popup-position-bottom-left,
    .se-popup-panel.popup-position-bottom-right {
        left: 1rem;
        right: 1rem;
        width: auto;
    }
    
    .se-popup-panel.popup-size-full {
        width: 100vw;
        height: 100vh;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        transform: none !important;
    }
    
    .se-popup-header {
        padding: 0.875rem 1rem;
    }
    
    .se-popup-body {
        padding: 1rem;
    }
    
    .se-popup-footer {
        padding: 0.875rem 1rem;
    }
}

/* ============ DARK MODE SUPPORT ============ */

@media (prefers-color-scheme: dark) {
    .se-popup-panel {
        background-color: #1f2937;
        box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    }
    
    .se-popup-header {
        border-bottom-color: #374151;
    }
    
    .se-popup-header h3 {
        color: #f9fafb;
    }
    
    .se-popup-close {
        color: #9ca3af;
    }
    
    .se-popup-close:hover {
        background-color: #374151;
        color: #f9fafb;
    }
    
    .se-popup-footer {
        border-top-color: #374151;
    }
}

/* ============ BUILDER PREVIEW STYLES ============ */

/* In builder, show panel inline for editing */
.se-builder-preview .se-popup-panel {
    position: relative !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    margin-top: 1rem;
}

.se-builder-preview .se-popup-overlay {
    display: none !important;
}
