/* TRACELIA_V265_MOBILE_NATIVE_CSS */

.v265-bottom-navigation,
.v265-more-backdrop {
    display: none;
}

@media (max-width: 760px) {
    :root {
        --v265-bottom-height: 70px;
    }

    body {
        padding-bottom:
            calc(
                var(--v265-bottom-height) +
                env(safe-area-inset-bottom)
            ) !important;
    }

    body.v265-more-open {
        overflow: hidden !important;
    }

    /*
     * En-tête compact : identité uniquement.
     * L’ancienne navigation est remplacée par la barre basse.
     */
    body .sidebar {
        position: sticky !important;
        top: 0 !important;
        z-index: 800 !important;
        display: flex !important;
        align-items: center !important;
        min-height: 64px !important;
        padding:
            calc(9px + env(safe-area-inset-top))
            16px
            9px !important;
        background:
            rgba(4, 4, 7, 0.96) !important;
        backdrop-filter:
            blur(18px) saturate(130%) !important;
        -webkit-backdrop-filter:
            blur(18px) saturate(130%) !important;
        border-bottom:
            1px solid rgba(255, 255, 255, 0.08) !important;
    }

    body .sidebar .brand {
        margin: 0 !important;
    }

    body .sidebar .navigation,
    body .sidebar .sidebar-footer {
        display: none !important;
    }

    body .main-content {
        padding:
            15px
            13px
            24px !important;
    }

    /*
     * Barre principale de l’application.
     */
    .v265-bottom-navigation {
        position: fixed;
        left: 10px;
        right: 10px;
        bottom:
            calc(
                8px +
                env(safe-area-inset-bottom)
            );
        z-index: 9500;
        display: grid;
        grid-template-columns:
            repeat(5, minmax(0, 1fr));
        min-height: var(--v265-bottom-height);
        padding: 7px;
        border:
            1px solid rgba(255, 255, 255, 0.13);
        border-radius: 22px;
        background:
            rgba(13, 13, 18, 0.94);
        box-shadow:
            0 18px 48px rgba(0, 0, 0, 0.48),
            0 0 0 1px rgba(0, 0, 0, 0.35);
        backdrop-filter:
            blur(22px) saturate(150%);
        -webkit-backdrop-filter:
            blur(22px) saturate(150%);
    }

    .v265-bottom-nav-item {
        position: relative;
        display: grid;
        place-items: center;
        align-content: center;
        gap: 4px;
        min-width: 0;
        border: 0;
        border-radius: 15px;
        color: #8f8f99;
        background: transparent;
        font: inherit;
        cursor: pointer;
        transition:
            color 160ms ease,
            background 160ms ease,
            transform 160ms ease;
    }

    .v265-bottom-nav-item.active {
        color: #ffffff;
        background:
            linear-gradient(
                145deg,
                rgba(240, 0, 60, 0.30),
                rgba(240, 0, 60, 0.10)
            );
    }

    .v265-bottom-nav-item.active::before {
        content: "";
        position: absolute;
        top: -7px;
        width: 24px;
        height: 3px;
        border-radius: 999px;
        background: #f0003c;
        box-shadow:
            0 0 16px rgba(240, 0, 60, 0.72);
    }

    .v265-bottom-nav-item:active {
        transform: scale(0.95);
    }

    .v265-bottom-nav-icon {
        display: grid;
        place-items: center;
        min-height: 20px;
        font-size: 18px;
        line-height: 1;
    }

    .v265-bottom-nav-label {
        max-width: 100%;
        overflow: hidden;
        font-size: 9px;
        font-weight: 750;
        line-height: 1;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /*
     * Feuille Plus.
     */
    .v265-more-backdrop {
        position: fixed;
        inset: 0;
        z-index: 9800;
        display: flex;
        align-items: flex-end;
        padding:
            16px
            12px
            calc(
                12px +
                env(safe-area-inset-bottom)
            );
        background: rgba(0, 0, 0, 0.68);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
    }

    .v265-more-backdrop[hidden] {
        display: none !important;
    }

    .v265-more-sheet {
        width: 100%;
        padding: 10px 14px 18px;
        border:
            1px solid rgba(255, 255, 255, 0.14);
        border-radius: 24px;
        color: #ffffff;
        background:
            linear-gradient(
                155deg,
                rgba(25, 9, 15, 0.98),
                rgba(8, 8, 12, 0.99) 42%
            );
        box-shadow:
            0 24px 70px rgba(0, 0, 0, 0.64);
    }

    .v265-more-handle {
        width: 42px;
        height: 4px;
        margin: 0 auto 13px;
        border-radius: 999px;
        background:
            rgba(255, 255, 255, 0.24);
    }

    .v265-more-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 16px;
        margin-bottom: 15px;
    }

    .v265-more-eyebrow {
        margin: 0 0 4px;
        color: #ff174f;
        font-size: 9px;
        font-weight: 850;
        letter-spacing: 0.2em;
    }

    .v265-more-header h2 {
        margin: 0;
        font-size: 25px;
    }

    .v265-more-close {
        width: 42px;
        height: 42px;
        border:
            1px solid rgba(255, 255, 255, 0.13);
        border-radius: 13px;
        color: #ffffff;
        background:
            rgba(255, 255, 255, 0.05);
        font-size: 25px;
    }

    .v265-more-actions {
        display: grid;
        gap: 9px;
    }

    .v265-more-view-button {
        display: grid;
        grid-template-columns:
            36px minmax(0, 1fr) auto;
        align-items: center;
        min-height: 58px;
        padding: 10px 13px;
        border:
            1px solid rgba(255, 255, 255, 0.10);
        border-radius: 15px;
        color: #ffffff;
        background:
            rgba(255, 255, 255, 0.035);
        font: inherit;
        font-size: 14px;
        font-weight: 750;
        text-align: left;
    }

    .v265-more-chevron {
        color: #777780;
        font-size: 25px;
    }

    /*
     * KPI réellement forcés en 2 × 2.
     */
    body .kpi-grid {
        display: grid !important;
        grid-template-columns:
            repeat(2, minmax(0, 1fr)) !important;
        gap: 9px !important;
    }

    body .kpi-card {
        min-height: 103px !important;
        padding: 11px 9px !important;
    }

    body .kpi-icon {
        width: 35px !important;
        height: 35px !important;
        font-size: 17px !important;
    }

    body .kpi-card strong {
        font-size: 24px !important;
    }

    /*
     * Les cartes caméra restent lisibles,
     * mais la caméra active apparaît en premier via JavaScript.
     */
    body .camera-card {
        min-height: 134px !important;
    }

    body .camera-preview,
    body .camera-preview img {
        min-height: 134px !important;
    }

    /*
     * Fenêtre de direct : feuille compacte et non plus page noire complète.
     */
    body #camera-live-modal.camera-live-backdrop {
        align-items: flex-end !important;
        padding: 0 !important;
        background:
            rgba(0, 0, 0, 0.78) !important;
    }

    body .v265-camera-live-card {
        display: grid !important;
        grid-template-rows:
            auto auto auto auto !important;
        width: 100% !important;
        max-width: 760px !important;
        height: auto !important;
        min-height: 0 !important;
        max-height:
            calc(
                100dvh -
                env(safe-area-inset-top)
            ) !important;
        margin: 0 auto !important;
        overflow-y: auto !important;
        border:
            1px solid rgba(255, 255, 255, 0.15) !important;
        border-bottom: 0 !important;
        border-radius:
            24px 24px 0 0 !important;
        background:
            #07070a !important;
        box-shadow:
            0 -24px 70px rgba(0, 0, 0, 0.68) !important;
    }

    body .v265-camera-live-header {
        position: relative !important;
        display: grid !important;
        grid-template-columns:
            minmax(0, 1fr) auto !important;
        align-items: center !important;
        min-height: 82px !important;
        padding:
            17px
            66px
            13px
            17px !important;
        border-bottom:
            1px solid rgba(255, 255, 255, 0.09) !important;
    }

    body .v265-camera-live-header h2 {
        margin: 3px 0 0 !important;
        font-size:
            clamp(21px, 6vw, 28px) !important;
        line-height: 1.08 !important;
    }

    body .camera-live-technical {
        margin-top: 6px !important;
        font-size: 11px !important;
    }

    body .v265-camera-live-close {
        position: absolute !important;
        top:
            calc(
                15px +
                env(safe-area-inset-top)
            ) !important;
        right: 15px !important;
        width: 42px !important;
        height: 42px !important;
        min-height: 42px !important;
        padding: 0 !important;
        border-radius: 13px !important;
        font-size: 25px !important;
    }

    body .camera-live-stage {
        width: 100% !important;
        min-height: 0 !important;
        height: auto !important;
        aspect-ratio: 16 / 9 !important;
        border-radius: 0 !important;
        background: #000000 !important;
    }

    body .camera-live-image {
        display: block !important;
        width: 100% !important;
        height: 100% !important;
        min-height: 0 !important;
        max-height: none !important;
        object-fit: contain !important;
    }

    body .v265-camera-live-controls {
        display: grid !important;
        grid-template-columns:
            repeat(3, minmax(0, 1fr)) !important;
        width: 100% !important;
        padding: 10px 12px !important;
        gap: 8px !important;
        border-top:
            1px solid rgba(255, 255, 255, 0.07) !important;
        border-bottom:
            1px solid rgba(255, 255, 255, 0.07) !important;
        background:
            rgba(255, 255, 255, 0.018) !important;
    }

    body .v265-camera-live-controls .badge {
        grid-column: 1 / -1 !important;
        justify-self: start !important;
        margin: 0 0 1px !important;
    }

    body .v265-camera-live-controls
    .camera-live-tool-button,
    body .v265-camera-live-controls
    .camera-live-fullscreen-button {
        width: 100% !important;
        min-width: 0 !important;
        min-height: 43px !important;
        padding: 8px 5px !important;
        border-radius: 12px !important;
        font-size: 10px !important;
        white-space: nowrap !important;
    }

    body #camera-live-capture::before,
    body #camera-live-reconnect::before,
    body #camera-live-fullscreen::before {
        display: none !important;
        content: none !important;
    }

    body .v265-camera-live-footer {
        display: grid !important;
        gap: 4px !important;
        min-height: 58px !important;
        padding:
            10px
            15px
            calc(
                11px +
                env(safe-area-inset-bottom)
            ) !important;
        font-size: 10px !important;
        color: #8d8d96 !important;
    }

    body .v265-camera-live-footer span {
        width: 100% !important;
        text-align: left !important;
    }

    /*
     * Le bouton PWA ne doit plus recouvrir la barre basse.
     */
    body #pwa-install-button {
        bottom:
            calc(
                var(--v265-bottom-height) +
                20px +
                env(safe-area-inset-bottom)
            ) !important;
    }
}

@media (
    max-width: 760px
) and (
    orientation: landscape
) {
    body .v265-camera-live-card {
        max-width: 900px !important;
        max-height: 100dvh !important;
        border-radius: 18px 18px 0 0 !important;
    }

    body .camera-live-stage {
        max-height: 58dvh !important;
    }

    body .v265-camera-live-header {
        min-height: 64px !important;
        padding:
            10px 60px 9px 14px !important;
    }

    body .v265-camera-live-header h2 {
        font-size: 19px !important;
    }
}
