/**
 * SMR Modal - Frontend Styles
 */

/* Overlay */
.smr-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.smr-modal-overlay.smr-modal-open {
    opacity: 1;
}

/* Container */
.smr-modal-container {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-width: 90%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.smr-modal-open .smr-modal-container {
    transform: scale(1);
}

/* Size variants */
.smr-modal-small {
    width: 400px;
}

.smr-modal-medium {
    width: 600px;
}

.smr-modal-large {
    width: 800px;
}

.smr-modal-xlarge {
    width: 1000px;
}

/* Content */
.smr-modal-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0; /* Critical: Allow flex children to shrink */
    position: relative;
}

/* Close button (X) */
.smr-modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
    z-index: 10;
}

.smr-modal-close:hover {
    background-color: #f0f0f0;
    color: #333;
}

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

/* Body */
.smr-modal-body {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 30px;
    padding-top: 50px; /* Space for close button */
    padding-bottom: 30px; /* Extra space at bottom */
    min-height: 0; /* Critical for flex scrolling */
}

/* Add extra spacing before last element to prevent footer overlap */
.smr-modal-body > *:last-child {
    margin-bottom: 20px;
}

/* Ensure forms have proper spacing */
.smr-modal-body form {
    margin-bottom: 0;
}

.smr-modal-body form button,
.smr-modal-body form input[type="submit"] {
    margin-bottom: 10px;
}

/* Footer */
.smr-modal-footer {
    padding: 20px 30px;
    border-top: 1px solid #e0e0e0;
    background-color: #f9f9f9;
    display: flex;
    justify-content: center;
    flex-shrink: 0; /* Don't allow footer to shrink */
    margin-top: auto; /* Push to bottom */
}

/* Close button (bottom) */
.smr-modal-close-btn {
    padding: 10px 30px;
    background-color: #0073aa;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.smr-modal-close-btn:hover {
    background-color: #005177;
}

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

/* Loading state */
.smr-modal-loading {
    text-align: center;
    padding: 40px;
    color: #666;
    font-size: 16px;
}

.smr-modal-loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    margin-left: 10px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #0073aa;
    border-radius: 50%;
    animation: smr-spin 1s linear infinite;
}

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

/* Error state */
.smr-modal-error {
    text-align: center;
    padding: 40px;
    color: #dc3232;
    font-size: 16px;
}

/* Modal trigger links/buttons */
.smr-modal-trigger {
    cursor: pointer;
}

/* Responsive */
@media (max-width: 768px) {
    .smr-modal-container {
        width: 95% !important;
        max-width: 95%;
        max-height: 95vh;
    }
    
    .smr-modal-body {
        padding: 20px;
        padding-top: 50px;
    }
    
    .smr-modal-footer {
        padding: 15px 20px;
    }
}

/* WordPress block editor content styles */
.smr-modal-body .wp-block-image img {
    max-width: 100%;
    height: auto;
}

.smr-modal-body .wp-block-group,
.smr-modal-body .wp-block-columns {
    margin-bottom: 1em;
}

.smr-modal-body p {
    margin-bottom: 1em;
}

.smr-modal-body h1,
.smr-modal-body h2,
.smr-modal-body h3,
.smr-modal-body h4,
.smr-modal-body h5,
.smr-modal-body h6 {
    margin-top: 1em;
    margin-bottom: 0.5em;
}

/* Form styles */
.smr-modal-body input[type="text"],
.smr-modal-body input[type="email"],
.smr-modal-body input[type="tel"],
.smr-modal-body input[type="number"],
.smr-modal-body textarea,
.smr-modal-body select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    margin-bottom: 10px;
}

.smr-modal-body input[type="submit"],
.smr-modal-body button[type="submit"] {
    padding: 10px 20px;
    background-color: #0073aa;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.smr-modal-body input[type="submit"]:hover,
.smr-modal-body button[type="submit"]:hover {
    background-color: #005177;
}

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

.smr-modal-container:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}
