/* Public read-only M-OS dashboard demo.
   The dashboard itself uses the same production styles and launcher component
   as /mos/user/dashboard.php. This file only contains iframe/device simulation
   and read-only interaction states. */
html,
body {
    width: 100%;
    height: 100%;
    min-height: 100%;
}

body.mos-demo-standalone {
    margin: 0;
    overflow: hidden;
}

.mos-demo-standalone .workspace-scroll {
    overscroll-behavior: contain;
}

.mos-demo-standalone .launcher-dashboard-workspace .workspace-scroll {
    align-content: start;
    justify-items: start;
}

/* Exact production launcher styling, but read-only in the public demo. */
.mos-demo-standalone .launcher-app-card {
    cursor: default;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

.mos-demo-standalone .launcher-app-card:focus-visible {
    outline: 3px solid rgba(var(--mws-primary-rgb), .28);
    outline-offset: 2px;
}

.mos-demo-standalone .launcher-app-card.is-hidden {
    display: none;
}

.demo-topbar-notifications {
    position: relative;
}

.demo-toast {
    position: fixed;
    left: 50%;
    bottom: max(18px, env(safe-area-inset-bottom));
    z-index: 1200;
    max-width: calc(100% - 30px);
    padding: 10px 14px;
    border: 1px solid rgba(var(--mws-primary-rgb), .24);
    border-radius: 999px;
    color: var(--mws-text);
    background: var(--mws-topbar-bg);
    box-shadow: var(--mws-shadow);
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 8px);
    transition: opacity .18s ease, transform .18s ease;
}

.demo-toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

@media (prefers-reduced-motion: reduce) {
    .demo-toast,
    .mos-demo-standalone .launcher-app-card {
        transition: none;
    }
}

/* ================================================================
   M-OS DEMO DEVICE MODES V1.3
   Strictly isolated Desktop / Tablet / Mobile values.

   IMPORTANT:
   - No viewport-width media query controls the M-OS shell or launcher.
   - Only data-demo-device selects the simulated device layout.
   - Every mode resets position/display/size values explicitly so switching
     devices cannot retain rules from the previous state.
   ================================================================ */

/* Shared containment only. Device geometry is defined below. */
.mos-demo-standalone .desktop {
    min-width: 0;
}

.mos-demo-standalone .topbar-slot {
    z-index: 40;
    pointer-events: none;
}

.mos-demo-standalone .top-bar.panel.topbar-profile {
    pointer-events: auto;
}

.mos-demo-standalone .workspace,
.mos-demo-standalone .workspace-scroll,
.mos-demo-standalone .launcher-dashboard-shell,
.mos-demo-standalone .launcher-dashboard-grid {
    min-width: 0;
    max-width: 100%;
}

/* ---------------------------------------------------------------
   DESKTOP — independent values
   --------------------------------------------------------------- */
html[data-demo-device="desktop"] .mos-demo-standalone .os-shell,
body[data-demo-device="desktop"].mos-demo-standalone .os-shell {
    width: calc(100% - 14px);
    max-width: none;
    height: 100dvh;
    min-height: 0;
    padding: 7px 0;
}

html[data-demo-device="desktop"] .mos-demo-standalone .desktop,
body[data-demo-device="desktop"].mos-demo-standalone .desktop {
    position: relative;
    display: block;
    width: 100%;
    height: calc(100dvh - 14px);
    min-height: 0;
}

html[data-demo-device="desktop"] .mos-demo-standalone .topbar-slot,
body[data-demo-device="desktop"].mos-demo-standalone .topbar-slot {
    position: absolute;
    top: 7px;
    right: 0;
    left: 0;
    display: flex;
    width: 100%;
    margin: 0;
    padding: 0;
    justify-content: flex-end;
}

html[data-demo-device="desktop"] .mos-demo-standalone .top-bar.panel.topbar-profile,
body[data-demo-device="desktop"].mos-demo-standalone .top-bar.panel.topbar-profile {
    --topbar-profile-size: 44px;
    width: auto;
    max-width: calc(100% - 8px);
    height: auto;
    min-height: 0;
    padding: 10px;
    gap: 10px;
    align-self: flex-start;
}

html[data-demo-device="desktop"] .mos-demo-standalone .workspace,
body[data-demo-device="desktop"].mos-demo-standalone .workspace {
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

html[data-demo-device="desktop"] .mos-demo-standalone .workspace-frame,
body[data-demo-device="desktop"].mos-demo-standalone .workspace-frame {
    inset: 18px;
}

html[data-demo-device="desktop"] .mos-demo-standalone .workspace-scroll,
body[data-demo-device="desktop"].mos-demo-standalone .workspace-scroll {
    width: 100%;
    height: 100%;
    min-height: 0;
    margin-top: 0;
    padding: 92px 34px 46px;
    overflow-x: hidden;
    overflow-y: auto;
}

html[data-demo-device="desktop"] .mos-demo-standalone .launcher-dashboard-grid,
body[data-demo-device="desktop"].mos-demo-standalone .launcher-dashboard-grid {
    grid-template-columns: repeat(6, minmax(116px, 136px));
    gap: 18px 20px;
    width: max-content;
    max-width: 100%;
}

html[data-demo-device="desktop"] .mos-demo-standalone .launcher-app-card,
body[data-demo-device="desktop"].mos-demo-standalone .launcher-app-card {
    width: 100%;
    min-height: 150px;
    padding: 10px 10px 8px;
}

html[data-demo-device="desktop"] .mos-demo-standalone .launcher-app-image-wrap,
body[data-demo-device="desktop"].mos-demo-standalone .launcher-app-image-wrap {
    width: min(100%, 98px);
}

html[data-demo-device="desktop"] .mos-demo-standalone .launcher-app-title,
body[data-demo-device="desktop"].mos-demo-standalone .launcher-app-title {
    font-size: .9rem;
    line-height: 1.25;
}

html[data-demo-device="desktop"] .demo-store-grid,
body[data-demo-device="desktop"].mos-demo-standalone .demo-store-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

html[data-demo-device="desktop"] .demo-app-hero,
body[data-demo-device="desktop"].mos-demo-standalone .demo-app-hero {
    align-items: flex-end;
    flex-direction: row;
}

html[data-demo-device="desktop"] .demo-store-card,
body[data-demo-device="desktop"].mos-demo-standalone .demo-store-card {
    min-height: 278px;
}

html[data-demo-device="desktop"] .demo-ticket-app .ticket-layout,
body[data-demo-device="desktop"].mos-demo-standalone .demo-ticket-app .ticket-layout {
    grid-template-columns: minmax(300px, .8fr) minmax(0, 1.2fr);
}

/* ---------------------------------------------------------------
   TABLET — independent values
   --------------------------------------------------------------- */
html[data-demo-device="tablet"] .mos-demo-standalone .os-shell,
body[data-demo-device="tablet"].mos-demo-standalone .os-shell {
    width: calc(100% - 12px);
    max-width: none;
    height: 100dvh;
    min-height: 0;
    padding: 6px 0;
}

html[data-demo-device="tablet"] .mos-demo-standalone .desktop,
body[data-demo-device="tablet"].mos-demo-standalone .desktop {
    position: relative;
    display: block;
    width: 100%;
    height: calc(100dvh - 12px);
    min-height: 0;
}

html[data-demo-device="tablet"] .mos-demo-standalone .topbar-slot,
body[data-demo-device="tablet"].mos-demo-standalone .topbar-slot {
    position: absolute;
    top: 6px;
    right: 0;
    left: 0;
    display: flex;
    width: 100%;
    margin: 0;
    padding: 0;
    justify-content: flex-end;
}

html[data-demo-device="tablet"] .mos-demo-standalone .top-bar.panel.topbar-profile,
body[data-demo-device="tablet"].mos-demo-standalone .top-bar.panel.topbar-profile {
    --topbar-profile-size: 42px;
    width: auto;
    max-width: calc(100% - 6px);
    height: auto;
    min-height: 0;
    padding: 8px;
    gap: 7px;
    align-self: flex-start;
}

html[data-demo-device="tablet"] .mos-demo-standalone .workspace,
body[data-demo-device="tablet"].mos-demo-standalone .workspace {
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

html[data-demo-device="tablet"] .mos-demo-standalone .workspace-frame,
body[data-demo-device="tablet"].mos-demo-standalone .workspace-frame {
    inset: 13px;
}

html[data-demo-device="tablet"] .mos-demo-standalone .workspace-scroll,
body[data-demo-device="tablet"].mos-demo-standalone .workspace-scroll {
    width: 100%;
    height: 100%;
    min-height: 0;
    margin-top: 0;
    padding: 84px 18px 30px;
    overflow-x: hidden;
    overflow-y: auto;
}

html[data-demo-device="tablet"] .mos-demo-standalone .launcher-dashboard-grid,
body[data-demo-device="tablet"].mos-demo-standalone .launcher-dashboard-grid {
    grid-template-columns: repeat(4, minmax(96px, 118px));
    gap: 14px 16px;
    width: 100%;
    max-width: 560px;
}

html[data-demo-device="tablet"] .mos-demo-standalone .launcher-app-card,
body[data-demo-device="tablet"].mos-demo-standalone .launcher-app-card {
    width: 100%;
    min-height: 138px;
    padding: 8px 6px 6px;
}

html[data-demo-device="tablet"] .mos-demo-standalone .launcher-app-image-wrap,
body[data-demo-device="tablet"].mos-demo-standalone .launcher-app-image-wrap {
    width: min(100%, 84px);
}

html[data-demo-device="tablet"] .mos-demo-standalone .launcher-app-title,
body[data-demo-device="tablet"].mos-demo-standalone .launcher-app-title {
    font-size: .84rem;
    line-height: 1.22;
}

html[data-demo-device="tablet"] .demo-store-grid,
body[data-demo-device="tablet"].mos-demo-standalone .demo-store-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

html[data-demo-device="tablet"] .demo-app-hero,
body[data-demo-device="tablet"].mos-demo-standalone .demo-app-hero {
    align-items: flex-start;
    flex-direction: column;
}

html[data-demo-device="tablet"] .demo-store-card,
body[data-demo-device="tablet"].mos-demo-standalone .demo-store-card {
    min-height: 0;
}

html[data-demo-device="tablet"] .demo-ticket-app .ticket-layout,
body[data-demo-device="tablet"].mos-demo-standalone .demo-ticket-app .ticket-layout {
    grid-template-columns: 1fr;
    min-height: 0;
}

/* ---------------------------------------------------------------
   MOBILE — independent values
   --------------------------------------------------------------- */
html[data-demo-device="mobile"] .mos-demo-standalone .os-shell,
body[data-demo-device="mobile"].mos-demo-standalone .os-shell {
    width: calc(100% - 8px);
    max-width: none;
    height: 100dvh;
    min-height: 0;
    padding: 4px 0;
}

html[data-demo-device="mobile"] .mos-demo-standalone .desktop,
body[data-demo-device="mobile"].mos-demo-standalone .desktop {
    position: relative;
    display: block;
    width: 100%;
    height: calc(100dvh - 8px);
    min-height: 0;
}

html[data-demo-device="mobile"] .mos-demo-standalone .topbar-slot,
body[data-demo-device="mobile"].mos-demo-standalone .topbar-slot {
    position: absolute;
    top: 4px;
    right: 0;
    left: 0;
    display: flex;
    width: 100%;
    margin: 0;
    padding: 0;
    justify-content: flex-end;
}

html[data-demo-device="mobile"] .mos-demo-standalone .top-bar.panel.topbar-profile,
body[data-demo-device="mobile"].mos-demo-standalone .top-bar.panel.topbar-profile {
    --topbar-profile-size: 40px;
    width: auto;
    max-width: calc(100% - 4px);
    height: auto;
    min-height: 0;
    padding: 5px;
    gap: 0;
    align-self: flex-start;
}

html[data-demo-device="mobile"] .mos-demo-standalone .topbar-profile-menu,
body[data-demo-device="mobile"].mos-demo-standalone .topbar-profile-menu {
    gap: 4px;
}

html[data-demo-device="mobile"] .mos-demo-standalone .topbar-search,
html[data-demo-device="mobile"] .mos-demo-standalone .topbar-search-toggle,
html[data-demo-device="mobile"] .mos-demo-standalone .topbar-button,
html[data-demo-device="mobile"] .mos-demo-standalone .theme-toggle,
body[data-demo-device="mobile"].mos-demo-standalone .topbar-search,
body[data-demo-device="mobile"].mos-demo-standalone .topbar-search-toggle,
body[data-demo-device="mobile"].mos-demo-standalone .topbar-button,
body[data-demo-device="mobile"].mos-demo-standalone .theme-toggle {
    width: 36px;
    min-width: 36px;
    height: 36px;
    min-height: 36px;
}

html[data-demo-device="mobile"] .mos-demo-standalone .topbar-search.is-open,
body[data-demo-device="mobile"].mos-demo-standalone .topbar-search.is-open {
    width: 82px;
    min-width: 36px;
}

html[data-demo-device="mobile"] .mos-demo-standalone .topbar-search.is-open .topbar-search-field,
body[data-demo-device="mobile"].mos-demo-standalone .topbar-search.is-open .topbar-search-field {
    max-width: 46px;
    padding-right: 6px;
    padding-left: 4px;
}

html[data-demo-device="mobile"] .mos-demo-standalone .workspace,
body[data-demo-device="mobile"].mos-demo-standalone .workspace {
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

html[data-demo-device="mobile"] .mos-demo-standalone .workspace-frame,
body[data-demo-device="mobile"].mos-demo-standalone .workspace-frame {
    inset: 9px;
}

html[data-demo-device="mobile"] .mos-demo-standalone .workspace-scroll,
body[data-demo-device="mobile"].mos-demo-standalone .workspace-scroll {
    width: 100%;
    height: 100%;
    min-height: 0;
    margin-top: 0;
    padding: 68px 12px 22px;
    overflow-x: hidden;
    overflow-y: auto;
}

html[data-demo-device="mobile"] .mos-demo-standalone .launcher-dashboard-grid,
body[data-demo-device="mobile"].mos-demo-standalone .launcher-dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 8px;
    width: 100%;
    max-width: none;
}

html[data-demo-device="mobile"] .mos-demo-standalone .launcher-app-card,
body[data-demo-device="mobile"].mos-demo-standalone .launcher-app-card {
    width: 100%;
    min-height: 122px;
    padding: 7px 4px 5px;
}

html[data-demo-device="mobile"] .mos-demo-standalone .launcher-app-image-wrap,
body[data-demo-device="mobile"].mos-demo-standalone .launcher-app-image-wrap {
    width: min(100%, 72px);
}

html[data-demo-device="mobile"] .mos-demo-standalone .launcher-app-title,
body[data-demo-device="mobile"].mos-demo-standalone .launcher-app-title {
    font-size: .76rem;
    line-height: 1.2;
}

html[data-demo-device="mobile"] .demo-app-view,
body[data-demo-device="mobile"].mos-demo-standalone .demo-app-view,
html[data-demo-device="tablet"] .demo-app-view,
body[data-demo-device="tablet"].mos-demo-standalone .demo-app-view {
    min-width: 0;
    max-width: 100%;
    overflow-x: hidden;
}

html[data-demo-device="mobile"] .demo-app-hero,
body[data-demo-device="mobile"].mos-demo-standalone .demo-app-hero,
html[data-demo-device="mobile"] .demo-store-summary,
body[data-demo-device="mobile"].mos-demo-standalone .demo-store-summary,
html[data-demo-device="mobile"] .demo-store-footer,
body[data-demo-device="mobile"].mos-demo-standalone .demo-store-footer {
    align-items: flex-start;
    flex-direction: column;
}

html[data-demo-device="mobile"] .demo-store-grid,
body[data-demo-device="mobile"].mos-demo-standalone .demo-store-grid {
    grid-template-columns: 1fr;
}

html[data-demo-device="mobile"] .demo-store-card,
body[data-demo-device="mobile"].mos-demo-standalone .demo-store-card {
    min-height: 0;
}

html[data-demo-device="mobile"] .demo-ticket-app .ticket-message,
body[data-demo-device="mobile"].mos-demo-standalone .demo-ticket-app .ticket-message {
    max-width: 88%;
}

html[data-demo-device="mobile"] .demo-ticket-app .ticket-conversation,
body[data-demo-device="mobile"].mos-demo-standalone .demo-ticket-app .ticket-conversation {
    min-height: 420px;
}

html[data-demo-device="mobile"] .demo-mode-chip,
body[data-demo-device="mobile"].mos-demo-standalone .demo-mode-chip {
    min-height: 28px;
    font-size: .6rem;
}

html[data-demo-device="mobile"] .demo-security-app .asset-state,
body[data-demo-device="mobile"].mos-demo-standalone .demo-security-app .asset-state {
    align-items: flex-start;
}

html[data-demo-device="mobile"] .demo-ticket-app .ticket-chat-header,
body[data-demo-device="mobile"].mos-demo-standalone .demo-ticket-app .ticket-chat-header {
    grid-template-columns: 38px minmax(0, 1fr);
}

html[data-demo-device="mobile"] .demo-ticket-app .ticket-chat-header > .ui-badge,
body[data-demo-device="mobile"].mos-demo-standalone .demo-ticket-app .ticket-chat-header > .ui-badge {
    grid-column: 2;
    width: max-content;
}

html[data-demo-device="mobile"] .demo-store-footer .ui-btn,
body[data-demo-device="mobile"].mos-demo-standalone .demo-store-footer .ui-btn {
    width: 100%;
}

html[data-demo-device="mobile"] .demo-ticket-app .ticket-layout,
body[data-demo-device="mobile"].mos-demo-standalone .demo-ticket-app .ticket-layout {
    grid-template-columns: 1fr;
    min-height: 0;
}

@media (max-height: 620px) and (orientation: landscape) {
    html[data-demo-device="mobile"] .mos-demo-standalone .workspace-scroll,
    body[data-demo-device="mobile"].mos-demo-standalone .workspace-scroll {
        padding-top: 58px;
        padding-bottom: 16px;
    }
}
