/* ===================================================
   explorer.css — Windows 7 / Frutiger Aero UI
   Mobile-first, slide-in sidebar drawer
   =================================================== */

body {
    padding-top: 60px !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    padding-bottom: 0 !important;
    align-items: stretch !important;
    justify-content: stretch !important;
}

/* ── Shell ── */
.explorer-shell {
    display: flex;
    flex-direction: column;
    width: calc(100vw - 16px);
    height: calc(100vh - 60px - 16px);
    max-width: 1100px;
    margin: 8px auto;
    background: linear-gradient(160deg, #e8f4ff 0%, #d0e8f8 50%, #c8e0f5 100%);
    border: 1px solid #7ab4e0;
    border-radius: 8px 8px 6px 6px;
    box-shadow:
        0 0 0 1px rgba(255,255,255,0.6) inset,
        0 12px 40px rgba(0,60,120,0.25),
        0 2px 4px rgba(0,0,0,0.1);
    overflow: hidden;
    min-height: 400px;
    position: relative;
}

/* ── Title bar ── */
.explorer-titlebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 36px;
    padding: 0 6px 0 8px;
    background: linear-gradient(180deg,
        #7ec8f0 0%, #4fa8e0 30%, #2e88cc 70%, #1a6ab5 100%);
    border-bottom: 1px solid #1258a0;
    box-shadow: 0 1px 0 rgba(255,255,255,0.35) inset;
    cursor: grab;
    user-select: none;
    flex-shrink: 0;
    gap: 8px;
}
.explorer-titlebar.dragging { cursor: grabbing; }

.explorer-tb-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}
.explorer-tb-icon {
    width: 18px; height: 18px;
    image-rendering: pixelated;
    flex-shrink: 0;
}
.explorer-tb-title {
    color: #fff;
    font-size: 0.82rem;
    font-weight: 700;
    text-shadow: 0 1px 3px rgba(0,0,0,0.4);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Hamburger button — mobile only */
.explorer-hamburger {
    display: none;
    align-items: center;
    justify-content: center;
    width: 32px; height: 28px;
    background: rgba(255,255,255,0.18);
    border: 1px solid rgba(255,255,255,0.35);
    border-radius: 4px;
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s;
}
.explorer-hamburger:hover { background: rgba(255,255,255,0.28); }

.explorer-tb-controls {
    display: flex;
    gap: 3px;
    flex-shrink: 0;
}
.explorer-ctrl {
    width: 28px; height: 22px;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 4px;
    background: linear-gradient(180deg, rgba(255,255,255,0.28) 0%, rgba(255,255,255,0.08) 100%);
    color: #fff;
    font-size: 0.8rem;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.12s;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.explorer-ctrl:hover { background: linear-gradient(180deg, rgba(255,255,255,0.42) 0%, rgba(255,255,255,0.18) 100%); }
.explorer-ctrl.close {
    background: linear-gradient(180deg, #f08080 0%, #d43030 100%);
    border-color: #a02020;
}
.explorer-ctrl.close:hover { background: linear-gradient(180deg, #f8a0a0 0%, #e05050 100%); }

/* ── Address bar ── */
.explorer-addressbar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 8px;
    background: linear-gradient(180deg, #d8eeff 0%, #bcd8f5 100%);
    border-bottom: 1px solid #8ab8dc;
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 4px;
}
.addr-back, .addr-forward {
    width: 28px; height: 26px;
    background: linear-gradient(180deg, #eef8ff 0%, #cce4f8 100%);
    border: 1px solid #88b5d8;
    border-radius: 4px;
    color: #1a5a90;
    font-size: 0.7rem;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.12s;
    box-shadow: 0 1px 0 rgba(255,255,255,0.7) inset;
}
.addr-back:hover, .addr-forward:hover {
    background: linear-gradient(180deg, #f5fbff 0%, #daeffe 100%);
}
.addr-path {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(255,255,255,0.85);
    border: 1px solid #88b5d8;
    border-radius: 4px;
    padding: 3px 10px;
    font-size: 0.82rem;
    min-height: 26px;
    box-shadow: 0 1px 3px rgba(0,60,120,0.08) inset;
    min-width: 80px;
}
.addr-crumb {
    color: #1a5a90;
    cursor: pointer;
    font-weight: 600;
}
.addr-crumb:hover { text-decoration: underline; }
.addr-crumb.active { color: #0a2a50; font-weight: 700; cursor: default; }
.addr-crumb.active:hover { text-decoration: none; }
.addr-sep { color: #88b0d0; font-size: 0.65rem; }
.addr-search {
    display: flex;
    align-items: center;
    background: rgba(255,255,255,0.85);
    border: 1px solid #88b5d8;
    border-radius: 4px;
    padding: 0 6px;
    box-shadow: 0 1px 3px rgba(0,60,120,0.08) inset;
}
.addr-search input {
    border: none;
    outline: none;
    font-size: 0.78rem;
    width: 130px;
    padding: 4px 0;
    background: transparent;
    color: #0a2a50;
}

/* ── Toolbar ── */
.explorer-toolbar {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 4px 8px;
    background: linear-gradient(180deg, #e4f2ff 0%, #cce0f5 100%);
    border-bottom: 1px solid #a8c8e5;
    flex-shrink: 0;
    min-height: 36px;
}
.tb-btn {
    padding: 4px 10px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    font-size: 0.8rem;
    color: #0a3060;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
}
.tb-btn:hover {
    background: linear-gradient(180deg, rgba(255,255,255,0.7) 0%, rgba(180,215,245,0.6) 100%);
    border-color: #88b5d8;
}
.tb-sep {
    width: 1px;
    height: 22px;
    background: linear-gradient(180deg, transparent, #a8c8e0, transparent);
    margin: 0 4px;
}
.tb-viewbtns { display: flex; gap: 2px; }
.tbv {
    width: 28px; height: 26px;
    background: linear-gradient(180deg, #eef8ff 0%, #cce4f8 100%);
    border: 1px solid #88b5d8;
    border-radius: 3px;
    color: #1a5a90;
    font-size: 0.75rem;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 1px 0 rgba(255,255,255,0.7) inset;
}
.tbv.active {
    background: linear-gradient(180deg, #a8d8f8 0%, #78b8f0 100%);
    border-color: #3a80c0;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.15);
    color: #fff;
}

/* ── Main layout ── */
.explorer-main {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* ── Sidebar overlay (mobile) ── */
.sidebar-overlay {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(0, 30, 70, 0.35);
    z-index: 50;
    backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; }

/* ── Sidebar ── */
.explorer-sidebar {
    width: 190px;
    flex-shrink: 0;
    background: linear-gradient(180deg,
        rgba(200,230,255,0.92) 0%,
        rgba(180,215,250,0.88) 100%);
    border-right: 1px solid rgba(120,180,230,0.5);
    overflow-y: auto;
    padding: 8px 0;
    backdrop-filter: blur(8px);
    transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
}
.sidebar-section { margin-bottom: 4px; }
.sidebar-header {
    font-size: 0.68rem;
    font-weight: 700;
    color: #1a5a90;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 8px 12px 4px;
    border-bottom: 1px solid rgba(120,180,230,0.4);
    margin-bottom: 2px;
    text-shadow: 0 1px 0 rgba(255,255,255,0.7);
}
.sidebar-item {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 6px 14px;
    font-size: 0.8rem;
    color: #0a3060;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.1s;
}
.sidebar-item:hover {
    background: linear-gradient(90deg, rgba(120,190,240,0.35), rgba(100,170,230,0.15));
}
.sidebar-item.active {
    background: linear-gradient(90deg, rgba(80,160,230,0.45), rgba(60,140,220,0.2));
    color: #051830;
    font-weight: 700;
    border-left: 3px solid #3a8ad0;
    padding-left: 11px;
}
.sidebar-icon {
    width: 16px; height: 16px;
    font-size: 14px;
    image-rendering: pixelated;
    flex-shrink: 0;
}
.detail-content {
    padding: 8px 12px;
    font-size: 0.78rem;
    color: #1a3a6a;
    line-height: 1.6;
}
.detail-content strong { display: block; font-size: 0.85rem; color: #0a2040; margin-bottom: 4px; }

/* ── File content area ── */
.explorer-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    background: rgba(255,255,255,0.72);
    backdrop-filter: blur(6px);
    position: relative;
}

/* ── Tiles view ── */
.explorer-content.view-tiles {
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 10px;
    padding: 14px;
}

/* ── List view ── */
.explorer-content.view-list {
    display: block;
    padding: 0;
}
.list-header {
    display: grid;
    grid-template-columns: 1fr 110px 80px 90px;
    padding: 4px 12px;
    background: linear-gradient(180deg, #deeefa 0%, #cce2f5 100%);
    border-bottom: 1px solid #a8c8e5;
    font-size: 0.72rem;
    font-weight: 700;
    color: #1a4a7a;
    position: sticky;
    top: 0;
    z-index: 1;
}
.list-header span { cursor: pointer; user-select: none; padding: 2px 4px; border-radius: 2px; }
.list-header span:hover { background: rgba(80,160,230,0.15); }

/* ── File tile ── */
.file-tile {
    width: 92px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 10px 5px 8px;
    border-radius: 8px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
    position: relative;
    -webkit-tap-highlight-color: transparent;
}
.file-tile:hover {
    background: linear-gradient(160deg, rgba(180,225,255,0.7), rgba(150,205,245,0.5));
    border-color: rgba(80,160,230,0.45);
    box-shadow: 0 2px 8px rgba(0,80,180,0.12), 0 0 0 1px rgba(255,255,255,0.5) inset;
}
.file-tile.selected {
    background: linear-gradient(160deg, rgba(100,180,240,0.55), rgba(70,155,225,0.4));
    border-color: #3a90d0;
    box-shadow: 0 2px 10px rgba(0,80,180,0.2), 0 0 0 1px rgba(255,255,255,0.6) inset;
}
.file-tile-icon {
    width: 56px; height: 56px;
    font-size: 46px;
    display: flex; align-items: center; justify-content: center;
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(0,60,120,0.2));
}
.file-tile-name {
    font-size: 0.72rem;
    text-align: center;
    color: #0a2040;
    word-break: break-word;
    line-height: 1.35;
    max-height: 2.7em;
    overflow: hidden;
    font-weight: 600;
    text-shadow: 0 1px 0 rgba(255,255,255,0.8);
}
.file-tile-tag {
    font-size: 0.62rem;
    color: #fff;
    background: linear-gradient(135deg, #4a9cd8, #2a7abf);
    border-radius: 10px;
    padding: 2px 7px;
    white-space: nowrap;
    max-width: 88px;
    overflow: hidden;
    text-overflow: ellipsis;
    box-shadow: 0 1px 3px rgba(0,60,120,0.25);
    text-shadow: 0 1px 1px rgba(0,0,0,0.2);
}

/* ── File row ── */
.file-row {
    display: grid;
    grid-template-columns: 1fr 110px 80px 90px;
    align-items: center;
    padding: 6px 12px;
    font-size: 0.8rem;
    color: #0a2040;
    border-bottom: 1px solid rgba(180,215,245,0.6);
    cursor: pointer;
    transition: background 0.1s;
    min-height: 44px;
}
.file-row:hover { background: rgba(150,205,245,0.25); }
.file-row.selected { background: rgba(80,160,230,0.2); }
.file-row-name {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}
.file-row-name-icon { font-size: 1rem; }
.file-row-tag {
    font-size: 0.7rem;
    color: #fff;
    background: linear-gradient(135deg, #4a9cd8, #2a7abf);
    border-radius: 10px;
    padding: 2px 7px;
    display: inline-block;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    box-shadow: 0 1px 2px rgba(0,60,120,0.2);
}
.file-row-date { color: #5a7090; font-size: 0.72rem; }

/* ── Admin buttons ── */
.file-admin-btns {
    position: absolute;
    top: 3px; right: 3px;
    display: none;
    gap: 2px;
}
.file-tile:hover .file-admin-btns,
.file-tile.selected .file-admin-btns { display: flex; }
.file-admin-btn {
    width: 20px; height: 20px;
    background: rgba(255,255,255,0.88);
    border: 1px solid #a8c8e0;
    border-radius: 3px;
    font-size: 0.6rem;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.1s;
    box-shadow: 0 1px 3px rgba(0,60,120,0.12);
}
.file-admin-btn:hover { background: #e4f4ff; }
.file-admin-btn.del:hover { background: #fde8e8; border-color: #e56b64; }

.file-row .file-row-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.1s;
}
.file-row:hover .file-row-actions { opacity: 1; }
.row-admin-btn {
    padding: 3px 7px;
    background: rgba(255,255,255,0.88);
    border: 1px solid #a8c8e0;
    border-radius: 3px;
    font-size: 0.65rem;
    cursor: pointer;
    color: #1a4a7a;
}
.row-admin-btn.del:hover { background: #fde8e8; border-color: #e56b64; color: #c0392b; }

/* ── Status bar ── */
.explorer-statusbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 3px 12px;
    background: linear-gradient(180deg, #d8eeff 0%, #c4d8f0 100%);
    border-top: 1px solid #9ac0dc;
    font-size: 0.72rem;
    color: #2a5a80;
    flex-shrink: 0;
    box-shadow: 0 -1px 0 rgba(255,255,255,0.5) inset;
}

/* ── Empty state ── */
.explorer-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #5a8aaa;
    gap: 8px;
    min-height: 200px;
}
.empty-icon { font-size: 3rem; filter: drop-shadow(0 2px 6px rgba(0,80,160,0.2)); }
.empty-text { font-size: 0.95rem; font-weight: 700; color: #2a5a80; }
.empty-sub { font-size: 0.8rem; color: #7aaac0; }

/* ── Context menu ── */
.ctx-menu {
    position: fixed;
    background: linear-gradient(160deg, rgba(225,245,255,0.97), rgba(205,232,252,0.97));
    border: 1px solid #88c0e0;
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0,60,120,0.2), 0 1px 0 rgba(255,255,255,0.8) inset;
    z-index: 9999;
    min-width: 180px;
    padding: 4px 0;
    font-size: 0.85rem;
    backdrop-filter: blur(8px);
}
.ctx-item {
    padding: 7px 18px;
    cursor: pointer;
    color: #0a3060;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.08s;
}
.ctx-item:hover { background: linear-gradient(90deg, rgba(100,180,240,0.4), rgba(80,160,230,0.2)); }
.ctx-sep { height: 1px; background: rgba(120,180,230,0.4); margin: 3px 0; }

/* ── Modals ── */
.file-viewer-window,
.file-editor-window {
    width: auto !important;
    max-width: min(600px, 95vw);
    position: fixed !important;
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
    z-index: 5000 !important;
}

/* ── Viewer content ── */
.viewer-title { font-size: 1.15rem; font-weight: 700; color: #0a2040; margin: 0 0 10px; }
.viewer-tag {
    display: inline-block;
    background: linear-gradient(135deg, #4a9cd8, #2a7abf);
    color: #fff;
    border-radius: 12px;
    padding: 2px 12px;
    font-size: 0.78rem;
    margin-bottom: 14px;
    box-shadow: 0 2px 6px rgba(0,80,160,0.25);
}
.viewer-desc {
    font-size: 0.9rem;
    color: #1a4060;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
    margin-bottom: 14px;
}
.viewer-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #2a6abf;
    font-size: 0.85rem;
    text-decoration: none;
    padding: 6px 14px;
    border: 1px solid #88b8e0;
    border-radius: 6px;
    background: linear-gradient(180deg, #eef8ff 0%, #d4ecf8 100%);
    transition: background 0.12s;
    box-shadow: 0 1px 0 rgba(255,255,255,0.8) inset;
}
.viewer-link:hover { background: linear-gradient(180deg, #dcf0ff 0%, #c0e0f5 100%); }
.viewer-meta { margin-top: 16px; font-size: 0.72rem; color: #7090b0; padding-top: 10px; border-top: 1px solid #d8eaf5; }
.viewer-admin-actions { display: flex; gap: 8px; margin-top: 14px; }

/* ── Loading ── */
.explorer-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #5a8aaa;
    font-size: 0.9rem;
    gap: 10px;
    min-height: 200px;
}
.spinner {
    width: 20px; height: 20px;
    border: 2px solid #c0dcf0;
    border-top-color: #3a8ad0;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════════════
   MOBILE — ≤ 768px
   Sidebar becomes a slide-in drawer
   ═══════════════════════════════════════════════ */
@media (max-width: 768px) {
    .explorer-shell {
        width: calc(100vw - 10px);
        height: calc(100vh - 60px - 10px);
        margin: 5px auto;
        border-radius: 6px;
    }

    /* Show hamburger */
    .explorer-hamburger { display: flex; }

    /* Sidebar becomes a drawer */
    .explorer-sidebar {
        position: absolute;
        top: 0; left: 0; bottom: 0;
        width: 220px;
        z-index: 60;
        transform: translateX(-100%);
        border-right: 1px solid rgba(80,160,230,0.4);
        box-shadow: 4px 0 20px rgba(0,60,120,0.2);
    }
    .explorer-sidebar.open {
        transform: translateX(0);
    }

    /* Address bar: hide search on small screens */
    .addr-search { display: none; }

    /* Tiles: larger tap targets, 2-column grid */
    .explorer-content.view-tiles {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 10px;
        padding: 12px;
        align-content: flex-start;
    }
    .file-tile {
        width: 100%;
        min-height: 90px;
    }
    .file-tile-icon { font-size: 40px; width: 48px; height: 48px; }

    /* Always show admin btns on mobile (no hover) */
    .file-admin-btns { display: flex; }
    .file-admin-btn { width: 24px; height: 24px; font-size: 0.75rem; }

    /* List view: simplified columns */
    .list-header,
    .file-row {
        grid-template-columns: 1fr 80px 70px;
    }
    .list-header span:last-child,
    .file-row > div:last-child { display: none; }

    /* Row actions always visible */
    .file-row .file-row-actions { opacity: 1; }

    /* Toolbar: hide label on view-toggle btn */
    .tb-btn .view-label { display: none; }
}

@media (max-width: 400px) {
    .explorer-addressbar { padding: 4px 5px; }
    .addr-back, .addr-forward { width: 24px; }
    .explorer-tb-title { font-size: 0.75rem; }

    .explorer-content.view-tiles {
        grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    }
}
/* ── File attachment ── */
.attach-zone label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 0.84rem;
    color: #1e293b;
}
.attach-droparea {
    border: 2px dashed #88b5d8;
    border-radius: 6px;
    padding: 14px 12px;
    text-align: center;
    cursor: pointer;
    background: rgba(220,240,255,0.4);
    color: #2a5a80;
    font-size: 0.82rem;
    transition: background 0.15s, border-color 0.15s;
}
.attach-droparea:hover,
.attach-droparea.drag-over {
    background: rgba(160,210,255,0.35);
    border-color: #3a8ad0;
}

/* ── Viewer attachment ── */
.viewer-attachment {
    margin: 14px 0;
    padding-top: 12px;
    border-top: 1px solid #d8eaf5;
}
.viewer-attach-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: #2a5a80;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
