/* ===== RESET ===== */
* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
        Roboto, Helvetica, Arial, sans-serif;
    background: #f6f7f9;
    color: #111;
}

/* ===== HEADER ===== */
header {
    padding: 20px;
    border-bottom: 1px solid #e5e5e5;
    background: #fff;
}

header h1 {
    margin: 0;
    font-size: 28px;
}

header p {
    margin: 4px 0 0;
    color: #666;
}

/* ===== SEARCH ===== */
#searchBox {
    width: calc(100% - 40px);
    margin: 16px 20px;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid #ddd;
    font-size: 15px;
}

#searchBox:focus {
    outline: none;
    border-color: #111;
}

/* ===== BREADCRUMB ===== */
#breadcrumb {
    padding: 0 20px 10px;
    font-size: 14px;
    color: #555;
    display: flex;
    align-items: center;
    gap: 12px;
}

#breadcrumb span {
    cursor: pointer;
}

#breadcrumb span:hover {
    text-decoration: underline;
}

/* ===== LAYOUT ===== */
.layout {
    display: flex;
    height: calc(100vh - 160px);
}

/* ===== FOLDER TREE ===== */
#folderTree {
    width: 260px;
    background: #fff;
    border-right: 1px solid #e5e5e5;
    padding: 16px;
    overflow-y: auto;
}

.tree {
    margin-bottom: 6px;
}

.tree-label {
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background .15s ease;
}

.tree-label:hover {
    background: #f0f0f0;
}

.tree.open>.tree-label {
    font-weight: 600;
}

.tree-children {
    display: none;
    margin-left: 14px;
    margin-top: 4px;
}

.tree.open>.tree-children {
    display: block;
}

/* ===== GALLERY ===== */
main {
    flex: 1;
    overflow-y: auto;
}

#gallery {
    padding: 16px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

#gallery img {
    width: 100%;
    border-radius: 12px;
    cursor: pointer;
    background: #ddd;
    transition: transform .2s ease, box-shadow .2s ease;
}

#gallery img:hover {
    transform: scale(1.03);
    box-shadow: 0 10px 20px rgba(0, 0, 0, .15);
}

/* ===== LIGHTBOX ===== */
#lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

#lightbox.show {
    display: flex;
}

#lightbox img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 8px;
}

/* nav buttons */
#lightbox button {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
}

#prev,
#next {
    position: absolute;
    top: 50%;
    font-size: 48px;
    transform: translateY(-50%);
    opacity: .7;
}

#prev:hover,
#next:hover {
    opacity: 1;
}

#prev {
    left: 20px;
}

#next {
    right: 20px;
}

/* top bar */
.top-bar {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#lbDownload {
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    text-decoration: underline;
    opacity: .85;
}

#lbDownload:hover {
    opacity: 1;
}

#close {
    font-size: 28px;
    opacity: .8;
}

#close:hover {
    opacity: 1;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .layout {
        flex-direction: column;
        height: auto;
    }

    #folderTree {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #e5e5e5;
        max-height: 220px;
    }

    main {
        height: calc(100vh - 380px);
    }
}

#downloadFolderBtn {
    margin-left: auto;
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid #ddd;
    background: #fff;
    cursor: pointer;
    font-size: 13px;
}

#downloadFolderBtn:hover {
    margin-left: auto;
    background: #111;
    color: #fff;
}

.zip-progress {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 260px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .2);
    padding: 10px;
    z-index: 9999;
}

.zip-progress.hidden {
    display: none;
}

.zip-progress .bar {
    height: 6px;
    background: #111;
    width: 0%;
    border-radius: 6px;
    transition: width .2s ease;
}

.zip-progress .label {
    font-size: 12px;
    margin-top: 6px;
    display: block;
    color: #555;
}
.loader {
    width: 48px;
    height: 48px;
    border: 4px solid #ddd;
    border-top-color: #111;
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
    margin: 40px auto;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loader.hidden {
    display: none;
}
