﻿/* =========================
   Media Manager (clean CSS)
   ========================= */

/* Modal width & stacking */
#mediaManagerModal .sbook-mm-dialog {
    width: auto;
    max-width: clamp(1200px,95vw,1600px);
    margin-inline: auto;
    --bs-modal-width: clamp(1200px,95vw,1600px);
}

#mediaManagerModal {
    z-index: 1400;
}

#imageAttributesModal {
    z-index: 1500;
}

#copyToModal {
    z-index: 3055 !important;
}

body.sbook-mm-open .modal-backdrop.show {
    z-index: 1390;
}

body.sbook-attrs-open .modal-backdrop.show {
    z-index: 1490;
}

.sbook-media *, .sbook-media *::before, .sbook-media *::after {
    box-sizing: border-box;
}

/* Shell: sidebar + main */
.sbook-media .mm-shell {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 80vh;
    height: 80vh; /* columns scroll independently */
}

.sbook-media .mm-sidebar {
    background: #fafcff;
    border-right: 1px solid var(--bs-border-color,#dee2e6);
    height: 100%;
    overflow: auto;
}

.sbook-media .mm-main {
    display: flex;
    flex-direction: column;
    min-height: 80vh;
    background: #fff;
}

.sbook-media .mm-list {
    height: 100%;
    overflow: auto;
}
/* Toolbar */
.mm-toolbar {
    background: #f8fbff;
}

    .mm-toolbar .btn-light {
        background: #fff;
    }

    .mm-toolbar .toolbar-row {
        display: flex;
        align-items: center;
        gap: .5rem;
        flex-wrap: nowrap;
        white-space: nowrap;
        overflow-x: auto;
        overflow-y: visible;
        position: relative;
    }

    .mm-toolbar .end-row {
        display: flex;
        align-items: center;
        gap: .5rem;
        margin-left: .75rem;
    }

    .mm-toolbar .search {
        min-width: 220px;
    }

    .mm-toolbar .grow {
        flex: 1 1 320px;
    }

/* Tree (shared: sidebar & destination modal) */
.mm-tree {
    padding: .5rem;
}

    .mm-tree .node {
        display: flex;
        align-items: center;
        gap: .5rem;
        padding: .42rem .6rem;
        border-radius: .5rem;
        cursor: pointer;
        user-select: none;
        position: relative;
        transition: background-color .12s ease, box-shadow .12s ease;
    }

        .mm-tree .node:hover {
            background: #eef6ff;
            box-shadow: inset 3px 0 0 #0d6efd33;
        }

        .mm-tree .node.active {
            background: #e7f1ff;
            box-shadow: inset 3px 0 0 #0d6efd;
        }

        .mm-tree .node .label {
            flex: 1;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .mm-tree .node .toggle {
            width: 16px;
            text-align: center;
            cursor: pointer;
            color: #6c757d;
        }

        .mm-tree .node.drop-hover {
            outline: 1px dashed #0d6efd;
            outline-offset: 2px;
        }

    .mm-tree .mm-spacer {
        display: inline-block;
        width: 16px;
    }
    /* caret placeholder for leaves */

    /* Indent ladder (deep trees) */
    .mm-tree .node.indent-0 {
        padding-left: .6rem;
    }

    .mm-tree .node.indent-1 {
        padding-left: 1.4rem;
    }

    .mm-tree .node.indent-2 {
        padding-left: 2.2rem;
    }

    .mm-tree .node.indent-3 {
        padding-left: 3.0rem;
    }

    .mm-tree .node.indent-4 {
        padding-left: 3.8rem;
    }

    .mm-tree .node.indent-5 {
        padding-left: 4.6rem;
    }

    .mm-tree .node.indent-6 {
        padding-left: 5.4rem;
    }

    .mm-tree .node.indent-7 {
        padding-left: 6.2rem;
    }

    .mm-tree .node.indent-8 {
        padding-left: 7.0rem;
    }

    /* Drag hint badges on tree nodes */
    .mm-tree .node.drag-copy .label::after {
        content: "Copy";
        display: inline-block;
        margin-left: .4rem;
        padding: 0 .4rem;
        font-size: 11px;
        line-height: 1.4;
        color: #fff;
        background: #0d6efd;
        border-radius: .5rem;
    }

    .mm-tree .node.drag-move .label::after {
        content: "Move";
        display: inline-block;
        margin-left: .4rem;
        padding: 0 .4rem;
        font-size: 11px;
        line-height: 1.4;
        color: #0d6efd;
        background: #e7f1ff;
        border: 1px solid #bcd3ff;
        border-radius: .5rem;
    }

/* Breadcrumb */
.sbook-media .mm-breadcrumb {
    overflow-x: auto;
}

    .sbook-media .mm-breadcrumb .crumb {
        padding: .25rem .5rem;
        border-radius: .5rem;
    }

        .sbook-media .mm-breadcrumb .crumb.drop-hover {
            background: #e7f1ff;
        }

/* Files: dropzone + list/grid */
.sbook-media .mm-dropzone {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

    .sbook-media .mm-dropzone.drag-over {
        outline: 3px dashed #0d6efd;
        outline-offset: -3px;
    }

.sbook-media .mm-list {
    flex: 1;
    overflow: auto;
    padding: 1rem;
}

    .sbook-media .mm-list.view-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit,minmax(200px,1fr));
        gap: 1rem;
        align-content: start;
        justify-content: start;
        grid-auto-rows: auto;
    }

.sbook-media .mm-card {
    border: 1px solid #e8eaef;
    border-radius: .9rem;
    background: #fff;
    box-shadow: 0 1px 3px rgba(18,38,63,.06);
    padding: .7rem;
    display: flex;
    flex-direction: column;
    gap: .6rem;
    transition: box-shadow .15s ease, border-color .15s ease;
    align-self: start;
    height: auto;
}

    .sbook-media .mm-card:hover {
        box-shadow: 0 4px 16px rgba(18,38,63,.08);
        border-color: #d7dbe3;
    }

.sbook-media .mm-thumb {
    width: 100%;
    aspect-ratio: 4/3;
    border-radius: .6rem;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f4f7fb;
}

    .sbook-media .mm-thumb img {
        width: 100%;
        height: 100%;
        object-fit: contain;
    }

.sbook-media .mm-card > .small:first-of-type {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.4em;
}

.sbook-media .mm-card .small, .sbook-media .mm-item .small {
    color: #4e5d78;
}

.sbook-media .mm-list .mm-card:hover, .sbook-media .mm-list .mm-item:hover {
    background: #f8f9fa;
    cursor: pointer;
}

.sbook-media .mm-card.selected {
    background: #f0f7ff;
    border: 2px dashed #0d6efd;
}

.sbook-media .mm-list.view-list .mm-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .5rem .75rem;
    border: 1px solid #dee2e6;
    border-radius: .75rem;
    background: #fff;
}

    .sbook-media .mm-list.view-list .mm-item.selected {
        border: 2px dashed #0d6efd;
        background: #eef6ff;
        box-shadow: inset 0 0 0 2px rgba(13,110,253,.15);
    }

        .sbook-media .mm-list.view-list .mm-item.selected .flex-grow-1 {
            font-weight: 600;
        }

/* Uploads panel */
.sbook-media .mm-progress {
    border-top: 1px solid #eee;
    background: #fff;
}

    .sbook-media .mm-progress.collapsed .mm-progress-list {
        display: none;
    }

.sbook-media .mm-progress-item {
    padding: .5rem 1rem;
    border-top: 1px dashed #eee;
}

.sbook-media .mm-progress-barwrap {
    height: 6px;
    background: #eee;
    border-radius: 6px;
    overflow: hidden;
}

.sbook-media .mm-progress-bar {
    height: 6px;
    width: 0%;
    background: #0d6efd;
}

/* Icons & drags */
.sbook-media .mm-icon {
    font-size: 2rem;
    color: #6c757d;
}

.sbook-media [draggable="true"] {
    cursor: grab;
}

    .sbook-media [draggable="true"]:active {
        cursor: grabbing;
    }

/* Sort menu (custom) */
.mm-ddmenu {
    position: fixed;
    display: none;
    z-index: 1450;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: .5rem;
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
    padding: .5rem;
    min-width: 14rem;
}

    .mm-ddmenu .mm-dd-h {
        font-size: .8rem;
        color: #6c757d;
        padding: .25rem .5rem;
    }

    .mm-ddmenu a {
        display: block;
        padding: .35rem .75rem;
        border-radius: .35rem;
        text-decoration: none;
        color: inherit;
    }

        .mm-ddmenu a:hover {
            background: #f1f5ff;
        }

    .mm-ddmenu hr {
        margin: .35rem 0;
        border-top: 1px solid #eee;
    }

/* Lasso (mouse-drag selection) */
.mm-lasso {
    position: absolute;
    border: 2px dashed #0d6efd;
    background: rgba(13,110,253,.08);
    pointer-events: none;
    z-index: 1460;
}

/* Responsive */
@media (max-width:991.98px) {
    /* allow stacked rows to scroll */
    .modal-dialog-scrollable .modal-body {
        overflow: auto !important;
    }

    .sbook-media .mm-shell {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        height: calc(100vh - 10rem); /* header+footer allowance */
    }

    .sbook-media .mm-sidebar {
        display: block !important;
        min-height: 180px;
        max-height: 42vh;
        overflow: auto;
        border-right: 0;
        border-bottom: 1px solid var(--bs-border-color,#dee2e6);
        background: #fafcff;
    }

    .sbook-media .mm-tree {
        min-height: 160px;
    }

    .sbook-media .mm-main {
        min-height: 40vh;
        display: flex;
        flex-direction: column;
    }
}

@media (max-width:575.98px) {
    .sbook-media .mm-list.view-grid {
        grid-template-columns: repeat(auto-fit,minmax(140px,1fr));
        gap: .6rem;
    }

    .sbook-media .mm-thumb {
        aspect-ratio: 1/1;
    }
    /* lightweight "Folders" header without markup change */
    .sbook-media .mm-sidebar::before {
        content: "Folders";
        display: block;
        position: sticky;
        top: 0;
        z-index: 1;
        padding: .5rem .75rem;
        font-weight: 600;
        background: #fafcff;
        border-bottom: 1px solid var(--bs-border-color,#dee2e6);
    }
}

#mediaManagerModal .modal-dialog-scrollable .modal-body {
    overflow: hidden; /* কেবল মেইন ম্যানেজারে outer scroll লক */
}

#copyToModal .modal-body {
    overflow: auto !important;
    max-height: calc(100vh - 7rem); /* header+footer বাদ দিয়ে আরামদায়ক উচ্চতা */
}
#copyToModal .mm-tree {
    max-height: 60vh;
    overflow: auto;
}
/* Tips strip in footer */
.mm-tips .bi-lightbulb {
    font-size: 1rem;
}

.mm-tips .btn.btn-sm {
    line-height: 1;
    padding-top: .15rem;
    padding-bottom: .15rem;
}

.mm-tips [data-mm="tips-text"] {
    max-width: 55vw;
}

@media (max-width: 575.98px) {
    .mm-tips [data-mm="tips-text"] {
        max-width: 70vw;
    }
}