/* ================================================================
   FileManager — Layout
================================================================ */

.fm-content { height: 100%; border: none; border-radius: 16px; overflow: hidden; background: var(--conteudo-bg); }

/* Header */
.fm-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; border-bottom: 1px solid var(--border-color); flex-shrink: 0; }
.fm-header-left { display: flex; align-items: center; gap: 10px; }
.fm-header-left i { font-size: 18px; color: var(--primary-color); }
.fm-header-left h3 { margin: 0; font-size: 16px; font-weight: 700; color: var(--text-color); }
.fm-header-badge { font-size: 12px; color: var(--text-color); opacity: .5; }
.fm-header-actions { display: flex; gap: 6px; }

.fm-btn-icon { width: 34px; height: 34px; border: 1px solid var(--border-color); border-radius: 8px; background: var(--conteudo-bg); color: var(--primary-color); font-size: 15px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background .15s; }
.fm-btn-icon:hover { background: var(--button-bg); }
#fileManager-btnVoltar { display: none; }
.fm-btn-close { color: var(--text-color); }
.fm-btn-close:hover { color: #DC3545; }

/* Body */
.fm-body { height: calc(100% - 60px); padding: 14px; min-height: 0; }
.fm-main { height: 100%; display: flex; flex-direction: column; min-height: 0; }

/* Painéis */
.fm-panel { flex: 1; display: flex; flex-direction: column; gap: 12px; min-height: 0; overflow-y: auto; }
.fm-panel::-webkit-scrollbar { width: 4px; }
.fm-panel::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }

/* Toolbar */
.fm-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-shrink: 0; }
.fm-search { flex: 1; max-width: 320px; height: 36px; border: 1px solid var(--border-color); border-radius: 10px; padding: 0 12px; font-size: 13px; font-family: var(--font); color: var(--text-color); background: var(--conteudo-bg); outline: none; }
.fm-search:focus { border-color: var(--primary-color); }
.fm-count { font-size: 13px; color: var(--text-color); opacity: .5; }

/* ================================================================
   Grid area (drop card + file cards)
================================================================ */

.fm-grid-area {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    align-content: start;
    overflow-y: auto;
    min-height: 0;
    padding: 2px;
}

.fm-grid-area::-webkit-scrollbar { width: 4px; }
.fm-grid-area::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }

/* Cards inline (sem wrapper extra) */
.fm-grid-inline { display: contents; }

/* Card base */
.fm-card {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    cursor: pointer;
    transition: all .15s;
    background: var(--conteudo-bg);
}
.fm-card:hover { border-color: var(--primary-color); box-shadow: 0 2px 8px rgba(0,0,0,.06); transform: translateY(-1px); }

/* Card drop (upload) */
.fm-card-drop { border-style: dashed; opacity: .6; }
.fm-card-drop:hover { opacity: 1; }
.fm-card-drop.highlight { border-color: var(--primary-color); opacity: 1; background: color-mix(in srgb, var(--primary-color) 5%, transparent); }

.fm-thumb { width: 100%; aspect-ratio: 16/10; border-radius: 8px; background: #1a1a2e; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.fm-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }

.fm-thumb-drop { background: transparent; border: none; color: var(--primary-color); font-size: 28px; }

.fm-caption { font-size: 12px; font-weight: 500; color: var(--text-color); line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; text-align: center; }

/* ================================================================
   Detalhes
================================================================ */

.fm-details-preview { flex-shrink: 0; position: relative; }
.fm-preview-box { border: 1px solid var(--border-color); border-radius: 12px; padding: 12px; display: flex; align-items: center; justify-content: center; min-height: 260px; max-height: 320px; background: var(--conteudo-bg); color: var(--text-color); font-size: 13px; overflow: hidden; }

/* Overlay de visualizar sobre o preview */
.fm-preview-overlay {
    position: absolute;
    inset: 0;
    border-radius: 12px;
    border: none;
    background: rgba(255,255,255,.08);
    color: var(--text-color);
    font-size: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity .2s;
}
.fm-details-preview:hover .fm-preview-overlay { opacity: 1; background: rgba(0,0,0,.35); color: #fff; }
.fm-preview-box iframe { width: 100%; height: 280px; border: none; }
.fm-preview-box img { max-width: 100%; max-height: 300px; object-fit: contain; }
.fm-preview-box video { max-width: 100%; max-height: 300px; border-radius: 8px; }
.fm-preview-box audio { width: 100%; }
.fm-preview-box pre { width: 100%; max-height: 280px; overflow: auto; margin: 0; padding: 8px; font-size: 12px; background: #1a1a2e; color: #e0e0e0; border-radius: 8px; white-space: pre-wrap; word-break: break-word; text-align: left; }

.fm-details-info { display: flex; flex-direction: column; gap: 10px; }
.fm-field { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.fm-field label { font-size: 11px; font-weight: 600; color: var(--text-color); opacity: .5; text-transform: uppercase; letter-spacing: .3px; }
.fm-field input { width: 100%; height: 34px; border: 1px solid var(--border-color); border-radius: 8px; padding: 0 10px; font-size: 13px; font-family: var(--font); color: var(--text-color); background: var(--conteudo-bg); outline: none; }
.fm-field input:focus { border-color: var(--primary-color); }
.fm-field input[readonly] { opacity: .6; cursor: default; }
.fm-field-row { display: flex; gap: 10px; }

.fm-details-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-shrink: 0; padding-top: 6px; border-top: 1px solid var(--border-color); }
.fm-details-actions-left, .fm-details-actions-right { display: flex; gap: 6px; }

.fm-btn { height: 34px; padding: 0 14px; border: none; border-radius: 8px; font-family: var(--font); font-size: 13px; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 6px; white-space: nowrap; transition: opacity .2s; }
.fm-btn:hover { opacity: .85; }
.fm-btn-green { background: #22C55E; color: #fff; }
.fm-btn-blue  { background: var(--primary-color); color: #fff; }
.fm-btn-red   { background: #DC3545; color: #fff; }
.fm-btn-gray  { background: var(--button-bg); color: var(--text-color); }

/* Mobile QR */
.fm-mobile-qr { display: flex; align-items: center; justify-content: center; padding: 40px 20px; border: 1px solid var(--border-color); border-radius: 12px; flex: 1; min-height: 0; }

/* Progress */
.fm-progress { height: 6px; background: var(--button-bg); border-radius: 99px; overflow: hidden; flex-shrink: 0; }
.fm-progress > #fm-bar { height: 100%; width: 0; background: var(--primary-color); transition: width .3s; }

/* ================================================================
   Responsivo
================================================================ */

@media (max-width: 768px) {
    #modal-fileManager .modal-dialog { width: 95% !important; max-width: 95% !important; height: calc(100vh - 10px) !important; margin: 5px auto !important; }
    .fm-body { padding: 8px; }
    .fm-grid-area { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 6px; }
    .fm-card { padding: 6px; }
    .fm-caption { font-size: 10px; }
    .fm-field-row { flex-direction: column; }
    .fm-details-actions { flex-direction: column; }
    .fm-details-actions-left, .fm-details-actions-right { width: 100%; }
    .fm-btn { width: 100%; justify-content: center; }
    .fm-search { max-width: 100%; }
}
