/* ========================================================
   1. RESET & NỀN TẢNG (BASE)
   ======================================================== */
* {
    box-sizing: border-box;
}

body {
    font-family: system-ui, -apple-system, sans-serif;
    margin: 0;
    background: #f5f7fa;
    color: #1e293b;
    overflow-x: hidden;
}

/* ========================================================
   2. HEADER & THANH TÌM KIẾM (STICKY)
   ======================================================== */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: #0f172a;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.header-main {
    padding: 6px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.controls-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.search {
    flex: 1;
}

.search input {
    width: 100%;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    color: white;
    font-size: 13px;
    outline: none;
}

.btn-upload {
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
}
.btn-upload:hover {
  background: #e2e8f0;
}
/* ===== PROGRESS BAR (CĂN TRÁI) ===== */
.progress-container {
  display:none;
  width: 100%;
  max-width: 250px; /* Độ rộng vừa phải cho bên trái */
  margin-top: 4px;
  color: white
}
/* ========================================================
   3. ĐIỀU HƯỚNG BREADCRUMB
   ======================================================== */
#path {
    padding: 4px 12px 6px;
    background: rgba(15, 23, 42, 0.95);
    display: flex;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none; /* Firefox */
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    color:white;
}

#path::-webkit-scrollbar { display: none; } /* Chrome/Safari */

#path span {
    padding: 2px 8px;
    background: rgba(255, 255, 255, 0.08);
    color: #cbd5e1;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: 0.2s;
}

#path span:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

#path .current {
    background: #2563eb;
    color: white;
    cursor: default;
}

/* ========================================================
   4. HỆ THỐNG LƯỚI (GRID) & THẺ (CARD)
   ======================================================== */
.grid {
    display: grid;
    gap: 16px;
    padding: 16px;
}

/* Responsive Grid */
@media (max-width: 640px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 641px) { .grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); } }

.card {
    background: white;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    transition: 0.2s ease;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
}

.card img {
    width: 100%;
    height: 140px;
    object-fit: contain;
    background: #f8fafc;
    padding: 5px;
}

.card .name {
    padding: 10px;
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    color: #334155;
    word-break: break-all;
}

.folder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    height: 140px;
    background: #f8fafc;
}

/* ========================================================
   5. CỬA SỔ XEM ẢNH (MODAL)
   ======================================================== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(15, 23, 42, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    touch-action: none;
}

.modal.show { display: flex; touch-action: none; }

/* Tên file hiện phía trên ảnh */
.preview-name {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1020;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    padding: 6px 15px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid rgba(255, 255, 255, 0.2);
    max-width: 80%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#previewImg {
    max-width: 90vw;
    max-height: 75vh;
    object-fit: contain;
    transition: opacity 0.3s, transform 0.3s;
}

/* Hiệu ứng chuyển cảnh */
.fade-out-left { opacity: 0; transform: translateX(-30px); }
.fade-out-right { opacity: 0; transform: translateX(30px); }

/* Nút điều hướng Next/Prev */
.nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: none;
    font-size: 30px;
    padding: 20px 15px;
    cursor: pointer;
    border-radius: 8px;
    z-index: 1010;
    transition: 0.2s;
}
/* Khóa cuộn trang khi mở Modal */
body.no-scroll {
    overflow: hidden !important;
    height: 100vh; /* Giới hạn chiều cao bằng màn hình */
}
.nav-btn:hover { background: rgba(255, 255, 255, 0.3); }
.prev { left: 20px; }
.next { right: 20px; }

/* Các nút chức năng (Download, Share, Close) */
.modal-actions {
    position: fixed;
    bottom: 48px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 12px;
    z-index: 1030;
}

.modal-actions button {
    padding: 12px 20px;
    border-radius: 10px;
    border: none;
    font-weight: 600;
    cursor: pointer;


    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);


    position: relative;
    will-change: transform;
}

.modal-actions button:hover {
    transform: translateY(-5px) scale(1.08);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}
.modal-actions button:active {
    transform: translateY(-1px) scale(0.95);
    transition: 0.1s;
}
.btn-primary { background: #3b82f6; color: white; }
.btn-share { background: #8b5cf6; color: white; }
.btn-close { background: white; color: #1e293b; }

/* ========================================================
   6. TỐI ƯU CHO THIẾT BỊ DI ĐỘNG (MOBILE)
   ======================================================== */
@media (max-width: 640px) {
    /* Thêm đoạn này để khóa cuộn triệt để trên Mobile */
    body.no-scroll {
        touch-action: none;
        -webkit-overflow-scrolling: none;
        overflow: hidden !important;
    }

    /* Giữ nguyên các phần cũ của bạn bên dưới */
    .nav-btn {
        padding: 15px 10px;
        font-size: 20px;
        background: rgba(0, 0, 0, 0.3);
    }

    .modal-actions {
        width: 95%;
        bottom: 20px;
        gap: 8px;
    }

    .modal-actions button {
        flex: 1;
        padding: 12px 5px;
        font-size: 13px;
    }
}
/* --- Panel Upload: Đảm bảo nội dung nằm gọn --- */
.upload-panel {
    background: white;
    padding: 25px;
    border-radius: 20px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
}

/* Nút chọn file: Đã sửa kích thước và hiệu ứng */
#btnSelectFile {
    display: block;
    width: 100%;
    padding: 15px 30px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.3);
    margin-bottom: 20px;
}

#btnSelectFile:hover {
    background: #2563eb;
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(59, 130, 246, 0.4);
}

#btnSelectFile:active {
    transform: translateY(0);
}

/* Khu vực nút chức năng bên dưới */
.upload-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    width: 100%;
}

.upload-actions button {
    flex: 1;
    padding: 12px 5px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    font-weight: 600;
    cursor: pointer;
    background: #f1f5f9;
    color: #1e293b;
    font-size: 14px;
    transition: all 0.2s;
}

.upload-actions button:hover {
    background: #e2e8f0;
    transform: translateY(-2px);
}
