/**
 * Micromodal.js - Lightweight Modal Library
 * Custom styling for CNM Popup Modal System
 */

/* Base Modal Container */
.micromodal-container {
    display: none;
}

.micromodal-container[aria-hidden="false"] {
    display: block;
}

/* Overlay Backdrop */
.micromodal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease-out;
}

/* Modal Dialog */
.micromodal-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 90vw;
    max-height: 90vh;
    width: 600px;
    background: white;
    border-radius: 4px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 1001;
    overflow: hidden;
    animation: slideIn 0.3s ease-out;
    display: flex;
    flex-direction: column;
}

/* Modal Size Variants */
/* Default: 600px (set on .micromodal-modal base) */
.micromodal-modal.modal-sm {
    width: 400px;  /* Small: 400px */
}

.micromodal-modal.modal-lg {
    width: 800px;  /* Large: 800px */
}

.micromodal-modal.modal-xl {
    width: 1000px; /* Extra Large: 1000px */
}

/* Modal Header */
.micromodal-header {
    padding: 20px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.micromodal-title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: #333;
    flex: 1;
}

/* Close Button */
.micromodal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: color 0.2s ease;
    flex-shrink: 0;
    position: relative;
    z-index: 1002;
}

.micromodal-close::before {
    content: "×";
    display: block;
}

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

.micromodal-close:active {
    outline: 2px solid #0073aa;
}

.micromodal-close:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Modal Body */
.micromodal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    font-size: 1rem;
    line-height: 1.6;
    color: #333;
}

/* Ensure content readability */
.micromodal-body p {
    margin: 0 0 15px 0;
}

.micromodal-body p:last-child {
    margin-bottom: 0;
}

.micromodal-body strong {
    font-weight: 600;
}

.micromodal-body img {
    max-width: 100%;
    height: auto;
    display: block;
}

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

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translate(-50%, -60%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .micromodal-modal,
    .micromodal-modal.modal-lg,
    .micromodal-modal.modal-xl {
        width: 95vw;
        max-width: 95vw;
        max-height: 95vh;
    }

    .micromodal-header {
        padding: 15px;
    }

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

    .micromodal-body {
        padding: 15px;
    }
}

/* Accessibility */
.micromodal-modal:focus {
    outline: none;
}

/* State Classes */
.micromodal-container.is-open .micromodal-overlay {
    animation: fadeIn 0.3s ease-out;
}

.micromodal-container.is-open .micromodal-modal {
    animation: slideIn 0.3s ease-out;
}

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