/* Mobile Header */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: white;
    border-bottom: 1px solid #e5e7eb;
    z-index: 1030; /* Abaixo do modal (1050) */
    padding: 0 16px;
    align-items: center;
    justify-content: space-between;
    -webkit-transform: translateZ(0); /* Fix para iOS */
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.mobile-menu-toggle {
    background: none;
    border: none;
    font-size: 24px;
    color: #1f2937;
    padding: 8px;
    cursor: pointer;
}

.mobile-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 18px;
    color: var(--primary-navy);
}

.mobile-logo i {
    font-size: 24px;
    color: var(--primary-blue);
}

.mobile-user .user-avatar {
    width: 36px;
    height: 36px;
    font-size: 14px;
}

/* Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Esconder overlay quando modal está aberto */
.modal-open .sidebar-overlay {
    display: none !important;
}

/* Mobile Styles */
@media (max-width: 768px) {
    .mobile-header {
        display: flex !important;
        position: fixed !important;
        top: 0 !important;
    }
    
    .sidebar-overlay {
        display: block;
        pointer-events: none;
    }
    
    .sidebar-overlay.active {
        pointer-events: all;
    }
    
    .sidebar {
        transform: translateX(-100%);
        position: fixed;
        z-index: 9998;
        transition: transform 0.3s ease;
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        padding-top: 60px;
        position: relative;
        z-index: 1;
    }
    
    .top-bar {
        display: none;
    }
    
    .content-wrapper {
        padding: 16px;
        padding-top: 8px; /* Reduzir espaçamento superior no mobile */
    }
    
    /* Reduzir espaçamento do dashboard mobile */
    .mobile-dashboard {
        margin-top: -8px;
    }
    
    .wizard-progress {
        overflow-x: auto;
        padding-bottom: 10px;
    }
    
    .wizard-step {
        min-width: 80px;
    }
    
    /* Cards em coluna única no mobile */
    .row.g-3 > [class*="col-lg"] {
        width: 100%;
    }
}

/* ========== MOBILE BOTTOM NAVIGATION (Global) ========== */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 65px;
    background: white;
    border-top: 1px solid #e5e7eb;
    display: none;
    justify-content: space-around;
    align-items: center;
    padding: 0 8px;
    padding-bottom: env(safe-area-inset-bottom, 0);
    z-index: 1020; /* Abaixo do modal (1050) */
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

/* ========== PWA INSTALL PROMPT (Bottom Sheet) ========== */
.pwa-install-sheet {
    position: fixed;
    bottom: -100%; /* Começa escondido */
    left: 0;
    right: 0;
    background: white;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -5px 25px rgba(0,0,0,0.15);
    z-index: 10000; /* Acima de tudo */
    padding: 20px;
    transition: bottom 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0));
}

.pwa-install-sheet.show {
    bottom: 0;
}

.pwa-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pwa-title {
    font-weight: 700;
    font-size: 18px;
    color: var(--primary-navy);
    display: flex;
    align-items: center;
    gap: 10px;
}

.pwa-close {
    background: #f3f4f6;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    cursor: pointer;
}

.pwa-body {
    font-size: 14px;
    color: #4b5563;
    line-height: 1.5;
}

.pwa-steps {
    margin-top: 10px;
    background: #f9fafb;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
}

.pwa-step-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.pwa-step-item:last-child {
    margin-bottom: 0;
}

.pwa-step-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    width: 24px;
    height: 24px;
    color: var(--primary-blue);
}

.pwa-gif-container {
    width: 100%;
    height: 140px; /* Altura fixa para o GIF */
    background: #eff6ff;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    border: 2px dashed #bfdbfe;
}

.pwa-gif-placeholder {
    text-align: center;
    color: var(--primary-blue);
    opacity: 0.7;
}

.pwa-actions {
    margin-top: 5px;
}

.btn-dont-show {
    width: 100%;
    padding: 12px;
    background: transparent;
    border: 1px solid #e5e7eb;
    color: #6b7280;
    border-radius: 10px;
    font-weight: 600;
    font-size: 13px;
}

/* Ajuste para quando o modal PWA está aberto */
body.pwa-open {
    overflow: hidden;
}

/* Overlay escuro para o PWA */
.pwa-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease;
}

.pwa-overlay.show {
    opacity: 1;
    visibility: visible;
}

@media (max-width: 991px) {
    .mobile-bottom-nav {
        display: flex;
    }
    
    /* Adicionar padding no conteúdo para não ficar atrás do menu */
    .main-content {
        padding-bottom: 80px;
    }
}

.mobile-bottom-nav .nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #6b7280;
    font-size: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all 0.2s;
    min-width: 60px;
}

.mobile-bottom-nav .nav-item i {
    font-size: 20px;
    margin-bottom: 2px;
}

.mobile-bottom-nav .nav-item.active {
    color: var(--primary-blue, #3b94d9);
}

.mobile-bottom-nav .nav-item.active i {
    color: var(--primary-blue, #3b94d9);
}

.mobile-bottom-nav .nav-item-center {
    padding: 0;
    margin-top: -20px;
}

.mobile-bottom-nav .nav-plus-btn {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--primary-blue, #3b94d9) 0%, #2980b9 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(59, 148, 217, 0.4);
    transition: all 0.3s;
}

.mobile-bottom-nav .nav-plus-btn i {
    color: white;
    font-size: 24px;
    margin: 0;
}

.mobile-bottom-nav .nav-plus-btn:active {
    transform: scale(0.95);
}

/* ========== CORREÇÕES DE MODAL NO MOBILE ========== */

@media (max-width: 991px) {
    /* SOLUÇÃO: Ocultar backdrop no mobile e usar fundo no próprio modal */
    .modal-backdrop {
        display: none !important;
        opacity: 0 !important;
        visibility: hidden !important;
    }
    
    /* Modal com fundo próprio no mobile */
    .modal {
        background-color: rgba(0, 0, 0, 0.5) !important;
    }
    
    /* Garantir que modal-dialog seja clicável */
    .modal-dialog {
        pointer-events: auto !important;
    }
    
    .modal-content {
        pointer-events: auto !important;
    }
}

/* Quando modal está aberto, reduzir z-index de outros elementos */
.modal-open .sidebar {
    z-index: 900 !important;
}

.modal-open .sidebar-overlay {
    display: none !important;
}

.modal-open .mobile-header {
    z-index: 1000 !important;
}

.modal-open .mobile-bottom-nav {
    z-index: 1000 !important;
}

@media (max-width: 991px) {
    /* Garantir que modal funcione corretamente no mobile */
    .modal {
        padding-right: 0 !important;
    }
    
    .modal-dialog {
        margin: 16px !important;
        max-width: calc(100% - 32px) !important;
        max-height: calc(100vh - 32px) !important;
    }
    
    .modal-content {
        max-height: calc(100vh - 50px);
        overflow-y: auto;
    }
    
    /* Modal fullscreen no mobile para melhor UX */
    .modal-dialog-scrollable .modal-content {
        max-height: calc(100vh - 100px);
    }
    
    /* Botões do modal mais acessíveis */
    .modal-footer {
        padding: 16px;
        gap: 8px;
    }
    
    .modal-footer .btn {
        flex: 1;
        padding: 12px;
    }
}
