/* ═══════════════════════════════════════════
   Quản lý văn bản — Frontend CSS v2.4.0
═══════════════════════════════════════════ */

/* ── Wrapper ── */
.tlkh-wrap {
    display: flex;
    border: 1px solid #dde3ea;
    border-radius: 6px;
    overflow: hidden;
    font-family: var(--tlkh-font, Arial, sans-serif);
    font-size: var(--tlkh-fsize, 13px);
    color: #333;
    background: #fff;
    margin: 16px 0;
    /* Chiều cao tự động theo nội dung bên phải */
    align-items: stretch;
}

/* ══════════════════════════
   SIDEBAR
══════════════════════════ */
.tlkh-sidebar {
    width: 240px;
    min-width: 240px;
    background: #f5f7fa;
    border-right: 1px solid #dde3ea;
    display: flex;
    flex-direction: column;
    /* Scroll độc lập bên trong, cao bằng main */
    overflow: hidden;
}

.tlkh-sidebar-header {
    background: var(--tlkh-color, #004FA0);
    color: #fff;
    padding: 10px 14px;
    font-size: var(--tlkh-tsize, 13px);
    font-weight: 600;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 7px;
}

/* Vùng scroll cây danh mục */
.tlkh-tree {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.tlkh-tree-loading {
    padding: 16px;
    color: #888;
    font-size: 12px;
    text-align: center;
}

/* ── Danh mục (cấp 1) ── */
.tlkh-dm-item {
    border-bottom: 1px solid #e0e6ef;
}

.tlkh-dm-title {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 9px 12px;
    font-size: var(--tlkh-fsize, 13px);
    font-weight: 600;
    color: #333;
    cursor: pointer;
    user-select: none;
    transition: background .15s, color .15s;
}

.tlkh-dm-title:hover {
    background: var(--tlkh-color-light, rgba(0,79,160,0.08));
    color: var(--tlkh-color, #004FA0);
}

.tlkh-dm-title.active {
    color: var(--tlkh-color, #004FA0);
    background: var(--tlkh-color-light, rgba(0,79,160,0.08));
}

.tlkh-dm-arrow {
    font-size: 9px;
    transition: transform .2s;
    color: #999;
    min-width: 10px;
}

.tlkh-dm-title.open .tlkh-dm-arrow {
    transform: rotate(90deg);
    color: var(--tlkh-color, #004FA0);
}
.tlkh-dm-arrow, .tlkh-muc-arrow {
    font-size: 10px;
    transition: transform .2s;
    min-width: 12px;
}

.tlkh-dm-dot {
    color: var(--tlkh-color, #004FA0);
    font-size: 10px;
}

/* ── Danh sách Mục (cấp 2) ── */
.tlkh-muc-list {
    display: none;
    background: #fff;
}

.tlkh-muc-list.open {
    display: block;
}

/* ── Mục (cấp 2) ── */
.tlkh-muc-item {}

.tlkh-muc-title {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px 7px 22px;
    font-size: calc(var(--tlkh-fsize, 13px) - 0px);
    color: #444;
    cursor: pointer;
    user-select: none;
    border-left: 3px solid transparent;
    transition: all .15s;
}

.tlkh-muc-title:hover {
    background: var(--tlkh-color-light, rgba(0,79,160,0.06));
    color: var(--tlkh-color, #004FA0);
}

.tlkh-muc-title.active {
    color: var(--tlkh-color, #004FA0);
    border-left-color: var(--tlkh-color, #004FA0);
    background: var(--tlkh-color-light2, rgba(0,79,160,0.12));
    font-weight: 600;
}

.tlkh-muc-arrow {
    font-size: 8px;
    transition: transform .2s;
    color: #bbb;
    min-width: 9px;
}

.tlkh-muc-title.open .tlkh-muc-arrow {
    transform: rotate(90deg);
    color: var(--tlkh-color, #004FA0);
}

/* ── Loại văn bản (cấp 3) ── */
.tlkh-loai-list {
    display: none;
    background: #f9fafb;
}

.tlkh-loai-list.open {
    display: block;
}

.tlkh-loai-item {
    padding: 5px 12px 5px 36px;
    font-size: calc(var(--tlkh-fsize, 13px) - 1px);
    color: #666;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: all .12s;
}

.tlkh-loai-item:hover {
    background: var(--tlkh-color-light, rgba(0,79,160,0.06));
    color: var(--tlkh-color, #004FA0);
}

.tlkh-loai-item.active {
    color: var(--tlkh-color, #004FA0);
    border-left-color: var(--tlkh-color, #004FA0);
    background: var(--tlkh-color-light2, rgba(0,79,160,0.12));
    font-weight: 600;
}

/* ══════════════════════════
   MAIN
══════════════════════════ */
.tlkh-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.tlkh-main-header {
    background: var(--tlkh-color, #004FA0);
    color: #fff;
    padding: 10px 16px;
    font-size: var(--tlkh-tsize, 13px);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* ── Tìm kiếm ── */
.tlkh-search-box {
    padding: 12px 16px;
    background: #fafbfd;
    border-bottom: 1px solid #dde3ea;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

.tlkh-search-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.tlkh-search-field {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
    min-width: 120px;
}

.tlkh-search-field label {
    font-size: 11px;
    color: #666;
    font-weight: 500;
}

.tlkh-search-field input,
.tlkh-search-field select {
    padding: 5px 8px;
    border: 1px solid #c8d3e0;
    border-radius: 4px;
    font-size: var(--tlkh-fsize, 13px);
    font-family: var(--tlkh-font, Arial, sans-serif);
    color: #333;
    background: #fff;
    height: 32px;
    box-sizing: border-box;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}

.tlkh-search-field input:focus,
.tlkh-search-field select:focus {
    border-color: var(--tlkh-color, #004FA0);
    box-shadow: 0 0 0 2px var(--tlkh-color-light, rgba(0,79,160,0.12));
}

.tlkh-search-btns {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.tlkh-btn-search,
.tlkh-btn-reset {
    padding: 0 14px;
    border-radius: 4px;
    font-size: var(--tlkh-fsize, 13px);
    cursor: pointer;
    height: 32px;
    border: 1px solid transparent;
    font-family: var(--tlkh-font, Arial, sans-serif);
    transition: all .15s;
    white-space: nowrap;
}

.tlkh-btn-search {
    background: var(--tlkh-color, #004FA0);
    color: #fff;
    border-color: var(--tlkh-color, #004FA0);
}
.tlkh-btn-search:hover {
    background: var(--tlkh-color-dark, #003d7a);
}

.tlkh-btn-reset {
    background: #fff;
    color: #555;
    border-color: #c8d3e0;
}
.tlkh-btn-reset:hover { background: #f0f2f5; }

/* ── Thông tin kết quả + phân trang trên ── */
.tlkh-table-info {
    padding: 7px 16px;
    font-size: 12px;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #dde3ea;
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 6px;
}

/* ── Bảng ── */
.tlkh-table-wrap {
    overflow-x: auto;
    flex: 1;
}

.tlkh-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--tlkh-fsize, 13px);
}

.tlkh-table thead tr {
    background: var(--tlkh-color, #004FA0);
}

.tlkh-table thead th {
    color: #fff;
    padding: 9px 10px;
    text-align: left;
    font-size: var(--tlkh-tsize, 13px);
    font-weight: 600;
    white-space: nowrap;
}

.tlkh-table .col-stt     { width: 40px; text-align: center; }
.tlkh-table .col-so-hieu { width: 130px; }
.tlkh-table .col-ngay    { width: 110px; }
.tlkh-table .col-file    { width: 130px; text-align: center; }

.tlkh-table tbody tr.tlkh-row {
    border-bottom: 1px solid #eaeff5;
    transition: background .12s;
}
.tlkh-table tbody tr.tlkh-row:hover {
    background: var(--tlkh-color-light, rgba(0,79,160,0.06));
}
.tlkh-table tbody tr.tlkh-row.active-row {
    background: var(--tlkh-color-light2, rgba(0,79,160,0.12));
}

.tlkh-table td {
    padding: 8px 10px;
    vertical-align: middle;
    line-height: 1.45;
}
.tlkh-table .col-stt { text-align: center; color: #888; }

/* Badge loại */
.tlkh-badge-loai {
    display: inline-block;
    background: var(--tlkh-color-light2, rgba(0,79,160,0.12));
    color: var(--tlkh-color, #004FA0);
    font-size: 10px;
    padding: 2px 7px;
    border-radius: 10px;
    margin-left: 5px;
    white-space: nowrap;
    vertical-align: middle;
}

/* ── Nút file & download ── */
.tlkh-file-actions {
    display: flex;
    align-items: center;
    gap: 5px;
    justify-content: center;
}

.tlkh-btn-expand {
    background: none;
    border: 1px solid var(--tlkh-color, #004FA0);
    color: var(--tlkh-color, #004FA0);
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: all .15s;
    font-family: var(--tlkh-font, Arial, sans-serif);
}
.tlkh-btn-expand:hover,
.tlkh-btn-expand.open {
    background: var(--tlkh-color, #004FA0);
    color: #fff;
}

.tlkh-btn-download {
    background: var(--tlkh-color, #004FA0);
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 3px 9px;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    transition: background .15s;
    height: 26px;
}
.tlkh-btn-download:hover {
    background: var(--tlkh-color-dark, #003d7a);
}

/* Dropdown nhiều file */
.tlkh-download-wrap { position: relative; }

.tlkh-download-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    background: #fff;
    border: 1px solid #dde3ea;
    border-radius: 5px;
    box-shadow: 0 4px 16px rgba(0,0,0,.12);
    z-index: 999;
    min-width: 220px;
    padding: 4px 0;
}
.tlkh-download-dropdown.open { display: block; }

.tlkh-download-dropdown a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    color: #333;
    text-decoration: none;
    font-size: 12px;
    transition: background .12s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tlkh-download-dropdown a:hover {
    background: var(--tlkh-color-light, rgba(0,79,160,0.08));
    color: var(--tlkh-color, #004FA0);
}

.tlkh-no-file { color: #bbb; }

/* ── File row inline ── */
.tlkh-file-row td {
    background: #f7faff;
    padding: 10px 10px 10px 36px !important;
    border-bottom: 1px solid #dde3ea;
}

.tlkh-file-list { display: flex; flex-direction: column; gap: 6px; }

.tlkh-file-entry {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: var(--tlkh-fsize, 13px);
}

.tlkh-ficon { font-size: 16px; min-width: 20px; }

.tlkh-file-link {
    color: var(--tlkh-color, #004FA0);
    text-decoration: none;
    flex: 1;
}
.tlkh-file-link:hover { text-decoration: underline; }

.tlkh-btn-dl-inline {
    background: none;
    border: 1px solid var(--tlkh-color, #004FA0);
    color: var(--tlkh-color, #004FA0);
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 11px;
    text-decoration: none;
    white-space: nowrap;
    transition: all .15s;
}
.tlkh-btn-dl-inline:hover {
    background: var(--tlkh-color, #004FA0);
    color: #fff;
}

/* ── Empty / Loading ── */
.tlkh-empty, .tlkh-loading {
    text-align: center;
    padding: 40px !important;
    color: #999;
    font-size: 13px;
}
.tlkh-loading { color: var(--tlkh-color, #004FA0); }

/* ── Phân trang ── */
.tlkh-pagination-wrap {
    padding: 10px 16px;
    border-top: 1px solid #eaeff5;
    display: flex;
    justify-content: flex-end;
    flex-shrink: 0;
}

.tlkh-pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.tlkh-pagination button {
    background: #fff;
    border: 1px solid #c8d3e0;
    border-radius: 4px;
    padding: 3px 9px;
    font-size: 12px;
    cursor: pointer;
    color: #444;
    transition: all .12s;
    min-width: 30px;
    font-family: var(--tlkh-font, Arial, sans-serif);
}
.tlkh-pagination button:hover:not(:disabled) {
    background: var(--tlkh-color-light);
    border-color: var(--tlkh-color);
    color: var(--tlkh-color);
}
.tlkh-pagination button.active {
    background: var(--tlkh-color, #004FA0);
    border-color: var(--tlkh-color, #004FA0);
    color: #fff;
    font-weight: 600;
}
.tlkh-pagination button:disabled {
    opacity: .4;
    cursor: not-allowed;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .tlkh-wrap { flex-direction: column; }
    .tlkh-sidebar {
        width: 100%;
        min-width: unset;
        border-right: none;
        border-bottom: 1px solid #dde3ea;
        max-height: 280px;
    }
    .tlkh-search-row { flex-direction: column; }
    .tlkh-search-field { min-width: unset; width: 100%; }
    .tlkh-table .col-ngay { display: none; }
}
