/* ==========================================================================
   1. KHUNG CHÍNH & THẺ NỀN (CARDS & CONTAINERS)
   ========================================================================== */
.chapter-header-box {
    background: var(--pico-card-background-color);
    border: 1px solid var(--pico-border-color);
    border-left: 5px solid var(--pico-primary);
    padding: 1rem 1.5rem;
    border-radius: var(--pico-border-radius);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    margin-bottom: 1.5rem;
}

.panel-card {
    background: var(--pico-card-background-color);
    padding: 1.5rem;
    border-radius: var(--pico-border-radius);
    border: 1px solid var(--pico-border-color);
    box-shadow: 0 4px 15px rgba(0,0,0,0.03);
}

.section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--pico-border-color);
    margin-bottom: 1.2rem;
    color: var(--pico-primary);
}

/* Thẻ collapsible (xổ xuống) đồng bộ chuẩn Pico CSS */
details.chapter-collapsible,
.chapter-collapsible {
    background-color: var(--pico-card-background-color) !important;
    color: var(--pico-color) !important;
    border: 1px solid var(--pico-card-border-color, var(--pico-border-color)) !important;
    border-radius: var(--pico-border-radius, 8px);
    margin-bottom: 1.25rem;
    padding: 0.75rem 1.25rem;
    box-shadow: none;
}

details.chapter-collapsible[open] {
    background-color: var(--pico-card-background-color) !important;
}

details.chapter-collapsible summary,
.chapter-collapsible summary {
    font-weight: 700;
    color: var(--pico-color) !important;
    cursor: pointer;
    padding: 0.2rem 0;
}

details.chapter-collapsible summary:hover,
.chapter-collapsible summary:hover {
    color: var(--pico-primary) !important;
}

/* ==========================================================================
   2. FORM, INPUT & DANH SÁCH KÉO THẢ
   ========================================================================== */
.radio-fieldset {
    border: 1px solid var(--pico-border-color) !important;
    border-radius: var(--pico-border-radius, 6px);
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    background-color: var(--pico-background-color) !important;
}

.radio-fieldset legend {
    padding: 0 6px;
    font-weight: 700;
    color: var(--pico-color);
}

.radio-fieldset input[type="radio"] {
    accent-color: var(--pico-primary);
    cursor: pointer;
}

.radio-item-highlight {
    font-weight: 600;
    color: var(--pico-primary);
}

/* Danh sách kéo thả */
.drag-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    margin-bottom: 6px;
    background: var(--pico-background-color);
    border: 1px solid var(--pico-border-color);
    border-radius: 6px;
    cursor: grab;
    transition: background 0.2s;
}
.drag-item:active { cursor: grabbing; }
.drag-item.sortable-ghost { opacity: 0.4; background: #e0e0e0; }

.btn-delete-item {
    background: transparent;
    border: none;
    color: #d9534f;
    cursor: pointer;
    padding: 2px 8px;
    font-size: 0.95rem;
    margin-bottom: 0;
    width: auto;
}
.btn-delete-item:hover { color: #a94442; }

/* ==========================================================================
   3. CÂY MỤC LỤC (TREEVIEW DESKTOP & MOBILE)
   ========================================================================== */
.manage-book-container { 
    display: flex; 
    flex-direction: column; 
    gap: 1.5rem; 
}

@media (min-width: 768px) and (orientation: landscape), (min-width: 992px) {
    .manage-book-container { flex-direction: row; align-items: flex-start; }
    .manage-tree-sidebar { 
        width: 330px; 
        flex-shrink: 0; 
        border-right: 1px solid var(--pico-border-color); 
        padding-right: 1rem; 
        max-height: 82vh;
        overflow-y: auto;
    }
    .manage-mobile-select { display: none !important; }
    .manage-form-content { flex: 1; }
}

@media (max-width: 767px), (orientation: portrait) {
    .manage-tree-sidebar { display: none !important; }
    .manage-mobile-select { display: block !important; }
}

.tree-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--pico-border-color);
}

.tree-header-btn {
    padding: 0 !important;
    width: 32px !important;
    height: 32px !important;
    font-size: 0.85rem !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 !important;
    line-height: 1 !important;
    box-sizing: border-box !important;
    vertical-align: middle !important;
}

/* Khung cuộn & định dạng dòng của TreeView */
#tree-container-desktop {
    font-size: 0.88rem !important;
    line-height: 1.25 !important;
    overflow-x: auto !important;
    overflow-y: hidden;
    white-space: nowrap !important;
    max-width: 100%;
    padding-bottom: 8px;
}

/* Đã gỡ bỏ padding-left !important để JS tự điều chỉnh thụt lề cấp con */
#tree-container-desktop ul,
.tree-container ul {
    list-style: none !important;
    margin: 0 !important;
    min-width: max-content;
}

#tree-container-desktop li,
.tree-container li {
    margin: 0 !important;
    padding: 0 !important;
    list-style-type: none !important;
    white-space: nowrap !important;
}

#tree-container-desktop details,
#tree-container-desktop summary,
.tree-container details,
.tree-container summary {
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
}

#tree-container-desktop summary::-webkit-details-marker {
    display: none;
}

.tree-node-row,
#tree-container-desktop summary {
    display: flex !important;
    align-items: center !important;
    white-space: nowrap !important;
    width: max-content !important;
    padding: 1px 0 !important;
    min-height: 22px;
}
/* Căn chỉnh nhánh cây nằm chính giữa tâm Icon Folder bên trên */
.tree-branch-symbol {
    color: #888;
    font-family: monospace;
    font-weight: bold;
    user-select: none;
    line-height: 1;
    display: inline-block;
    margin-right: 2px;
}

/* Icon folder và file cố định độ rộng để căn lề chuẩn xác */
.tree-node-icon {
    width: 16px !important;
    text-align: center;
    margin-right: 6px;
    flex-shrink: 0;
}

#tree-container-desktop a {
    white-space: nowrap !important;
    display: inline-block;
}

.tree-node-active {
    background-color: var(--pico-primary-background) !important;
    color: var(--pico-primary) !important;
    font-weight: 700 !important;
    border-radius: 4px;
    padding: 2px 8px;
    display: inline-block;
    border: 1px solid var(--pico-primary-border) !important;
}



.tree-toggle-icon {
    cursor: pointer;
    display: inline-block;
    width: 18px;
    text-align: center;
    margin-right: 4px;
    color: var(--pico-primary);
}

.tree-scroll-container {
    max-height: 78vh;
    overflow-x: auto;
    overflow-y: auto;
    white-space: nowrap;
    padding-right: 10px;
}

/* ==========================================================================
   4. PHÂN LOẠI KHÁC (BADGES, BREADCRUMB, PREVIEW)
   ========================================================================== */
.badge-book-title {
    background-color: var(--pico-primary);
    color: #ffffff !important;
    padding: 0.35rem 0.85rem;
    border-radius: 20px;
    font-size: 1rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.stat-badge-box {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    background: rgba(0,0,0,0.03);
    padding: 10px 15px;
    border-radius: 6px;
    margin-bottom: 15px;
    font-size: 0.85rem;
}

.stat-badge-item { 
    display: inline-flex; 
    align-items: center; 
    gap: 5px; 
}

.content-summary-preview {
    background: var(--pico-card-background-color, #f9f9f9);
    border: 1px solid var(--pico-border-color);
    border-radius: 6px;
    padding: 1rem;
    max-height: 250px;
    overflow-y: auto;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--pico-color);
}

.custom-breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    margin-bottom: 12px;
    color: var(--pico-muted-color);
    padding: 6px 12px;
    background: var(--pico-card-background-color, rgba(255, 255, 255, 0.03));
    border-radius: 6px;
    border: 1px solid var(--pico-border-color);
}

.custom-breadcrumb a {
    color: var(--pico-color);
    text-decoration: none;
}

.custom-breadcrumb a:hover {
    text-decoration: underline;
}

