/**
 * PHAMHUY DOCS - 100% PURE CUSTOM CSS
 * Zero Bootstrap - Lightweight - Dark/Light Mode - Fully Responsive
 */

:root {
    --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

    /* Light Theme Palette */
    --bg-body: #f8fafc;
    --bg-surface: #ffffff;
    --bg-sidebar: #0f172a;
    --bg-sidebar-hover: #1e293b;
    --bg-sidebar-active: #2563eb;
    --bg-code: #0f172a;
    --bg-inline-code: #e2e8f0;
    --bg-input: #ffffff;
    --bg-hover: #f1f5f9;

    --text-main: #1e293b;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --text-inverse: #f8fafc;
    --text-sidebar: #cbd5e1;
    --text-sidebar-bright: #ffffff;

    --border: #e2e8f0;
    --border-sidebar: #1e293b;

    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-dark: #1e3a8a;
    --primary-subtle: #eff6ff;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #10b981;
    --warning: #f59e0b;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.12);

    --sidebar-width: 290px;
    --header-height: 60px;
}

[data-theme="dark"] {
    --bg-body: #0b1120;
    --bg-surface: #111827;
    --bg-sidebar: #070d19;
    --bg-sidebar-hover: #111827;
    --bg-sidebar-active: #2563eb;
    --bg-code: #030712;
    --bg-inline-code: #1f2937;
    --bg-input: #1f2937;
    --bg-hover: #1e293b;

    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --text-light: #6b7280;
    --text-inverse: #ffffff;
    --text-sidebar: #9ca3af;
    --text-sidebar-bright: #f3f4f6;

    --border: #1f2937;
    --border-sidebar: #111827;
    --primary-subtle: #1e293b;
    --primary-dark: #0c1b3b;
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* --- Reset & Global --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 15px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.2;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.2s ease, color 0.2s ease;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.15s ease;
}
a:hover {
    color: var(--primary-hover);
}

button, input, select, textarea {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

/* SVG Icon Helper */
.svg-icon {
    width: 1.25rem;
    height: 1.25rem;
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
}
.svg-icon-xs {
    width: 0.8rem;
    height: 0.8rem;
}
.svg-icon-sm {
    width: 1rem;
    height: 1rem;
}
.svg-icon-lg {
    width: 1.5rem;
    height: 1.5rem;
}

/* --- Layout Structure --- */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* --- Sidebar --- */
.app-sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--primary), var(--primary-dark));
    color: #ffffff;
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
    z-index: 100;
    flex-shrink: 0;
    border-right: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.12);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.app-sidebar::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

.sidebar-header {
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    color: #ffffff;
    font-weight: 600;
    font-size: 1.15rem;
}
.sidebar-logo {
    width: 42px;
    height: 42px;
    object-fit: contain;
    border-radius: 50%;
    border: 2px solid transparent;
    padding: 1.5px;
    background: linear-gradient(#ffffff, #ffffff) padding-box, conic-gradient(from 0deg, #ff0000, #ff7700, #ffdd00, #00e676, #00b0ff, #3d5afe, #d500f9, #ff0000) border-box;
    display: block;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    transition: transform 0.25s ease;
}
.sidebar-logo:hover {
    transform: scale(1.08);
}

/* User Dropdown in Sidebar Header */
.user-dropdown-container {
    position: relative;
}
.user-dropdown-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
}
.user-dropdown-btn:hover, .user-dropdown-btn.active {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.45);
    transform: scale(1.05);
}

.user-dropdown-menu {
    position: absolute;
    top: calc(100% + 0.6rem);
    right: 0;
    min-width: 220px;
    background: var(--bg-surface);
    color: var(--text-main);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    padding: 0.5rem 0;
    z-index: 250;
    display: none;
    animation: dropdownFadeIn 0.15s ease;
}
.user-dropdown-menu.show {
    display: block;
}

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

.user-dropdown-header {
    padding: 0.6rem 1rem;
}
.user-dropdown-header .user-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-main);
    word-break: break-word;
}
.user-dropdown-header .user-email {
    font-size: 0.8rem;
    color: var(--text-muted);
    word-break: break-word;
}
.user-dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 0.4rem 0;
}
.user-dropdown-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 1rem;
    color: var(--text-main);
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    text-decoration: none;
    transition: background 0.12s ease, color 0.12s ease;
    text-align: left;
}
.user-dropdown-item:hover {
    background: var(--bg-hover);
    color: var(--primary);
}
.user-dropdown-item.text-danger {
    color: var(--danger);
}
.user-dropdown-item.text-danger:hover {
    background: rgba(239, 68, 68, 0.08);
}

.pinned-nav-item {
    color: #fef08a !important;
    font-weight: 600;
}
.pinned-nav-item:hover {
    background-color: rgba(255, 255, 255, 0.15) !important;
    color: #ffffff !important;
}
.badge-pinned {
    background: #eab308 !important;
    color: #0f172a !important;
    font-weight: 600;
}

.sidebar-search-box {
    padding: 0.85rem 1.25rem 0.5rem;
}

.search-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.85rem;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: var(--radius-md);
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.search-trigger:hover {
    background: rgba(255, 255, 255, 0.22);
    border-color: rgba(255, 255, 255, 0.4);
    color: #ffffff;
}
.search-trigger kbd {
    margin-left: auto;
    font-size: 0.75rem;
    background: rgba(0, 0, 0, 0.25);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    color: rgba(255, 255, 255, 0.85);
    font-family: var(--font-mono);
}

.sidebar-actions {
    padding: 0.5rem 1.25rem 0.75rem;
}
.btn-create-doc {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: #ffffff;
    color: var(--primary-dark);
    padding: 0.65rem 1rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.92rem;
    border: none;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    transition: background 0.15s ease, transform 0.1s ease, color 0.15s ease;
}
.btn-create-doc:hover {
    background: #f8fafc;
    color: var(--primary);
    transform: translateY(-1px);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0.75rem;
    overscroll-behavior: contain;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
}

/* Khoảng đệm chân Menu Left (Tránh URL tooltip trình duyệt trên PC & thanh điều hướng trên Mobile) */
.sidebar-nav-buffer {
    height: 6rem;
    height: calc(6rem + env(safe-area-inset-bottom, 0px));
    width: 100%;
    flex-shrink: 0;
    pointer-events: none;
}

.sidebar-nav::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

.nav-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.7);
    padding: 0.85rem 0.6rem 0.4rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius-sm);
    color: rgba(255, 255, 255, 0.88);
    font-size: 0.92rem;
    font-weight: 500;
    margin-bottom: 2px;
    transition: background 0.15s ease, color 0.15s ease;
    word-break: break-word;
}
.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.15);
    color: #ffffff;
}
.nav-item.active {
    background-color: rgba(255, 255, 255, 0.25);
    color: #ffffff;
    font-weight: 600;
    border-left: 3px solid #ffffff;
}
.nav-item.pinned-item {
    color: #fef08a;
}
.nav-item.pinned-item:hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.15);
}
.nav-item .badge {
    margin-left: auto;
    font-size: 0.75rem;
    background: rgba(255, 255, 255, 0.22);
    color: #ffffff;
    padding: 0.12rem 0.5rem;
    border-radius: 10px;
    font-weight: 600;
}

.sidebar-footer {
    padding: 0.85rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #ffffff;
    font-size: 0.9rem;
    font-weight: 600;
}
.sidebar-footer-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.sidebar-footer-actions .icon-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    padding: 0.4rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
}
.sidebar-footer-actions .icon-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

/* --- Main Content Area --- */
.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.app-topbar {
    height: var(--header-height);
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(8px);
}
.topbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
}
.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}
.mobile-menu-toggle {
    display: none;
}

/* Ẩn logo topbar trên PC vì đã có ở Sidebar */
.mobile-topbar-brand {
    display: none;
}

/* --- Breadcrumb trên Topbar PC --- */
.topbar-breadcrumb-wrapper {
    display: flex;
    align-items: center;
    min-width: 0;
    max-width: 100%;
}
.topbar-breadcrumb-wrapper .breadcrumb-trail {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.9rem;
    margin: 0;
    padding: 0;
    white-space: nowrap;
    overflow: hidden;
}
.topbar-breadcrumb-wrapper .breadcrumb-link,
.topbar-breadcrumb-wrapper a {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    padding: 0.2rem 0.45rem;
    border-radius: var(--radius-sm);
    transition: color 0.15s ease, background-color 0.15s ease;
}
.topbar-breadcrumb-wrapper .breadcrumb-link:hover,
.topbar-breadcrumb-wrapper a:hover {
    color: var(--primary);
    background-color: var(--bg-hover);
}
.topbar-breadcrumb-wrapper .breadcrumb-sep {
    display: inline-flex;
    align-items: center;
    color: var(--text-light);
    opacity: 0.6;
    user-select: none;
}
.topbar-breadcrumb-wrapper .breadcrumb-current,
.topbar-breadcrumb-wrapper .current {
    color: var(--text-main);
    font-weight: 600;
    padding: 0.2rem 0.45rem;
    max-width: 380px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Breadcrumb trong nội dung bị ẩn trên PC */
.mobile-breadcrumb-wrapper {
    display: none !important;
}

.breadcrumb-trail {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.88rem;
    color: var(--text-muted);
    margin-bottom: 1.25rem;
}
.breadcrumb-trail .breadcrumb-link,
.breadcrumb-trail a {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.15s ease;
}
.breadcrumb-trail .breadcrumb-link:hover,
.breadcrumb-trail a:hover {
    color: var(--primary);
}
.breadcrumb-trail .breadcrumb-sep {
    display: inline-flex;
    align-items: center;
    color: var(--text-light);
    opacity: 0.7;
    user-select: none;
}
.breadcrumb-trail .breadcrumb-current,
.breadcrumb-trail .current {
    color: var(--text-main);
    font-weight: 600;
}

.content-wrapper {
    flex: 1;
    padding: 1.75rem 2.5rem;
    max-width: 100%;
    width: 100%;
    margin: 0;
}

/* --- Document Reader View --- */
.doc-header {
    margin-bottom: 1.15rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.doc-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.5rem;
    margin-bottom: 0.45rem;
}

.doc-title {
    font-size: 20px;
    font-weight: 600;
    line-height: 1.4;
    color: var(--text-main);
    letter-spacing: -0.01em;
}

.doc-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* --- Unified Action Buttons System (Hệ thống nút bấm đồng bộ) --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    height: 38px;
    padding: 0 1.15rem;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.16s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    user-select: none;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}
.btn:active {
    transform: translateY(0);
    box-shadow: none;
}
.btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Kích cỡ nút đồng bộ */
.btn-sm {
    height: 32px;
    padding: 0 0.8rem;
    font-size: 0.82rem;
    gap: 0.35rem;
}
.btn-lg {
    height: 44px;
    padding: 0 1.5rem;
    font-size: 0.95rem;
    gap: 0.55rem;
}

/* Các biến thể màu sắc chuẩn hóa */
.btn-primary {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
}
.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.28);
}

.btn-outline {
    background: var(--bg-surface);
    border-color: var(--border);
    color: var(--text-main);
}
.btn-outline:hover {
    background: var(--bg-hover);
    border-color: var(--text-muted);
    color: var(--primary);
}

.btn-danger {
    background: var(--danger);
    color: #ffffff;
    border-color: var(--danger);
}
.btn-danger:hover {
    background: var(--danger-hover);
    border-color: var(--danger-hover);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(225, 29, 72, 0.28);
}

/* Nút viền đỏ (Outline Danger) */
.btn-outline-danger,
.btn-outline.text-danger {
    background: var(--bg-surface);
    border-color: var(--border);
    color: var(--danger);
}
.btn-outline-danger:hover,
.btn-outline.text-danger:hover {
    background: rgba(225, 29, 72, 0.08);
    border-color: var(--danger);
    color: var(--danger);
}

/* Nút Ghim trong trang chi tiết: Khi ĐÃ GHIM (Giống CSS hiện tại khi chưa ghim, icon ngôi sao vàng) */
.btn-pinned {
    background: var(--bg-surface) !important;
    border-color: var(--border) !important;
    color: var(--text-main) !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04) !important;
}
.btn-pinned .svg-icon,
.btn-pinned svg {
    color: #eab308 !important;
}
.btn-pinned:hover {
    background: var(--bg-hover) !important;
    border-color: var(--text-muted) !important;
    color: var(--primary) !important;
}

/* Nút Ghim trong trang chi tiết: Khi CHƯA GHIM (Kiểu xám nhạt) */
.doc-actions [data-pin-btn]:not(.btn-pinned) {
    background: var(--bg-hover);
    border-color: var(--border);
    color: var(--text-muted);
}
.doc-actions [data-pin-btn]:not(.btn-pinned):hover {
    background: var(--bg-surface);
    border-color: var(--text-muted);
    color: var(--text-main);
}

/* Khối nút thao tác trong bảng & hàng */
.table-actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.35rem;
}

/* Nút thao tác dạng icon vuông đồng đều */
.action-btn,
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-surface);
    color: var(--text-muted);
    cursor: pointer;
    text-decoration: none;
    transition: all 0.16s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
    flex-shrink: 0;
    line-height: 1;
}
.action-btn:hover,
.icon-btn:hover {
    background: var(--bg-hover);
    color: var(--primary);
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}
.action-btn:active,
.icon-btn:active {
    transform: translateY(0);
}

/* Nút Ghim trong bảng khi CHƯA GHIM (Kiểu xám nhạt) */
.action-btn.action-btn-pin {
    background: var(--bg-hover);
    border-color: var(--border);
    color: var(--text-light);
    opacity: 0.85;
    box-shadow: none;
}
.action-btn.action-btn-pin:hover {
    background: var(--bg-surface);
    border-color: var(--text-muted);
    color: var(--text-main);
    opacity: 1;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

/* Nút Ghim trong bảng khi ĐÃ GHIM (Giống CSS hiện tại khi chưa ghim, icon ngôi sao vàng) */
.action-btn.action-btn-pin.active {
    background: var(--bg-surface) !important;
    border-color: var(--border) !important;
    color: var(--text-main) !important;
    opacity: 1 !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04) !important;
}
.action-btn.action-btn-pin.active .svg-icon,
.action-btn.action-btn-pin.active svg {
    color: #eab308 !important;
}
.action-btn.action-btn-pin.active:hover {
    background: var(--bg-hover) !important;
    border-color: rgba(234, 179, 8, 0.45) !important;
}

/* Nút Sửa trong bảng */
.action-btn.action-btn-edit:hover,
.icon-btn[title*="Chỉnh sửa"]:hover {
    background: var(--primary-subtle);
    border-color: var(--primary);
    color: var(--primary);
}

/* Nút Xóa trong bảng */
.action-btn.action-btn-delete:hover,
.icon-btn.text-danger:hover,
.icon-btn[style*="danger"]:hover {
    background: rgba(225, 29, 72, 0.1);
    border-color: var(--danger);
    color: var(--danger) !important;
}

.doc-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1.25rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.doc-meta span {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.category-tag {
    background: var(--primary-subtle);
    color: var(--primary);
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-weight: 600;
}

/* --- Document Content & Rich Text (Standard Typography for All Tags) --- */
.doc-body {
    font-size: 16px;
    line-height: 1.68;
    color: var(--text-main);
    word-break: break-word;
    letter-spacing: -0.005em;
}

/* Đảm bảo phần tử đầu tiên không bị đẩy khoảng cách trên */
.doc-body > *:first-child {
    margin-top: 0 !important;
}

/* Tiêu đề các cấp (h1 - h6) - Gọn gàng, khoảng cách vừa vặn, font-weight <= 600 */
.doc-body h1,
.doc-body h2,
.doc-body h3,
.doc-body h4,
.doc-body h5,
.doc-body h6 {
    color: var(--text-main);
    font-weight: 600;
    line-height: 1.35;
    margin-top: 1.35rem;
    margin-bottom: 0.45rem;
    letter-spacing: -0.015em;
}

.doc-body h1 {
    font-size: 1.55rem;
    padding-bottom: 0.35rem;
    border-bottom: 2px solid var(--border);
}

.doc-body h2 {
    font-size: 1.3rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--border);
}

.doc-body h3 {
    font-size: 1.15rem;
}

.doc-body h4 {
    font-size: 1.05rem;
}

.doc-body h5 {
    font-size: 0.95rem;
}

.doc-body h6 {
    font-size: 0.88rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Đoạn văn & Văn bản định dạng */
.doc-body p {
    margin-bottom: 0.75rem;
}

.doc-body p.lead {
    font-size: 1.1rem;
    line-height: 1.6;
    color: var(--text-muted);
    margin-bottom: 0.85rem;
}

.doc-body strong,
.doc-body b {
    font-weight: 600;
    color: var(--text-main);
}

.doc-body em,
.doc-body i {
    font-style: italic;
}

.doc-body mark {
    background-color: #fef08a;
    color: #1e293b;
    padding: 0.12rem 0.35rem;
    border-radius: 3px;
}
[data-theme="dark"] .doc-body mark {
    background-color: #854d0e;
    color: #fef08a;
}

.doc-body del,
.doc-body s,
.doc-body strike {
    text-decoration: line-through;
    color: var(--text-muted);
}

.doc-body ins,
.doc-body u {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.doc-body small {
    font-size: 0.85em;
    color: var(--text-muted);
}

.doc-body sub,
.doc-body sup {
    font-size: 75%;
    line-height: 0;
    position: relative;
    vertical-align: baseline;
}
.doc-body sup { top: -0.5em; }
.doc-body sub { bottom: -0.25em; }

.doc-body abbr[title] {
    text-decoration: underline dotted;
    cursor: help;
}

/* Phím tắt KBD */
.doc-body kbd {
    display: inline-block;
    padding: 0.12rem 0.4rem;
    font-family: var(--font-mono);
    font-size: 0.82em;
    font-weight: 600;
    line-height: 1;
    color: var(--text-main);
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-bottom: 2px solid var(--text-light);
    border-radius: 4px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.06);
}

/* Đường dẫn liên kết (Links) */
.doc-body a {
    color: var(--primary);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 1.5px;
    transition: color 0.15s ease, text-decoration-color 0.15s ease;
}
.doc-body a:hover {
    color: var(--primary-hover);
    text-decoration-color: var(--primary-hover);
}

/* Danh sách (Unordered & Ordered Lists) */
.doc-body ul,
.doc-body ol {
    margin-top: 0.25rem;
    margin-bottom: 0.75rem;
    padding-left: 1.5rem;
}

.doc-body li {
    margin-bottom: 0.25rem;
    line-height: 1.62;
}

.doc-body li::marker {
    color: var(--primary);
}

.doc-body ul ul,
.doc-body ol ol,
.doc-body ul ol,
.doc-body ol ul {
    margin-top: 0.2rem;
    margin-bottom: 0.2rem;
    padding-left: 1.25rem;
}

/* Danh sách định nghĩa (Definition list) */
.doc-body dl {
    margin-bottom: 0.75rem;
}
.doc-body dt {
    font-weight: 600;
    color: var(--text-main);
    margin-top: 0.45rem;
}
.doc-body dd {
    margin-left: 1.25rem;
    margin-bottom: 0.35rem;
    color: var(--text-muted);
}

/* Trích dẫn (Blockquote) */
.doc-body blockquote {
    border-left: 4px solid var(--primary);
    background: var(--primary-subtle);
    padding: 0.65rem 2.5rem 0.65rem 1rem;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin: 0.85rem 0;
    color: var(--text-main);
    font-style: normal;
    position: relative;
    min-height: 38px;
}
[data-theme="dark"] .doc-body blockquote {
    background: rgba(37, 99, 235, 0.1);
}
.doc-body blockquote p:last-child {
    margin-bottom: 0;
}
.doc-body blockquote cite {
    display: block;
    font-size: 0.85em;
    color: var(--text-muted);
    margin-top: 0.35rem;
    font-style: italic;
}

/* Mã nguồn nội dòng (Inline Code) */
.doc-body code:not(pre code) {
    background-color: var(--bg-inline-code);
    color: #e11d48;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.88em;
    border: 1px solid rgba(0, 0, 0, 0.05);
}
[data-theme="dark"] .doc-body code:not(pre code) {
    color: #fb7185;
    border-color: rgba(255, 255, 255, 0.08);
}

/* Khối Code PRE với nút Copy */
.code-block-wrapper {
    position: relative;
    margin: 0.85rem 0;
}

.doc-body pre, pre.code-snippet {
    background-color: var(--bg-code);
    color: #e2e8f0;
    padding: 0.85rem 1.15rem;
    border-radius: var(--radius-md);
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    line-height: 1.55;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: var(--shadow-sm);
    position: relative;
}

.doc-body pre code {
    background: transparent;
    color: inherit;
    padding: 0;
    font-family: inherit;
    font-size: inherit;
}

/* Nút Copy đồng bộ: Icon vuông, chỉ hiện khi rê chuột (hover) */
.btn-copy-code,
.btn-copy-quote {
    position: absolute;
    width: 30px;
    height: 30px;
    padding: 0;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 5;
    user-select: none;
    line-height: 1;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-2px);
    transition: opacity 0.16s ease, transform 0.16s ease, background 0.16s ease, border-color 0.16s ease;
    pointer-events: none;
}

/* Nút Copy cho Mã Code (pre) */
.btn-copy-code {
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #cbd5e1;
    backdrop-filter: blur(4px);
}
.btn-copy-code:hover {
    background: rgba(255, 255, 255, 0.28);
    color: #ffffff;
}

/* Nút Copy cho Khối Trích Dẫn (blockquote) */
.btn-copy-quote {
    top: 0.45rem;
    right: 0.5rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    box-shadow: var(--shadow-sm);
}
.btn-copy-quote:hover {
    background: var(--bg-hover);
    color: var(--primary);
    border-color: var(--primary);
}

/* Kích hoạt hiển thị khi rê chuột (Hover) */
pre:hover .btn-copy-code,
pre.code-snippet:hover .btn-copy-code,
.code-block-wrapper:hover .btn-copy-code,
blockquote:hover .btn-copy-quote,
.btn-copy-code:focus,
.btn-copy-quote:focus,
.btn-copy-code.copied,
.btn-copy-quote.copied {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

/* Trạng thái đã sao chép (Checkmark xanh) */
.btn-copy-code.copied,
.btn-copy-quote.copied {
    background: var(--success) !important;
    color: #ffffff !important;
    border-color: var(--success) !important;
}

/* Hỗ trợ màn hình cảm ứng/mobile không có chuột rê */
@media (hover: none) {
    .btn-copy-code,
    .btn-copy-quote {
        opacity: 0.8;
        visibility: visible;
        pointer-events: auto;
        transform: none;
    }
}

/* Bảng dữ liệu (Table) chuẩn đẹp, bo góc, phân cách rõ ràng */
.doc-body table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 0.85rem 0;
    font-size: 0.92rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.doc-body th,
.doc-body td {
    padding: 0.45rem 0.75rem;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
    line-height: 1.5;
}

.doc-body th:last-child,
.doc-body td:last-child {
    border-right: 0;
}

.doc-body tr:last-child td {
    border-bottom: 0;
}

.doc-body th {
    background-color: var(--bg-hover);
    font-weight: 600;
    color: var(--text-main);
}

.doc-body tbody tr:nth-child(even) {
    background-color: rgba(0, 0, 0, 0.015);
}
[data-theme="dark"] .doc-body tbody tr:nth-child(even) {
    background-color: rgba(255, 255, 255, 0.02);
}

.doc-body tbody tr:hover {
    background-color: var(--bg-hover);
}

/* Đường phân cách ngang (HR) */
.doc-body hr {
    border: 0;
    height: 1px;
    background: var(--border);
    margin: 1.25rem 0;
}

/* Hình ảnh & Chú thích (Figure & Figcaption) */
.doc-body img {
    max-width: min(1200px, 100%);
    height: auto;
    border-radius: var(--radius-md);
    margin: 0.85rem auto;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    display: block;
    cursor: zoom-in;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.doc-body img:hover {
    box-shadow: var(--shadow-md);
}

.doc-hero-thumbnail img {
    max-width: min(1200px, 100%);
    cursor: zoom-in;
    transition: box-shadow 0.18s ease, transform 0.18s ease;
}
.doc-hero-thumbnail img:hover {
    box-shadow: var(--shadow-lg) !important;
}

.doc-body figure {
    margin: 0.85rem auto;
    text-align: center;
}

.doc-body figure img {
    margin: 0 auto;
}

.doc-body figcaption {
    margin-top: 0.35rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Hộp đóng mở nội dung (Details / Summary) */
.doc-body details {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.85rem;
    margin: 0.75rem 0;
    transition: border-color 0.15s ease;
}

.doc-body details[open] {
    border-color: var(--primary);
}

.doc-body summary {
    font-weight: 600;
    cursor: pointer;
    color: var(--text-main);
    user-select: none;
    outline: none;
}

.doc-body details[open] summary {
    margin-bottom: 0.45rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--border);
}

/* Hộp thông báo đặc biệt (Callout / Alert boxes) */
.doc-body .callout,
.doc-body .alert {
    padding: 0.65rem 1rem;
    border-radius: var(--radius-sm);
    margin: 0.85rem 0;
    border-left: 4px solid var(--primary);
    background: var(--primary-subtle);
    color: var(--text-main);
}
.doc-body .callout-info, .doc-body .alert-info {
    border-color: var(--primary);
    background: var(--primary-subtle);
}
.doc-body .callout-success, .doc-body .alert-success {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.1);
}
.doc-body .callout-warning, .doc-body .alert-warning {
    border-color: var(--warning);
    background: rgba(245, 158, 11, 0.1);
}
.doc-body .callout-danger, .doc-body .alert-danger {
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

/* Video & Iframe Auto-Responsive (YouTube, Vimeo, Video nhúng) */
.doc-body iframe,
.doc-body video,
.doc-body embed,
.doc-body object {
    max-width: 100% !important;
    box-sizing: border-box;
}

.doc-body iframe:not(.video-responsive iframe),
.doc-body video {
    width: 100% !important;
    max-width: 760px !important;
    aspect-ratio: 16 / 9;
    height: auto !important;
    border: 0;
    border-radius: var(--radius-md);
    margin: 1rem auto !important;
    display: block;
    box-shadow: var(--shadow-md);
}

.video-responsive {
    position: relative;
    width: 100%;
    max-width: 760px; /* Bề rộng tối đa đẹp mắt trên PC (không bị bè full-width) */
    aspect-ratio: 16 / 9;
    height: auto;
    overflow: hidden;
    border-radius: var(--radius-md);
    margin: 1rem auto; /* Căn giữa trang nhã */
    box-shadow: var(--shadow-md);
}

.video-responsive iframe,
.video-responsive video,
.video-responsive embed,
.video-responsive object {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    aspect-ratio: auto !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: var(--radius-md);
}

/* --- Form Styles (Doc Edit / Create) --- */
.form-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-sm);
}

.form-group {
    margin-bottom: 1.25rem;
}
.form-label {
    display: block;
    font-size: 14px !important;
    font-weight: 600 !important;
    margin-bottom: 0.45rem;
    color: var(--text-main);
    line-height: 1.4;
}

.form-control, .form-select {
    width: 100%;
    height: 42px;
    font-size: 16px !important;
    font-weight: 400 !important;
    padding: 0.5rem 0.9rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form-control:focus, .form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.form-control-lg {
    font-size: 16px !important;
    font-weight: 400 !important;
    height: 42px;
    padding: 0.5rem 0.9rem;
}

/* 2-Cột Layout: Cột 1 (Title, Chuyên mục + Ghim, Slug + Ẩn hiện) | Cột 2 (Ảnh đại diện) */
.doc-form-top-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
    gap: 1.5rem;
    margin-bottom: 0.5rem;
    align-items: stretch;
}

.doc-form-col-left {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.form-sub-row {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.form-sub-row .flex-1 {
    flex: 1;
    min-width: 0;
}

.form-switch-group {
    width: 140px;
    flex-shrink: 0;
}

.switch-wrapper {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    height: 42px;
}

/* Nút Gạt Hiện Đại (Modern Toggle Switch) */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 24px;
    flex-shrink: 0;
    cursor: pointer;
    margin: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
    pointer-events: none;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: var(--border);
    border-radius: 24px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.toggle-slider::before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: #ffffff;
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--primary);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(22px);
}

.switch-status-text {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
    user-select: none;
}

/* Cột 2: Ảnh đại diện Thumbnail Box */
.doc-form-col-right {
    display: flex;
    flex-direction: column;
}

.thumbnail-picker-box {
    flex: 1;
    min-height: 150px;
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-body);
    overflow: hidden;
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.thumbnail-picker-box:hover {
    border-color: var(--primary);
    background: var(--primary-subtle);
}

.thumbnail-preview-wrap {
    width: 100%;
    height: 100%;
    min-height: 150px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.thumbnail-preview-img {
    width: 100%;
    height: 100%;
    max-height: 170px;
    object-fit: contain;
    background: var(--bg-body);
    display: block;
}

.thumbnail-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    font-size: 13px;
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.2s ease;
    backdrop-filter: blur(2px);
}

.thumbnail-picker-box:hover .thumbnail-overlay {
    opacity: 1;
}

.thumbnail-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    text-align: center;
    color: var(--text-muted);
}

.thumbnail-icon-wrap {
    margin-bottom: 0.4rem;
    color: var(--text-light);
}

.thumbnail-hint {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
}

.thumbnail-subhint {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 3px;
}

.btn-clear-thumb {
    background: none;
    border: 0;
    color: var(--danger);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.15rem 0.4rem;
    border-radius: var(--radius-sm);
    transition: background-color 0.15s ease;
}
.btn-clear-thumb:hover {
    background: rgba(239, 68, 68, 0.1);
}

@media (max-width: 768px) {
    .form-card {
        padding: 0.85rem 0.65rem !important;
        border-radius: var(--radius-md);
    }
    .doc-form-top-grid {
        grid-template-columns: 1fr;
        gap: 0.85rem;
        margin-bottom: 0.25rem;
    }
    .form-sub-row {
        display: flex !important;
        flex-direction: row !important;
        align-items: flex-start !important;
        gap: 0.65rem !important;
    }
    .form-switch-group {
        width: auto !important;
        min-width: 46px !important;
        flex-shrink: 0 !important;
        text-align: center;
    }
    .form-switch-group .form-label {
        text-align: center;
        white-space: nowrap;
        font-size: 13px !important;
    }
    .switch-wrapper {
        justify-content: center;
        width: 46px;
    }
    .switch-status-text {
        display: none !important;
    }
    .thumbnail-picker-box {
        min-height: 135px;
    }
}

.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}
.form-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* --- Login Page --- */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: radial-gradient(circle at top, #1e293b, #0f172a);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: #ffffff;
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    box-shadow: var(--shadow-lg);
}
[data-theme="dark"] .auth-card {
    background: #1e293b;
    border: 1px solid #334155;
}

.auth-brand {
    text-align: center;
    margin-bottom: 2rem;
}
.auth-brand .logo-badge {
    width: 48px;
    height: 48px;
    font-size: 1.5rem;
    margin: 0 auto 0.75rem;
}
.auth-brand .auth-logo {
    width: 60px;
    height: 60px;
    object-fit: contain;
    border-radius: 50%;
    border: 3px solid transparent;
    padding: 2px;
    background: linear-gradient(#ffffff, #ffffff) padding-box, conic-gradient(from 0deg, #ff0000, #ff7700, #ffdd00, #00e676, #00b0ff, #3d5afe, #d500f9, #ff0000) border-box;
    display: block;
    margin: 0 auto 0.75rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: transform 0.25s ease;
}
.auth-brand .auth-logo:hover {
    transform: scale(1.08);
}
.auth-brand h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #0f172a;
}
[data-theme="dark"] .auth-brand h1 {
    color: #fff;
}
.auth-brand p {
    font-size: 0.88rem;
    color: #64748b;
}

.auth-btn {
    width: 100%;
    padding: 0.8rem;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
}
.auth-btn:hover {
    background: var(--primary-hover);
}

/* --- Native HTML5 Dialog Modal --- */
dialog {
    border: none;
    border-radius: var(--radius-lg);
    background: var(--bg-surface);
    color: var(--text-main);
    box-shadow: var(--shadow-lg);
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    margin: auto;
}
dialog::backdrop {
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
}
.dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}
.dialog-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
}
.dialog-body {
    margin-bottom: 1.5rem;
    color: var(--text-muted);
}
.dialog-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* --- Search Modal (Ctrl + K) --- */
#search-dialog {
    max-width: 640px;
    padding: 1.5rem;
}
.search-input-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-input);
    border: 2px solid var(--primary);
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
}
.search-input-wrapper input {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    font-size: 1.1rem;
    font-weight: 500;
}
.search-results-list {
    max-height: 380px;
    overflow-y: auto;
    list-style: none;
}
.search-result-item a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    color: var(--text-main);
    transition: background 0.15s ease;
}
.search-result-item a:hover {
    background: var(--bg-hover);
    color: var(--primary);
}
.search-result-title {
    font-weight: 500;
    font-size: 0.98rem;
}
.search-result-pinned {
    color: #ef4444;
    font-weight: 500;
    font-size: 0.85rem;
    flex-shrink: 0;
    margin-left: 0.75rem;
}

/* --- Toast Notification (Đưa lên Top) --- */
#toast-container {
    position: fixed;
    top: 1.25rem;
    right: 1.5rem;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    pointer-events: none;
}
.toast-item {
    background: var(--bg-surface);
    color: var(--text-main);
    border: 1px solid var(--border);
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
    font-size: 0.9rem;
    animation: toastSlideDown 0.25s ease;
    min-width: 260px;
    max-width: 420px;
    pointer-events: auto;
}
.toast-item.toast-success { border-left: 4px solid var(--success); }
.toast-item.toast-error   { border-left: 4px solid var(--danger); }
.toast-item.toast-info    { border-left: 4px solid var(--primary); }

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

/* --- Image Zoom Lightbox Viewer --- */
.image-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.22s ease;
}

.image-lightbox.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.lightbox-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    cursor: zoom-out;
}

.lightbox-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    max-width: 95vw;
    max-height: 95vh;
    padding: 1rem;
    box-sizing: border-box;
}

.lightbox-img {
    max-width: 92vw;
    max-height: 84vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: var(--radius-sm);
    box-shadow: 0 15px 45px rgba(0, 0, 0, 0.55);
    cursor: zoom-out;
    user-select: none;
    transform: scale(0.95);
    transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.image-lightbox.active .lightbox-img {
    transform: scale(1);
}

.lightbox-close-btn {
    position: absolute;
    top: -2.85rem;
    right: 0;
    width: 38px;
    height: 38px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.16s ease;
    backdrop-filter: blur(4px);
    padding: 0;
}
.lightbox-close-btn svg {
    width: 20px;
    height: 20px;
}
.lightbox-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.08);
}

.lightbox-caption {
    margin-top: 0.75rem;
    color: #cbd5e1;
    font-size: 0.9rem;
    font-weight: 500;
    text-align: center;
    max-width: 80vw;
    line-height: 1.4;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

@media (max-width: 768px) {
    .lightbox-close-btn {
        top: -2.25rem;
        right: 0.25rem;
        width: 34px;
        height: 34px;
    }
    .lightbox-img {
        max-width: 96vw;
        max-height: 80vh;
    }
}

/* --- Media Library Modal --- */
#media-dialog,
.media-dialog {
    max-width: 920px;
    width: 95%;
    border-radius: var(--radius-lg);
}

.media-upload-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.85rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--border);
}

.media-drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    padding: 1.25rem 1rem;
    text-align: center;
    cursor: pointer;
    margin-bottom: 0.85rem;
    color: var(--text-muted);
    background: var(--bg-surface);
    transition: all 0.2s ease;
}

.media-drop-zone:hover,
.media-drop-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-subtle);
    color: var(--primary);
}

.media-message {
    padding: 0.6rem 0.85rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.media-message.info {
    background: var(--primary-subtle);
    color: var(--primary);
}
.media-message.success {
    background: rgba(16, 185, 129, 0.12);
    color: #10b981;
}
.media-message.error,
.media-message.danger {
    background: rgba(239, 68, 68, 0.12);
    color: var(--danger);
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
    gap: 0.85rem;
    max-height: 440px;
    overflow-y: auto;
    padding: 0.25rem;
}

.media-card {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 185px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.media-card:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
}

.media-card.selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary);
    background: var(--primary-subtle);
}

.media-card-img-wrap {
    width: 100%;
    height: 118px;
    flex-shrink: 0;
    overflow: hidden;
    background: var(--bg-body);
    display: flex;
    align-items: center;
    justify-content: center;
}

.media-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.2s ease;
}

.media-card:hover .media-card-img {
    transform: scale(1.05);
}

.media-card-footer {
    padding: 0.4rem 0.55rem;
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: var(--bg-surface);
}

.media-card-title {
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.media-card-size {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Checkbox on top-left */
.media-check {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 5;
    cursor: pointer;
    margin: 0;
}
.media-check input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.media-check span {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255, 255, 255, 0.95);
    border-radius: 6px;
    background: rgba(15, 23, 42, 0.55);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    transition: all 0.15s ease;
}
.media-check input:checked + span,
.media-card.selected .media-check span {
    background: var(--primary);
    border-color: var(--primary);
}
.media-check input:checked + span::after,
.media-card.selected .media-check span::after {
    content: "";
    width: 10px;
    height: 6px;
    border: solid #ffffff;
    border-width: 0 0 2.5px 2.5px;
    transform: rotate(-45deg) translate(1px, -1px);
}

/* Delete item button on top-right */
.btn-delete-item {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 5;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 6px;
    color: #ffffff;
    background: var(--danger);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: scale(0.85);
    transition: all 0.15s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}
.media-card:hover .btn-delete-item {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
}
.btn-delete-item:hover {
    background: #dc2626;
    transform: scale(1.1) !important;
}

@media (hover: none) {
    .btn-delete-item {
        opacity: 0.9;
        visibility: visible;
        transform: scale(1);
    }
}

/* --- Category List & Table Styles --- */
.category-page-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
}
.category-filter-bar {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
}
.filter-group-left, .filter-group-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.filter-control-item {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}
.filter-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
}
.filter-icon-select-wrapper {
    display: inline-flex;
    align-items: center;
    position: relative;
}
.filter-mobile-icon {
    display: none;
}

/* --- Bọc Tìm Kiếm Theo Danh Mục (Composite Search Wrapper) --- */
.search-composite-wrapper {
    display: inline-flex;
    align-items: center;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    height: 42px;
    box-sizing: border-box;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    max-width: 100%;
}
.search-composite-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-subtle);
}
.search-category-select-wrapper {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0 0.5rem 0 0.8rem;
    height: 100%;
    position: relative;
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color 0.15s ease;
    border-top-left-radius: var(--radius-sm);
    border-bottom-left-radius: var(--radius-sm);
}
.search-category-select-wrapper:hover {
    background: var(--bg-hover);
}
.search-category-icon {
    color: var(--text-muted);
    pointer-events: none;
    flex-shrink: 0;
}
.search-category-select {
    border: none;
    background: transparent;
    color: var(--text-main);
    font-size: 0.88rem;
    font-weight: 600;
    outline: none;
    cursor: pointer;
    max-width: 180px;
    padding-right: 0.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}
.search-category-select option {
    background: var(--bg-surface);
    color: var(--text-main);
}
.search-category-arrow {
    color: var(--text-muted);
    pointer-events: none;
    flex-shrink: 0;
    margin-left: 0.1rem;
}
.search-composite-divider {
    width: 1px;
    height: 24px;
    background: var(--border);
    flex-shrink: 0;
}
.search-input-field {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0 0.75rem;
    height: 100%;
    flex: 1;
    min-width: 200px;
    width: 280px;
}
.search-input-icon {
    color: var(--text-muted);
    flex-shrink: 0;
}
.search-input-field input {
    border: none;
    background: transparent;
    outline: none;
    font-size: 0.92rem;
    color: var(--text-main);
    width: 100%;
    height: 100%;
}
.search-input-field input::placeholder {
    color: var(--text-light);
    font-size: 0.88rem;
}
.search-clear-btn {
    display: inline-flex;
    align-items: center;
    color: var(--text-light);
    padding: 0.2rem;
    border-radius: var(--radius-sm);
    transition: color 0.15s ease;
    flex-shrink: 0;
}
.search-clear-btn:hover {
    color: var(--text-main);
}
.filter-search-btn {
    height: 42px;
    padding: 0 1.15rem;
    font-size: 0.88rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.filter-select {
    height: 42px;
    padding: 0 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-main);
    font-size: 0.88rem;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.15s ease;
}
.filter-select:focus {
    border-color: var(--primary);
}

.docs-table-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
}
.docs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.93rem;
}
.docs-table th {
    background: var(--bg-hover);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
    white-space: nowrap;
}
.docs-table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-main);
    vertical-align: middle;
    white-space: nowrap;
}
.docs-table tr:last-child td {
    border-bottom: none;
}
.docs-table tr:hover td {
    background: var(--bg-hover);
}

/* Cột Tiêu đề tài liệu cho phép xuống tối đa 2 hàng */
.docs-table th.col-title,
.docs-table td.col-title {
    white-space: normal;
    min-width: 220px;
    max-width: 480px;
}
.doc-row-title {
    font-weight: 600;
    font-size: 0.96rem;
    display: inline-flex;
    align-items: flex-start;
    gap: 0.45rem;
    color: var(--text-main);
    text-decoration: none;
    line-height: 1.4;
}
.doc-row-title:hover {
    color: var(--primary);
}
.doc-row-title .svg-icon,
.doc-row-title svg {
    flex-shrink: 0;
    margin-top: 2px;
}
.doc-row-title.pinned .svg-icon,
.doc-row-title.pinned svg {
    color: #eab308;
}
.doc-title-text {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
    max-height: calc(1.4em * 2);
    word-break: break-word;
}
.doc-row-summary {
    font-size: 0.83rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word;
}

/* --- Các nút thao tác trong bảng có màu phân biệt rõ ràng --- */
.table-actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.4rem;
    white-space: nowrap;
}
.action-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.18s ease;
    border: 1px solid transparent;
    flex-shrink: 0;
}
.action-btn:hover {
    transform: translateY(-1px);
}

/* Nút Ghim: Màu Vàng Cam (Amber) */
.action-btn-pin {
    background: rgba(245, 158, 11, 0.12);
    border-color: rgba(245, 158, 11, 0.3);
    color: #d97706;
}
.action-btn-pin:hover {
    background: #f59e0b;
    border-color: #f59e0b;
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.35);
}
.action-btn-pin.active {
    background: #f59e0b;
    border-color: #f59e0b;
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.35);
}
.action-btn-pin.active:hover {
    background: #d97706;
    border-color: #d97706;
    color: #ffffff;
}

/* Nút Sửa: Màu Xanh Lam (Primary Blue) */
.action-btn-edit {
    background: rgba(37, 99, 235, 0.1);
    border-color: rgba(37, 99, 235, 0.3);
    color: #2563eb;
}
.action-btn-edit:hover {
    background: #2563eb;
    border-color: #2563eb;
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.35);
}

/* Nút Xóa: Màu Đỏ (Danger Red) */
.action-btn-delete {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: #ef4444;
}
.action-btn-delete:hover {
    background: #ef4444;
    border-color: #ef4444;
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.35);
}

/* Màu nút thao tác cho chế độ Dark Mode */
[data-theme="dark"] .action-btn-pin {
    background: rgba(245, 158, 11, 0.2);
    border-color: rgba(245, 158, 11, 0.4);
    color: #fbbf24;
}
[data-theme="dark"] .action-btn-pin:hover,
[data-theme="dark"] .action-btn-pin.active {
    background: #f59e0b;
    border-color: #f59e0b;
    color: #ffffff;
}
[data-theme="dark"] .action-btn-edit {
    background: rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.4);
    color: #60a5fa;
}
[data-theme="dark"] .action-btn-edit:hover {
    background: #3b82f6;
    border-color: #3b82f6;
    color: #ffffff;
}
[data-theme="dark"] .action-btn-delete {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
    color: #f87171;
}
[data-theme="dark"] .action-btn-delete:hover {
    background: #ef4444;
    border-color: #ef4444;
    color: #ffffff;
}

/* --- Advanced Pagination (Gọn gàng, rõ nét, đồng bộ) --- */
.pagination-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1rem 0.25rem 0.5rem;
    margin-top: 0.5rem;
    border-top: 1px solid var(--border);
    font-size: 0.88rem;
    color: var(--text-muted);
}

.pagination-info {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.25rem;
    font-size: 0.88rem;
    color: var(--text-muted);
    font-weight: 500;
    line-height: 1.4;
}

.pagination-info strong {
    color: var(--text-main);
    font-weight: 600;
}

.pagination-nav {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    list-style: none;
    padding: 0;
    margin: 0;
}

.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 0.55rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-surface);
    color: var(--text-main);
    font-size: 0.88rem;
    font-weight: 600;
    font-family: var(--font-main);
    font-variant-numeric: tabular-nums;
    text-decoration: none;
    line-height: 1;
    user-select: none;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    transition: all 0.16s cubic-bezier(0.4, 0, 0.2, 1);
}

.page-btn svg,
.page-btn .svg-icon {
    width: 15px;
    height: 15px;
    stroke-width: 2.2;
    flex-shrink: 0;
}

.page-btn:hover:not(.disabled):not(.active) {
    background: var(--bg-hover);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.page-btn:active:not(.disabled):not(.active) {
    transform: translateY(0);
    box-shadow: none;
}

.page-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
    cursor: default;
    pointer-events: none;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.32);
}

.page-btn.disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
    background: var(--bg-body);
    border-color: var(--border);
    color: var(--text-light);
    box-shadow: none;
}

.page-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 34px;
    color: var(--text-light);
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 1px;
    user-select: none;
}

/* --- Responsive Media Queries --- */
@media (max-width: 1024px) {
    .content-wrapper {
        padding: 1.5rem 1.5rem;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .app-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }
    .app-sidebar.show {
        transform: translateX(0);
    }
    .sidebar-nav-buffer {
        height: 7.5rem;
        height: calc(7.5rem + env(safe-area-inset-bottom, 0px));
    }
    .app-topbar {
        height: var(--header-height);
        padding: 0 0.85rem;
        background: linear-gradient(180deg, var(--primary), var(--primary-dark));
        border-bottom: 1px solid rgba(255, 255, 255, 0.15);
        color: #ffffff;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    }
    .topbar-left {
        gap: 0.5rem;
    }
    .topbar-right {
        gap: 0.45rem;
    }

    /* Ẩn breadcrumb trên topbar mobile (nhường chỗ cho logo mobile) */
    .topbar-breadcrumb-wrapper,
    .topbar-category-badge {
        display: none !important;
    }

    /* Giữ nguyên breadcrumb trong Content Area trên mobile */
    .mobile-breadcrumb-wrapper {
        display: block !important;
    }

    /* Hiện logo canh trái trên mobile */
    .mobile-topbar-brand {
        display: inline-flex;
        align-items: center;
        gap: 0.6rem;
        text-decoration: none;
        color: #ffffff;
        font-weight: 600;
        font-size: 1.02rem;
    }
    .topbar-logo {
        width: 38px;
        height: 38px;
        object-fit: contain;
        border-radius: 50%;
        border: 2px solid transparent;
        padding: 1.5px;
        background: linear-gradient(#ffffff, #ffffff) padding-box, conic-gradient(from 0deg, #ff0000, #ff7700, #ffdd00, #00e676, #00b0ff, #3d5afe, #d500f9, #ff0000) border-box;
        display: block;
        flex-shrink: 0;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
        transition: transform 0.25s ease;
    }
    .topbar-logo:hover {
        transform: scale(1.08);
    }
    .topbar-brand-text {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 140px;
        font-weight: 600;
        color: #ffffff;
    }

    /* Nút topbar trên mobile: ẩn chữ chỉ hiện icon & tương thích background gradient */
    .topbar-btn .btn-label {
        display: none;
    }
    .topbar-btn {
        width: 34px;
        height: 34px;
        padding: 0;
        justify-content: center;
        flex-shrink: 0;
    }
    .app-topbar .btn-outline {
        background: rgba(255, 255, 255, 0.16);
        border-color: rgba(255, 255, 255, 0.3);
        color: #ffffff;
    }
    .app-topbar .btn-outline:hover,
    .app-topbar .btn-outline:active {
        background: rgba(255, 255, 255, 0.26);
        border-color: rgba(255, 255, 255, 0.45);
        color: #ffffff;
    }
    .app-topbar .btn-primary {
        background: #ffffff;
        border-color: #ffffff;
        color: var(--primary-dark);
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    }
    .app-topbar .btn-primary:hover,
    .app-topbar .btn-primary:active {
        background: #f8fafc;
        border-color: #f8fafc;
        color: var(--primary);
    }
    .mobile-menu-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 34px;
        height: 34px;
        flex-shrink: 0;
        background: rgba(255, 255, 255, 0.16);
        border: 1px solid rgba(255, 255, 255, 0.3);
        color: #ffffff;
        border-radius: var(--radius-sm);
        cursor: pointer;
        transition: all 0.15s ease;
    }
    .mobile-menu-toggle:hover,
    .mobile-menu-toggle:active {
        background: rgba(255, 255, 255, 0.26);
        border-color: rgba(255, 255, 255, 0.45);
        color: #ffffff;
    }
    .content-wrapper {
        padding: 0.65rem 0.5rem;
    }
    .breadcrumb-trail {
        margin-bottom: 0.65rem;
        font-size: 0.82rem;
        gap: 0.3rem;
    }
    .doc-header {
        margin-bottom: 1.25rem;
        padding-bottom: 0.75rem;
    }
    .doc-title {
        font-size: 1.5rem;
    }
    .doc-title-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.65rem;
    }
    .doc-actions {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 0.4rem;
    }
    .category-filter-bar {
        display: grid;
        grid-template-columns: 1fr auto auto;
        gap: 0.5rem;
        align-items: center;
        padding: 0.65rem 0.5rem;
        margin-bottom: 0.85rem;
    }
    .filter-group-left {
        display: contents;
    }
    .filter-group-right {
        display: contents;
    }
    .search-composite-wrapper {
        grid-column: 1 / -1;
        width: 100%;
        min-width: 0;
        height: 42px;
        display: flex;
        align-items: center;
        background: var(--bg-input);
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        box-sizing: border-box;
        overflow: hidden;
    }
    .search-category-select-wrapper {
        display: flex;
        align-items: center;
        gap: 0.2rem;
        padding: 0 0.35rem 0 0.5rem;
        height: 100%;
        max-width: 120px;
        min-width: 85px;
        flex-shrink: 0;
        border-radius: 0;
        border-bottom: none;
        box-sizing: border-box;
    }
    .search-category-icon {
        flex-shrink: 0;
        width: 14px;
        height: 14px;
    }
    .search-category-select {
        flex: 1;
        min-width: 0;
        width: 100%;
        font-size: 0.8rem;
        padding: 0;
        border: none;
        background: transparent;
        color: var(--text-main);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .search-category-arrow {
        flex-shrink: 0;
        width: 10px;
        height: 10px;
        margin-left: 0.05rem;
    }
    .search-composite-divider {
        display: block;
        width: 1px;
        height: 20px;
        background: var(--border);
        flex-shrink: 0;
        margin: 0;
    }
    .search-input-field {
        display: flex;
        align-items: center;
        gap: 0.35rem;
        padding: 0 0.5rem;
        height: 100%;
        flex: 1;
        min-width: 0;
        width: auto;
        box-sizing: border-box;
        background: transparent;
    }
    .search-input-icon {
        flex-shrink: 0;
        width: 14px;
        height: 14px;
    }
    .search-input-field input {
        width: 100%;
        min-width: 0;
        font-size: 0.84rem;
        border: none;
        background: transparent;
        color: var(--text-main);
        padding: 0;
    }
    .search-clear-btn {
        flex-shrink: 0;
        padding: 0.15rem;
    }
    .filter-search-btn {
        grid-column: 1;
        width: 100%;
        height: 42px;
        justify-content: center;
        border-radius: var(--radius-sm);
        margin: 0;
        display: inline-flex;
        align-items: center;
        gap: 0.4rem;
    }
    .filter-control-item {
        margin: 0;
        padding: 0;
        display: inline-flex;
        align-items: center;
    }
    .filter-sort-item {
        grid-column: 2;
    }
    .filter-perpage-item {
        grid-column: 3;
    }
    .filter-label {
        display: none !important;
    }
    .filter-icon-select-wrapper {
        position: relative;
        width: 42px;
        height: 42px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: var(--bg-surface);
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        box-shadow: var(--shadow-sm);
        cursor: pointer;
        flex-shrink: 0;
        transition: all 0.15s ease;
    }
    .filter-icon-select-wrapper:active {
        background: var(--bg-hover);
        border-color: var(--primary);
    }
    .filter-mobile-icon {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        color: var(--text-main);
        pointer-events: none;
    }
    .filter-icon-select-wrapper select.filter-select {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        opacity: 0;
        cursor: pointer;
        -webkit-appearance: none;
        appearance: none;
        padding: 0;
        margin: 0;
        border: none;
        background: transparent;
        z-index: 2;
    }
    .docs-table-card {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 1rem;
        border-radius: var(--radius-sm);
    }
    .docs-table th,
    .docs-table td {
        padding: 0.65rem 0.55rem;
    }
    .docs-table th.col-title,
    .docs-table td.col-title {
        max-width: 340px;
        min-width: 320px;
    }
    .doc-row-title {
        max-width: 340px;
    }
    .doc-body table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .pagination-wrapper {
        flex-direction: column;
        align-items: center;
        gap: 0.75rem;
        padding-top: 0.85rem;
        text-align: center;
    }
    .pagination-info {
        justify-content: center;
        font-size: 0.84rem;
    }
    .pagination-nav {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.25rem;
    }
    .page-btn {
        min-width: 32px;
        height: 32px;
        font-size: 0.84rem;
        padding: 0 0.45rem;
    }
    .page-ellipsis {
        min-width: 18px;
        height: 32px;
    }
    .user-dropdown-menu {
        position: absolute;
        top: calc(100% + 0.6rem);
        right: 0;
        min-width: 200px;
    }
    #toast-container {
        top: 0.75rem;
        right: 0.75rem;
        left: 0.75rem;
        align-items: center;
    }
    .toast-item {
        width: 100%;
        min-width: 0;
        max-width: 100%;
        box-sizing: border-box;
    }
}
