/* Widget System Styles */


/* Widget Containers */
.widget-sidebar-container {
    background: #ffffff;
    border-radius: 0.5rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.widget-sidebar-header {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 1px solid #dee2e6;
    border-radius: 0.5rem 0.5rem 0 0;
}

.widget-sidebar-content {
    background: #fff;
    border-radius: 0 0 0.5rem 0.5rem;
}

/* Widget Triggers */
.widget-trigger {
    margin-bottom: 1rem;
}

.widget-trigger .btn {
    transition: all 0.2s ease;
    border: 1px solid #dee2e6;
    background: #fff;
    color: #495057;
}

.widget-trigger .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.15);
    border-color: #007bff;
    color: #007bff;
}

/* Widget Headers */
.widget-header {
    padding-bottom: 1rem;
    border-bottom: 1px solid #e9ecef;
    margin-bottom: 1rem;
}

.widget-header h5, .widget-header h6 {
    color: #343a40;
    margin-bottom: 0.5rem;
}

.widget-header .text-muted {
    font-size: 0.875rem;
}

/* Widget Content Areas */
.widget-content {
    line-height: 1.6;
}

.widget-content .card {
    border: 1px solid #e9ecef;
    transition: all 0.2s ease;
}

.widget-content .card:hover {
    border-color: #007bff;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 123, 255, 0.15);
}

/* Specific Widget Styles */

/* Muc Luc Widget */
.widget-muc-luc .list-group-item {
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
}

.widget-muc-luc .list-group-item:hover {
    border-left-color: #007bff;
    background-color: #f8f9fa;
}

.widget-muc-luc .badge {
    min-width: 2rem;
    text-align: center;
}

/* Noi Dung Van Ban Widget */
.widget-noi-dung-van-ban .van-ban-content {
    font-family: 'Times New Roman', Times, serif;
    font-size: 1rem;
    line-height: 1.8;
    text-align: justify;
}

.widget-noi-dung-van-ban mark {
    background-color: #fff3cd;
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
}

/* Thu Tuc Hanh Chinh Widget */
.widget-thu-tuc-hanh-chinh .timeline {
    position: relative;
}

.widget-thu-tuc-hanh-chinh .timeline-item {
    display: flex;
    margin-bottom: 1.5rem;
}

.widget-thu-tuc-hanh-chinh .timeline-marker {
    margin-right: 1rem;
    position: relative;
}

.widget-thu-tuc-hanh-chinh .timeline-marker-icon {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: bold;
    background: #007bff;
    color: white;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 123, 255, 0.25);
}

.widget-thu-tuc-hanh-chinh .timeline-marker-line {
    position: absolute;
    left: 50%;
    top: 2.5rem;
    width: 2px;
    height: 2rem;
    background: linear-gradient(to bottom, #007bff, #e9ecef);
    transform: translateX(-50%);
}

.widget-thu-tuc-hanh-chinh .timeline-content {
    flex: 1;
    padding-top: 0.5rem;
}

/* Dieu Khoan Widget */
.widget-noi-dung-dieu-khoan .dieu-khoan-content {
    font-family: 'Times New Roman', Times, serif;
    font-size: 1rem;
    line-height: 1.8;
    text-align: justify;
}

.widget-noi-dung-dieu-khoan mark {
    background-color: #d4edda;
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
}

/* YouTube Widget */
.widget-youtube-video .ratio {
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.15);
    border-radius: 0.5rem;
    overflow: hidden;
}

.widget-youtube-video .ratio iframe {
    border-radius: 0.5rem;
}

/* Iframe Widget */
.widget-iframe .iframe-container {
    position: relative;
    min-height: 400px;
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
    overflow: hidden;
    background: #f8f9fa;
}

.widget-iframe .iframe-loading {
    background: linear-gradient(45deg, #f8f9fa 25%, transparent 25%),
                linear-gradient(-45deg, #f8f9fa 25%, transparent 25%),
                linear-gradient(45deg, transparent 75%, #f8f9fa 75%),
                linear-gradient(-45deg, transparent 75%, #f8f9fa 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

/* Widget Actions */
.widget-actions {
    padding-top: 1rem;
    border-top: 1px solid #e9ecef;
    margin-top: 1rem;
}

.widget-actions .btn-group .btn {
    font-size: 0.875rem;
    padding: 0.375rem 0.75rem;
}

/* Widget Toast */
#widget-toast {
    z-index: 9999;
}

#widget-toast .toast-header {
    font-weight: 600;
}

/* Widget Modals */
.modal-xl .modal-content {
    border-radius: 0.75rem;
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.175);
}

.modal-xl .modal-header {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 1px solid #dee2e6;
    border-radius: 0.75rem 0.75rem 0 0;
}

.modal-xl .modal-body {
    padding: 2rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .widget-sidebar-container {
        margin: 0.5rem;
    }
    
    .widget-sidebar-header {
        padding: 1rem;
    }
    
    .widget-sidebar-content {
        padding: 1rem;
    }
    
    .widget-thu-tuc-hanh-chinh .timeline-item {
        flex-direction: column;
    }
    
    .widget-thu-tuc-hanh-chinh .timeline-marker {
        margin-right: 0;
        margin-bottom: 0.5rem;
        align-self: flex-start;
    }
    
    .widget-thu-tuc-hanh-chinh .timeline-marker-line {
        display: none;
    }
}

/* Animation và Transitions */
.widget-trigger .btn,
.widget-content .card,
.widget-muc-luc .list-group-item {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Loading States */
.widget-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: #6c757d;
}

.widget-loading .spinner-border {
    width: 2rem;
    height: 2rem;
    margin-right: 1rem;
}

/* Error States */
.widget-error {
    padding: 1.5rem;
    text-align: center;
    color: #dc3545;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 0.5rem;
}

.widget-error .fas {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

/* Custom Scrollbars */
.widget-sidebar-content::-webkit-scrollbar,
.widget-content::-webkit-scrollbar {
    width: 6px;
}

.widget-sidebar-content::-webkit-scrollbar-track,
.widget-content::-webkit-scrollbar-track {
    background: #f8f9fa;
    border-radius: 3px;
}

.widget-sidebar-content::-webkit-scrollbar-thumb,
.widget-content::-webkit-scrollbar-thumb {
    background: #dee2e6;
    border-radius: 3px;
}

.widget-sidebar-content::-webkit-scrollbar-thumb:hover,
.widget-content::-webkit-scrollbar-thumb:hover {
    background: #adb5bd;
}

/* ==============================
   MLV (Mục lục văn bản) Styling - Simple & Clean
   ============================== */
.mlv-container {
    background: #ffffff;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 0;
}

.mlv-container .mlv-header {
    padding: 1rem 1.25rem;
    background: #f8f9fa;
    border-bottom: 1px solid #ddd;
}

.mlv-container .mlv-header .fw-bold {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
}

.mlv-container .mlv-header .text-muted,
.mlv-container .mlv-header .small {
    color: #666 !important;
    font-size: 0.875rem;
}

.mlv-container .mlv-header .btn {
    background: white;
    border: 1px solid #ddd;
    color: #333;
    font-size: 0.875rem;
}

.mlv-container .mlv-header .btn:hover {
    background: #f8f9fa;
    border-color: #aaa;
}

/* Tree content area */
.mlv-container > ul {
    padding: 0.5rem;
    background: white;
}

.mlv-container ul {
    margin: 0;
    padding-left: 0;
    list-style: none;
}

/* Nested levels: CHỈ 2px mỗi cấp */
.mlv-container ul ul {
    margin-left: 0;
    padding-left: 0;
}

/* Tree item styling - Simple with borders */
.mlv-item {
    position: relative;
    padding: 0.4rem 0.5rem;
    padding-left: 0.5rem; /* Base padding cho level 0 */
    margin: 0;
    border-bottom: 1px solid #e9e9e9;
    line-height: 1.2;
    background: white;
}

/* Thụt lùi 2px cho mỗi level - áp dụng vào item không phải ul */
.mlv-item.level-0 { padding-left: 0.5rem; }
.mlv-item.level-1 { padding-left: calc(0.5rem + 2px); }
.mlv-item.level-2 { padding-left: calc(0.5rem + 4px); }
.mlv-item.level-3 { padding-left: calc(0.5rem + 6px); }
.mlv-item.level-4 { padding-left: calc(0.5rem + 8px); }
.mlv-item.level-5 { padding-left: calc(0.5rem + 10px); }
.mlv-item.level-6 { padding-left: calc(0.5rem + 12px); }
.mlv-item.level-7 { padding-left: calc(0.5rem + 14px); }
.mlv-item.level-8 { padding-left: calc(0.5rem + 16px); }
.mlv-item.level-9 { padding-left: calc(0.5rem + 18px); }
.mlv-item.level-10 { padding-left: calc(0.5rem + 20px); }

.mlv-item:hover {
    background: #f8f9fa;
}

/* Toggle button - Absolute position để không ảnh hưởng text wrap */
.mlv-toggle {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    color: #666;
    background: transparent;
    border: none;
    padding: 0;
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.mlv-toggle i {
    transition: transform 0.2s ease;
    font-size: 0.7rem;
}

.mlv-toggle i.rotated {
    transform: rotate(90deg);
}

/* Title styling - Block để wrap đúng */
.mlv-title {
    display: block;
    color: #333;
    font-size: 0.95rem;
    line-height: 1.2;
    text-decoration: none;
}

/* Link styling */
a.mlv-title {
    color: #0d6efd;
    text-decoration: none;
    cursor: pointer;
}

a.mlv-title:hover {
    color: #0a58ca;
    text-decoration: underline;
}

/* Items có toggle cần padding-left thêm cho toggle button */
.mlv-item.has-children {
    padding-left: calc(0.5rem + 24px) !important;
}

.mlv-item.has-children.level-1 { padding-left: calc(0.5rem + 24px + 2px) !important; }
.mlv-item.has-children.level-2 { padding-left: calc(0.5rem + 24px + 4px) !important; }
.mlv-item.has-children.level-3 { padding-left: calc(0.5rem + 24px + 6px) !important; }
.mlv-item.has-children.level-4 { padding-left: calc(0.5rem + 24px + 8px) !important; }
.mlv-item.has-children.level-5 { padding-left: calc(0.5rem + 24px + 10px) !important; }
.mlv-item.has-children.level-6 { padding-left: calc(0.5rem + 24px + 12px) !important; }
.mlv-item.has-children.level-7 { padding-left: calc(0.5rem + 24px + 14px) !important; }
.mlv-item.has-children.level-8 { padding-left: calc(0.5rem + 24px + 16px) !important; }
.mlv-item.has-children.level-9 { padding-left: calc(0.5rem + 24px + 18px) !important; }
.mlv-item.has-children.level-10 { padding-left: calc(0.5rem + 24px + 20px) !important; }

/* Hide icons - keep it simple */
.mlv-cap-icon {
    display: none;
}

/* Phần - UPPERCASE, BOLD */
.mlv-item.cap-phan .mlv-title {
    text-transform: uppercase;
    font-weight: 700;
    font-size: 1rem;
    color: #000;
}

/* Chương - UPPERCASE, BOLD */
.mlv-item.cap-chuong .mlv-title {
    text-transform: uppercase;
    font-weight: 700;
    font-size: 0.95rem;
    color: #000;
}

/* Mục - Bold (không uppercase) */
.mlv-item.cap-muc .mlv-title {
    font-weight: 700;
    color: #333;
    text-transform: none !important;
}

/* Tiểu mục - Bold (không uppercase) */
.mlv-item.cap-tieumuc .mlv-title {
    font-weight: 700;
    color: #333;
    text-transform: none !important;
}

/* Điều - Normal (force không viết hoa) */
.mlv-item.cap-dieu .mlv-title {
    font-weight: 400;
    color: #333;
    text-transform: none !important;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .mlv-container .mlv-header {
        padding: 0.75rem 1rem;
    }
    
    .mlv-container > ul {
        padding: 0.25rem;
    }
    
    .mlv-container ul ul {
        margin-left: 1rem;
    }
    
    .mlv-item {
        padding: 0.35rem 0.4rem;
        font-size: 0.9rem;
    }
}

/* Print styles */
@media print {
    .mlv-container {
        border: 1px solid #ccc;
    }
    
    .mlv-toggle {
        display: none;
    }
    
    .mlv-item.collapsed > ul {
      display: block !important;
  }
}

/* ==============================
   Embedded Dashboard (Right Column)
   ============================== */
.embedded-dashboard {
    margin-top: .5rem;
}

.embedded-dashboard .metric-box {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: .5rem;
    padding: .5rem .75rem;
    text-align: center;
}

.embedded-dashboard .metric-value {
    font-weight: 700;
    font-size: 1.1rem;
}

.embedded-dashboard .metric-label {
    color: #6c757d;
    font-size: .85rem;
}

.embedded-dashboard .related-docs .doc-item {
    padding: .5rem .75rem;
    border: 1px solid #e9ecef;
    border-radius: .5rem;
    margin-bottom: .5rem;
    background: #fff;
}

.embedded-dashboard .related-docs .doc-title a {
    color: #0d6efd;
    text-decoration: none;
}

.embedded-dashboard .related-docs .doc-title a:hover {
    text-decoration: underline;
}

.embedded-dashboard .related-links ul {
    margin: 0;
}

.embedded-dashboard .related-links ul li {
    padding: .25rem 0;
}

/* Ensure sidebar stays above dashboard when embedded */
.widget-embedded-container #widget-sidebar {
    z-index: 10; /* dashboard content is below (default stacking) */
}
