/**
 * Popup Display System Styles
 * Responsive design for both image and text-only popups
 * Includes animations, accessibility features, and mobile optimization
 */

/* Popup Overlay */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.popup-overlay.active {
    display: flex;
}

.popup-overlay.visible {
    opacity: 1;
    visibility: visible;
}

/* Popup Container */
.popup-container {
    position: relative;
    max-width: 800px;
    width: auto;
    max-height: 85vh;
    overflow: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.popup-overlay.visible .popup-container {
    transform: translateY(0) scale(1);
}

/* Popup Content */
.popup-content {
    background: white;
    border-radius: 0;
    box-shadow: none;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Close Button */
.popup-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all 0.2s ease;
    backdrop-filter: blur(8px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.popup-close:hover {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.popup-close:focus {
    outline: 2px solid #FFB90F;
    outline-offset: 2px;
}

.popup-close i {
    font-size: 1.1rem;
    color: #666;
}

/* Image Container - Conditional Display */
.popup-image-container {
    position: relative;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.popup-image-container.landscape,
.popup-image-container.portrait,
.popup-image-container.square {
    width: auto;
    height: auto;
    max-height: 85vh;
}

.popup-image {
    max-width: 100%;
    max-height: 85vh;
    width: auto;
    height: auto;
    object-fit: contain;
    object-position: center;
    transition: transform 0.3s ease;
    display: block;
}

.popup-image:hover {
    transform: scale(1.0);
}

/* Text Content */
.popup-text-content {
    padding: 2rem;
}

/* Text-only popup gets more padding */
.popup-content.text-only .popup-text-content {
    padding: 2.5rem;
    text-align: center;
}

/* Image popup gets less top padding */
.popup-content.has-image .popup-text-content {
    padding-top: 1.5rem;
}

.popup-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 1rem 0;
    line-height: 1.3;
}

.popup-content.text-only .popup-title {
    font-size: 1.75rem;
    margin-bottom: 1.5rem;
}

.popup-message {
    color: #1a1a1a;
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

.popup-message p {
    margin: 0 0 1rem 0;
}

.popup-message p:last-child {
    margin-bottom: 0;
}

/* Popup Actions */
.popup-actions {
    padding: 0 2rem 2rem 2rem;
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.popup-content.text-only .popup-actions {
    padding-top: 0;
}

.popup-btn {
    padding: 0.75rem 2rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 120px;
}

.popup-btn-primary {
    background: linear-gradient(135deg, #FFB90F 0%, #FF8C00 100%);
    color: black;
    box-shadow: 0 4px 12px rgba(255, 185, 15, 0.3);
}

.popup-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(255, 185, 15, 0.4);
}

.popup-btn-primary:focus {
    outline: 2px solid #FFB90F;
    outline-offset: 2px;
}

.popup-btn-secondary {
    background: #f7fafc;
    color: #4a5568;
    border: 1px solid #e2e8f0;
}

.popup-btn-secondary:hover {
    background: #edf2f7;
    border-color: #cbd5e0;
}

/* Loading States */
.popup-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: #666;
}

.popup-loading i {
    font-size: 2rem;
    margin-right: 1rem;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Error States */
.popup-error {
    padding: 2rem;
    text-align: center;
    color: #e53e3e;
}

.popup-error i {
    font-size: 2rem;
    margin-bottom: 1rem;
    display: block;
}

/* Responsive Design */
@media (max-width: 768px) {
    .popup-overlay {
        padding: 0.5rem;
    }

    .popup-container {
        max-height: 95vh;
    }

    .popup-content {
        border-radius: 0;
    }

    .popup-close {
        top: 0.75rem;
        right: 0.75rem;
        width: 36px;
        height: 36px;
    }

    .popup-close i {
        font-size: 1rem;
    }

    .popup-text-content {
        padding: 1.5rem;
    }

    .popup-content.text-only .popup-text-content {
        padding: 2rem 1.5rem;
    }

    .popup-content.has-image .popup-text-content {
        padding-top: 1rem;
    }

    .popup-title {
        font-size: 1.25rem;
    }

    .popup-content.text-only .popup-title {
        font-size: 1.5rem;
    }

    .popup-message {
        font-size: 0.95rem;
    }

    .popup-actions {
        padding: 0 1.5rem 1.5rem 1.5rem;
        flex-direction: column;
    }

    .popup-btn {
        width: 100%;
        padding: 1rem;
    }

    /* Adjust image heights for mobile */
    .popup-container {
        max-width: 95vw;
        max-height: 80vh;
    }

    .popup-image-container,
    .popup-image-container.landscape,
    .popup-image-container.portrait,
    .popup-image-container.square {
        max-height: 80vh;
    }

    .popup-image {
        max-height: 80vh;
    }
}

@media (max-width: 480px) {
    .popup-overlay {
        padding: 0.25rem;
    }

    .popup-text-content {
        padding: 1.25rem;
    }

    .popup-content.text-only .popup-text-content {
        padding: 1.75rem 1.25rem;
    }

    .popup-title {
        font-size: 1.1rem;
    }

    .popup-content.text-only .popup-title {
        font-size: 1.35rem;
    }

    .popup-message {
        font-size: 0.9rem;
    }

    .popup-actions {
        padding: 0 1.25rem 1.25rem 1.25rem;
    }

    /* Smaller image heights for very small screens */
    .popup-container {
        max-width: 98vw;
        max-height: 75vh;
    }

    .popup-image-container,
    .popup-image-container.landscape,
    .popup-image-container.portrait,
    .popup-image-container.square {
        max-height: 75vh;
    }

    .popup-image {
        max-height: 75vh;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .popup-content {
        border: 2px solid #000;
    }

    .popup-close {
        background: white;
        border: 2px solid #000;
    }

    .popup-btn-primary {
        background: #000;
        color: white;
        border: 2px solid #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {

    .popup-overlay,
    .popup-container,
    .popup-image,
    .popup-btn {
        transition: none;
        animation: none;
    }

    .popup-overlay.visible .popup-container {
        transform: none;
    }

    .popup-loading i {
        animation: none;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .popup-content {
        background: #2d3748;
        color: #e2e8f0;
    }

    .popup-title {
        color: #f7fafc;
    }

    .popup-message {
        color: #cbd5e0;
    }

    .popup-close {
        background: rgba(45, 55, 72, 0.9);
        color: #e2e8f0;
    }

    .popup-close:hover {
        background: rgba(45, 55, 72, 1);
    }

    .popup-btn-secondary {
        background: #4a5568;
        color: #e2e8f0;
        border-color: #718096;
    }

    .popup-btn-secondary:hover {
        background: #2d3748;
        border-color: #4a5568;
    }
}

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

/* Focus styles for better accessibility */
.popup-content *:focus {
    outline: 2px solid #FFB90F;
    outline-offset: 2px;
}

/* Animation for popup entrance */
@keyframes popupSlideIn {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.popup-overlay.visible .popup-content {
    animation: popupSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Hover effects for interactive elements */
.popup-content.has-image:hover .popup-image {
    transform: scale(1.02);
}

.popup-btn:active {
    transform: translateY(1px);
}

/* Custom scrollbar for popup content */
.popup-container::-webkit-scrollbar {
    width: 6px;
}

.popup-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.popup-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.popup-container::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}