/**
 * Popup Engine - Core CSS Library
 * Lightweight popup styling for generated code
 */

/* Base Popup Overlay */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
}

.popup-overlay.popup-show {
    display: flex !important;
}

/* Base Dialog Container */
.popup-dialog {
    position: relative;
    background: #ffffff;
    border-radius: 8px;
    border: 1px solid #dee2e6;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    max-width: 90vw;
    max-height: 90vh;
    width: 500px;
}

/* Header Styles */
.popup-header {
    background: #f8f9fa;
    padding: 15px 20px;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.popup-title {
    margin: 0;
    font-size: 24px;
    font-family: Arial, sans-serif;
    font-weight: bold;
    color: #333333;
}

.popup-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    transition: color 0.3s ease;
}

.popup-close:hover {
    color: #333;
}

/* Content Styles */
.popup-content {
    background: #ffffff;
    color: #333333;
    font-size: 16px;
    font-family: Arial, sans-serif;
    padding: 20px;
    line-height: 1.5;
    overflow-y: auto;
}

/* Footer Styles */
.popup-footer {
    background: #f8f9fa;
    padding: 15px 20px;
    border-top: 1px solid #dee2e6;
    text-align: right;
}

.popup-close-btn {
    background: #6c757d;
    color: #ffffff;
    font-size: 14px;
    padding: 8px 16px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.popup-close-btn:hover {
    background: #5a6268;
}

/* Position Variants */
.popup-overlay.popup-position-top-left {
    align-items: flex-start;
    justify-content: flex-start;
    padding: 20px;
}

.popup-overlay.popup-position-top-center {
    align-items: flex-start;
    justify-content: center;
    padding: 20px;
}

.popup-overlay.popup-position-top-right {
    align-items: flex-start;
    justify-content: flex-end;
    padding: 20px;
}

.popup-overlay.popup-position-center-left {
    align-items: center;
    justify-content: flex-start;
    padding: 20px;
}

.popup-overlay.popup-position-center {
    align-items: center;
    justify-content: center;
}

.popup-overlay.popup-position-center-right {
    align-items: center;
    justify-content: flex-end;
    padding: 20px;
}

.popup-overlay.popup-position-bottom-left {
    align-items: flex-end;
    justify-content: flex-start;
    padding: 20px;
}

.popup-overlay.popup-position-bottom-center {
    align-items: flex-end;
    justify-content: center;
    padding: 20px;
}

.popup-overlay.popup-position-bottom-right {
    align-items: flex-end;
    justify-content: flex-end;
    padding: 20px;
}

/* Form Type Variants */
.popup-overlay.popup-form-banner-top {
    align-items: flex-start;
    justify-content: center;
    padding: 0;
}

.popup-overlay.popup-form-banner-top .popup-dialog {
    width: 100%;
    max-width: 100%;
    border-radius: 0;
    border: none;
    border-bottom: 1px solid #dee2e6;
}

.popup-overlay.popup-form-banner-bottom {
    align-items: flex-end;
    justify-content: center;
    padding: 0;
}

.popup-overlay.popup-form-banner-bottom .popup-dialog {
    width: 100%;
    max-width: 100%;
    border-radius: 0;
    border: none;
    border-top: 1px solid #dee2e6;
}

.popup-overlay.popup-form-sidebar-left {
    align-items: stretch;
    justify-content: flex-start;
    padding: 0;
}

.popup-overlay.popup-form-sidebar-left .popup-dialog {
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    border: none;
    border-right: 1px solid #dee2e6;
    width: 300px;
}

.popup-overlay.popup-form-sidebar-right {
    align-items: stretch;
    justify-content: flex-end;
    padding: 0;
}

.popup-overlay.popup-form-sidebar-right .popup-dialog {
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    border: none;
    border-left: 1px solid #dee2e6;
    width: 300px;
}

/* Animation Base Classes */
.popup-animated {
    animation-duration: 0.3s;
    animation-fill-mode: both;
}

/* Fade Animations */
@keyframes popupFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes popupFadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

.popup-fadeIn { animation-name: popupFadeIn; }
.popup-fadeOut { animation-name: popupFadeOut; }

/* Slide Animations */
@keyframes popupSlideInDown {
    from {
        opacity: 0;
        transform: translate3d(0, -100%, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes popupSlideInUp {
    from {
        opacity: 0;
        transform: translate3d(0, 100%, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes popupSlideInLeft {
    from {
        opacity: 0;
        transform: translate3d(-100%, 0, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes popupSlideInRight {
    from {
        opacity: 0;
        transform: translate3d(100%, 0, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes popupSlideOutUp {
    to {
        opacity: 0;
        transform: translate3d(0, -100%, 0);
    }
}

@keyframes popupSlideOutDown {
    to {
        opacity: 0;
        transform: translate3d(0, 100%, 0);
    }
}

@keyframes popupSlideOutLeft {
    to {
        opacity: 0;
        transform: translate3d(-100%, 0, 0);
    }
}

@keyframes popupSlideOutRight {
    to {
        opacity: 0;
        transform: translate3d(100%, 0, 0);
    }
}

.popup-slideInDown { animation-name: popupSlideInDown; }
.popup-slideInUp { animation-name: popupSlideInUp; }
.popup-slideInLeft { animation-name: popupSlideInLeft; }
.popup-slideInRight { animation-name: popupSlideInRight; }
.popup-slideOutUp { animation-name: popupSlideOutUp; }
.popup-slideOutDown { animation-name: popupSlideOutDown; }
.popup-slideOutLeft { animation-name: popupSlideOutLeft; }
.popup-slideOutRight { animation-name: popupSlideOutRight; }

/* Bounce Animations */
@keyframes popupBounceIn {
    from, 20%, 40%, 60%, 80%, to {
        animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
    }
    0% {
        opacity: 0;
        transform: scale3d(0.3, 0.3, 0.3);
    }
    20% {
        transform: scale3d(1.1, 1.1, 1.1);
    }
    40% {
        transform: scale3d(0.9, 0.9, 0.9);
    }
    60% {
        opacity: 1;
        transform: scale3d(1.03, 1.03, 1.03);
    }
    80% {
        transform: scale3d(0.97, 0.97, 0.97);
    }
    to {
        opacity: 1;
        transform: scale3d(1, 1, 1);
    }
}

@keyframes popupBounceOut {
    20% {
        transform: scale3d(0.9, 0.9, 0.9);
    }
    50%, 55% {
        opacity: 1;
        transform: scale3d(1.1, 1.1, 1.1);
    }
    to {
        opacity: 0;
        transform: scale3d(0.3, 0.3, 0.3);
    }
}

.popup-bounceIn { animation-name: popupBounceIn; }
.popup-bounceOut { animation-name: popupBounceOut; }

/* Zoom Animations */
@keyframes popupZoomIn {
    from {
        opacity: 0;
        transform: scale3d(0.3, 0.3, 0.3);
    }
    50% {
        opacity: 1;
    }
}

@keyframes popupZoomOut {
    50% {
        opacity: 0;
        transform: scale3d(0.3, 0.3, 0.3);
    }
    to {
        opacity: 0;
    }
}

.popup-zoomIn { animation-name: popupZoomIn; }
.popup-zoomOut { animation-name: popupZoomOut; }

/* Flip Animations */
@keyframes popupFlipInX {
    from {
        transform: perspective(400px) rotate3d(1, 0, 0, 90deg);
        animation-timing-function: ease-in;
        opacity: 0;
    }
    40% {
        transform: perspective(400px) rotate3d(1, 0, 0, -20deg);
        animation-timing-function: ease-in;
    }
    60% {
        transform: perspective(400px) rotate3d(1, 0, 0, 10deg);
        opacity: 1;
    }
    80% {
        transform: perspective(400px) rotate3d(1, 0, 0, -5deg);
    }
    to {
        transform: perspective(400px);
    }
}

@keyframes popupFlipOutX {
    from {
        transform: perspective(400px);
    }
    30% {
        transform: perspective(400px) rotate3d(1, 0, 0, -20deg);
        opacity: 1;
    }
    to {
        transform: perspective(400px) rotate3d(1, 0, 0, 90deg);
        opacity: 0;
    }
}

.popup-flipInX { animation-name: popupFlipInX; }
.popup-flipOutX { animation-name: popupFlipOutX; }

/* Rotate Animations */
@keyframes popupRotateIn {
    from {
        transform-origin: center;
        transform: rotate3d(0, 0, 1, -200deg);
        opacity: 0;
    }
    to {
        transform-origin: center;
        transform: translate3d(0, 0, 0);
        opacity: 1;
    }
}

@keyframes popupRotateOut {
    from {
        transform-origin: center;
        opacity: 1;
    }
    to {
        transform-origin: center;
        transform: rotate3d(0, 0, 1, 200deg);
        opacity: 0;
    }
}

.popup-rotateIn { animation-name: popupRotateIn; }
.popup-rotateOut { animation-name: popupRotateOut; }

/* Responsive Design */
@media (max-width: 768px) {
    .popup-dialog {
        width: 95vw;
        max-width: 95vw;
        margin: 10px;
    }
    
    .popup-header {
        padding: 12px 15px;
    }
    
    .popup-content {
        padding: 15px;
        font-size: 14px;
    }
    
    .popup-footer {
        padding: 12px 15px;
    }
    
    .popup-title {
        font-size: 20px;
    }
    
    .popup-overlay.popup-form-sidebar-left .popup-dialog,
    .popup-overlay.popup-form-sidebar-right .popup-dialog {
        width: 100%;
        height: auto;
        max-height: 90vh;
        border: 1px solid #dee2e6;
        border-radius: 8px;
        margin: 20px;
    }
    
    .popup-overlay.popup-form-sidebar-left,
    .popup-overlay.popup-form-sidebar-right {
        align-items: center;
        justify-content: center;
        padding: 20px;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .popup-overlay {
        background: rgba(0, 0, 0, 0.8);
    }
    
    .popup-dialog {
        border: 2px solid #000;
    }
    
    .popup-header,
    .popup-footer {
        border-color: #000;
    }
    
    .popup-close:hover {
        background: #000;
        color: #fff;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .popup-animated,
    .popup-fadeIn,
    .popup-fadeOut,
    .popup-slideInDown,
    .popup-slideInUp,
    .popup-slideInLeft,
    .popup-slideInRight,
    .popup-slideOutUp,
    .popup-slideOutDown,
    .popup-slideOutLeft,
    .popup-slideOutRight,
    .popup-bounceIn,
    .popup-bounceOut,
    .popup-zoomIn,
    .popup-zoomOut,
    .popup-flipInX,
    .popup-flipOutX,
    .popup-rotateIn,
    .popup-rotateOut {
        animation: none !important;
    }
    
    .popup-close,
    .popup-close-btn {
        transition: none !important;
    }
}

/* Focus Management */
.popup-overlay:focus-within .popup-dialog {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

.popup-close:focus,
.popup-close-btn:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .popup-overlay {
        display: none !important;
    }
}
