/* --- Main Container Styles --- */
.button-container {
    position: absolute;
    top: 0px;
    right: -30px;
    z-index: 10;
}
.view-button {
    background-color: rgba(255, 255, 255, 0.7);
    border: none;
    padding: 10px;
    font-size: 20px;
    cursor: pointer;
    margin-left: 10px;
    border-radius: 5px;
    transition: background-color 0.3s, color 0.3s;
}
.view-button i {
    color: #333;
}
.view-button:hover {
    background-color: #ff9913;
}
.view-button:hover i {
    color: #fff;
}
.file-container {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}
.file-item p {
    font-size: 12px;
    margin-top: 5px;
    text-align: center;
    word-break: break-word;
}
.file-item {
    cursor: pointer;
}
.file-item img[alt] {
    font-size: 10px;
}
.file-item img:before {
    content: "\f15b";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 24px;
    color: #888;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
}
.folder-icon {
    width: 120px;
    min-width: 80px;
    height: 170px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 48px;
    color: white;
    background-color: #ff9913;
    border-radius: 5px;
}

.file-icon {
    width: 120px;
    height: 170px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 36px;
    color: #888;
    background-color: #efeeef;
    border-radius: 5px;
    border: 1px solid #ccc;
}

/* --- Grid View --- */
.grid-view {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}
.grid-view .file-item {
    width: 120px;
    text-align: center;
}
.grid-view .file-item p {
    width: 120px; /* Match width */
}
.grid-view .file-item img {
    width: 120px; /* Match width */
    height: 170px;
    object-fit: cover;
    border-radius: 5px;
    border: 0.1px solid #ccc;
    background: #eee;
    display: block;
}

/* --- List View --- */
.list-view {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
}
.list-view .file-item {
    display: flex;
    align-items: center;
    gap: 15px;
    width: 100%;
    flex-wrap: nowrap;
}
.list-view .file-inner {
    display: flex;
    align-items: center;
    gap: 15px;
}
.list-view .file-item img {
    width: 45px;
    height: 60px;
    object-fit: cover;
    border-radius: 5px;
    border: 1px solid #ccc;
    flex-shrink: 0;
    background: #eee;
}
.list-view .file-item p {
    margin: 0;
    font-size: 14px;
    flex-grow: 1;
    text-align: left;
    white-space: normal;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-view .file-item .file-icon {
    width: 45px;
    min-width: 45px;
    height: 60px;
    font-size: 14px;
    }

/* --- Popup Styles --- */
#popup-container {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    justify-content: center;
    align-items: center;
    z-index: 99999;
}
#popup {
    position: relative;
    background: white;
    padding: 15px;
    width: 80%;
    max-width: 700px;
    border-radius: 10px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}
#popup iframe {
    width: 100%;
    height: 450px;
    border: 1px solid #ccc;
    border-radius: 10px;
}
#popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 10px;
    border-bottom: 1px solid #eee;
}
#file-name {
    font-weight: bold;
    text-align: left;
    flex-grow: 1;
}
#popup-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
}
#popup-buttons .view-button {
    padding: 8px 10px;
    font-size: 16px;
}
#close-popup {
    cursor: pointer;
    font-size: 18px;
    color: red;
    border: none;
    background: none;
    padding: 8px 10px;
    border-radius: 5px;
    transition: background 0.3s, color 0.3s;
}
#close-popup:hover {
    background-color: #ff9913;
    color: #fff;
}
#back-button {
    background-color: rgba(238, 238, 238, 0.7);
    border: none;
    padding: 8px 10px;
    cursor: pointer;
    border-radius: 5px;
    font-size: 16px;
    transition: background 0.3s, color 0.3s;
}
#back-button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}
#back-button:not(:disabled):hover {
    background-color: #ff9913;
    color: #fff;
}
#download-button {
    display: inline-block;
    margin-top: 10px;
    padding: 8px 15px;
    background: #38b6ff;
    color: white;
    border-radius: 5px;
    text-decoration: none;
    font-size: 16px;
    transition: background 0.2s ease-in-out;
}
#download-button:hover {
    background: #ff9913;
}
#preview-folder {
    width: 100%;
    height: 450px; /* Match iframe height */
    overflow-y: auto;
    display: block;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 10px;
    background: #f9f9f9;
    box-sizing: border-box;
}

/* --- Responsive Styles --- */
@media (max-width: 1024px) {
    .button-container {
        top: 10px;
        right: 10px;
    }
}
@media (max-width: 768px) {
    .button-container {
        top: 5px;
        right: 5px;
    }
    .view-button {
        padding: 7px;
        font-size: 13px;
    }
    .grid-view .file-item,
    .grid-view .file-item p,
    .grid-view .file-item img,
    .folder-icon {
        width: 80px;
    }
    .grid-view .file-item img,
    .folder-icon {
        height: 120px;
    }
    .file-icon {
    width: 80px;
    height: 120px;
    }
    
    #popup {
        width: 95%;
        padding: 10px;
    }
    #popup iframe, #preview-folder {
        height: 400px;
    }
    #popup-header {
        font-size: 12px;
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    #popup-buttons {
        align-self: flex-end;
    }
}