/* drive.css - v23.0 Zero-Shift & Perfect Center */

/* === 版面佈局 === */
.drive-layout {
    display: flex;
    height: 100%;
    gap: 20px;
    overflow: hidden;
}

.drive-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 右側預覽區 */
.drive-sidebar {
    width: 320px;
    background: var(--card-bg);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    border-radius: 16px;
    padding: 20px;
    overflow-y: auto;
    transition: 0.3s;
    flex-shrink: 0;
}

/* === 工具列 === */
.drive-toolbar {
    background: var(--card-bg);
    padding: 12px 20px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 1px solid var(--border-color);
    margin-bottom: 15px;
    gap: 15px;
    flex-shrink: 0;
}

.toolbar-left {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* 下拉選單 */
select.custom-select {
    appearance: none;
    -webkit-appearance: none;
    background-color: var(--input-bg) !important;
    color: var(--text-main) !important;
    border: 1px solid var(--border-color);
    padding: 8px 30px 8px 12px;
    border-radius: 8px;
    outline: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 14px;
}

/* 搜尋框 */
.search-wrapper {
    position: relative;
    flex: 1;
    max-width: 400px;
    display: flex;
    justify-content: center;
}

.search-wrapper input {
    background-color: var(--input-bg) !important;
    border: 1px solid var(--border-color);
    padding: 10px 15px 10px 40px;
    border-radius: 20px;
    color: var(--text-main) !important;
    width: 100%;
    outline: none;
    transition: 0.3s;
}

.search-wrapper input:focus {
    border-color: var(--accent);
    background-color: var(--card-bg) !important;
}

.search-wrapper i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-sub);
}

/* 按鈕 */
.btn-tool {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--input-bg);
    color: var(--text-sub);
    transition: 0.2s;
    font-size: 1.1rem;
}

.btn-tool:hover {
    background: var(--accent);
    color: white;
}

.btn-tool.active {
    background: var(--accent) !important;
    color: white !important;
    border: 1px solid var(--accent);
}

.btn-tool:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    background: var(--input-bg);
    color: var(--text-sub);
}

.divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
    margin: 0 5px;
}

.file-container-wrapper {
    flex: 1;
    overflow-y: auto;
    padding-right: 5px;
    position: relative;
}

/* =========================================
   ★ 格狀檢視 (Grid View) ★
   ========================================= */
.grid-files {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 15px;
    padding-bottom: 20px;
}

.grid-files .file-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    /* 預設 1px 邊框 */
    border-radius: 12px;
    height: auto;
    min-height: 160px;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: 0.1s;
    /* 確保內容置中 */
    align-items: center;
    justify-content: flex-start;
}

/* 懸停狀態 */
.grid-files .file-card:hover {
    transform: translateY(-4px);
    background: var(--bg-hover) !important;
}

/* ★★★ 關鍵修復：選取狀態不改變 border-width，改用 box-shadow 模擬 ★★★ */
/* 這樣內容就不會因為邊框變粗而往右/往下移 */
.grid-files .file-card.selected {
    border-color: var(--accent);
    background: var(--bg-hover) !important;
    /* 內陰影模擬加粗邊框，不佔空間 */
    box-shadow: inset 0 0 0 1px var(--accent);
}

/* 圖示區 */
.grid-files .file-icon-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--input-bg);
    width: 100%;
    padding: 15px 0;
}

.grid-files .file-icon-area img.file-icon {
    width: 64px;
    height: 64px;
    object-fit: contain;
    filter: drop-shadow(0 5px 5px rgba(0, 0, 0, 0.2));
}

.grid-files .file-icon-area img.preview-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.9;
}

/* 檔名區 (絕對置中) */
.grid-files .file-info {
    padding: 10px;
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
    min-height: 45px;
    display: flex;
    align-items: center;
    /* 垂直置中 */
    justify-content: center;
    /* 水平置中 */
    width: 100%;
    text-align: center;
    /* 文字置中 */
}

.grid-files .file-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-main);
    width: 100%;
    /* 換行邏輯 */
    white-space: normal;
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
}


/* =========================================
   ★ 條列檢視 (List View) ★
   ========================================= */
.list-files {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.list-files .file-card {
    display: flex;
    flex-direction: row;
    align-items: center;
    /* 垂直置中 */
    padding: 10px 20px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    /* 預設 1px */
    border-radius: 10px;
    cursor: pointer;
    height: auto;
    min-height: 60px;
    transition: 0.1s;
}

.list-files .file-card:hover {
    background: var(--bg-hover) !important;
}

/* ★★★ 關鍵修復：條列式選取狀態 ★★★ */
.list-files .file-card.selected {
    border-color: var(--accent);
    background: var(--bg-hover) !important;
    /* 內陰影模擬加粗 */
    box-shadow: inset 0 0 0 1px var(--accent);
}

/* 圖示區 */
.list-files .file-icon-area {
    width: 40px;
    height: 40px;
    background: transparent;
    margin-right: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.list-files .file-icon-area img.file-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.list-files .file-icon-area img.preview-thumb {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    object-fit: cover;
}

/* 檔名區 */
.list-files .file-info {
    background: transparent;
    border: none;
    padding: 0;
    display: flex;
    align-items: center;
    /* 垂直置中 */
    flex: 1;
    height: 100%;
}

.list-files .file-name {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-main);
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}


/* =========================================
   ★ 預覽區 (Preview) ★
   ========================================= */
.preview-placeholder {
    text-align: center;
    color: var(--text-sub);
    margin-top: 100px;
}

.preview-content {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.preview-image-box {
    width: 100%;
    height: 250px;
    background: #000;
    border-radius: 12px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.preview-image-box img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.preview-image-box i {
    font-size: 6rem;
    color: #555;
}

.preview-header {
    font-size: 1.2rem;
    font-weight: bold;
    text-align: center;
    margin-bottom: 20px;
    word-break: break-all;
    color: var(--text-main);
    line-height: 1.4;
}

.preview-details {
    flex: 1;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
    align-items: flex-start;
}

.detail-label {
    color: var(--text-sub);
    min-width: 50px;
    flex-shrink: 0;
    margin-top: 2px;
}

.detail-value {
    color: var(--text-main);
    font-weight: 500;
    text-align: right;
    white-space: normal;
    word-break: break-all;
    max-width: 75%;
    line-height: 1.4;
}

.btn-preview-action {
    flex: 1;
    padding: 12px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 1rem;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-secondary {
    background: var(--input-bg);
    color: var(--text-main);
}

/* 捲軸美化 */
.file-container-wrapper::-webkit-scrollbar {
    width: 8px;
}

.file-container-wrapper::-webkit-scrollbar-track {
    background: transparent;
}

.file-container-wrapper::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 4px;
}

.file-container-wrapper::-webkit-scrollbar-thumb:hover {
    background: #666;
}