/* =====================================================================
   MASTER SUITE — ENTERPRISE COMPONENT LIBRARY
   Sprint UI-002
   Compatible extension of frozen UI-001 Foundation.
   ===================================================================== */

.ms-hidden {
    display: none !important;
}

/* ---------------------------------------------------------------------
   TOAST / NOTIFICATION
   --------------------------------------------------------------------- */

.ms-toast-region {
    position: fixed;
    top: 58px;
    right: 18px;
    z-index: 120;

    width: min(340px, calc(100vw - 28px));

    display: flex;
    flex-direction: column;
    gap: 8px;

    pointer-events: none;
}

.ms-toast {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr) 24px;
    gap: 9px;
    align-items: start;

    padding: 11px;

    border: 1px solid var(--line);
    border-left: 3px solid var(--ms-accent);
    border-radius: var(--ms-radius-md);

    background: var(--surface);
    color: var(--text);

    box-shadow: 0 10px 35px rgba(0, 18, 42, .18);

    opacity: 0;
    pointer-events: auto;
    transform: translateX(12px);

    transition:
        opacity .2s ease,
        transform .2s ease;
}

.ms-toast.is-visible {
    opacity: 1;
    transform: translateX(0);
}

.ms-toast__icon {
    width: 26px;
    height: 26px;

    display: grid;
    place-items: center;

    border-radius: 50%;

    background: var(--ms-accent-soft);
    color: var(--ms-accent-hover);
    font-weight: 800;
}

.ms-toast__content strong,
.ms-toast__content small {
    display: block;
}

.ms-toast__content strong {
    margin-bottom: 3px;
    font-size: 10px;
}

.ms-toast__content small {
    color: var(--muted);
    font-size: 8px;
    line-height: 1.45;
}

.ms-toast__close {
    width: 22px;
    height: 22px;

    border: 0;
    border-radius: 4px;

    background: transparent;
    color: var(--muted);
}

.ms-toast[data-type="success"] {
    border-left-color: var(--green);
}

.ms-toast[data-type="danger"] {
    border-left-color: var(--red);
}

.ms-toast[data-type="info"] {
    border-left-color: var(--blue);
}

/* ---------------------------------------------------------------------
   MODAL
   --------------------------------------------------------------------- */

.ms-modal-layer {
    position: fixed;
    inset: 0;
    z-index: 130;

    display: grid;
    place-items: center;

    padding: 18px;

    background: rgba(2, 15, 30, .60);

    opacity: 0;
    visibility: hidden;

    transition:
        opacity .18s ease,
        visibility .18s ease;
}

.ms-modal-layer.is-open {
    opacity: 1;
    visibility: visible;
}

.ms-modal {
    width: min(620px, 100%);
    max-height: calc(100vh - 36px);

    overflow: auto;

    border: 1px solid var(--line);
    border-radius: 10px;

    background: var(--surface);
    color: var(--text);

    box-shadow: 0 22px 70px rgba(0, 10, 28, .30);

    transform: translateY(10px) scale(.985);

    transition: transform .18s ease;
}

.ms-modal-layer.is-open .ms-modal {
    transform: translateY(0) scale(1);
}

.ms-modal__header {
    min-height: 51px;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;

    padding: 11px 14px;

    border-bottom: 1px solid var(--line);
}

.ms-modal__title strong,
.ms-modal__title small {
    display: block;
}

.ms-modal__title strong {
    font-size: 12px;
}

.ms-modal__title small {
    margin-top: 3px;
    color: var(--muted);
    font-size: 8px;
}

.ms-modal__close {
    width: 30px;
    height: 30px;

    border: 0;
    border-radius: 5px;

    background: transparent;
    color: var(--text);

    font-size: 19px;
}

.ms-modal__body {
    padding: 15px;
}

.ms-modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;

    padding: 11px 14px;

    border-top: 1px solid var(--line);
    background: var(--surface-soft);
}

.ms-button {
    min-height: 32px;
    padding: 0 12px;

    border: 1px solid var(--line);
    border-radius: 6px;

    background: var(--surface);
    color: var(--text);
}

.ms-button:hover {
    background: var(--surface-hover);
}

.ms-button--primary {
    border-color: var(--ms-accent);
    background: var(--ms-accent);
    color: var(--ms-accent-contrast);
    font-weight: 700;
}

/* ---------------------------------------------------------------------
   COMMAND CENTER
   --------------------------------------------------------------------- */

.ms-command-layer {
    position: fixed;
    inset: 0;
    z-index: 150;

    display: flex;
    justify-content: center;
    align-items: flex-start;

    padding: min(12vh, 92px) 18px 18px;

    background: rgba(2, 13, 28, .67);
    backdrop-filter: blur(3px);

    opacity: 0;
    visibility: hidden;

    transition:
        opacity .16s ease,
        visibility .16s ease;
}

.ms-command-layer.is-open {
    opacity: 1;
    visibility: visible;
}

.ms-command-center {
    width: min(720px, 100%);
    max-height: min(680px, calc(100vh - 120px));

    display: flex;
    flex-direction: column;
    overflow: hidden;

    border: 1px solid var(--line);
    border-radius: 11px;

    background: var(--surface);
    color: var(--text);

    box-shadow: 0 30px 90px rgba(0, 10, 28, .38);

    transform: translateY(-8px) scale(.985);

    transition: transform .16s ease;
}

.ms-command-layer.is-open .ms-command-center {
    transform: translateY(0) scale(1);
}

.ms-command-search {
    min-height: 62px;

    display: grid;
    grid-template-columns: 30px minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;

    padding: 0 15px;

    border-bottom: 1px solid var(--line);
}

.ms-command-search__icon {
    display: grid;
    place-items: center;

    color: var(--ms-accent);
    font-size: 22px;
}

.ms-command-search input {
    min-width: 0;
    height: 44px;

    border: 0;
    outline: 0;

    background: transparent;
    color: var(--text);

    font-size: 15px;
}

.ms-command-search input::placeholder {
    color: var(--muted);
}

.ms-command-search kbd,
.ms-command-shortcut {
    padding: 4px 7px;

    border: 1px solid var(--line);
    border-radius: 5px;

    background: var(--surface-soft);
    color: var(--muted);

    font-size: 8px;
}

.ms-command-body {
    min-height: 210px;
    overflow: auto;
    padding: 9px;
}

.ms-command-group {
    margin-bottom: 11px;
}

.ms-command-group__title {
    padding: 5px 9px;

    color: var(--muted);

    font-size: 8px;
    font-weight: 800;
    letter-spacing: .8px;
}

.ms-command-item {
    width: 100%;
    min-height: 47px;

    display: grid;
    grid-template-columns: 32px minmax(0, 1fr) auto;
    align-items: center;
    gap: 9px;

    padding: 7px 9px;

    border: 1px solid transparent;
    border-radius: 7px;

    background: transparent;
    color: var(--text);

    text-align: left;
}

.ms-command-item:hover,
.ms-command-item.is-active {
    border-color: rgba(var(--ms-accent-rgb), .42);
    background: var(--ms-accent-soft);
}

.ms-command-item__icon {
    width: 30px;
    height: 30px;

    display: grid;
    place-items: center;

    border-radius: 6px;

    background: var(--surface-soft);
    color: var(--ms-accent-hover);

    font-size: 14px;
}

.ms-command-item__content strong,
.ms-command-item__content small {
    display: block;
}

.ms-command-item__content strong {
    font-size: 10px;
}

.ms-command-item__content small {
    margin-top: 2px;
    color: var(--muted);
    font-size: 8px;
}

.ms-command-empty {
    padding: 45px 15px;
    text-align: center;
    color: var(--muted);
}

.ms-command-empty strong,
.ms-command-empty small {
    display: block;
}

.ms-command-empty strong {
    color: var(--text);
    font-size: 12px;
}

.ms-command-empty small {
    margin-top: 5px;
}

.ms-command-footer {
    min-height: 38px;

    display: flex;
    align-items: center;
    gap: 13px;

    padding: 0 13px;

    border-top: 1px solid var(--line);
    background: var(--surface-soft);

    color: var(--muted);
    font-size: 8px;
}

.ms-command-footer span {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* ---------------------------------------------------------------------
   WIDGET TOOLBAR
   --------------------------------------------------------------------- */

.ms-widget-tools {
    display: flex;
    align-items: center;
    gap: 2px;
}

.ms-widget-tool {
    width: 25px;
    height: 25px;

    display: grid;
    place-items: center;

    border: 0;
    border-radius: 5px;

    background: transparent;
    color: var(--muted);
}

.ms-widget-tool:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.ms-widget-menu {
    position: fixed;
    z-index: 110;

    min-width: 178px;

    padding: 5px;

    border: 1px solid var(--line);
    border-radius: 7px;

    background: var(--surface);
    color: var(--text);

    box-shadow: 0 12px 35px rgba(0, 15, 35, .20);
}

.ms-widget-menu button {
    width: 100%;
    min-height: 31px;

    display: grid;
    grid-template-columns: 21px minmax(0, 1fr);
    align-items: center;
    gap: 6px;

    padding: 0 8px;

    border: 0;
    border-radius: 5px;

    background: transparent;
    color: var(--text);

    text-align: left;
}

.ms-widget-menu button:hover {
    background: var(--surface-hover);
}

/* ---------------------------------------------------------------------
   LOADING / SKELETON
   --------------------------------------------------------------------- */

.ms-widget-loading {
    position: absolute;
    inset: 34px 0 0;
    z-index: 6;

    display: grid;
    place-items: center;

    background: rgba(255, 255, 255, .74);
    backdrop-filter: blur(2px);
}

html[data-theme="dark"] .ms-widget-loading {
    background: rgba(6, 20, 38, .76);
}

.ms-spinner {
    width: 25px;
    height: 25px;

    border: 3px solid var(--line);
    border-top-color: var(--ms-accent);
    border-radius: 50%;

    animation: ms-spin .72s linear infinite;
}

@keyframes ms-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ---------------------------------------------------------------------
   GENERIC ENTITY COMPONENTS
   --------------------------------------------------------------------- */

.ms-entity-list {
    display: grid;
    gap: 8px;
}

.ms-entity-card {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;

    padding: 10px;

    border: 1px solid var(--line);
    border-radius: 7px;

    background: var(--surface);
}

.ms-entity-card:hover {
    border-color: rgba(var(--ms-accent-rgb), .5);
    background: var(--surface-hover);
}

.ms-entity-card__avatar {
    width: 36px;
    height: 36px;

    display: grid;
    place-items: center;

    border-radius: 8px;

    background: var(--ms-accent-soft);
    color: var(--ms-accent-hover);

    font-weight: 800;
}

.ms-entity-card__content strong,
.ms-entity-card__content small {
    display: block;
}

.ms-entity-card__content small {
    margin-top: 3px;
    color: var(--muted);
    font-size: 8px;
}

.ms-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;

    padding: 3px 7px;

    border-radius: 12px;

    background: var(--ms-accent-soft);
    color: var(--ms-accent-hover);

    font-size: 7px;
    font-style: normal;
    font-weight: 700;
}

.ms-status-badge--success {
    background: #dcfae6;
    color: #067647;
}

.ms-status-badge--danger {
    background: #fee4e2;
    color: #b42318;
}

html[data-theme="dark"] .ms-status-badge--success {
    background: rgba(21, 148, 90, .20);
    color: #5dd69a;
}

html[data-theme="dark"] .ms-status-badge--danger {
    background: rgba(220, 52, 46, .20);
    color: #ff817c;
}

@media (max-width: 620px) {
    .ms-command-layer {
        padding: 12px;
        align-items: center;
    }

    .ms-command-center {
        max-height: calc(100vh - 24px);
    }

    .ms-command-footer {
        flex-wrap: wrap;
        padding-top: 7px;
        padding-bottom: 7px;
    }

    .ms-toast-region {
        top: 10px;
        right: 10px;
    }
}
