/*
 * MEBSaaS Modal System
 * Shared modal standard for Expense, Leave, Document and Management module surfaces.
 */

:root {
    --meb-modal-radius: 1.25rem;
    --meb-modal-border: rgba(15, 23, 42, .08);
    --meb-modal-soft-bg: rgba(13, 110, 253, .035);
    --meb-modal-muted-bg: rgba(15, 23, 42, .025);
    --meb-modal-header-bg: linear-gradient(135deg, rgba(13, 110, 253, .08), rgba(13, 110, 253, .015));
    --meb-modal-shadow: 0 1.5rem 4rem rgba(15, 23, 42, .18);
}

[data-bs-theme="dark"] {
    --meb-modal-border: rgba(255, 255, 255, .12);
    --meb-modal-soft-bg: rgba(13, 110, 253, .16);
    --meb-modal-muted-bg: rgba(255, 255, 255, .04);
    --meb-modal-header-bg: linear-gradient(135deg, rgba(13, 110, 253, .20), rgba(255, 255, 255, .035));
    --meb-modal-shadow: 0 1.5rem 4rem rgba(0, 0, 0, .36);
}

.meb-modal-host .modal-backdrop,
.modal-backdrop {
    --bs-backdrop-opacity: .55;
}

.meb-modal-dialog {
    --bs-modal-margin: 1rem;
}

.meb-modal-dialog--confirm {
    max-width: 460px;
}

.meb-modal-dialog--form {
    max-width: 760px;
}

.meb-modal-dialog--detail {
    max-width: 1040px;
}

.meb-modal-dialog--workspace {
    width: calc(100vw - 2rem);
    max-width: 1320px;
}

.meb-modal {
    overflow: hidden;
    border-radius: var(--meb-modal-radius) !important;
    border: 1px solid var(--meb-modal-border) !important;
    box-shadow: var(--meb-modal-shadow) !important;
}

.meb-modal__header {
    position: relative;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.15rem 1.25rem 1rem;
    border-bottom: 1px solid var(--meb-modal-border) !important;
    background: var(--meb-modal-header-bg);
}

.meb-modal__title-group {
    min-width: 0;
}

.meb-modal__eyebrow {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    margin-bottom: .35rem;
    color: var(--bs-primary);
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.meb-modal__title {
    margin: 0;
    font-weight: 700;
    line-height: 1.25;
}

.meb-modal__subtitle {
    margin-top: .3rem;
    color: var(--bs-secondary-color);
    font-size: .875rem;
    line-height: 1.4;
}

.meb-modal__actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: .5rem;
    flex: 0 0 auto;
    flex-wrap: wrap;
}

.meb-modal__close {
    width: 2.25rem;
    height: 2.25rem;
    padding: .65rem;
    border-radius: 999px;
    background-color: var(--bs-body-bg);
    box-shadow: 0 .25rem 1rem rgba(15, 23, 42, .10);
    opacity: .86;
}

.meb-modal__close:hover,
.meb-modal__close:focus {
    opacity: 1;
}

.meb-modal__body {
    padding: 1.25rem;
    background: var(--bs-body-bg);
}

.meb-modal__body--workspace {
    background: linear-gradient(180deg, var(--meb-modal-muted-bg), transparent 220px), var(--bs-body-bg);
}

.meb-modal__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--meb-modal-border) !important;
    background: rgba(var(--bs-body-bg-rgb), .95);
}

.meb-modal__footer-status {
    min-width: 0;
    color: var(--bs-secondary-color);
    font-size: .85rem;
}

.meb-modal__footer-actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: .5rem;
    flex: 0 0 auto;
    flex-wrap: wrap;
}

.meb-modal__panel {
    min-width: 0;
    border: 1px solid var(--meb-modal-border);
    border-radius: 1.1rem;
    background: var(--bs-body-bg);
    box-shadow: 0 .35rem 1.5rem rgba(15, 23, 42, .055);
}

.meb-modal__panel > .meb-modal__panel-body,
.meb-modal__panel.meb-modal__panel-body {
    padding: 1rem;
}

.meb-modal__panel--accent {
    background: var(--meb-modal-soft-bg);
    border-style: dashed;
}

.meb-modal__section-title {
    font-weight: 700;
    line-height: 1.3;
}

.meb-modal__section-subtitle {
    color: var(--bs-secondary-color);
    font-size: .85rem;
    line-height: 1.4;
}

.meb-modal .form-label {
    font-weight: 600;
}

.meb-modal .table-summary tbody th {
    color: var(--bs-secondary-color);
    font-size: .84rem;
    font-weight: 700;
    white-space: nowrap;
}

.meb-modal .table-summary tbody td {
    font-weight: 500;
}

.meb-modal .table-responsive {
    border: 1px solid var(--meb-modal-border);
    border-radius: 1rem;
}

.meb-modal .table-responsive > .table {
    margin-bottom: 0;
}

.meb-modal__callout {
    border: 1px solid var(--meb-modal-border);
    border-radius: 1rem;
    padding: .9rem 1rem;
    background: var(--meb-modal-muted-bg);
}

.meb-modal__callout--info {
    border-color: rgba(13, 110, 253, .22);
    background: rgba(13, 110, 253, .055);
}

.meb-modal__callout--warning {
    border-color: rgba(255, 193, 7, .32);
    background: rgba(255, 193, 7, .08);
}

.meb-modal__workspace-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(380px, .95fr);
    gap: 1rem;
    align-items: start;
}

.meb-modal__workspace-sticky {
    position: sticky;
    top: 0;
}

.meb-modal--confirm .meb-modal__body {
    padding-top: 1rem;
}

.meb-modal--confirm .meb-modal__footer {
    justify-content: flex-end;
}

.meb-modal--workspace .meb-modal__footer,
.meb-modal--detail .meb-modal__footer,
.meb-modal--form .meb-modal__footer {
    position: sticky;
    bottom: 0;
    z-index: 2;
}

@media (max-width: 991.98px) {
    .meb-modal-dialog--workspace,
    .meb-modal-dialog--detail,
    .meb-modal-dialog--form {
        width: auto;
        max-width: var(--bs-modal-width);
    }

    .meb-modal__workspace-grid {
        grid-template-columns: 1fr;
    }

    .meb-modal__workspace-sticky {
        position: static;
    }
}

@media (max-width: 575.98px) {
    .meb-modal-dialog {
        margin: .5rem;
    }

    .meb-modal__header,
    .meb-modal__body,
    .meb-modal__footer {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .meb-modal__header {
        align-items: flex-start;
    }

    .meb-modal__actions {
        gap: .35rem;
    }

    .meb-modal__footer {
        align-items: stretch;
        flex-direction: column;
    }

    .meb-modal__footer-actions {
        width: 100%;
    }

    .meb-modal__footer-actions > .btn {
        flex: 1 1 auto;
    }
}


/* Document Center / Employee Document modal refinements */
.meb-modal .dc-drop-zone,
.meb-modal .dc-online-edit-step {
    border-radius: 1rem;
}

.meb-modal .dc-preview-frame {
    width: 100%;
    min-height: min(68vh, 760px);
    border: 1px solid var(--meb-modal-border);
    border-radius: 1rem;
    background: var(--bs-body-bg);
}

.meb-modal--workspace .dc-preview-frame {
    min-height: min(72vh, 820px);
}

.meb-modal--workspace .dc-modal-embedded-panel {
    border-radius: 1rem;
}

.meb-modal__body--workspace.p-0 .dc-preview-frame,
.meb-modal__body--workspace.p-0 iframe,
.meb-modal__body--workspace.p-0 embed,
.meb-modal__body--workspace.p-0 object {
    border-radius: 0;
}

.meb-modal .dc-modal-help-button {
    flex: 0 0 auto;
}

.meb-modal .dc-modal-icon-button {
    flex: 0 0 auto;
}

@media (max-width: 575.98px) {
    .meb-modal .dc-modal-help-button span[data-context-help-label="true"] {
        display: none;
    }
}


/* Management / authorization modal refinements */
.meb-modal .perm-kpi-card,
.meb-modal .user-detail-section-card,
.meb-modal .position-detail-section-card {
    border-radius: 1rem;
}

.meb-modal--workspace .user-detail-sticky-nav {
    top: 0;
    z-index: 3;
}

.meb-modal .permission-module,
.meb-modal .template-permission-module {
    border-radius: 1rem;
}


/* Work / project / workflow modal refinements */
.meb-modal-host--work .meb-modal .comment-list,
.meb-modal-host--work .meb-modal .attachment-list,
.meb-modal-host--work .meb-modal .activity-list {
    max-height: min(48vh, 520px);
    overflow: auto;
    border-color: var(--meb-modal-border) !important;
}

.meb-modal-host--work .meb-modal .detail-tab-pane {
    min-height: 260px;
}

.meb-modal-host--work .meb-modal .attachment-dropzone {
    border: 1px dashed var(--meb-modal-border);
    border-radius: 1rem;
    padding: 1rem;
    background: var(--meb-modal-muted-bg);
}

.meb-modal-host--work .meb-modal .card.rounded-4 {
    border-color: var(--meb-modal-border);
    box-shadow: 0 .35rem 1.5rem rgba(15, 23, 42, .045);
}

.meb-modal-host--workflow-detail .meb-modal__body--workspace {
    max-height: min(78vh, 860px);
    overflow: auto;
}

.meb-modal-host--task .meb-modal__body,
.meb-modal-host--project .meb-modal__body {
    background: linear-gradient(180deg, var(--meb-modal-muted-bg), transparent 240px), var(--bs-body-bg);
}

@media (max-width: 575.98px) {
    .meb-modal-host--work .nav-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
    }
}


/* Dashboard / Chat / Calendar / shell drawer refinements */
.meb-drawer {
    border-left: 1px solid var(--meb-modal-border) !important;
    box-shadow: var(--meb-modal-shadow);
}

.meb-drawer__header {
    gap: .75rem;
    border-bottom: 1px solid var(--meb-modal-border) !important;
    background: var(--meb-modal-header-bg);
}

.meb-drawer__body {
    background: linear-gradient(180deg, var(--meb-modal-muted-bg), transparent 220px), var(--bs-body-bg);
}

.meb-drawer--theme-settings {
    max-width: min(100vw, 420px);
}

.meb-drawer--calendar-events {
    max-width: min(100vw, 460px);
}

.meb-drawer--assistant {
    border: 1px solid var(--meb-modal-border);
    border-radius: 1.25rem;
    box-shadow: var(--meb-modal-shadow);
}

.meb-modal--fullscreen-menu {
    border-radius: 0 !important;
}

.meb-modal-host--shell-menu .page-modules {
    background: linear-gradient(180deg, var(--meb-modal-muted-bg), transparent 260px), var(--bs-body-bg);
}

.meb-modal-host--dashboard-catalog .module-catalog-toolbar {
    border: 1px solid var(--meb-modal-border);
    border-radius: 1rem;
    padding: .85rem;
    background: var(--meb-modal-muted-bg);
}

.meb-modal-host--chat .chat-member-picker,
.meb-modal-host--chat .chat-forward-list,
.meb-modal-host--chat .chat-info-member-list,
.meb-modal-host--chat .chat-files-list,
.meb-modal-host--chat .chat-audio-list {
    max-height: min(52vh, 520px);
    overflow: auto;
}

.meb-modal-host--chat .chat-file-preview-modal-body {
    min-height: min(58vh, 620px);
    border-color: var(--meb-modal-border);
    background: var(--meb-modal-muted-bg);
}

.meb-calendar-event-actions {
    justify-content: flex-end;
}

.meb-modal--custom-confirm {
    border-radius: 1rem !important;
    border: 1px solid var(--meb-modal-border) !important;
    box-shadow: var(--meb-modal-shadow) !important;
}

@media (max-width: 575.98px) {
    .meb-drawer--theme-settings,
    .meb-drawer--calendar-events {
        max-width: 100vw;
    }

    .meb-calendar-event-actions {
        flex-direction: column;
    }
}


/* Final TenantWeb cleanup modal/drawer refinements */
.meb-drawer {
    border: 0 !important;
    box-shadow: var(--meb-modal-shadow);
}

.meb-drawer__header {
    border-bottom: 1px solid var(--meb-modal-border);
    background: var(--meb-modal-header-bg);
    padding: 1rem 1.25rem;
}

.meb-drawer__title {
    font-weight: 700;
    letter-spacing: -.01em;
}

.meb-drawer__close {
    border-radius: 999px;
    box-shadow: 0 .4rem 1rem rgba(15, 23, 42, .08);
}

.meb-drawer__body {
    background: linear-gradient(180deg, var(--meb-modal-muted-bg), transparent 260px), var(--bs-body-bg);
}

.meb-modal-host--approval-decision .meb-modal__body,
.meb-modal-host--ticket-detail .meb-modal__body,
.meb-modal-host--announcement-detail .meb-modal__body,
.meb-modal-host--position-catalog .meb-modal__body {
    max-height: min(72vh, 820px);
    overflow: auto;
}

.meb-modal-host--activity-detail .json-box,
.meb-modal-host--ticket-detail #commentList,
.meb-modal-host--announcement-detail #detailReadList {
    max-height: 360px;
    overflow: auto;
}

.meb-modal-host--org-unit-detail .modal-dialog.meb-modal-dialog--workspace {
    width: min(1320px, calc(100vw - 2rem));
    max-width: calc(100vw - 2rem);
    height: calc(100vh - 2rem);
    margin: 1rem auto;
}

.meb-modal-host--org-unit-detail .meb-modal--workspace {
    height: 100%;
}

.meb-modal-host--org-unit-detail .org-map-toolbar.meb-modal__header {
    border-radius: 0;
    flex-wrap: wrap;
}

.meb-modal-host--org-unit-detail .org-map-workspace.meb-modal__body--workspace {
    padding: 0;
    min-height: 0;
}

.meb-modal-host--org-unit-form .modal-footer,
.meb-modal-host--position-catalog .modal-footer {
    gap: .75rem;
}

@media (max-width: 767.98px) {
    .meb-drawer {
        width: min(100vw, 420px) !important;
    }

    .meb-modal-host--org-unit-detail .modal-dialog.meb-modal-dialog--workspace {
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        margin: 0;
    }

    .meb-modal-host--org-unit-detail .meb-modal--workspace {
        border-radius: 0 !important;
    }

    .meb-modal-host--org-unit-detail .org-map-toolbar-actions {
        width: 100%;
        justify-content: flex-start;
        overflow-x: auto;
        padding-bottom: .25rem;
    }
}
