/* ==========================================================================
   MsComponents - Layouts & Containers Design System
   MsDialog, MsToolbar, MsDropDownButton, MsSplitter, MsTab
   Chuẩn UI vOffice: Màu chủ đạo #00676b, Segoe UI / Roboto, Icon Phosphor
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. MsDialog (Modal Popup)
   -------------------------------------------------------------------------- */
.ms-dialog-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(15, 23, 42, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
    user-select: none;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease-in-out;
}

.ms-dialog-backdrop.show {
    opacity: 1;
    pointer-events: auto;
}

.ms-dialog {
    position: relative;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    max-width: 98vw;
    max-height: 96vh;
    overflow: hidden;
    user-select: auto;
    opacity: 0;
    transition: opacity 0.15s ease-in-out;
}

.ms-dialog-backdrop.show .ms-dialog {
    opacity: 1;
}

.ms-dialog.dragging {
    transition: none !important;
}

/* Header */
.ms-dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
    min-height: 40px;
    height: 40px;
    box-sizing: border-box;
}

.ms-dialog-header.allow-drag {
    cursor: move;
}

.ms-dialog-title {
    font-size: 14px;
    font-weight: 600;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 0;
    line-height: 1.2;
}

.ms-dialog-title h1,
.ms-dialog-title h2,
.ms-dialog-title h3,
.ms-dialog-title h4,
.ms-dialog-title h5,
.ms-dialog-title h6 {
    font-size: 14px !important;
    font-weight: 600 !important;
    color: #0f172a !important;
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1.2 !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
}

.ms-dialog-title i {
    color: #00676b;
    font-size: 16px;
}

.ms-dialog-close-btn {
    background: transparent;
    border: none;
    border-radius: 4px;
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
    margin-left: auto;
}

.ms-dialog-close-btn:hover {
    background: #fee2e2;
    color: #dc2626;
}

/* Content */
.ms-dialog-content {
    padding: 6px;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    font-size: 13px;
    color: #334155;
    line-height: 1.5;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

/* Footer */
.ms-dialog-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 10px 16px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   2. MsToolbar (Thanh công cụ cố định chiều cao, chống vỡ layout trên mobile)
   -------------------------------------------------------------------------- */
.ms-toolbar {
    display: flex;
    align-items: center;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 0 6px;
    height: 38px !important;
    min-height: 38px !important;
    max-height: 38px !important;
    gap: 4px;
    box-sizing: border-box;
    width: 100%;
    position: relative;
    white-space: nowrap !important;
    overflow: hidden !important;
}

/* Vùng cuộn ngang Scrollable */
.ms-toolbar-scroll-container,
.ms-toolbar-popup-container {
    display: flex;
    align-items: center;
    flex: 1 1 auto;
    width: 100%;
    height: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
    white-space: nowrap !important;
}

.ms-toolbar-scroll-container::-webkit-scrollbar,
.ms-toolbar-popup-container::-webkit-scrollbar {
    display: none;
}

/* Nút điều hướng cuộn trái / phải */
.ms-toolbar-nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 26px;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    color: #475569;
    cursor: pointer;
    font-size: 13px;
    flex-shrink: 0;
    z-index: 2;
    transition: all 0.15s ease;
    padding: 0;
}

.ms-toolbar-nav-btn:hover {
    background: #e2e8f0;
    color: #00676b;
    border-color: #00676b;
}

.ms-toolbar-items {
    display: flex;
    align-items: center;
    gap: 6px;
    width: auto;
    height: 100%;
    flex-wrap: nowrap !important;
    white-space: nowrap !important;
}

.ms-toolbar-item {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0 !important;
    white-space: nowrap !important;
    font-size: 13px;
    color: #334155;
    gap: 6px;
    height: 100%;
}

/* Triệt tiêu 100% tình trạng rớt dòng của text / label / span trong item */
.ms-toolbar-item,
.ms-toolbar-item *,
.ms-toolbar-item > span,
.ms-toolbar-item > label {
    white-space: nowrap !important;
    flex-shrink: 0 !important;
}

.ms-toolbar-item.align-right {
    margin-left: auto;
}

.ms-toolbar-item.align-center {
    margin-left: auto;
    margin-right: auto;
}

.ms-toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 10px;
    height: 28px;
    font-size: 13px;
    font-weight: 500;
    color: #334155;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    line-height: 1;
    transition: all 0.15s ease;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
}

.ms-toolbar-btn:hover:not(:disabled) {
    background: #f1f5f9;
    color: #00676b;
    border-color: #e2e8f0;
}

.ms-toolbar-btn:active:not(:disabled) {
    background: #e2e8f0;
}

.ms-toolbar-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ms-toolbar-separator {
    width: 1px;
    height: 20px;
    background: #cbd5e1;
    margin: 0 4px;
    display: inline-block;
    align-self: center;
    flex-shrink: 0 !important;
}

/* Nút Overflow Popup (...) */
.ms-toolbar-overflow-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    margin-left: auto;
    flex-shrink: 0;
    z-index: 5;
    padding-left: 4px;
}

.ms-toolbar-overflow-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    color: #475569;
    cursor: pointer;
    font-size: 16px;
    padding: 0;
    transition: all 0.15s ease;
}

.ms-toolbar-overflow-btn:hover {
    background: #e2e8f0;
    color: #00676b;
    border-color: #00676b;
}

.ms-toolbar-popup-backdrop {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 99998 !important;
    background: rgba(0, 0, 0, 0.08) !important;
    cursor: default;
}

.ms-toolbar-popup-menu {
    position: fixed !important;
    background: #ffffff !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 8px !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.18) !important;
    padding: 8px 10px !important;
    z-index: 99999 !important;
    min-width: 240px;
    max-width: 360px;
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    overflow-y: auto !important;
    max-height: 70vh !important;
    box-sizing: border-box !important;
}

.ms-toolbar-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2px 4px 6px 4px;
    border-bottom: 1px solid #e2e8f0;
}

.ms-toolbar-popup-title {
    font-size: 13px;
    font-weight: 600;
    color: #334155;
}

.ms-toolbar-popup-close-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    color: #64748b;
    padding: 2px 4px;
    font-size: 14px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.ms-toolbar-popup-close-btn:hover {
    background: #f1f5f9;
    color: #ef4444;
}

.ms-toolbar-popup-items {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    width: 100% !important;
}

.ms-toolbar-popup-items .ms-toolbar-item {
    width: 100% !important;
    justify-content: flex-start !important;
    height: auto !important;
    display: flex !important;
    align-items: center !important;
}

.ms-toolbar-popup-items .ms-toolbar-item .ms-dropdownlist-wrapper,
.ms-toolbar-popup-items .ms-toolbar-item .ms-textbox-wrapper,
.ms-toolbar-popup-items .ms-toolbar-item .ms-datepicker-wrapper,
.ms-toolbar-popup-items .ms-toolbar-item .ms-combobox-wrapper {
    width: 100% !important;
    max-width: 100% !important;
}

.ms-toolbar-popup-items .ms-toolbar-btn,
.ms-toolbar-popup-items .ms-toolbar-item .ms-btn,
.ms-toolbar-popup-items .ms-toolbar-item .e-btn,
.ms-toolbar-popup-items .ms-toolbar-item button {
    width: 100% !important;
    justify-content: flex-start !important;
    text-align: left !important;
}

.ms-toolbar-popup-items .ms-toolbar-separator {
    width: 100% !important;
    height: 1px !important;
    background: #e2e8f0 !important;
    margin: 4px 0 !important;
}

/* --------------------------------------------------------------------------
   3. MsDropDownButton (Nút menu thả xuống)
   -------------------------------------------------------------------------- */
.ms-dropdown-button-wrapper {
    position: relative;
    display: inline-block;
}

.ms-dropdown-button-menu {
    position: fixed !important;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    z-index: 99999 !important;
    min-width: 160px;
    padding: 4px 0;
    margin: 0;
    list-style: none;
    box-sizing: border-box;
    user-select: none;
}

.ms-dropdown-button-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    font-size: 13px;
    color: #1e293b;
    cursor: pointer;
    transition: background-color 0.12s ease, color 0.12s ease;
    white-space: nowrap;
}

.ms-dropdown-button-item i {
    font-size: 16px;
    color: #64748b;
}

.ms-dropdown-button-item:hover {
    background-color: #f0fdfa;
    color: #00676b;
}

.ms-dropdown-button-item:hover i {
    color: #00676b;
}

.ms-dropdown-button-item.separator {
    height: 1px;
    background-color: #f1f5f9;
    margin: 4px 0;
    padding: 0;
    pointer-events: none;
}

.ms-dropdown-button-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* --------------------------------------------------------------------------
   4. MsSplitter (Chia khung màn hình kéo thả)
   -------------------------------------------------------------------------- */
.ms-splitter {
    display: flex;
    position: relative;
    overflow: hidden;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
}

.ms-splitter.horizontal {
    flex-direction: row;
}

.ms-splitter.vertical {
    flex-direction: column;
}

.ms-splitter-pane {
    position: relative;
    overflow: auto;
    box-sizing: border-box;
    scrollbar-width: thin;
}

.ms-splitter.horizontal > .ms-splitter-pane {
    height: 100%;
}

.ms-splitter.vertical > .ms-splitter-pane {
    width: 100%;
}

.ms-splitter-bar {
    flex-shrink: 0;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    transition: background-color 0.15s ease, border-color 0.15s ease;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    position: relative;
    box-sizing: border-box;
}

.ms-splitter-bar.horizontal {
    cursor: col-resize;
    width: 6px;
    height: 100%;
}

.ms-splitter-bar.vertical {
    cursor: row-resize;
    height: 7px;
    width: 100%;
}

.ms-splitter-bar:hover,
.ms-splitter-bar.dragging {
    background: #00676b !important;
    border-color: #004d50 !important;
}

.ms-splitter-handle {
    background: #94a3b8;
    border-radius: 2px;
    transition: background-color 0.15s ease;
}

.ms-splitter-bar.horizontal .ms-splitter-handle {
    width: 2px;
    height: 28px;
}

.ms-splitter-bar.vertical .ms-splitter-handle {
    height: 2px;
    width: 32px;
}

.ms-splitter-bar:hover .ms-splitter-handle,
.ms-splitter-bar.dragging .ms-splitter-handle {
    background: #ffffff !important;
}

/* --------------------------------------------------------------------------
   5. MsTab (Điều hướng Tab)
   -------------------------------------------------------------------------- */
.ms-tab {
    display: flex;
    flex-direction: column;
    width: 100%;
    box-sizing: border-box;
}

/* Default / Segmented Pill Header Style */
.ms-tab-header,
.ms-tab-segmented .ms-tab-header {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    margin-bottom: 0px;
    position: relative;
    overflow-x: auto;
    scrollbar-width: none;
    max-width: 100%;
}

.ms-tab-header::-webkit-scrollbar {
    display: none;
}

.ms-tab-item {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    user-select: none;
    border: 1px solid transparent;
}

.ms-tab-item i,
.ms-tab-item .ms-tab-icon {
    font-size: 15px;
    display: inline-flex;
    align-items: center;
    color: #64748b;
    transition: color 0.15s ease;
}

.ms-tab-item:hover:not(.disabled) {
    color: #0f172a;
    background: rgba(255, 255, 255, 0.65);
}

.ms-tab-item:hover:not(.disabled) i,
.ms-tab-item:hover:not(.disabled) .ms-tab-icon {
    color: #00676b;
}

.ms-tab-item.active {
    color: #00676b;
    background: #ffffff;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
    border-color: rgba(226, 232, 240, 0.9);
}

.ms-tab-item.active i,
.ms-tab-item.active .ms-tab-icon {
    color: #00676b;
}

.ms-tab-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ms-tab-badge {
    background: #e2e8f0;
    color: #475569;
    font-size: 11px;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: 10px;
    line-height: 1.2;
    transition: all 0.15s ease;
    margin-left: 2px;
}

.ms-tab-item.active .ms-tab-badge {
    background: #00676b;
    color: #ffffff;
}

/* Line Header Style (Underline classic) */
.ms-tab-line .ms-tab-header {
    display: flex;
    width: 100%;
    background: transparent;
    padding: 0;
    border: none;
    border-radius: 0;
    border-bottom: 2px solid #e2e8f0;
    gap: 8px;
    margin-bottom: 14px;
}

.ms-tab-line .ms-tab-item {
    border-radius: 6px 6px 0 0;
    border: none;
    border-bottom: 2.5px solid transparent;
    margin-bottom: -2px;
    padding: 8px 16px;
    background: transparent;
}

.ms-tab-line .ms-tab-item:hover:not(.disabled) {
    color: #00676b;
    background: #f8fafc;
}

.ms-tab-line .ms-tab-item.active {
    color: #00676b;
    background: #f0fdfa;
    border-bottom: 2.5px solid #00676b;
    box-shadow: none;
}

/* Card Header Style (Folder Card) */
.ms-tab-card .ms-tab-header {
    display: flex;
    width: 100%;
    background: #f8fafc;
    padding: 6px 6px 0 6px;
    border: 1px solid #e2e8f0;
    border-radius: 8px 8px 0 0;
    gap: 4px;
    margin-bottom: 0;
}

.ms-tab-card .ms-tab-item {
    border-radius: 6px 6px 0 0;
    border: 1px solid transparent;
    border-bottom: none;
    padding: 8px 16px;
    background: transparent;
}

.ms-tab-card .ms-tab-item.active {
    background: #ffffff;
    border-color: #e2e8f0;
    color: #00676b;
    font-weight: 600;
    box-shadow: none;
    margin-bottom: -1px;
}

.ms-tab-card .ms-tab-content {
    border: 1px solid #e2e8f0;
    border-top: none;
    border-radius: 0 0 8px 8px;
    padding: 12px;
}

.ms-tab-content {
    flex: 1;
    box-sizing: border-box;
}

/* --------------------------------------------------------------------------
   6. MsTooltip (Gợi ý và Popover hành động)
   -------------------------------------------------------------------------- */
.ms-tooltip-container {
    position: relative;
    display: inline-flex;
    vertical-align: middle;
}

.ms-tooltip-trigger {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.ms-tooltip-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9998;
    background: transparent;
}

.ms-tooltip-popup {
    position: absolute;
    z-index: 9999;
    background: #ffffff;
    color: #1e293b;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    padding: 8px 12px;
    font-size: 13px;
    white-space: nowrap;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ms-tooltip-text {
    font-size: 12px;
    color: #1e293b;
    line-height: 1.4;
}

.ms-tooltip-top {
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 8px;
}

.ms-tooltip-bottom {
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 8px;
}

.ms-tooltip-left {
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-right: 8px;
}

.ms-tooltip-right {
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 8px;
}

