/* Modern Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(12px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Modern Modal Content */
.modal-content {
    position: relative;
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    width: min(96vw, 1280px);
    height: min(92vh, 900px);
    height: min(92dvh, 900px);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: hidden;
    transform: scale(0.96) translateY(12px);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active .modal-content {
    transform: scale(1) translateY(0);
}

/* Enhanced Close Button */
.close-button {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(4px);
    border: none;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
    font-size: 0;
    color: transparent;
}

.close-button:hover {
    background: rgba(0, 0, 0, 0.3);
    transform: rotate(90deg);
}

.close-button::before,
.close-button::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 2px;
    background: #ffffff;
}

.close-button::before {
    transform: rotate(45deg);
}

.close-button::after {
    transform: rotate(-45deg);
}

.modal-image-container {
    position: relative;
    overflow: auto;
    width: 100%;
    min-height: 0;
    padding: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.18);
    overscroll-behavior: contain;
}

.modal-image-container.loading::before {
    content: 'Loading image...';
    position: absolute;
    color: var(--text-muted);
    font-size: 14px;
    pointer-events: none;
}

.modal-image {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    transform-origin: center center;
    touch-action: none;
    user-select: none;
    transition: transform 0.3s ease;
}

.modal-controls {
    background-color: var(--card-bg);
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    padding: 12px 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.zoom-button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    width: 40px;
    height: 40px;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
}

.zoom-button:hover {
    background-color: var(--primary-dark);
}

.zoom-level {
    font-size: 16px;
    font-weight: bold;
    min-width: 60px;
    text-align: center;
}

.modal-title {
    background-color: var(--card-bg);
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    padding: 14px 64px 12px 20px;
    font-size: 18px;
    font-weight: bold;
    line-height: 1.25;
    text-align: left;
    min-height: 52px;
    display: flex;
    align-items: center;
}

/* Make visualizations clickable */
.visualization-container {
    position: relative;
    cursor: pointer;
    overflow: hidden;
}

.visualization-container:hover::after {
    content: '🔍';
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: var(--card-bg);
    color: var(--text-color);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 16px;
}

.visualization-container img {
    transition: transform 0.2s ease;
}

.visualization-container:hover img {
    transform: scale(1.02);
}

.star-rating {
    display: flex;
    flex-direction: row-reverse;
    justify-content: flex-end;
    padding: 10px 0;
}

.star-rating input {
    display: none;
}

.star-rating label {
    font-size: 36px;
    color: var(--border-color);
    cursor: pointer;
    transition: color 0.2s ease;
    margin: 0 3px;
}

.star-rating label:hover,
.star-rating label:hover ~ label,
.star-rating input:checked ~ label {
    color: var(--warning);
    transform: scale(1.1);
}

.checkbox-field {
    margin-bottom: 28px;
}

/* Improved checkbox styling */
.checkbox-container {
    display: flex;
    align-items: flex-start;
    position: relative;
    padding: 3px 0;
    cursor: pointer;
}

.checkbox-container input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkbox-text {
    position: relative;
    padding-left: 34px;
    font-size: 14px;
    line-height: 1.4;
    color: var(--text-color);
}

.checkbox-text:before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 22px;
    height: 22px;
    border: 2px solid rgba(56, 189, 248, 0.2);
    border-radius: 4px;
    background-color: var(--surface-elevated);
    transition: all 0.2s ease;
}

.checkbox-container input[type="checkbox"]:checked ~ .checkbox-text:before {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.checkbox-container input[type="checkbox"]:checked ~ .checkbox-text:after {
    content: '';
    position: absolute;
    left: 8px;
    top: 4px;
    width: 6px;
    height: 12px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.checkbox-container:hover .checkbox-text:before {
    border-color: var(--primary-color);
}

/* Success animation */
@keyframes checkmark-circle {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes checkmark-check {
    0% {
        height: 0;
        width: 0;
        opacity: 0;
    }
    40% {
        height: 12px;
        width: 6px;
        opacity: 1;
    }
    100% {
        height: 12px;
        width: 6px;
        opacity: 1;
    }
}

.checkmark-circle {
    width: 56px;
    height: 56px;
    position: relative;
    border-radius: 50%;
    background-color: var(--success);
    margin-bottom: 12px;
    animation: checkmark-circle 0.5s cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
}

.checkmark {
    position: absolute;
    top: 50%;
    left: 50%;
    height: 0;
    width: 0;
    margin-left: -2px;
    margin-top: -6px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    animation: checkmark-check 0.3s cubic-bezier(0.22, 0.61, 0.36, 1) 0.2s forwards;
}

.checkmark-text {
    font-size: 16px;
    font-weight: 600;
    color: var(--success);
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.5s ease 0.3s;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .modal-content {
        width: calc(100vw - 16px);
        height: calc(100vh - 16px);
        height: calc(100dvh - 16px);
        border-radius: 14px;
    }
    
    .modal-title {
        min-height: 48px;
        padding: 12px 56px 10px 14px;
        font-size: 15px;
    }

    .modal-image-container {
        padding: 8px;
    }

    .modal-controls {
        gap: 10px;
        padding: 10px;
    }
    
    .zoom-controls {
        gap: 8px;
    }
    
    .zoom-button {
        min-width: 40px;
        min-height: 40px;
        font-size: 14px;
    }

    .zoom-level {
        min-width: 50px;
        font-size: 14px;
    }
}
