/* Aplicação instalável: iPhone, Android e computador */

.app-header {
    padding-top: env(safe-area-inset-top);
    background: #111111;
}

.pwa-nav-install {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: 8px;
    border: 1px solid rgba(2, 144, 10, 0.7);
    background: #02900A;
    color: #ffffff;
    font-weight: 700;
    font-size: 14px;
    line-height: 1;
    border-radius: 10px;
    padding: 10px 14px;
    white-space: nowrap;
    cursor: pointer;
}

.pwa-nav-install[hidden] {
    display: none !important;
}

.pwa-nav-install:hover {
    background: #03a80d;
}

.pwa-install {
    position: fixed;
    z-index: 1200;
    left: 12px;
    right: 12px;
    bottom: calc(78px + env(safe-area-inset-bottom));
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 14px 14px 16px;
    background: #111111;
    color: #ffffff;
    border: 1px solid rgba(2, 144, 10, 0.55);
    border-radius: 16px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

.pwa-install-copy {
    flex: 1;
    min-width: 0;
}

.pwa-install-copy strong {
    display: block;
    font-size: 15px;
    margin-bottom: 2px;
}

.pwa-install-copy p {
    margin: 0;
    color: rgba(255, 255, 255, 0.78);
    font-size: 13px;
    line-height: 1.35;
}

.pwa-install-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 0 0 auto;
}

.pwa-install-go,
.pwa-install-close {
    border: 0;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
    padding: 8px 12px;
}

.pwa-install-go {
    background: #02900A;
    color: #ffffff;
}

.pwa-install-close {
    background: transparent;
    color: rgba(255, 255, 255, 0.8);
}

.app-tabbar {
    display: none;
}

.app-sheet-backdrop,
.app-sheet {
    display: none;
}

@media (max-width: 991.98px) {
    .pwa-nav-install {
        display: none !important;
    }

    .crm-app > .footer {
        display: none;
    }

    .app-tabbar {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1080;
        background: #111111;
        border-top: 1px solid rgba(2, 144, 10, 0.45);
        min-height: 64px;
        padding: 8px 4px calc(10px + env(safe-area-inset-bottom));
        justify-content: space-around;
        align-items: stretch;
    }

    .app-tab {
        flex: 1 1 0;
        min-width: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        padding: 4px 2px;
        border: 0;
        background: transparent;
        color: rgba(255, 255, 255, 0.72);
        text-decoration: none;
        font-size: 11px;
        font-weight: 600;
        line-height: 1.1;
    }

    .app-tab i {
        font-size: 20px;
        line-height: 1;
    }

    .app-tab.active,
    .app-tab[aria-expanded="true"] {
        color: #3dce4a;
    }

    .crm-app main.crm-main {
        padding-bottom: calc(96px + env(safe-area-inset-bottom)) !important;
    }

    .app-sheet-backdrop.is-open {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1090;
        background: rgba(0, 0, 0, 0.45);
    }

    .app-sheet.is-open {
        display: block;
        position: fixed;
        left: 0;
        right: 0;
        bottom: calc(74px + env(safe-area-inset-bottom));
        z-index: 1095;
        max-height: min(70vh, 520px);
        overflow: auto;
        background: #ffffff;
        border-radius: 18px 18px 0 0;
        box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.25);
        padding: 8px 8px 12px;
    }

    .app-sheet-title {
        margin: 8px 12px 10px;
        font-size: 13px;
        font-weight: 700;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        color: #64748b;
    }

    .app-sheet a {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px 14px;
        border-radius: 12px;
        color: #111111;
        text-decoration: none;
        font-weight: 600;
    }

    .app-sheet a i {
        width: 22px;
        text-align: center;
        color: #02900A;
        font-size: 18px;
    }

    .app-sheet a:active,
    .app-sheet a.active {
        background: rgba(2, 144, 10, 0.1);
    }

    .app-sheet a.is-danger {
        color: #b91c1c;
    }

    .app-sheet a.is-danger i {
        color: #b91c1c;
    }
}

body:not(.crm-app) .pwa-install {
    bottom: calc(16px + env(safe-area-inset-bottom));
}

@media (min-width: 992px) {
    .pwa-install {
        left: auto;
        right: 24px;
        bottom: 24px;
        width: 380px;
    }
}

.crm-netbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    padding-top: calc(10px + env(safe-area-inset-top));
    background: #7a4b00;
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.35;
}

.crm-netbar[hidden] {
    display: none !important;
}

.crm-netbar[data-state="sync"] {
    background: #02900A;
}

.crm-netbar[data-state="error"] {
    background: #8b1e1e;
}

.crm-netbar-text {
    flex: 1;
    min-width: 0;
}

.crm-netbar-actions {
    display: flex;
    gap: 8px;
    flex: 0 0 auto;
}

.crm-netbar-btn {
    border: 0;
    border-radius: 10px;
    background: #ffffff;
    color: #111111;
    font-weight: 700;
    padding: 8px 10px;
    cursor: pointer;
}

body.crm-netbar-on {
    padding-top: calc(46px + env(safe-area-inset-top));
}

@media print {
    .pwa-install,
    .pwa-nav-install,
    .app-tabbar,
    .app-sheet,
    .app-sheet-backdrop,
    .crm-netbar {
        display: none !important;
    }
}

body.auth-page,
body:has(.recovery-card),
body:has(.reset-card) {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}
