/* ==========================================
   1. THIẾT LẬP NỀN TẢNG VÀ BIẾN ĐỊNH DẠNG (UI)
   ========================================== */
:root {
    --bg-main: #1e293b;         /* Màu nền tối xung quanh file */
    --bg-header: #0f172a;       /* Màu nền đen thanh công cụ */
    --text-white: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: #334155;
    
    /* Màu thương hiệu định dạng file */
    --color-pdf: #ef4444;       /* Đỏ góc PDF */
    --color-word: #2563eb;      /* Xanh đậm Word */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden; /* Chặn thanh cuộn toàn cục của trình duyệt */
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-main);
    /* Chặn hành vi giật kéo trang trên mobile (Pull-to-refresh) khi đang cuộn văn bản */
    overscroll-behavior-y: contain; 
}

/* ==========================================
   2. THANH CÔNG CỤ PHÍA TRÊN (HEADER BAR)
   ========================================== */
.viewer-header {
    height: 60px;
    width: 100%;
    background-color: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    position: relative;
    z-index: 10;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Nút quay lại tinh tế */
.back-btn {
    color: var(--text-muted);
    font-size: 18px;
    text-decoration: none;
    width: 36px;
    height: 36px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.back-btn:hover {
    color: var(--text-white);
    background-color: rgba(255, 255, 255, 0.08);
}

/* Khu vực hiển thị thông tin File */
.file-info {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 60vw;
}

.file-info i {
    font-size: 20px;
}

/* Đổi màu icon động theo định dạng file */
.pdf-icon { color: var(--color-pdf); }
.word-icon { color: var(--color-word); }
.excel-icon { color: #16a34a; }
.ppt-icon { color: #ea580c; }
.doc-icon { color: var(--text-muted); }

.file-name {
    color: var(--text-white);
    font-size: 15px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Nút Tải về (Download Button) */
.action-btn {
    background-color: #2563eb;
    color: white;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.action-btn:hover {
    background-color: #1d4ed8;
}

.action-btn:active {
    transform: scale(0.97);
}

/* ==========================================
   3. KHUNG HIỂN THỊ FILE CHÍNH (MAIN WORKSPACE)
   ========================================== */
.viewer-container {
    width: 100%;
    height: calc(100% - 60px); /* Trừ đi chiều cao thanh Header */
    position: relative;
    background-color: var(--bg-main);
    
    /* FIX LỖI CUỘN TRÊN IOS: Ép vùng chứa kiểm soát thanh cuộn thay vì iframe */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; 
}

/* Ép Iframe chiếm trọn không gian, sửa
/* ==========================================
   BỔ SUNG: CẤU HÌNH KHUNG HIỂN THỊ FILE WORD/PDF
   ========================================== */
.viewer-container {
    width: 100%;
    height: calc(100% - 60px); /* Chừa 60px cho thanh Header phía trên */
    position: relative;
    background-color: #1e293b;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; 
}

/* Ép Iframe tràn full 100% không gian còn lại */
#docViewer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    min-width: 100%;
    max-width: 100%;
    min-height: 100%;
    max-height: 100%;
    display: block;
    border: none;
    background-color: #f1f5f9;
}

/* --- THANH ĐIỀU HƯỚNG --- */
.navigation-header {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #ffffff;
    padding: 12px 20px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
    margin-bottom: 5px;
}

.nav-home-link {
    font-size: 14.5px;
    font-weight: 600;
    color: #0056b3;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: color 0.2s ease, transform 0.2s ease;
}

.nav-home-link:hover {
    color: #0042cc;
    transform: translateY(-1px);
}

.nav-separator {
    color: #94a3b8;
    font-size: 14px;
    user-select: none;
}

.nav-current {
    font-size: 14.5px;
    color: #64748b;
    font-weight: 500;
}

@media (max-width: 576px) {
    .navigation-header {
        padding: 10px 15px;
        font-size: 13.5px;
    }
}