/* Creativity application loader and install control */
.ca-loader {
    position: fixed;
    inset: 0;
    z-index: 2147483000;
    display: grid;
    place-items: center;
    padding: 20px;
    background: color-mix(in srgb, var(--theme-bg, #07101f) 78%, transparent);
    backdrop-filter: blur(11px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .18s ease, visibility .18s ease;
}

.ca-loader.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.ca-loader-card {
    width: min(350px, calc(100vw - 32px));
    min-height: 116px;
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    align-items: center;
    gap: 15px;
    padding: 18px;
    border-radius: 24px;
    border: 1px solid color-mix(in srgb, var(--theme-accent, #1683ff) 34%, var(--theme-border, rgba(148,163,184,.18)));
    background: var(--theme-surface, #ffffff);
    color: var(--theme-text, #0f172a);
    box-shadow: 0 30px 90px rgba(0,0,0,.34);
}

.ca-loader-logo-wrap {
    position: relative;
    width: 68px;
    height: 68px;
    display: grid;
    place-items: center;
}

.ca-loader-logo {
    width: 54px;
    height: 54px;
    object-fit: contain;
    border-radius: 16px;
    position: relative;
    z-index: 2;
}

.ca-loader-ring {
    position: absolute;
    inset: 1px;
    border-radius: 50%;
    border: 3px solid color-mix(in srgb, var(--theme-accent, #1683ff) 18%, transparent);
    border-top-color: var(--theme-accent, #1683ff);
    animation: creativitySpin .8s linear infinite;
}

.ca-loader-copy {
    min-width: 0;
}

.ca-loader-copy strong,
.ca-loader-copy small {
    display: block;
}

.ca-loader-copy strong {
    font-size: 15px;
    line-height: 1.25;
    font-weight: 950;
}

.ca-loader-copy small {
    margin-top: 5px;
    color: var(--theme-muted, #64748b);
    font-size: 12px;
    font-weight: 780;
}

.ca-install-button {
    position: fixed;
    right: 18px;
    bottom: 144px;
    z-index: 999996;
    min-height: 46px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 14px;
    border: 1px solid color-mix(in srgb, var(--theme-accent, #1683ff) 38%, var(--theme-border, rgba(148,163,184,.18)));
    border-radius: 16px;
    color: #fff;
    background: linear-gradient(135deg, var(--theme-accent, #1683ff), var(--theme-accent-2, #005ee8));
    box-shadow: 0 16px 38px color-mix(in srgb, var(--theme-accent, #1683ff) 28%, transparent);
    cursor: pointer;
    font-size: 12px;
    font-weight: 950;
}

.ca-install-button svg {
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.ca-install-toast {
    position: fixed;
    right: 18px;
    bottom: 202px;
    z-index: 2147482000;
    width: min(360px, calc(100vw - 28px));
    display: none;
    padding: 17px;
    border-radius: 20px;
    border: 1px solid color-mix(in srgb, var(--theme-accent, #1683ff) 28%, var(--theme-border, rgba(148,163,184,.18)));
    background: var(--theme-surface, #fff);
    color: var(--theme-text, #0f172a);
    box-shadow: 0 24px 70px rgba(0,0,0,.30);
}

.ca-install-toast.is-visible {
    display: block;
}

.ca-install-toast strong {
    display: block;
    font-size: 15px;
    font-weight: 950;
}

.ca-install-toast p {
    margin: 7px 0 13px;
    color: var(--theme-muted, #64748b);
    font-size: 13px;
    line-height: 1.45;
    font-weight: 760;
}

.ca-install-toast button {
    min-height: 36px;
    padding: 0 13px;
    border: 0;
    border-radius: 12px;
    color: #fff;
    background: linear-gradient(135deg, var(--theme-accent, #1683ff), var(--theme-accent-2, #005ee8));
    cursor: pointer;
    font-weight: 900;
}

.order-theme-floating-btn,
.theme-floating-btn,
.co-theme-floating-btn {
    z-index: 999997 !important;
}

@keyframes creativitySpin {
    to { transform: rotate(360deg); }
}

@media (max-width: 700px) {
    .ca-loader-card {
        grid-template-columns: 60px minmax(0, 1fr);
    }

    .ca-loader-logo-wrap {
        width: 58px;
        height: 58px;
    }

    .ca-loader-logo {
        width: 46px;
        height: 46px;
    }

    .ca-install-button {
        right: 12px;
        bottom: 138px;
        min-width: 48px;
        width: 48px;
        padding: 0;
        justify-content: center;
    }

    .ca-install-button span {
        display: none;
    }

    .ca-install-toast {
        right: 12px;
        bottom: 194px;
    }
}


/* Install App belongs inside the Theme / Options panel. */
.ca-install-button {
    display: none !important;
}

.ca-options-install-group {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--theme-border, rgba(148,163,184,.18));
}

.ca-options-install-copy strong,
.ca-options-install-copy span {
    display: block;
}

.ca-options-install-copy strong {
    color: var(--theme-text, #0f172a);
    font-size: 13px;
    font-weight: 950;
}

.ca-options-install-copy span {
    margin-top: 3px;
    color: var(--theme-muted, #64748b);
    font-size: 11.5px;
    line-height: 1.35;
    font-weight: 760;
}

.ca-options-install-button {
    width: 100%;
    min-height: 42px;
    margin-top: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid transparent;
    border-radius: 14px;
    color: #ffffff;
    background: linear-gradient(
        135deg,
        var(--theme-accent, #1683ff),
        var(--theme-accent-2, #005ee8)
    );
    box-shadow: 0 12px 28px color-mix(
        in srgb,
        var(--theme-accent, #1683ff) 24%,
        transparent
    );
    cursor: pointer;
    font-family: inherit;
    font-size: 12px;
    font-weight: 950;
}

.ca-options-install-button svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Keep the Theme / Options button visible above page, drawer and modal content. */
#OrderThemeFloatingBtn,
.order-theme-floating-btn,
.theme-floating-btn,
.co-theme-floating-btn {
    display: grid !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    z-index: 2147482500 !important;
}


/* PWA installation status lives inside the Theme / Options panel. */
.ca-options-install-status {
    min-height: 18px;
    margin-top: 8px;
    padding: 7px 9px;
    border-radius: 10px;
    color: var(--theme-muted, #64748b);
    background: color-mix(
        in srgb,
        var(--theme-text, #0f172a) 4%,
        transparent
    );
    font-size: 10.5px;
    line-height: 1.35;
    font-weight: 800;
}

.ca-options-install-status.is-ready {
    color: #166534;
    background: rgba(34, 197, 94, .12);
    border: 1px solid rgba(34, 197, 94, .24);
}

.ca-options-install-status.is-installed {
    color: #1d4ed8;
    background: rgba(59, 130, 246, .12);
    border: 1px solid rgba(59, 130, 246, .22);
}

.ca-options-install-status.is-waiting {
    color: #92400e;
    background: rgba(245, 158, 11, .12);
    border: 1px solid rgba(245, 158, 11, .24);
}

.ca-options-install-button:disabled,
.ca-options-install-button.is-waiting {
    cursor: wait;
    opacity: .62;
    box-shadow: none;
    filter: saturate(.65);
}

.ca-options-install-button:disabled:hover {
    transform: none;
}

/* Remove the old floating installation message. */
.ca-install-toast {
    display: none !important;
}


/* =========================================================
   RESPONSIVE + TABLET SAFE AREA PASS v20260715_01
   Preserves the existing design while preventing clipping.
========================================================= */
html {
    width: 100%;
    max-width: 100%;
    min-height: 100%;
    overflow-x: clip;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}
body, form {
    width: 100%;
    max-width: 100%;
    min-height: 100%;
    margin: 0;
}
body { overflow-x: clip; }
img, video, canvas, svg, iframe { max-width: 100%; }
iframe { display: block; }
button, input, select, textarea { max-width: 100%; }

@supports (min-height: 100dvh) {
    .app-page, .cos-page, .mm-page, .order-page,
    .login-page, .logout-page, .co-page, .po-page,
    .aa-page, .aep-page, .ci-page, .cti-page {
        min-height: 100dvh;
    }
}

@media (max-width: 1180px) {
    :where(.cos-main,.mm-main,.order-content,.main-content,.page-content) {
        min-width: 0 !important;
        max-width: 100% !important;
    }
}

@media (max-width: 900px) {
    body {
        padding-left: env(safe-area-inset-left, 0px);
        padding-right: env(safe-area-inset-right, 0px);
    }
    :where(.modal,.modal-content,[role="dialog"],
           .pl-modal,.entries-modal,.co-small-modal,.co-frame-modal,.co-access-modal,
           .ro-invoice-modal,.invoice-modal,.customer-modal-card,.lookup-modal) {
        max-width: calc(100vw - 16px) !important;
        max-height: calc(100dvh - 16px) !important;
    }
    :where(.modal-overlay,.pl-modal-overlay,.entries-modal-overlay,.co-modal-overlay,
           .ro-invoice-overlay,.info-drawer-overlay) {
        padding-top: max(8px, env(safe-area-inset-top, 0px)) !important;
        padding-right: max(8px, env(safe-area-inset-right, 0px)) !important;
        padding-bottom: max(8px, env(safe-area-inset-bottom, 0px)) !important;
        padding-left: max(8px, env(safe-area-inset-left, 0px)) !important;
    }
}

@media (max-width: 640px) {
    :where(.modal,.modal-content,[role="dialog"],
           .pl-modal,.entries-modal,.co-small-modal,.co-frame-modal,.co-access-modal,
           .ro-invoice-modal,.invoice-modal,.customer-modal-card,.lookup-modal) {
        width: calc(100vw - 8px) !important;
        max-width: calc(100vw - 8px) !important;
        height: auto;
        max-height: calc(100dvh - 8px) !important;
        border-radius: 16px !important;
    }
    :where(input,select,textarea) { font-size: 16px !important; }
}


/* =========================================================
   RESPONSIVE FOUNDATION v20260714_02
========================================================= */
html,body,form{max-width:100%;min-width:0}
html{overflow-x:hidden}
body{min-height:100dvh;overflow-x:hidden}
img,svg,video,canvas,iframe{max-width:100%}
@supports(padding:max(0px)){body{padding-left:env(safe-area-inset-left);padding-right:env(safe-area-inset-right)}}
@media(max-width:1180px){
  .ca-global-loader,.co-loader{inset:0!important;height:100dvh!important}
  .order-theme-panel,.theme-panel,.co-theme-panel{max-height:calc(100dvh - 90px)!important;overflow:auto!important}
}



/* PWA manager v5 */
.ca-options-install-button[hidden]{display:none!important}
.ca-options-install-status.is-error{color:#b91c1c;background:rgba(239,68,68,.11);border:1px solid rgba(239,68,68,.22)}
