/**
 * Modal system styles
 *
 * @link       https://freelancementors.com
 * @since      1.0.0
 */

/* Modal Container */
.fmjt-modal-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999999;
    display: none;
    -webkit-overflow-scrolling: touch;
}

.fmjt-modal-container.fmjt-modal-visible {
    display: flex;
}

/* Modal Backdrop */
.fmjt-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.fmjt-modal-visible .fmjt-modal-backdrop {
    opacity: 1;
}

/* Modal Dialog */
.fmjt-modal-dialog {
    position: relative;
    width: 100%;
    height: 100%;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    transform: translateY(-20px);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.fmjt-modal-visible .fmjt-modal-dialog {
    transform: translateY(0);
    opacity: 1;
}

/* Modal Frame (Parent) */
.fmjt-modal-frame {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 90vw;
    max-height: 90vh;
    background-image: url('../images/journal-open_v01.svg');
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    
    /* Maintain SVG aspect ratio (1600x1150 = 1.39:1) */
    aspect-ratio: 1.39;
    
    /* Ensure the frame scales to fit within viewport while maintaining aspect ratio */
    width: min(90vw, calc(90vh * 1.39));
    height: min(90vh, calc(90vw / 1.39));
}

/* Content Window (Child) */
.fmjt-modal-content-window {
    width: 85%;
    height: 75%;
    margin-top: -50px;
    /* background-color: #f2ebdc; */
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 300px;
    min-height: 200px;
}

/* Modal Header */
.fmjt-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    border-bottom: 1px solid #e0e0e0;
    /* background-color: #f2ebdc; */
    flex-shrink: 0;
}

.fmjt-modal-title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: #333;
}

.fmjt-modal-close {
    padding: 0.5rem;
    background: none;
    border: none;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.3s ease;
}

.fmjt-modal-close:hover {
    opacity: 1;
}

.fmjt-modal-close svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

/* Modal Navigation */
.fmjt-modal-nav {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background-color: #f5f5f5;
    border-radius: 4px;
    margin: 1rem;
    flex-shrink: 0;
}

.fmjt-modal-nav-item {
    padding: 0.5rem 1rem;
    background: none;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    color: #666;
    transition: all 0.3s ease;
}

.fmjt-modal-nav-item:hover {
    background-color: #e0e0e0;
    color: #333;
}

.fmjt-modal-nav-item.active {
    background-color: #4CAF50;
    color: #fff;
}

/* Modal Content */
.fmjt-modal-content {
    position: relative;
    padding: 1.5rem;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    /* background-color: #f2ebdc; */
}

/* Control SVG sizes within modal content */
.fmjt-modal-content svg {
    width: 32px;
    height: 32px;
    max-width: 100%;
    max-height: 100%;
    display: inline-block;
    vertical-align: middle;
}

/* Allow specific size classes to override default size */
.fmjt-modal-content svg.fmjt-icon-small {
    width: 24px;
    height: 24px;
}

.fmjt-modal-content svg.fmjt-icon-medium {
    width: 32px;
    height: 32px;
}

.fmjt-modal-content svg.fmjt-icon-large {
    width: 48px;
    height: 48px;
}

/* Loading State */
.fmjt-loading {
    position: relative;
    pointer-events: none;
}

.fmjt-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #4CAF50;
    border-radius: 50%;
    animation: fmjt-spin 1s linear infinite;
}

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

/* Error State */
.fmjt-modal-error {
    padding: 1rem;
    margin: 1rem 0;
    background-color: #ffebee;
    border: 1px solid #ffcdd2;
    border-radius: 4px;
    color: #c62828;
    text-align: center;
}

/* Body Lock */
body.fmjt-modal-open {
    overflow: hidden;
    padding-right: var(--scrollbar-width, 0);
}

/* Responsive Design */
@media screen and (max-width: 1200px) {
    .fmjt-modal-dialog {
        padding: 1rem;
    }
    
    .fmjt-modal-content-window {
        width: 85%;
        height: 75%;
    }
}

@media screen and (max-width: 768px) {
    .fmjt-modal-dialog {
        padding: 0.5rem;
    }
    
    .fmjt-modal-content-window {
        width: 80%;
        height: 70%;
        min-width: 250px;
        min-height: 200px;
    }

    .fmjt-modal-header {
        padding: 1rem;
    }

    .fmjt-modal-content {
        padding: 1rem;
    }

    .fmjt-modal-nav {
        flex-wrap: wrap;
        margin: 0.5rem;
    }
}

@media screen and (max-width: 480px) {
    .fmjt-modal-content-window {
        width: 75%;
        height: 65%;
        min-width: 200px;
        min-height: 150px;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .fmjt-modal-dialog,
    .fmjt-modal-backdrop,
    .fmjt-modal-close {
        transition: none;
    }
}

/* High Contrast Mode */
@media (forced-colors: active) {
    .fmjt-modal-content-window {
        border: 2px solid ButtonText;
    }

    .fmjt-modal-close {
        border: 1px solid ButtonText;
    }

    .fmjt-modal-nav-item.active {
        border: 2px solid ButtonText;
    }
}