/* JA Labs Backoffice — PWA mobile-first */

/* ── Safe areas (iPhone notch) ── */
body.fi-panel-group {
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.jalabs-pwa-standalone body.fi-panel-group .fi-topbar {
    padding-top: env(safe-area-inset-top, 0);
}

/* Menu utilisateur backoffice — éviter clipping */
body.fi-panel-group .fi-topbar-ctn,
body.fi-panel-group .fi-topbar,
body.fi-panel-group .fi-topbar-end {
    overflow: visible !important;
}

body.fi-panel-group .fi-dropdown-panel {
    z-index: 10050 !important;
    max-height: min(70dvh, calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 1.5rem)) !important;
    overflow-y: auto !important;
}

/* ── Offline banner ── */
.jalabs-offline-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    padding: 0.45rem 0.75rem;
    text-align: center;
    font-size: 0.78rem;
    font-weight: 700;
    background: rgba(239, 68, 68, 0.92);
    color: #fff;
    transform: translateY(-100%);
    transition: transform 0.25s ease;
}

.jalabs-offline-banner.is-visible {
    transform: translateY(0);
}

/* ── Install prompts ── */
.jalabs-pwa-install,
.jalabs-ios-install {
    position: fixed;
    left: 0.75rem;
    right: 0.75rem;
    bottom: calc(0.75rem + env(safe-area-inset-bottom, 0));
    z-index: 9998;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.75rem 0.85rem;
    border-radius: 1rem;
    border: 1px solid rgba(123, 63, 242, 0.35);
    background: rgba(15, 15, 20, 0.96);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
    transform: translateY(120%);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.jalabs-pwa-install.is-visible,
.jalabs-ios-install.is-visible {
    transform: translateY(0);
    opacity: 1;
}

.jalabs-pwa-install__text {
    margin: 0;
    flex: 1;
    font-size: 0.78rem;
    color: #cbd5e1;
    line-height: 1.4;
}

.jalabs-pwa-install__text strong {
    display: block;
    color: #f8fafc;
    font-size: 0.88rem;
}

.jalabs-pwa-install__btn {
    padding: 0.45rem 0.85rem;
    border: none;
    border-radius: 999px;
    background: linear-gradient(135deg, #7b3ff2, #6b2fe0);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 800;
    cursor: pointer;
}

.jalabs-pwa-install__close,
.jalabs-ios-install__close {
    border: none;
    background: transparent;
    color: #94a3b8;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.25rem;
}

.jalabs-ios-install__body {
    flex: 1;
    font-size: 0.78rem;
    color: #cbd5e1;
}

.jalabs-ios-install__body strong {
    display: block;
    color: #f8fafc;
    margin-bottom: 0.15rem;
}

/* Biometric hint (login) */
.jalabs-biometric-hint {
    margin: 0.75rem 0 0;
    padding: 0.55rem 0.75rem;
    border-radius: 0.65rem;
    background: rgba(123, 63, 242, 0.12);
    border: 1px solid rgba(123, 63, 242, 0.25);
    font-size: 0.78rem;
    color: #c4b5fd;
    text-align: center;
}

body:not(.fi-auth-page) .jalabs-biometric-hint,
body:not(.fi-auth-page) #jalabs-biometric-badge {
    display: none !important;
}

/* Toast */
.jalabs-pwa-toast {
    position: fixed;
    bottom: 1rem;
    left: 1rem;
    right: 1rem;
    z-index: 9997;
    padding: 0.75rem;
    border-radius: 0.85rem;
    background: rgba(15, 15, 20, 0.95);
    border: 1px solid rgba(123, 63, 242, 0.3);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.jalabs-pwa-toast p {
    margin: 0;
    font-size: 0.82rem;
    color: #e2e8f0;
}

.jalabs-pwa-toast button {
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    border: none;
    background: #7b3ff2;
    color: #fff;
    font-weight: 700;
    font-size: 0.75rem;
}

/* ── Organisations : desktop vs mobile cards ── */
.ja-orgs-hub__card-mobile {
    display: none;
}

@media (max-width: 767px) {
    .ja-orgs-hub__card-desktop {
        display: none;
    }

    .ja-orgs-hub__card-mobile {
        display: block;
    }

    .ja-orgs-hub-page .fi-ta-content-grid {
        gap: 0.35rem !important;
    }

    .ja-orgs-hub-page .fi-ta-record {
        margin: 0 !important;
    }

    .ja-orgs-hub__kpis {
        display: flex;
        overflow-x: auto;
        gap: 0.5rem;
        padding-bottom: 0.25rem;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .ja-orgs-hub__kpis::-webkit-scrollbar {
        display: none;
    }

    .ja-orgs-hub__kpi {
        flex: 0 0 auto;
        min-width: 7.5rem;
        padding: 0.55rem 0.65rem;
    }

    .ja-orgs-hub__kpi-value {
        font-size: 1rem;
    }

    .ja-orgs-hub-page .fi-header {
        padding-bottom: 0.25rem;
    }

    .ja-orgs-hub-page .fi-ta-actions {
        display: none;
    }
}

/* Mobile org row — ~52px, 8–10 visibles */
.ja-orgs-mobile__row {
    display: flex;
    align-items: stretch;
    gap: 0.35rem;
    padding: 0.45rem 0.5rem;
    border-radius: 0.75rem;
    border: 1px solid rgba(148, 163, 184, 0.12);
    background: rgba(15, 15, 20, 0.65);
}

.ja-orgs-mobile__row:active {
    background: rgba(123, 63, 242, 0.1);
}

.ja-orgs-mobile__main {
    flex: 1;
    min-width: 0;
    text-decoration: none;
    color: inherit;
}

.ja-orgs-mobile__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.35rem;
    margin-bottom: 0.2rem;
}

.ja-orgs-mobile__name {
    margin: 0;
    font-size: 0.82rem;
    font-weight: 800;
    color: #f8fafc;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ja-orgs-mobile__org-status {
    flex-shrink: 0;
    font-size: 0.75rem;
}

.ja-orgs-mobile__badges {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem;
}

.ja-orgs-mobile__badge {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    padding: 0.1rem 0.35rem;
    border-radius: 999px;
    font-size: 0.62rem;
    font-weight: 800;
    border: 1px solid transparent;
}

.ja-orgs-mobile__badge-key {
    opacity: 0.75;
    font-size: 0.58rem;
    text-transform: uppercase;
}

.ja-orgs-mobile__badge--active {
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.22);
    color: #86efac;
}

.ja-orgs-mobile__badge--trial {
    background: rgba(168, 85, 247, 0.14);
    border-color: rgba(168, 85, 247, 0.25);
    color: #d8b4fe;
}

.ja-orgs-mobile__badge--none {
    background: rgba(148, 163, 184, 0.08);
    color: #94a3b8;
}

.ja-orgs-mobile__badge--expired {
    background: rgba(239, 68, 68, 0.12);
    color: #fca5a5;
}

.ja-orgs-mobile__users {
    font-size: 0.62rem;
    font-weight: 700;
    color: #64748b;
    margin-left: 0.15rem;
}

.ja-orgs-mobile__qa {
    flex-shrink: 0;
    width: 2.25rem;
    border: none;
    border-radius: 0.55rem;
    background: rgba(123, 63, 242, 0.15);
    color: #c4b5fd;
    font-size: 1.1rem;
    font-weight: 900;
    line-height: 1;
    cursor: pointer;
    touch-action: manipulation;
}

.ja-orgs-mobile__qa:active {
    background: rgba(123, 63, 242, 0.35);
}

/* Quick actions sheet */
.jalabs-qa-backdrop {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.jalabs-qa-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
}

.jalabs-qa-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10001;
    max-height: 75dvh;
    padding: 0 0 calc(env(safe-area-inset-bottom, 0) + 0.5rem);
    border-radius: 1.25rem 1.25rem 0 0;
    background: #12121a;
    border-top: 1px solid rgba(123, 63, 242, 0.3);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    overflow: hidden;
}

.jalabs-qa-sheet.is-open {
    transform: translateY(0);
}

.jalabs-qa-sheet__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1rem 0.5rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

.jalabs-qa-sheet__title {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 800;
    color: #f8fafc;
}

.jalabs-qa-sheet__close {
    border: none;
    background: transparent;
    color: #94a3b8;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}

.jalabs-qa-sheet__actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.45rem;
    padding: 0.75rem 0.85rem 0.5rem;
    overflow-y: auto;
    max-height: calc(75dvh - 3.5rem);
}

.jalabs-qa-sheet__btn {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.7rem 0.75rem;
    border-radius: 0.75rem;
    border: 1px solid rgba(148, 163, 184, 0.14);
    background: rgba(0, 0, 0, 0.2);
    color: #e2e8f0;
    font-size: 0.78rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    touch-action: manipulation;
    min-height: 2.75rem;
}

.jalabs-qa-sheet__btn--primary {
    border-color: rgba(123, 63, 242, 0.35);
    background: rgba(123, 63, 242, 0.15);
}

.jalabs-qa-sheet__btn--danger {
    border-color: rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.jalabs-qa-sheet__btn--trial {
    border-color: rgba(255, 154, 60, 0.3);
    color: #fdba74;
}

.jalabs-qa-sheet__icon {
    font-size: 1rem;
    line-height: 1;
}

body.jalabs-qa-open {
    overflow: hidden;
}

/* PWA standalone — Filament mobile polish */
.jalabs-pwa-standalone.jalabs-bp-mobile .fi-sidebar {
    width: min(85vw, 18rem);
}

.jalabs-pwa-standalone .fi-main {
    min-height: 100dvh;
}
