﻿/* Modal responsive */

@media (min-width: 992px) {
    #kt_modal_file_manager .modal-dialog {
        max-width: 1200px;
    }
}

.file-manager-modal {
    width: 90vw;
    max-width: 1440px;
}

.folder_source_tree {
    border-right: var(--bs-modal-header-border-width) solid var(--bs-modal-header-border-color);
}

#file-explorer-side-bar {
    position: relative;
    display: block;
    outline-color: rgb(23, 25, 28);
    border-right: var(--bs-modal-footer-border-width) solid var(--bs-modal-footer-border-color) !important;
    min-width: 255px;
}

#file-explorer-side-bar {
    font-weight: 600;
    max-height: 650px;
}

    #file-explorer-side-bar .menu-item {
        padding: 0;
    }

#file_explorer_sidebar_menu .menu-link {
    border-radius: unset;
    margin-right: 0px;
    font-size: 1.1rem;
    font-weight: 500;
}

#file-explorer-side-bar .menu-item {
    box-shadow: -1px 0px 0px 0px var(--bs-text-gray-100);
}

#file-explorer-side-bar .menu-link.active {
    background-color: var(--bs-primary) !important;
}

    #file-explorer-side-bar .menu-link.active .menu-title {
        color: var(--bs-primary-inverse);
    }

#file-explorer-side-bar .menu-arrow::after {
    background-color: var(--bs-text-muted);
}

#file-explorer-side-bar .menu-arrow::before {
    background-color: var(--bs-text-muted);
}

#file-explorer-side-bar .menu-link.active .menu-arrow::after {
    background-color: var(--bs-primary-inverse);
}

#file-explorer-side-bar .menu-link.active .menu-arrow::before {
    background-color: var(--bs-primary-inverse);
}

#file-explorer-side-bar .menu-link:hover {
    background-color: #65656540;
}

/* Toolbar responsive */
.file_explorer_toolbar {
    flex-wrap: wrap;
    padding: 0.75rem;
    background-color: var(--bs-gray-50, #f8f9fa);
    border-radius: 0.5rem;
    margin-bottom: 1rem;
}

@media (max-width: 767.98px) {
    .file_explorer_toolbar {
        padding: 0.5rem;
    }
}

/* File gallery responsive */
#file-explorer-content .file_gallery {
    display: grid;
    grid-gap: 10px;
    grid-template-columns: repeat(auto-fill, minmax(var(--file-gallery-size, 120px), 1fr));
    -webkit-user-select: none;
    user-select: none;
    outline: none;
}

/* Responsive gallery size */
@media (max-width: 575.98px) {
    #file-explorer-content .file_gallery {
        --file-gallery-size: 100px;
        grid-gap: 8px;
    }
}

@media (min-width: 576px) and (max-width: 767.98px) {
    #file-explorer-content .file_gallery {
        --file-gallery-size: 120px;
    }
}

@media (min-width: 768px) and (max-width: 991.98px) {
    #file-explorer-content .file_gallery {
        --file-gallery-size: 130px;
    }
}

@media (min-width: 992px) {
    #file-explorer-content .file_gallery {
        --file-gallery-size: 140px;
        grid-gap: 13.6px;
    }
}

#file-explorer-content .file_gallery_item {
    min-width: var(--file-gallery-size, 120px);
    min-height: var(--file-gallery-size, 120px);
    cursor: pointer;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    overflow: hidden;
    border-radius: 0.5rem;
}

.file_gallery_item .item_img {
    min-height: calc(var(--file-gallery-size, 120px) * 0.7);
    height: calc(var(--file-gallery-size, 120px) * 0.7);
    width: 100%;
    object-fit: cover;
}

.file_gallery_item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.file_gallery_item .thumb-icon {
    min-height: calc(var(--file-gallery-size, 120px) * 0.7);
    height: calc(var(--file-gallery-size, 120px) * 0.7);
    width: 100%;
    justify-content: center;
    align-items: center;
    display: flex;
}

    .file_gallery_item .thumb-icon span i {
        font-size: clamp(40px, 4vw, 60px);
    }

#file-explorer-content .file_check {
    display: none;
}

.file_gallery_item.active {
    outline-style: solid;
    outline-color: var(--bs-primary);
    outline-width: 2px;
    box-shadow: 0 0 0 2px var(--bs-primary);
}

    .file_gallery_item.active .file_check {
        display: block !important;
        color: var(--bs-primary);
    }

.file_gallery_item:hover .file_check {
    display: block !important;
}

/* Content area responsive */
.file_explorer_view_content {
    flex: 1 1 auto;
    min-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    max-height: calc(100vh - 400px);
}


#file-explorer-content {
    overflow-y: unset;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

    #file-explorer-content > .d-flex.flex-column.flex-column-fluid {
        display: flex;
        flex-direction: column;
        min-height: 0; /* Important for flex children to respect overflow */
        flex: 1 1 auto;
    }

.menu-link .menu_line {
    position: absolute;
    width: 2rem;
    top: 50%;
    height: 0.5px;
    left: -1rem;
    background-color: var(--bs-text-gray-500);
    opacity: 0.3;
}

.item_title {
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0.5rem;
    white-space: nowrap;
    font-size: 0.75rem;
    line-height: 1.2;
}

    .item_title .text-muted {
        font-size: 0.65rem;
        margin-top: 0.25rem;
    }

/* File extension badge responsive */
.file_gallery_item .bg-dark {
    font-size: 0.6rem;
    padding: 0.15rem 0.4rem;
}

@media (min-width: 768px) {
    .file_gallery_item .bg-dark {
        font-size: 0.7rem;
        padding: 0.2rem 0.5rem;
    }
}

/* Pagination responsive */
#file_pagination .pagination {
    flex-shrink: 0;
    padding-top: 1rem;
    padding-bottom: 0.5rem;
    background-color: transparent;
}

#file_pagination .page-link {
    padding: 0.375rem 0.5rem;
    font-size: 0.875rem;
}

@media (max-width: 575.98px) {
    #file_pagination .page-link {
        padding: 0.25rem 0.4rem;
        font-size: 0.75rem;
    }

    #file_pagination .paging-first-item,
    #file_pagination .paging-last-item {
        display: none;
    }
}

/* Modal z-index */
#kt_modal_file_manager {
    z-index: 100001;
}

.sub_modal {
    z-index: 100003;
}

.modal-backdrop.fade + .modal-backdrop.fade {
    z-index: 1056;
}

.modal-backdrop.fade.show:nth-child(2) {
    z-index: 100002;
}

.swal2-container.swal2-center {
    z-index: 100003;
}

/* Empty state responsive */
.file_explorer_view_content .mw-400px {
    max-width: 100%;
    width: 100%;
}

@media (min-width: 576px) {
    .file_explorer_view_content .mw-400px {
        max-width: 400px;
    }
}

/* Search input responsive */
#file_manager_search {
    transition: all 0.3s ease;
}

    #file_manager_search:focus {
        border-color: var(--bs-primary);
        box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.25);
    }

/* Button improvements */
#btn_upload_file .indicator-progress {
    display: none;
}

#btn_upload_file[data-kt-indicator="on"] .indicator-label {
    display: none;
}

#btn_upload_file[data-kt-indicator="on"] .indicator-progress {
    display: inline-flex;
    align-items: center;
}

/* Smooth scroll */
.file_explorer_view_content {
    scroll-behavior: smooth;
}

    /* Loading state */
    .file_explorer_view_content.loading {
        opacity: 0.6;
        pointer-events: none;
    }

    .item_title .badge {
        max-width: 50px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

.file_gallery_item .file_check {
    z-index: 10;
    background-color: rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    padding: 2px;
}