/* Custom Modal System - Reusable Component */

/* Modal Container */
.cstm-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.cstm-modal.cstm-modal-open {
    opacity: 1;
    visibility: visible;
}

/* Modal Backdrop */
.cstm-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(2px);
    cursor: pointer;
}

/* Modal Container */
.cstm-modal-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    overflow-y: auto;
}

/* Modal Content */
.cstm-modal-content {
    position: relative;
    background: white;
    border-radius: 16px;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.4);
    max-width: 90vw;
    width: 60vw !important;
    max-height: 90vh;
    width: auto;
    transform: scale(0.8) translateY(50px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
}

.cstm-modal.cstm-modal-open .cstm-modal-content {
    transform: scale(1) translateY(0);
}

/* Modal Header */
.cstm-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 20px;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
}

.cstm-modal-title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: #111827;
    line-height: 1.2;
}

.cstm-modal-close {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    border-radius: 8px;
    color: #6b7280;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cstm-modal-close:hover {
    background: #f3f4f6;
    color: #374151;
    transform: scale(1.1);
}

.cstm-modal-close:active {
    transform: scale(0.95);
}

/* Modal Body */
.cstm-modal-body {
    padding: 10px;
    overflow-y: auto;
    max-height: calc(90vh - 140px);
}

/* Modal Footer */
.cstm-modal-footer {
    padding: 10px;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
    display: flex;
    justify-content: center;
    gap: 12px;
}

/* Image Modal Specific Styles */
.cstm-modal.cstm-image-modal .cstm-modal-content {
    max-width: 95vw;
    max-height: 95vh;
    width: auto;
}

.cstm-modal.cstm-image-modal .cstm-modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.cstm-image-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin-bottom: 20px;
}

.cstm-image-container img {
    max-width: 100%;
    max-height: 75vh;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.cstm-image-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #111827;
    margin: 0 0 8px 0;
}

.cstm-image-subtitle {
    font-size: 1rem;
    color: #6b7280;
    margin: 0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .cstm-modal-container {
        padding: 15px;
    }
    
    .cstm-modal-content {
        max-width: 95vw;
        max-height: 95vh;
        border-radius: 12px;
        width: 100% !important;
    }
    
    .cstm-modal-header {
        padding: 20px 20px;
    }
    
    .cstm-modal-title {
        font-size: 1.25rem;
    }
    
    .cstm-modal-body {
        padding: 20px;
        max-height: calc(95vh - 120px);
    }
    
    .cstm-modal-footer {
        padding: 15px 20px;
    }
    
    .cstm-image-container img {
        max-height: 65vh;
        border-radius: 8px;
    }
    
    .cstm-image-title {
        font-size: 1.25rem;
    }
    
    .cstm-image-subtitle {
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .cstm-modal-container {
        padding: 10px;
    }
    
    .cstm-modal-content {
        max-width: 98vw;
        max-height: 98vh;
        border-radius: 8px;
    }
    
    .cstm-modal-header {
        padding: 16px;
    }
    
    .cstm-modal-title {
        font-size: 1.125rem;
    }
    
    .cstm-modal-body {
        padding: 16px;
        max-height: calc(98vh - 100px);
    }
    
    .cstm-modal-footer {
        padding: 12px 16px;
    }
    
    .cstm-image-container {
        margin-bottom: 16px;
    }
    
    .cstm-image-container img {
        max-height: 55vh;
    }
    
    .cstm-image-title {
        font-size: 1.125rem;
    }
    
    .cstm-image-subtitle {
        font-size: 0.875rem;
    }
}

/* Animation Classes */
.cstm-modal-fade-in {
    animation: cstmModalFadeIn 0.3s ease-out;
}

.cstm-modal-fade-out {
    animation: cstmModalFadeOut 0.3s ease-in;
}

@keyframes cstmModalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(50px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes cstmModalFadeOut {
    from {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
    to {
        opacity: 0;
        transform: scale(0.8) translateY(50px);
    }
}

/* Prevent body scroll when modal is open */
body.cstm-modal-open {
    overflow: hidden;
    padding-right: 0;
}

/* Loading state */
.cstm-modal-loading .cstm-image-container {
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cstm-modal-loading .cstm-image-container::before {
    content: '';
    width: 40px;
    height: 40px;
    border: 3px solid #f3f4f6;
    border-top: 3px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
