:root {
    --careapp-brand: var(--ion-color-primary, #15c3ba);
}

/* The ERP chat launcher belongs to the desktop ERP shell, not the carer app. */
#jit-chat-launcher,
#jit-chat-toast {
    display: none !important;
}

#careappPreloader,
#careappLoadingOverlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 14px;
    background: rgba(248, 250, 252, 0.96);
    backdrop-filter: blur(10px);
    transition: opacity 180ms ease, visibility 180ms ease;
}

#careappPreloader.is-hidden,
#careappLoadingOverlay.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.careapp-spinner {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 4px solid rgba(21, 195, 186, 0.18);
    border-top-color: var(--careapp-brand);
    animation: careapp-spin 0.85s linear infinite;
}

.careapp-loading-title {
    color: #0f172a;
    font-family: var(--ion-font-family, system-ui, sans-serif);
    font-size: 15px;
    font-weight: 900;
}

.careapp-loading-subtitle {
    color: #64748b;
    font-family: var(--ion-font-family, system-ui, sans-serif);
    font-size: 12px;
    font-weight: 700;
    margin-top: -8px;
}

.careapp-toast {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 18px);
    left: 50%;
    z-index: 100000;
    width: min(90vw, 420px);
    transform: translate(-50%, -16px);
    opacity: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-radius: 16px;
    background: #10b981;
    color: white;
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.18);
    font-family: var(--ion-font-family, system-ui, sans-serif);
    font-size: 14px;
    font-weight: 900;
    text-align: left;
    transition: opacity 180ms ease, transform 180ms ease;
}

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

.careapp-toast.is-error {
    background: #ef4444;
}

.careapp-network-popup {
    position: fixed;
    left: 14px;
    right: 14px;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 86px);
    z-index: 100001;
    display: grid;
    grid-template-columns: 34px 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 12px 12px;
    border: 1px solid #fde68a;
    border-radius: 16px;
    background: #fffbeb;
    color: #78350f;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.22);
    font-family: var(--ion-font-family, system-ui, sans-serif);
    transform: translateY(18px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 180ms ease, transform 180ms ease, visibility 180ms ease;
}

.careapp-network-popup.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.careapp-network-popup.offline {
    border-color: #fecaca;
    background: #fef2f2;
    color: #7f1d1d;
}

.careapp-network-icon {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f59e0b;
    color: #fff;
    font-weight: 900;
}

.careapp-network-popup.offline .careapp-network-icon {
    background: #ef4444;
}

.careapp-network-copy {
    min-width: 0;
}

.careapp-network-copy strong,
.careapp-network-copy span {
    display: block;
}

.careapp-network-copy strong {
    font-size: 13px;
    font-weight: 900;
}

.careapp-network-copy span {
    margin-top: 2px;
    font-size: 11px;
    line-height: 1.25;
    font-weight: 800;
}

.careapp-network-popup button {
    border: 0;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.08);
    color: inherit;
    padding: 8px 10px;
    font: inherit;
    font-size: 11px;
    font-weight: 900;
}

.careapp-submit-spinner {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.45);
    border-top-color: #fff;
    animation: careapp-spin 0.75s linear infinite;
}

button.is-careapp-loading,
ion-button.is-careapp-loading {
    opacity: 0.84;
    pointer-events: none;
}

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