/* ============================= */
/* UI MODAL BASE STYLES */
/* ============================= */

.ui-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    font-family: var(--font-body, sans-serif);
}

.ui-modal.show {
    display: block;
}

.ui-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(44, 62, 80, 0.5);
    backdrop-filter: blur(3px);
}

.ui-modal-content {
    position: relative;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    margin: 50px auto;
    background-color: var(--light-color, #f8f9fa);
    border-radius: 1rem;
    box-shadow: 0 20px 40px rgba(44, 62, 80, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Changed from overflow-y: auto */
    animation: ui-modal-slide-in 0.3s ease;
}

.ui-modal-header {
    display: flex;
    justify-content: flex-end;
    padding: 1rem;
    border-bottom: 2px solid var(--primary-color, #4361ee);
    background: inherit;
    border-radius: 1rem 1rem 0 0;
    flex-shrink: 0; /* Prevent header from shrinking */
}

.ui-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.5rem;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    color: var(--dark-color, #2c3e50);
    transition: all 0.2s ease;
}

.ui-modal-close:hover {
    background-color: rgba(67, 97, 238, 0.1);
    color: var(--primary-color, #4361ee);
    transform: rotate(90deg);
}

.ui-modal-body {
    padding: 2rem;
    color: var(--dark-color, #2c3e50);
    overflow-y: auto; /* Moved scrollbar to body only */
    flex: 1; /* Take remaining space */
    
    /* Custom scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color, #4361ee) rgba(67, 97, 238, 0.1);
}

/* Webkit scrollbar styling (Chrome, Safari, Edge) */
.ui-modal-body::-webkit-scrollbar {
    width: 8px;
}

.ui-modal-body::-webkit-scrollbar-track {
    background: rgba(67, 97, 238, 0.1);
    border-radius: 0 0 1rem 0; /* Rounded corner at bottom */
}

.ui-modal-body::-webkit-scrollbar-thumb {
    background-color: var(--primary-color, #4361ee);
    border-radius: 4px;
    border: 2px solid transparent;
    background-clip: content-box;
}

.ui-modal-body::-webkit-scrollbar-thumb:hover {
    background-color: var(--secondary-color, #3a0ca3);
}

/* Ensure last child doesn't get cut off by scrollbar */
.ui-modal-body > *:last-child {
    margin-bottom: 0;
}


.ui-modal img {
    width: 100%;
    border-radius: 6px;
    object-fit: contain;
    max-height: 300px;
}

.view-media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.view-media-card {
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 4/3;
  background: #f0f0f0;
}
.view-media-card img,
.view-media-card video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ============================= */
/* UI MODAL GALLERY VARIANT */
/* ============================= */

.ui-modal.ui-modal-gallery .ui-modal-content {
    max-width: 900px;
    background-color: transparent;
    box-shadow: none;
    overflow: visible; /* Gallery doesn't need scrolling */
}

.ui-modal.ui-modal-gallery .ui-modal-header {
    background: transparent;
    border-bottom: none;
}

.ui-modal.ui-modal-gallery .ui-modal-close {
    background: rgba(248, 249, 250, 0.2);
    color: var(--light-color, #f8f9fa);
    backdrop-filter: blur(5px);
}

.ui-modal.ui-modal-gallery .ui-modal-close:hover {
    background: var(--primary-color, #4361ee);
    color: var(--light-color, #f8f9fa);
}

.ui-gallery-container {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    min-height: 400px;
    background: transparent;
}

.ui-gallery-image {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    border-radius: 0.5rem;
    box-shadow: 0 20px 40px rgba(44, 62, 80, 0.3);
}

.ui-gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(67, 97, 238, 0.2);
    color: var(--light-color, #f8f9fa);
    border: none;
    padding: 1rem 1.2rem;
    cursor: pointer;
    font-size: 1.2rem;
    border-radius: 0.5rem;
    backdrop-filter: blur(5px);
    transition: all 0.2s ease;
    border: 1px solid rgba(248, 249, 250, 0.1);
}

.ui-gallery-nav:hover {
    background: var(--primary-color, #4361ee);
    transform: translateY(-50%) scale(1.1);
    border-color: var(--light-color, #f8f9fa);
}

.ui-gallery-prev {
    left: 1rem;
}

.ui-gallery-next {
    right: 1rem;
}

/* ============================= */
/* UI MODAL FORM STYLES */
/* ============================= */

.ui-modal .ui-form {
    width: 100%;
    max-width: 100%;
    background: transparent;
    padding: 0;
    box-shadow: none;
}

.ui-modal .form-group {
    margin-bottom: 1.5rem;
}

.ui-modal .form-group:last-child {
    margin-bottom: 0;
}

.ui-modal label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--secondary-color, #3a0ca3);
    margin-bottom: 0.35rem;
    letter-spacing: 0.3px;
}

.ui-modal input,
.ui-modal select,
.ui-modal textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 0.6rem;
    border: 1px solid rgba(44, 62, 80, 0.2);
    font-size: 0.95rem;
    font-family: var(--font-body, sans-serif);
    transition: all 0.2s ease;
    background: var(--light-color, #f8f9fa);
    color: var(--dark-color, #2c3e50);
}

.ui-modal input:focus,
.ui-modal select:focus,
.ui-modal textarea:focus {
    border-color: var(--primary-color, #4361ee);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.2);
    outline: none;
}

.ui-modal input::placeholder,
.ui-modal textarea::placeholder {
    color: rgba(44, 62, 80, 0.4);
}

.ui-modal .form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
    flex-shrink: 0;
}

.ui-modal .btn {
    padding: 0.7rem 1.4rem;
    border-radius: 0.6rem;
    border: none;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-body, sans-serif);
    transition: all 0.2s ease;
}

.ui-modal .btn-primary {
    background: var(--primary-color, #4361ee);
    color: var(--light-color, #f8f9fa);
}

.ui-modal .btn-primary:hover {
    background: var(--secondary-color, #3a0ca3);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(67, 97, 238, 0.3);
}

.ui-modal .btn-secondary {
    background: rgba(44, 62, 80, 0.1);
    color: var(--dark-color, #2c3e50);
    border: 1px solid rgba(44, 62, 80, 0.2);
}

.ui-modal .btn-secondary:hover {
    background: var(--dark-color, #2c3e50);
    color: var(--light-color, #f8f9fa);
    transform: translateY(-2px);
}

/* ============================= */
/* UI MODAL STATUS VARIANTS */
/* ============================= */

.ui-modal.success .ui-modal-header {
    border-bottom-color: var(--success-color, #2ecc71);
}

.ui-modal.success .ui-modal-close:hover {
    color: var(--success-color, #2ecc71);
}

.ui-modal.success .ui-modal-body::-webkit-scrollbar-thumb {
    background-color: var(--success-color, #2ecc71);
}

.ui-modal.warning .ui-modal-header {
    border-bottom-color: var(--warning-color, #f39c12);
}

.ui-modal.warning .ui-modal-close:hover {
    color: var(--warning-color, #f39c12);
}

.ui-modal.warning .ui-modal-body::-webkit-scrollbar-thumb {
    background-color: var(--warning-color, #f39c12);
}

.ui-modal.danger .ui-modal-header {
    border-bottom-color: var(--danger-color, #e74c3c);
}

.ui-modal.danger .ui-modal-close:hover {
    color: var(--danger-color, #e74c3c);
}

.ui-modal.danger .ui-modal-body::-webkit-scrollbar-thumb {
    background-color: var(--danger-color, #e74c3c);
}

/* ============================= */
/* UI MODAL SIZES */
/* ============================= */

.ui-modal.small .ui-modal-content {
    max-width: 400px;
}

.ui-modal.large .ui-modal-content {
    max-width: 800px;
}

.ui-modal.xlarge .ui-modal-content {
    max-width: 1100px;
}

.ui-modal.fullscreen .ui-modal-content {
    max-width: 95%;
    height: 95vh;
    margin: 2.5vh auto;
}

/* ============================= */
/* ANIMATIONS */
/* ============================= */

@keyframes ui-modal-slide-in {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes ui-modal-fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes ui-modal-scale-in {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Animation variants */
.ui-modal.slide-in .ui-modal-content {
    animation: ui-modal-slide-in 0.3s ease;
}

.ui-modal.fade-in .ui-modal-content {
    animation: ui-modal-fade-in 0.3s ease;
}

.ui-modal.scale-in .ui-modal-content {
    animation: ui-modal-scale-in 0.3s ease;
}

/* ============================= */
/* RESPONSIVE ADJUSTMENTS */
/* ============================= */

@media (max-width: 768px) {
    .ui-modal-content {
        width: 95%;
        margin: 30px auto;
    }
    
    .ui-modal-body {
        padding: 1.5rem;
    }
    
    .ui-gallery-container {
        min-height: 300px;
    }
    
    .ui-gallery-nav {
        padding: 0.8rem 1rem;
    }
    
    .ui-modal.small .ui-modal-content,
    .ui-modal.large .ui-modal-content,
    .ui-modal.xlarge .ui-modal-content {
        max-width: 95%;
    }
    
    /* Adjust scrollbar for mobile */
    .ui-modal-body::-webkit-scrollbar {
        width: 4px;
    }
}

@media (max-width: 480px) {
    .ui-modal-body {
        padding: 1rem;
    }
    
    .ui-modal .form-actions {
        flex-direction: column;
    }
    
    .ui-modal .form-actions button {
        width: 100%;
    }
}

/* ============================= */
/* FIREFOX SCROLLBAR FIXES */
/* ============================= */

/* Ensure border radius is preserved in Firefox */
.ui-modal-content {
    scrollbar-width: none; /* Hide Firefox scrollbar on container */
}

.ui-modal-body {
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color, #4361ee) rgba(67, 97, 238, 0.1);
    
    /* Firefox border radius fix */
    mask-image: radial-gradient(white, black);
    -webkit-mask-image: radial-gradient(white, black);
}

/* ============================= */
/* SCROLLBAR CONTAINER FIX */
/* ============================= */

/* Add a wrapper for content that needs scrolling */
.ui-modal-scrollable {
    overflow-y: auto;
    flex: 1;
    
    /* Custom scrollbar */
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color, #4361ee) rgba(67, 97, 238, 0.1);
}

.ui-modal-scrollable::-webkit-scrollbar {
    width: 8px;
}

.ui-modal-scrollable::-webkit-scrollbar-track {
    background: rgba(67, 97, 238, 0.1);
    border-radius: 0 0 1rem 0;
}

.ui-modal-scrollable::-webkit-scrollbar-thumb {
    background-color: var(--primary-color, #4361ee);
    border-radius: 4px;
    border: 2px solid transparent;
    background-clip: content-box;
}

/* Ensure content inside scrollable area doesn't affect border radius */
.ui-modal-scrollable > *:last-child {
    margin-bottom: 0;
}

.video-thumbnail {
        position: relative;
        width: 100%;
        height: 172px;
        overflow: hidden;
        border-radius: .75rem;
    }
    
    .video-thumbnail video {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
    
    .video-thumbnail:hover .video-play-icon {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.1);
    }
    
    .ui-gallery-video {
        max-width: 100%;
        max-height: 70vh;
        border-radius: 0.5rem;
        box-shadow: 0 20px 40px rgba(44, 62, 80, 0.3);
    }
    
    .ui-gallery-media-container {
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 400px;
    }
    
    .ui-gallery-counter {
        position: absolute;
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
        background: rgba(0, 0, 0, 0.6);
        color: white;
        padding: 0.5rem 1rem;
        border-radius: 2rem;
        font-size: 0.9rem;
        backdrop-filter: blur(5px);
        z-index: 10;
    }

    .ui-modal input[type=checkbox],
    .ui-modal input[type=radio] {
        width: auto;
    }

    .feature-chips {
        display: flex;
        flex-wrap: wrap;
        gap: .75rem;
    }

    .feature-chip {
        background-color: var(--primary-color);
        border-radius: 1rem;
        padding: .25rem .5rem;
    }