/* =============================================
   PWA Mobile — Bottom Navigation & Layout Fixes
   Enter FrioVale
   ============================================= */

/* ========================
   Splash Screen
   ======================== */
#pwa-splash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #556ee6 0%, #3b4fd1 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999999;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

#pwa-splash.pwa-splash-hide {
    opacity: 0;
    visibility: hidden;
}

#pwa-splash .pwa-splash-logo {
    width: 100px;
    height: 100px;
    border-radius: 24px;
    margin-bottom: 28px;
    animation: pwa-splash-bounce 1.2s ease-in-out infinite;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
}

#pwa-splash .pwa-splash-title {
    color: #fff;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 1px;
    margin-bottom: 32px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

#pwa-splash .pwa-splash-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(255, 255, 255, 0.25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: pwa-spin 0.8s linear infinite;
}

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

@keyframes pwa-splash-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* ========================
   Bottom Navigation Bar
   ======================== */
.pwa-bottom-nav {
    display: none;
}

@media (max-width: 992px) {
    .pwa-bottom-nav {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 60px;
        background: #fff;
        border-top: 1px solid #e9ecef;
        z-index: 1050;
        justify-content: space-around;
        align-items: center;
        padding: 0;
        box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.08);
    }

    .pwa-bottom-nav a {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-decoration: none;
        color: #74788d;
        font-size: 10px;
        font-weight: 500;
        flex: 1;
        height: 100%;
        transition: color 0.2s ease;
        position: relative;
        -webkit-tap-highlight-color: transparent;
    }

    .pwa-bottom-nav a i {
        font-size: 22px;
        margin-bottom: 2px;
        transition: color 0.2s ease;
    }

    .pwa-bottom-nav a span {
        line-height: 1;
    }

    .pwa-bottom-nav a.active {
        color: #556ee6;
    }

    .pwa-bottom-nav a.active::before {
        content: '';
        position: absolute;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 32px;
        height: 3px;
        background: #556ee6;
        border-radius: 0 0 4px 4px;
    }

    .pwa-bottom-nav a:active {
        background: rgba(85, 110, 230, 0.06);
    }

    /* ========================
       Layout adjustments for bottom nav
       ======================== */
    .main-content {
        padding-bottom: 70px !important;
    }

    .footer {
        padding-bottom: 70px !important;
    }

    /* ========================
       Sidebar as overlay on mobile
       ======================== */
    .pwa-sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1059;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    body.pwa-sidebar-open .pwa-sidebar-overlay {
        display: block;
        opacity: 1;
    }

    body.pwa-sidebar-open .vertical-menu {
        display: block !important;
        position: fixed !important;
        left: 0 !important;
        top: 0 !important;
        bottom: 0 !important;
        width: 260px !important;
        z-index: 1060 !important;
        transform: translateX(0) !important;
        box-shadow: 4px 0 16px rgba(0, 0, 0, 0.15);
        transition: transform 0.3s ease;
        overflow-y: auto;
    }

    /* ========================
       Mobile responsive improvements
       ======================== */
    
    /* Tabelas com scroll horizontal */
    .table-responsive,
    .dataTables_wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Cards melhores no mobile */
    .card {
        margin-bottom: 12px;
    }

    .card-body {
        padding: 12px;
    }

    /* Page title mais compacto */
    .page-title-box {
        padding: 10px 0 !important;
    }

    .page-title {
        font-size: 16px !important;
    }

    /* Breadcrumb escondido no mobile */
    .page-title-right {
        display: none !important;
    }

    /* Melhor toque em botões */
    .btn {
        min-height: 38px;
    }

    /* Badge e status labels legíveis */
    .badge {
        font-size: 11px;
        padding: 4px 8px;
    }

    /* Form inputs maiores para mobile */
    .form-control,
    .form-select,
    .select2-container .select2-selection--single {
        min-height: 40px !important;
        font-size: 14px !important;
    }

    /* Avatar menor no sidebar mobile */
    .user-wid {
        padding: 12px 0 !important;
    }

    .user-wid .avatar-md {
        width: 48px !important;
        height: 48px !important;
    }

    /* Topbar ajustes */
    .navbar-header {
        padding: 0 8px;
    }

    /* DataTables font size */
    .dataTable td,
    .dataTable th {
        font-size: 12px;
        padding: 8px 6px !important;
    }
}

/* ========================
   PWA Standalone adjustments
   ======================== */
.pwa-standalone .navbar-header {
    padding-top: env(safe-area-inset-top, 0px);
}

.pwa-standalone .pwa-bottom-nav {
    padding-bottom: env(safe-area-inset-bottom, 0px);
    height: calc(60px + env(safe-area-inset-bottom, 0px));
}

/* Safe area for notched devices */
@supports (padding: max(0px)) {
    .pwa-bottom-nav {
        padding-bottom: max(0px, env(safe-area-inset-bottom));
        height: calc(60px + max(0px, env(safe-area-inset-bottom)));
    }
}

/* ========================
   Small phone adjustments
   ======================== */
@media (max-width: 380px) {
    .pwa-bottom-nav a {
        font-size: 9px;
    }

    .pwa-bottom-nav a i {
        font-size: 20px;
    }

    .pwa-splash-title {
        font-size: 18px !important;
    }
}
