:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-glow: rgba(37, 99, 235, 0.2);
    --bg-color: #f1f5f9;
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-bg-inner: rgba(255, 255, 255, 0.6);
    --glass-border: rgba(0, 0, 0, 0.08);
    --text-main: #0f172a;
    --text-muted: #64748b;
    --success: #059669;
    --font-main: 'Inter', sans-serif;
    --sidebar-bleed: 1.75rem;
    --sidebar-inner-x: 0.2rem;
}

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

body {
    font-family: var(--font-main);
    background: var(--bg-color);
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(37, 99, 235, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 85% 30%, rgba(16, 185, 129, 0.05) 0%, transparent 50%);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    overflow: hidden;
}

.app-container {
    display: flex;
    width: 100vw;
    height: 100vh;
    padding: 1.5rem;
    gap: 1.5rem;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 1.25rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.05);
}

.glass-panel-inner {
    background: var(--glass-bg-inner);
    border: 1px solid var(--glass-border);
    border-radius: 0.75rem;
}

/* Sidebar */
.sidebar {
    width: 332px;
    padding: 1.75rem;
    display: flex;
    flex-direction: column;
    gap: 1.4rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-icon {
    font-size: 2.5rem;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 4px 6px var(--primary-glow));
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: #1e293b;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
}

.filters {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: calc(100% + (var(--sidebar-bleed) * 2));
    margin-left: calc(var(--sidebar-bleed) * -1);
    padding-inline: var(--sidebar-inner-x);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.select-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 44px;
    align-items: stretch;
    gap: 0.5rem;
    width: 100%;
}

.filter-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-left: 0;
    padding-inline: 0.3rem;
}

.search-select {
    position: relative;
    flex: 1;
}

.search-select-trigger {
    width: 100%;
    min-height: 44px;
    padding: 0.68rem 0.9rem;
    background: #ffffff;
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    border-radius: 0.75rem;
    font-size: 0.9rem;
    font-family: var(--font-main);
    outline: none;
    transition: all 0.3s ease;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-align: left;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}

.search-select-trigger:focus,
.search-select.open .search-select-trigger {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.search-select-trigger:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: #f8fafc;
}

.search-select-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: 0.75rem;
}

.search-select-caret {
    font-size: 0.8rem;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.search-select.open .search-select-caret {
    transform: rotate(180deg);
}

.search-select-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 0.9rem;
    box-shadow: 0 18px 38px rgba(15, 23, 42, 0.14);
    z-index: 50;
    overflow: hidden;
}

.search-select-search {
    padding: 0.6rem 0.6rem 0.45rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.search-select-input {
    width: 100%;
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 0.7rem;
    background: #f8fafc;
    color: var(--text-main);
    padding: 0.65rem 0.8rem;
    font-size: 0.86rem;
    font-family: var(--font-main);
    outline: none;
}

.search-select-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
    background: #ffffff;
}

.search-select-options {
    max-height: 220px;
    overflow-y: auto;
    padding: 0.3rem;
}

.search-select-option {
    width: 100%;
    border: none;
    background: transparent;
    border-radius: 0.7rem;
    color: var(--text-main);
    font-size: 0.88rem;
    font-family: var(--font-main);
    text-align: left;
    padding: 0.7rem 0.8rem;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.search-select-option:hover,
.search-select-option.is-active {
    background: #eff6ff;
    color: var(--primary);
}

.search-select-option.is-selected {
    background: rgba(37, 99, 235, 0.08);
    color: var(--primary);
    font-weight: 600;
}

.search-select-empty {
    padding: 0.9rem 1rem 1rem;
    color: var(--text-muted);
    font-size: 0.88rem;
    text-align: center;
}

.status-card {
    padding: 1.5rem;
    text-align: center;
    margin-top: auto;
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    background: #ffffff;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* File List Header with Upload Button */
.file-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0;
}

/* Icon Buttons (Download / Upload) */
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    background: transparent;
    color: var(--text-muted);
    flex-shrink: 0;
}

.icon-btn:hover {
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary);
    transform: scale(1.1);
}

.icon-btn:active {
    transform: scale(0.95);
}

.icon-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none !important;
    background: transparent !important;
    color: var(--text-muted) !important;
}

.icon-btn .material-symbols-rounded {
    font-size: 20px;
}

/* Upload button specific */
.upload-btn {
    position: absolute;
    top: 0.55rem;
    right: 0.55rem;
    background: linear-gradient(180deg, #f8fbff, #e8f0ff);
    color: var(--primary);
    border: 1px solid rgba(37, 99, 235, 0.18);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.12);
}

.upload-btn:hover:not(:disabled) {
    background: rgba(37, 99, 235, 0.18);
    border-color: rgba(37, 99, 235, 0.3);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.15);
}

.create-folder-btn {
    width: 44px;
    min-width: 44px;
    height: 44px;
    background: linear-gradient(180deg, #f8fbff, #e8f0ff);
    color: var(--primary);
    border: 1px solid rgba(37, 99, 235, 0.18);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.08);
}

.create-folder-btn:hover:not(:disabled) {
    background: rgba(37, 99, 235, 0.18);
    border-color: rgba(37, 99, 235, 0.3);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.15);
}

.create-folder-btn:disabled {
    opacity: 0.45;
    background: linear-gradient(180deg, #f8fbff, #eef4ff) !important;
    color: #7c8da8 !important;
    border: 1px solid rgba(148, 163, 184, 0.2) !important;
    box-shadow: none;
}

/* Download button in file row */
.download-btn {
    opacity: 0;
    transition: all 0.2s ease;
}

.file-list li:hover .download-btn {
    opacity: 1;
}

/* File Actions Container */
.file-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: auto;
    flex-shrink: 0;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    overflow: hidden;
}

.top-bar {
    padding: 1.25rem 2rem;
    display: flex;
    align-items: center;
    background: #ffffff;
}

.top-bar h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
}

.content-area {
    flex: 1;
    display: flex;
    gap: 1.5rem;
    overflow: hidden;
}

.file-list-container {
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    padding: 0.55rem 0 0;
    width: calc(100% + (var(--sidebar-bleed) * 2));
    margin-left: calc(var(--sidebar-bleed) * -1);
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 1.05rem;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 252, 0.94));
    box-shadow: 0 14px 32px rgba(15, 23, 42, 0.08);
    display: flex;
}

.file-list-header {
    padding: 0 0.45rem 0 0.55rem;
    min-height: 1.9rem;
}

.file-list-container h3 {
    margin-bottom: 0;
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    letter-spacing: -0.01em;
}

.file-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow-y: auto;
    margin-top: 0.45rem;
    padding: 0.18rem 0 0.18rem 0;
    background: rgba(248, 250, 252, 0.72);
    border-top: 1px solid rgba(148, 163, 184, 0.12);
    border-bottom: none;
}

/* Custom Scrollbar */
.file-list::-webkit-scrollbar {
    width: 6px;
}
.file-list::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.05);
    border-radius: 10px;
}
.file-list::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.15);
    border-radius: 10px;
}
.file-list::-webkit-scrollbar-thumb:hover {
    background: rgba(0,0,0,0.25);
}

.file-list li {
    padding: 0.8rem 0.55rem;
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 0;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: flex-start;
    gap: 0.8rem;
}

.file-list li:hover {
    background: rgba(37, 99, 235, 0.05);
    transform: none;
}

.file-list li.active {
    background: #eff6ff;
    box-shadow: inset 3px 0 0 var(--primary);
}

.file-list li.active .download-btn {
    opacity: 1;
}

.file-list li:last-child {
    border-bottom: none;
}

.file-icon {
    font-size: 1.5rem;
    line-height: 1;
    margin-top: 0.1rem;
}

.file-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
    min-width: 0;
}

.file-name {
    font-weight: 600;
    font-size: 0.88rem;
    color: #1e293b;
    line-height: 1.4;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.empty-state {
    flex-direction: column;
    align-items: center !important;
    text-align: center;
    padding: 3rem 1rem !important;
    background: #f8fafc !important;
    border: 1px dashed #cbd5e1 !important;
    cursor: default !important;
}

.empty-state:hover {
    transform: none !important;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state-minimal {
    margin: 0.35rem;
    background: transparent !important;
    border: 1px dashed #cbd5e1 !important;
    border-radius: 0.85rem !important;
}

.empty-icon-small {
    font-size: 2rem;
}

.viewer-container {
    flex: 1;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    background: #f1f5f9;
    border: 1px solid var(--glass-border);
}

.viewer-placeholder {
    text-align: center;
    max-width: 400px;
    padding: 2rem;
}

.icon-doc {
    font-size: 5rem;
    margin-bottom: 1.5rem;
    opacity: 0.2;
    filter: drop-shadow(0 4px 10px rgba(0,0,0,0.1));
}

.viewer-placeholder h2 {
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
    color: var(--text-main);
    font-weight: 600;
}

.viewer-placeholder p {
    color: var(--text-muted);
    line-height: 1.6;
}

.doc-viewer {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 1.25rem;
    background: white;
}

.custom-viewer {
    width: 100%;
    height: 100%;
    background: white;
    border-radius: 1.25rem;
    overflow-y: auto;
    overflow-x: auto;
    position: relative;
    padding: 0.2rem;
}

.viewer-content {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center; /* Căn giữa đẹp mắt trên màn hình máy tính/tablet ngang */
    gap: 1.5rem;
}

#pdf-container canvas {
    max-width: 100%;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    margin: 0 auto 0.35rem auto; /* Căn giữa PDF an toàn, không gây lỗi scroll */
    border: 1px solid var(--glass-border);
    display: block;
}

.word-content {
    width: 100%;
    margin: 0;
    padding: 0;
    background: #f1f5f9; /* docx pages are usually white, so light background helps */
}

.docx-wrapper {
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* Image Viewer */
.image-content {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    padding: 0.35rem;
}

.current-selection {
    font-size: 0.84rem;
    color: var(--text-muted);
    text-align: center;
    padding-top: 0.9rem;
    width: calc(100% + (var(--sidebar-bleed) * 2));
    margin-left: calc(var(--sidebar-bleed) * -1);
    padding-inline: 0.3rem;
    border-top: 1px solid var(--glass-border);
    line-height: 1.35;
    word-break: break-word;
}

.image-viewer-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    position: relative;
}

.image-preview {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 0.75rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    opacity: 0;
    transform: scale(0.95);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    user-select: none;
}

.image-preview.loaded {
    opacity: 1;
    transform: scale(1);
}

.image-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    color: var(--primary);
}

/* Toast Notifications */
.toast-notification {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    opacity: 0;
    background: #1e293b;
    color: #f8fafc;
    padding: 0.875rem 1.5rem;
    border-radius: 0.75rem;
    font-family: var(--font-main);
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    z-index: 10000;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    max-width: 90vw;
    white-space: nowrap;
}

.toast-notification.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast-notification .material-symbols-rounded {
    font-size: 20px;
    flex-shrink: 0;
}

.toast-success {
    background: linear-gradient(135deg, #059669, #047857);
}

.toast-error {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
}

.toast-info {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
}

.loading-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    color: var(--primary);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(37, 99, 235, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin { 100% { transform: rotate(360deg); } }

.hidden {
    display: none !important;
}

/* Mobile Optimization */
@media (max-width: 768px) {
    :root {
        --sidebar-bleed: 0.35rem;
        --sidebar-inner-x: 0.08rem;
    }
    body {
        overflow-y: auto;
    }
    .app-container {
        flex-direction: column;
        padding: 0;
        gap: 0;
        height: auto;
        min-height: 100vh;
    }
    .sidebar {
        width: 100%;
        padding: 0.35rem;
        gap: 1rem;
        border-radius: 0;
        border-bottom: 1px solid var(--glass-border);
        box-shadow: 0 4px 10px rgba(0,0,0,0.03);
    }
    .brand {
        justify-content: center;
        margin-bottom: 0.2rem;
    }
    .subtitle {
        display: none;
    }
    .status-card {
        display: none; /* Bỏ bớt box thống kê cho đơn giản */
    }
    .filters {
        gap: 0.65rem;
    }
    .search-select-trigger {
        min-height: 42px;
        padding: 0.7rem 0.75rem;
        font-size: 0.9rem;
    }
    .select-row {
        grid-template-columns: minmax(0, 1fr) 42px;
        gap: 0.4rem;
    }
    .search-select-dropdown {
        top: calc(100% + 0.4rem);
    }
    .main-content {
        gap: 0;
        overflow: visible;
    }
    .top-bar {
        display: none; /* Bỏ tên file / trạng thái ở thanh ngang trên cùng */
    }
    .content-area {
        flex-direction: column;
        gap: 0;
        overflow: visible;
    }
    .file-list-container {
        max-height: 40vh;
        border-radius: 0;
        border-bottom: 1px solid var(--glass-border);
        padding: 0.55rem 0 0.45rem;
        box-shadow: none;
    }
    .file-list-header {
        padding: 0 0.2rem 0 0.3rem;
    }
    .file-list-container h3 {
        font-size: 0.92rem;
        margin-bottom: 0.2rem;
    }
    .viewer-container {
        width: 100%;
        min-height: 60vh;
        border-radius: 0;
        box-shadow: none;
        border: none;
    }
    .custom-viewer {
        border-radius: 0;
        padding: 0;
    }
    .file-list li {
        padding: 0.72rem 0.35rem;
    }
    .file-name {
        font-size: 0.85rem;
    }
    .file-icon {
        font-size: 1.25rem;
    }
    #pdf-container canvas {
        width: 100% !important; /* Force canvas to fit screen width on mobile */
        height: auto !important;
    }
    .word-content {
        font-size: 1rem;
        padding: 0;
    }
    .viewer-content {
        align-items: flex-start !important; /* Mở khóa mép trái riêng cho màn hình dọc (điện thoại) */
    }
    
    /* Mobile: always show download button */
    .download-btn {
        opacity: 1;
    }
    
    .icon-btn {
        width: 30px;
        height: 30px;
    }

    .create-folder-btn {
        width: 42px;
        min-width: 42px;
        height: 42px;
    }

    .upload-btn {
        top: 0.38rem;
        right: 0.18rem;
    }
    
    .icon-btn .material-symbols-rounded {
        font-size: 18px;
    }
    
    .toast-notification {
        bottom: 1rem;
        font-size: 0.85rem;
        padding: 0.75rem 1.25rem;
    }

    .image-content {
        padding: 0;
    }

    .current-selection {
        padding-top: 0.75rem;
        padding-inline: 0.2rem;
    }
}
