/* =========================================
   THX_EC TOOLBAR: SINGLE ROW LAYOUT (STRICT)
   ========================================= */

.thx-ec-learning-helper-panel {
    display: none;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 999px;
    padding: 6px 22px;
    gap: 16px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

    /* Căn giữa trang */
    margin: 25px auto !important;
    width: fit-content;
    max-width: 98%;

    /* Không bắt buộc 1 hàng nữa, dựa vào @media để xử lý responsive */
    flex-wrap: nowrap;
    user-select: none;
}

.thx-ec-learning-helper-panel.has-content {
    display: flex;
    /* Kích hoạt Flexbox */
}

/* Container trung gian bao quanh các Tabs */
#thx-ec-panel-options-container {
    display: flex;
    /* Bắt buộc phải là flex để con của nó không bị block */
    align-items: center;
    min-width: 0;
    /* Tránh lỗi overflow trong flex item */
}

/* Nội dung từng Tab (chứa các settings con) */
.thx-ec-tab-content {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: nowrap;
}

/* Từng nhóm Setting (Toggle/Select) */
.thx-ec-toolbar__group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    /* Không cho phép bị co nhỏ làm vỡ layout */
    height: 32px;
}

/* Đường kẻ dọc */
.thx-ec-toolbar__divider {
    width: 1px;
    height: 18px;
    background-color: #e5e7eb;
    flex-shrink: 0;
    margin: 0;
    display: block;
    /* Đảm bảo hiển thị */
}

.thx-ec-toolbar__label {
    font-size: 14px;
    color: var(--tv-neutral-fg, #1f2937);
    font-weight: 500;
    line-height: 1;
}

/* --- CUSTOM SELECT & INPUTS --- */
/* Giữ nguyên style đẹp cũ */
.thx-ec-custom-select {
    position: relative;
    height: 32px;
    font-size: 13px;
    font-weight: 500;
    color: #111827;
    cursor: pointer;
}

.thx-ec-select-trigger {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: #fff;
    border: 1px solid #d1d5db;
    border-radius: 16px;
    padding: 0 30px 0 12px;
    position: relative;
    transition: all 0.2s ease;
}

.thx-ec-select-trigger::after {
    content: '';
    position: absolute;
    right: 10px;
    top: 50%;
    width: 10px;
    height: 6px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236b7280' fill='none' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    transform: translateY(-50%);
    transition: transform 0.2s;
}

.thx-ec-custom-select.is-open .thx-ec-select-trigger::after {
    transform: translateY(-50%) rotate(180deg);
}

.thx-ec-custom-select.is-open .thx-ec-select-trigger {
    border-color: var(--tv-accent, #4A5D23);
    box-shadow: 0 0 0 2px rgba(74, 93, 35, 0.1);
}

@media (hover: hover) {
    .thx-ec-custom-select:hover .thx-ec-select-trigger::after {
        transform: translateY(-50%) rotate(180deg);
    }
    .thx-ec-custom-select:hover .thx-ec-select-trigger {
        border-color: var(--tv-accent, #4A5D23);
        box-shadow: 0 0 0 2px rgba(74, 93, 35, 0.1);
    }
}

.thx-ec-select-options {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 100%;
    width: max-content;
    max-width: 250px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    padding: 6px;
    z-index: 10001;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s;
}

.thx-ec-select-options::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 0;
    width: 100%;
    height: 10px;
    background: transparent;
    z-index: 1;
}

.thx-ec-custom-select.is-open .thx-ec-select-options {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

@media (hover: hover) {
    .thx-ec-custom-select:hover .thx-ec-select-options {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }
}

.thx-ec-option {
    padding: 8px 12px;
    border-radius: 8px;
    color: #374151;
    cursor: pointer;
    font-size: 13px;
    line-height: 1.4;
    position: relative;
    z-index: 2;
}

.thx-ec-option:hover {
    background-color: #f3f4f6;
    color: var(--tv-accent, #4A5D23);
}

.thx-ec-option.selected {
    background-color: rgba(74, 93, 35, 0.08);
    color: var(--tv-accent, #4A5D23);
    font-weight: 600;
}

/* Mode Selector Style */
.thx-ec-mode-selector .thx-ec-custom-select {
    margin-right: 0;
}

.thx-ec-mode-selector .thx-ec-select-trigger {
    background-color: rgba(74, 93, 35, 0.08);
    border: 1px solid rgba(74, 93, 35, 0.15);
    color: var(--tv-accent, #4A5D23);
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0 26px 0 14px;
}

.thx-ec-mode-selector .thx-ec-select-trigger::after {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%234A5D23' fill='none' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    width: 9px;
    right: 10px;
}

.thx-ec-mode-selector .thx-ec-option {
    font-size: 12px;
    text-transform: uppercase;
    font-weight: 600;
}

/* Checkbox */
.thx-ec-toolbar__checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    line-height: 1;
}

.thx-ec-toolbar__checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--tv-accent, #4A5D23);
    cursor: pointer;
}

/* Mobile Responsive Layout (Stack/Wrap) */
@media (max-width: 600px) {
    .thx-ec-learning-helper-panel {
        max-width: 95%;
        border-radius: 12px;
        flex-wrap: wrap; /* Cho rớt dòng */
        justify-content: center;
        padding: 12px;
        gap: 10px;
    }
    
    #thx-ec-panel-options-container {
        flex-wrap: wrap;
        justify-content: center;
        width: 100%;
    }
    
    .thx-ec-tab-content {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
    }

    .thx-ec-toolbar__divider {
        display: none; /* Ẩn các thanh dọc chia cách khi hiển thị trên Mobile */
    }
    
    .thx-ec-document-actions, .thx-ec-mode-selector {
        width: 100%;
        justify-content: center;
    }
    
    .thx-ec-custom-select, .thx-ec-toolbar__group {
        width: 100%;
        justify-content: center;
    }
}

/* =========================================
   DOCUMENT ACTIONS: LIKE & SAVE BUTTONS
   ========================================= */
.thx-ec-document-actions {
    white-space: nowrap;
}

.thx-ec-document-actions .js-lemh-interact-btn {
    transition: all 0.2s;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    color: #888;
}

.thx-ec-document-actions .js-lemh-interact-btn:hover {
    opacity: 0.7;
}

.thx-ec-document-actions .js-lemh-interact-btn svg {
    vertical-align: -3px;
    margin-right: 4px;
    transition: all 0.2s;
}

/* Like Active */
.thx-ec-document-actions .js-lemh-interact-btn[data-type="like"].savelike-is-active {
    color: #f53d5c;
}

.thx-ec-document-actions .js-lemh-interact-btn[data-type="like"].savelike-is-active svg {
    fill: #f53d5c;
    stroke: #f53d5c;
}


/* =========================================
   COMMENTS AREA (Shared with Excerpts)
   ========================================= */
#thx-ec-comments-area {
    max-width: 800px;
    margin: 60px auto 100px;
    padding: 0 20px;
}

#thx-ec-comments-area h3 {
    color: #1e293b;
    margin-bottom: 30px;
    border-bottom: 2px solid #f1f5f9;
    padding-bottom: 15px;
    font-size: 1.2rem;
    font-weight: 700;
}

.thx-ec-comments-list {
    list-style: none;
    padding: 0;
    margin: 0 0 40px;
}

.thx-ec-comments-list .comment {
    margin-bottom: 20px;
    padding: 15px 20px;
    background: #fff;
    border-radius: 16px;
    border: 1px solid #f1f5f9;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.02);
    list-style: none;
}

.comment-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: relative;
}

.comment-author {
    display: flex;
    align-items: center;
    gap: 12px;
}

.comment-author img {
    border-radius: 50%;
    width: 32px;
    height: 32px;
}

.comment-author cite {
    font-style: normal;
    font-weight: 700;
    color: #1e293b;
    font-size: 0.95rem;
}

.comment-meta {
    font-size: 0.75rem;
    color: #94a3b8;
}

.comment-content {
    color: #475569;
    line-height: 1.5;
    font-size: 0.98rem;
    margin-top: 5px;
}

.reply {
    margin-top: 8px;
}

.reply a,
.comment-edit-link,
.comment-delete-link,
.comment-restore-link,
.comment-view-link {
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    padding: 4px 10px;
    border-radius: 6px;
    transition: all 0.2s;
    cursor: pointer;
    display: inline-block;
    margin-right: 5px;
}

.reply a,
.comment-edit-link {
    color: #8b5cf6;
    background: rgba(139, 92, 246, 0.05);
}

.reply a:hover,
.comment-edit-link:hover {
    background: #8b5cf6;
    color: #fff;
}

.comment-delete-link {
    color: #94a3b8;
}

.comment-delete-link:hover {
    color: #ef4444;
}

.comment-delete-link.is-hard {
    color: #ef4444;
}

.comment-respond {
    background: #fff;
    padding: 20px;
    border-radius: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
    border: 1px solid #f1f5f9;
    margin-top: 30px;
}

.comment-form-comment textarea {
    width: 100% !important;
    border-radius: 12px !important;
    border: 1px solid #cbd5e1 !important;
    padding: 10px 15px !important;
    font-family: inherit !important;
    font-size: 0.95rem !important;
    min-height: 46px !important;
    transition: border-color 0.2s !important;
    resize: none !important;
}

.thx-ec-btn-submit,
.form-submit input {
    background: #8b5cf6 !important;
    color: #fff !important;
    border: none !important;
    padding: 10px 24px !important;
    border-radius: 12px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: opacity 0.2s !important;
}

.thx-ec-btn-submit:hover,
.form-submit input:hover {
    opacity: 0.9;
}