/* css/widget-sidebar.css: Sidebar styles for widget system */

.widget-sidebar {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background: #fff;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 1050;
    transition: right 0.3s ease;
    border-left: 1px solid #dee2e6;
    display: flex;
    flex-direction: column;
}

.widget-sidebar.show {
    right: 0;
}

.widget-sidebar .sidebar-header {
    background: var(--brown-tone) !important;
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #495057;
}

.widget-sidebar .sidebar-content {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
}

.widget-sidebar .article-content {
    line-height: 1.6;
}

.widget-sidebar .article-content h5 {
    border-bottom: 2px solid #007bff;
    padding-bottom: 8px;
}

.widget-sidebar .article-content strong {
    color: #0056b3;
}

/* 📱 MOBILE: Hide sidebar completely (use modal instead) */
@media (max-width: 767px) {
    .widget-sidebar {
        display: none !important;
        /* Force hide - mobile uses modal only */
    }

    body.sidebar-open {
        overflow: auto;
        /* Allow scroll since no sidebar */
    }
}

/* Desktop: don't prevent body scroll */
@media (min-width: 769px) {
    body.sidebar-open {
        /* Don't override overflow on desktop to preserve menu functionality */
        overflow: auto;
    }
}

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

.widget-trigger button {
    transition: all 0.2s ease;
}

.widget-trigger button:hover {
    transform: translateX(2px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Loading states */
.widget-sidebar .spinner-border {
    width: 2rem;
    height: 2rem;
}

/* Article formatting in sidebar */
.widget-sidebar .article-header {
    border-bottom: 1px solid #dee2e6;
}

.widget-sidebar .article-footer {
    font-size: 0.875rem;
}

/* (embedded overrides removed to keep fixed overlay slide-in behavior) */

/* Embedded slide-in inside right column content section */
.widget-embedded-container {
    position: relative;
    /* establish containing block */
    overflow: hidden;
    /* hide off-canvas panel during slide */
}

.widget-embedded-container #widget-sidebar {
    position: absolute;
    /* slide within container, not viewport */
    top: 0;
    right: -100%;
    /* off-canvas to the right */
    width: 100%;
    /* full width of content section */
    height: 100%;
    /* match container height */
    max-width: 100%;
    background: #fff;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.05);
    border-left: 1px solid #dee2e6;
    z-index: 10;
    /* above content inside the container */
    transition: right 0.3s ease;
}

.widget-embedded-container #widget-sidebar.show {
    right: 0;
    /* slide into view */
}

.widget-embedded-container #widget-sidebar .sidebar-content {
    flex: 1;
    height: auto;
    /* reset fixed height so flex works */
    overflow-y: auto;
    /* scroll content area only */
}

/* Collapsible text mechanism with arrow icon */
.collapsed-wrapper {
    display: block;
    transition: all 0.3s ease;
}

.collapsed-wrapper.text-collapsed {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

#sidebar-doc-link .collapsed-wrapper.text-collapsed {
    -webkit-line-clamp: 1;
    /* Link chỉ hiển thị 1 dòng cho gọn */
    line-clamp: 1;
}

.collapsed-wrapper.text-expanded {
    display: block;
    overflow: visible;
    -webkit-line-clamp: unset;
    line-clamp: unset;
}

.sidebar-toggle-btn {
    transition: transform 0.2s ease, opacity 0.2s ease;
    opacity: 0.7;
}

.sidebar-toggle-btn:hover {
    opacity: 1;
    transform: scale(1.2);
}

.sidebar-maximize-btn {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: sidebarBtnFadeIn 0.5s ease-out both;
    animation-delay: 0.3s;
}

@keyframes sidebarBtnFadeIn {
    from {
        opacity: 0;
        transform: translateY(-50%) scale(0.5) translateX(10px);
    }

    to {
        opacity: 1;
        transform: translateY(-50%) scale(1) translateX(0);
    }
}

.sidebar-maximize-btn:hover {
    background-color: var(--brown-tone) !important;
    color: white !important;
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2) !important;
}

.sidebar-maximize-btn:active {
    transform: translateY(-50%) scale(0.95);
}

.sidebar-header h6 {
    font-size: 0.95rem;
    line-height: 1.3;
    display: flex;
    align-items: flex-start;
}

#sidebar-doc-link {
    display: flex !important;
    align-items: center;
    line-height: 1.4;
    font-size: 13px;
    text-decoration: none;
}

#sidebar-doc-link:hover {
    text-decoration: none;
}

#sidebar-doc-link .collapsed-wrapper {
    flex: 1;
    min-width: 0;
    /* Cho phép truncate bên trong flex */
}

/* Footer gọn gàng hơn */
.sidebar-footer {
    padding: 10px 12px !important;
}

.sidebar-footer .small {
    font-size: 11px !important;
    margin-bottom: 4px !important;
}

/* 🏢 MODAL OPTIMIZATION: Max height 90% and fixed header/footer */
.modal-dialog-scrollable {
    max-height: 90vh !important;
    margin-top: 5vh !important;
    margin-bottom: 5vh !important;
}

.modal-dialog-scrollable .modal-content {
    max-height: 90vh !important;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.2) !important;
}

.modal-dialog-scrollable .modal-body {
    padding: 25px !important;
    background-color: #fdfdfd;
}

.modal-dialog-scrollable .modal-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #eee;
    padding: 1rem 1.5rem;
}

.modal-dialog-scrollable .modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #eee;
}

.modal-dialog-scrollable .article-content {
    font-size: 1.05rem;
    line-height: 1.7;
    color: #2c3e50;
}