/* =============================================
   Media Browser Modal Styles
   ============================================= */

/* Modal sizing */
.btmh-media-browser-modal .modal-inner-wrap {
    max-width: 80vw;
    width: 80vw;
}

.btmh-media-browser-content {
    min-height: 50vh;
}

/* Header: search + upload */
.btmh-media-header {
    display: flex;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid #ccc;
    margin-bottom: 10px;
}

.btmh-media-search {
    flex: 1;
    min-width: 200px;
}

.btmh-upload-btn {
    cursor: pointer;
    white-space: nowrap;
    padding: 6px 15px;
}

/* Body: sidebar + main */
.btmh-media-body {
    display: flex;
    gap: 15px;
    min-height: 45vh;
}

/* Sidebar: folder list */
.btmh-media-sidebar {
    width: 180px;
    flex-shrink: 0;
    border-right: 1px solid #e0e0e0;
    padding-right: 15px;
}

.btmh-folder-title {
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 13px;
    color: #333;
}

.btmh-folder-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.btmh-folder-list li {
    padding: 6px 10px;
    cursor: pointer;
    border-radius: 3px;
    font-size: 13px;
    color: #555;
}

.btmh-folder-list li:hover {
    background: #f0f0f0;
}

.btmh-folder-list li.active {
    background: #e3f2fd;
    color: #1565c0;
    font-weight: 600;
}

/* Main content area */
.btmh-media-main {
    flex: 1;
    min-width: 0;
}

/* Dropzone */
.btmh-media-dropzone {
    min-height: 40vh;
    position: relative;
}

.btmh-dropzone-text {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 30vh;
    border: 2px dashed #ccc;
    border-radius: 6px;
    color: #999;
    font-size: 14px;
}

.btmh-media-dropzone.btmh-dragover .btmh-dropzone-text,
.btmh-media-dropzone.btmh-dragover {
    border-color: #1565c0;
    background: #e3f2fd;
}

/* Loading spinner */
.btmh-media-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 20vh;
}

.btmh-media-loading .spinner {
    width: 30px;
    height: 30px;
    border: 3px solid #e0e0e0;
    border-top-color: #1565c0;
    border-radius: 50%;
    animation: btmh-spin 0.6s linear infinite;
}

@keyframes btmh-spin {
    to { transform: rotate(360deg); }
}

/* Upload progress */
.btmh-upload-progress {
    text-align: center;
    padding: 10px;
    color: #1565c0;
    font-weight: 600;
}

/* =============================================
   Thumbnail Grid
   ============================================= */

.btmh-media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    padding: 5px 0;
}

.btmh-media-item {
    border: 2px solid #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
    background: #fafafa;
    position: relative;
}

.btmh-media-item:hover {
    border-color: #90caf9;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.btmh-media-item.selected {
    border-color: #1565c0;
    box-shadow: 0 0 0 2px rgba(21, 101, 192, 0.3);
}

.btmh-media-thumb {
    width: 100%;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #f5f5f5;
}

.btmh-media-thumb img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.btmh-media-info {
    padding: 6px 8px;
    border-top: 1px solid #eee;
}

.btmh-media-name {
    display: block;
    font-size: 11px;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btmh-media-size {
    font-size: 10px;
    color: #999;
}

/* Item action buttons (rename/delete) */
.btmh-media-actions {
    display: none;
    position: absolute;
    top: 4px;
    right: 4px;
    gap: 3px;
}

.btmh-media-item:hover .btmh-media-actions {
    display: flex;
}

.btmh-btn-rename,
.btmh-btn-delete {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #ccc;
    border-radius: 3px;
    padding: 2px 6px;
    font-size: 10px;
    cursor: pointer;
    line-height: 1.3;
}

.btmh-btn-rename:hover {
    background: #e3f2fd;
    border-color: #1565c0;
}

.btmh-btn-delete:hover {
    background: #ffebee;
    border-color: #c62828;
    color: #c62828;
}

/* =============================================
   Pagination
   ============================================= */

.btmh-media-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 10px 0;
    border-top: 1px solid #e0e0e0;
    margin-top: 10px;
}

.btmh-page-info {
    font-size: 13px;
    color: #555;
}

/* =============================================
   Media Browser Field (inline on form)
   ============================================= */

.btmh-media-browser-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.btmh-media-preview {
    max-width: 300px;
}

.btmh-preview-image {
    max-width: 100%;
    max-height: 200px;
    border: 1px solid #ddd;
    border-radius: 4px;
    object-fit: contain;
    background: #f9f9f9;
}

.btmh-preview-file {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.btmh-file-icon {
    font-size: 20px;
}

.btmh-preview-video {
    max-width: 100%;
    max-height: 200px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #000;
}

.btmh-preview-filename {
    font-size: 11px;
    color: #777;
    margin-top: 4px;
    word-break: break-all;
}

.btmh-media-field-actions {
    display: flex;
    gap: 8px;
}

.btmh-browse-media-btn,
.btmh-clear-media-btn {
    font-size: 12px;
    padding: 5px 12px;
}
