/* --- CÀI ĐẶT CHUNG & BIẾN MÀU --- */
:root {
  /* Chế độ sáng (Mặc định) */
  --bg-color: #f4f6fa;
  --content-bg-color: #ffffff;
  --header-bg-color: #ffffff;
  --text-color-primary: #202124;
  --text-color-secondary: #5f6368;
  --border-color: #dadce0;
  --hover-bg-color: #f1f3f4;
  --table-header-bg: linear-gradient(90deg, #eef3fa, #f7fafd 90%);
  --table-row-odd-bg: #f8fafc;
  --table-row-hover-bg: #e9f3ff;
  --table-border-color: #d5e2f3;
  --modal-bg: rgba(0,0,0,0.4);
  --shadow-color-light: #1976d210;
  --shadow-color-medium: #1976d222;
  --link-color: #1976d2;

  /* Màu gốc không đổi */
  --primary-color: #1a73e8;
  --danger-color: #d93025;
  --success-color: #1e8e3e;
  --info-color: #17a2b8;
  --background-blur: rgba(255, 255, 255, 0.85);
}

body.dark-mode {
  /* Chế độ tối */
  --bg-color: #121212;
  --content-bg-color: #1e1e1e;
  --header-bg-color: #1f1f1f;
  --text-color-primary: #e8eaed;
  --text-color-secondary: #9aa0a6;
  --border-color: #3c4043;
  --hover-bg-color: #2d2d2d;
  --table-header-bg: linear-gradient(90deg, #2a2a2a, #2c2c2c 90%);
  --table-row-odd-bg: #242424;
  --table-row-hover-bg: #3c4043;
  --table-border-color: #3c4043;
  --modal-bg: rgba(0,0,0,0.7);
  --shadow-color-light: #00000030;
  --shadow-color-medium: #00000050;
  --link-color: #8ab4f8;
  --background-blur: rgba(30, 30, 30, 0.85);
}

body { 
  font-family: 'Google Sans', 'Be Vietnam Pro', Arial, sans-serif; 
  margin: 0; 
  color: var(--text-color-primary);
  background-color: var(--bg-color);
  transition: background-color 0.3s, color 0.3s;
}
button, .btn { cursor: pointer; border: none; background: none; font-family: inherit; }

/* === NÚT GẠT CHẾ ĐỘ TỐI === */
.theme-switch-wrapper {
  display: flex;
  align-items: center;
}
.theme-switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
}
.theme-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 24px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}
input:checked + .slider {
  background-color: var(--primary-color);
}
input:checked + .slider:before {
  transform: translateX(26px);
}
/* Thêm icon mặt trời/mặt trăng */
.slider:after {
    content: '☀️';
    font-size: 12px;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    right: 6px;
}
body.dark-mode .slider:after {
    content: '🌙';
    left: 6px;
    right: auto;
}


/* --- GIAO DIỆN KHI CHƯA ĐĂNG NHẬP --- */
#login-wrapper {
    display: flex; 
    justify-content: center; 
    align-items: center; 
    height: 100vh; 
    margin: 0; 
    background: linear-gradient(45deg, #6dd5ed, #2193b0);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
}
@keyframes gradientBG {
    0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; }
}
#login-container { 
  display: flex; flex-direction: column; text-align: center; 
  padding: 45px; border-radius: 20px; box-shadow: 0 15px 35px rgba(0,0,0,0.15); 
  width: 90%; max-width: 420px; background-color: var(--background-blur);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  animation: fadeIn 0.8s ease-out;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }
.logo {
    width: 80px; height: 80px;
    background-image: url('/api/itq.png');
    background-size: cover; background-position: center;
    border-radius: 50%; margin: 0 auto 20px auto;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}
#login-container h1 { font-size: 28px; font-weight: 700; margin-bottom: 10px; color: var(--text-color-primary); }
#login-container p { font-size: 16px; color: var(--text-color-secondary); margin-bottom: 30px; }
.google-btn { display: inline-flex; align-items: center; justify-content: center; padding: 12px 24px; background: #fff; color: #444; border: 1px solid var(--border-color); border-radius: 10px; text-decoration: none; font-weight: 500; transition: all 0.3s ease; }
.google-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.1); }
.google-btn img { margin-right: 12px; }

/* --- GIAO DIỆN ỨNG DỤNG CHÍNH --- */
#app-container { 
    display: none; 
}
.drive-header { display: flex; align-items: center; background: var(--header-bg-color); height: 57px; box-shadow: 0 1px 8px var(--shadow-color-medium); padding: 0 28px; z-index: 10; border-bottom: 1px solid var(--border-color);}
.header-title { font-size: 21px; color: var(--link-color); font-weight: 700; }
.user-info { margin-left: auto; display: flex; align-items: center; gap: 15px; }
#user-display { font-size: 14px; color: var(--text-color-primary); }
#logout-btn { background: none; border: 1px solid var(--border-color); color: var(--text-color-secondary); padding: 8px 12px; border-radius: 5px; transition: background-color 0.2s; }
#logout-btn:hover { background-color: var(--hover-bg-color); }

/* --- CHỈNH SỬA ---: Nới rộng khung nội dung chính ra 95% */
.main-content {
    width: 95%; /* Đặt chiều rộng bằng 95% */
    max-width: none; /* Gỡ bỏ giới hạn chiều rộng tối đa cũ */
    margin: 28px auto; /* Căn giữa theo chiều ngang và thêm khoảng cách trên dưới */
    background: var(--content-bg-color);
    border-radius: 18px;
    box-shadow: 0 2px 28px var(--shadow-color-light);
    padding: 32px 40px 36px 40px;
    min-height: 540px;
}

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 18px; }
.toolbar .upload-label, .toolbar .btn-create {
    height: 40px;
    box-sizing: border-box;
}
.btn-create { background: var(--primary-color); color: #fff; border: none; border-radius: 8px;}
.btn-create:hover { background: #0c56a5; }
.upload-label { padding: 9px 19px; border-radius: 8px; font-size: 16px; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center;}
.upload-label.upload-file { background: var(--success-color); color: #fff; }
.upload-label.upload-file:hover { background: #188038; }
.upload-label input { display: none; }
.breadcrumbs { margin-bottom: 14px; font-size: 16px; color: var(--text-color-primary); display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }
.breadcrumbs span { cursor: pointer; color: var(--link-color); font-weight: 500; }
.breadcrumbs .mdi-chevron-right { color: var(--text-color-secondary); }
.breadcrumbs .breadcrumb-current { font-weight: bold; color: var(--text-color-primary); background: var(--hover-bg-color); border-radius: 5px; padding: 1px 7px; pointer-events: none; }

/* Bảng file */
.file-list { width: 100%; border-collapse: separate; border-spacing: 0; background: transparent; border-radius: 13px; overflow: hidden; box-shadow: 0 1px 16px var(--shadow-color-light); }
.file-list th, .file-list td { font-size: 15.8px; padding: 14px 12px; vertical-align: middle; text-align: left;}
.file-list th { color: var(--link-color); font-weight: 700; background: var(--table-header-bg); border-bottom: 2px solid var(--table-border-color); }
.file-list tbody tr { background: var(--content-bg-color); border-bottom: 1.5px solid var(--border-color); transition: background-color 0.2s ease;}
.file-list tbody tr:nth-child(odd) { background: var(--table-row-odd-bg); }
.file-list tbody tr:hover { background: var(--table-row-hover-bg); }
tr.row-selected { background-color: rgba(26, 115, 232, 0.15) !important;}
.file-list td { color: var(--text-color-primary); word-break: break-all; }
.col-name { width: 50%; font-weight: 600; }
.col-time, .col-size, .col-action { text-align: center; }
.col-action .action-group { justify-content: center; display: flex;}
.btn-action { background: none; border: none; font-size: 24px; cursor: pointer; padding: 5px; border-radius: 50%;}
.btn-download { color: var(--success-color); }
.btn-delete { color: var(--danger-color); }
.btn-download:hover { background: var(--hover-bg-color); }
.btn-delete:hover { background: var(--hover-bg-color); }

/* Toast, Modal, Progress bar */
.progress-wrap { display: none; align-items: center; gap: 10px; flex-grow: 1; }
.progress-bar { width: 0%; height: 8px; background-color: var(--primary-color); border-radius: 4px; transition: width 0.2s; }
.progress-text { font-size: 12px; color: var(--text-color-secondary); white-space: nowrap; }
.btn-cancel-upload { font-size: 20px; color: var(--text-color-secondary); padding: 5px; border-radius: 50%; }
.btn-cancel-upload:hover { background-color: #e0e0e0; color: var(--danger-color); }
#toast-container { position: fixed; top: 20px; right: 20px; z-index: 1000; }
.toast { padding: 12px 18px; border-radius: 4px; color: #fff; margin-bottom: 10px; box-shadow: 0 2px 10px rgba(0,0,0,0.2); display: flex; align-items: center; gap: 10px; animation: slideIn 0.3s ease; }
.toast.fade-out { animation: fadeOut 0.5s ease forwards; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; transform: translateY(-20px); } }
.toast-success { background-color: var(--success-color); }
.toast-error { background-color: var(--danger-color); }
.toast-info { background-color: var(--info-color); }
.modal-bg { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: var(--modal-bg); display: none; align-items: center; justify-content: center; z-index: 1001; }
.modal { background: var(--content-bg-color); padding: 24px; border-radius: 8px; width: 90%; max-width: 400px; box-shadow: 0 4px 20px rgba(0,0,0,0.2); animation: zoomIn 0.3s; }
@keyframes zoomIn { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-title { font-size: 18px; font-weight: 500; display: flex; align-items: center; gap: 10px; margin-bottom: 15px; color: var(--link-color);}
.modal input[type="text"] { width: 100%; padding: 10px; border: 1px solid var(--border-color); border-radius: 4px; font-size: 16px; box-sizing: border-box; background-color: var(--bg-color); color: var(--text-color-primary);}
.modal-actions { margin-top: 20px; display: flex; justify-content: flex-end; gap: 10px; }
.modal .btn-primary { background-color: var(--primary-color); color: #fff; }
.modal .btn-cancel { border: 1px solid var(--border-color); color: var(--text-color-primary);}
.drop-area { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(26, 115, 232, 0.1); border: 2px dashed var(--primary-color); z-index: 9999; display: none; align-items: center; justify-content: center; font-size: 24px; color: var(--primary-color); font-weight: 500; pointer-events: none; }
.drop-area.drop-area-show { display: flex; }

/* === CSS CHO GIAO DIỆN MỚI & TÍNH NĂNG CHỌN NHIỀU FILE === */

/* --- CHỈNH SỬA ---: Làm gọn thanh thông tin */
.storage-bar-container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px 15px; /* Khoảng cách dọc 5px, ngang 15px */
    margin-bottom: 20px;
    padding: 8px 15px;
    background-color: var(--hover-bg-color);
    border-radius: 8px;
}
.storage-text, .storage-limit-text {
    font-size: 13px; /* Giảm kích thước chữ */
    color: var(--text-color-secondary);
    margin: 0; /* Bỏ margin không cần thiết */
}

.storage-progress {
    width: 100%;
    height: 8px;
    background-color: var(--hover-bg-color);
    border-radius: 4px;
    overflow: hidden;
}
.storage-progress-bar {
    height: 100%;
    width: 0%;
    background-color: var(--primary-color);
    border-radius: 4px;
    transition: width 0.5s ease-in-out;
}

/* Cột ô tích */
.col-checkbox {
    width: 40px;
    text-align: center;
}
#select-all-checkbox, .file-checkbox {
    cursor: pointer;
    width: 18px;
    height: 18px;
}

/* Thanh công cụ xóa hàng loạt */
.bulk-actions-toolbar {
    display: none; /* Mặc định ẩn */
    align-items: center;
    padding: 10px 15px;
    margin-bottom: 15px;
    background-color: var(--primary-color);
    color: white;
    border-radius: 8px;
    animation: slideDown 0.3s ease-out;
}
#selection-count {
    font-weight: 500;
    margin-right: auto;
}
.bulk-actions-toolbar .btn-delete {
    background-color: white;
    color: var(--danger-color);
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    border-radius: 5px;
}
.bulk-actions-toolbar .btn-delete:hover {
    background-color: #fce8e6;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Đổi màu chữ tên file/thư mục sang vàng trong chế độ tối */
body.dark-mode .file-link {
    color: #fdd835 !important; /* Màu vàng sáng 
body.dark-mode .file-link, 
body.dark-mode .folder-link {*/
}

/* Style cho nhóm nút trên thanh công cụ hàng loạt */
.bulk-buttons {
    display: flex;
    gap: 10px;
}

.bulk-actions-toolbar .btn-download {
    background-color: white;
    color: var(--success-color);
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    border-radius: 5px;
}

.bulk-actions-toolbar .btn-download:hover {
    background-color: #e6f4ea;
}

/* =================================== */
/* === TỐI ƯU CHO THIẾT BỊ DI ĐỘNG === */
/* =================================== */

@media (max-width: 768px) {
    body {
        padding: 0; /* Bỏ padding của body trên mobile */
    }

    /* --- Tối ưu Header --- */
    .drive-header {
        padding: 0 15px;
        height: 60px;
    }
    .header-title {
        font-size: 18px; /* Giảm kích thước tiêu đề */
    }
    #user-display {
        display: none; /* Ẩn tên người dùng để tiết kiệm không gian */
    }

    /* --- Tối ưu Content Area --- */
    /* --- CHỈNH SỬA ---: Bỏ `width: 95%` trên mobile vì nó đã full-width */
    .main-content {
        margin: 15px;
        padding: 20px 15px; /* Giảm padding bên trong */
        min-height: auto;
    }

    /* --- Chuyển các nút thành dạng dọc --- */
    .toolbar {
        flex-direction: column; /* Xếp các nút theo chiều dọc */
        align-items: stretch; /* Kéo dài các nút cho bằng nhau */
    }
    .toolbar .upload-label, .toolbar .btn-create {
        width: 100%; /* Các nút chiếm toàn bộ chiều rộng */
        justify-content: center;
    }
    .progress-wrap {
        width: 100%;
    }

    /* --- Biến bảng thành dạng thẻ (card) --- */
    .file-list {
        border: none;
        box-shadow: none;
    }
    .file-list thead {
        display: none; /* Ẩn header của bảng */
    }
    .file-list tbody, .file-list tr, .file-list td {
        display: block; /* Chuyển tất cả thành dạng block */
        width: 100% !important; /* Ghi đè các style cũ */
        box-sizing: border-box;
    }
    .file-list tr {
        margin-bottom: 15px;
        border-radius: 8px;
        border: 1px solid var(--border-color);
        padding: 10px;
        box-shadow: 0 1px 4px rgba(0,0,0,0.05);
    }
    body.dark-mode .file-list tr {
         box-shadow: 0 1px 4px rgba(0,0,0,0.2);
    }

    .file-list td {
        padding: 8px 5px;
        border: none;
        display: flex;
        align-items: center;
        justify-content: space-between; /* Căn chỉnh nội dung */
    }

    /* Thêm lại "tiêu đề" cho từng dòng dữ liệu */
    .file-list td:before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-color-secondary);
        margin-right: 10px;
    }

    /* Căn chỉnh lại các cột */
    .col-checkbox {
        justify-content: flex-start !important;
    }
    .col-checkbox:before {
        content: "Chọn";
    }
    .col-name {
        font-size: 1.1em;
        word-break: break-all;
        flex-wrap: wrap;
    }
    .col-name:before {
        display: none; /* Không cần nhãn cho cột tên */
    }
    .col-time:before {
        content: "Ngày cập nhật:";
    }
    .col-size:before {
        content: "Dung lượng:";
    }
    .col-action {
         border-top: 1px solid var(--border-color);
         padding-top: 10px !important;
         margin-top: 5px;
    }
    .col-action:before {
        content: "Tác vụ:";
    }
    .col-action .action-group {
        justify-content: flex-end; /* Đẩy nút tác vụ sang phải */
    }

    /* Tối ưu Modal */
    .modal {
        padding: 20px;
    }

    /* Tối ưu thanh công cụ hàng loạt */
    .bulk-actions-toolbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    #selection-count {
        margin-right: 0;
        margin-bottom: 5px;
    }
    .bulk-buttons {
        align-self: flex-end; /* Đẩy các nút sang phải */
    }
}

/* ================================================ */
/* === TÙY CHỈNH CỘT CHO ADMIN (THÊM MỚI) === */
/* ================================================ */

/* Đặt chiều rộng cố định cho 2 cột của Admin */
.file-list .col-admin {
    width: 150px; /* Bạn có thể thay đổi số này */
    white-space: nowrap; /* Ngăn tiêu đề bị xuống dòng */
    text-align: right; /* Căn phải cho đẹp hơn */
}

/* Chỉnh lại kích thước ô nhập liệu bên trong */
.quota-input {
    width: 100px; /* Bạn có thể thay đổi số này */
    padding: 6px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-color);
    color: var(--text-color-primary);
    border-radius: 4px;
    box-sizing: border-box; /* Quan trọng: để padding không làm tăng kích thước */
    text-align: right;
}