/* ========================================
   CORREÇÃO ESPECÍFICA PARA CATEGORIAS MOBILE
   Solução definitiva para botões grandes e quebra de layout
   ======================================== */

/* Reset e override de estilos conflitantes */
.categories-grid-mobile {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 0.75rem !important;
    padding: 0.75rem !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow: hidden !important;
}

/* Correção específica para botões de categoria mobile - 4 colunas QUADRADOS */
.category-item-mobile {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 0.5rem 0.25rem !important;
    background: #ffffff !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 8px !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08) !important;
    transition: all 0.2s ease !important;
    text-decoration: none !important;
    aspect-ratio: 1/1.3 !important;
    width: 100% !important;
    max-width: 100% !important;
    position: relative !important;
    cursor: pointer !important;
    overflow: visible !important;
    min-height: 90px !important;
    box-sizing: border-box !important;
}

/* Correção para ícones das categorias - 4 colunas QUADRADOS */
.category-icon-mobile {
    width: 24px !important;
    height: 24px !important;
    object-fit: cover !important;
    border-radius: 6px !important;
    border: 1px solid #f3f4f6 !important;
    transition: all 0.2s ease !important;
    margin-bottom: 0.375rem !important;
    flex-shrink: 0 !important;
}

/* Correção para texto das categorias - 4 colunas QUADRADOS */
.category-text-mobile {
    font-size: 0.65rem !important;
    font-weight: 600 !important;
    color: #374151 !important;
    text-align: center !important;
    line-height: 1.1 !important;
    margin: 0 !important;
    padding: 0.125rem 0.125rem !important;
    overflow: visible !important;
    text-overflow: ellipsis !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    word-wrap: break-word !important;
    hyphens: auto !important;
    white-space: normal !important;
    word-break: normal !important;
    overflow-wrap: break-word !important;
    max-height: 1.43rem !important; /* 2 linhas * 0.65rem * 1.1 */
    min-height: 0.715rem !important;
    -webkit-hyphens: auto !important;
    -moz-hyphens: auto !important;
    -ms-hyphens: auto !important;
    -webkit-word-break: break-word !important;
    -moz-word-break: break-word !important;
    -ms-word-break: break-word !important;
}

/* Estados de hover otimizados - 4 colunas */
.category-item-mobile:hover {
    border-color: #3b82f6 !important;
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.2) !important;
    transform: translateY(-2px) !important;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%) !important;
}

.category-item-mobile:hover .category-icon-mobile {
    transform: scale(1.1) !important;
    border-color: #3b82f6 !important;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3) !important;
}

.category-item-mobile:hover .category-text-mobile {
    color: #1d4ed8 !important;
    font-weight: 700 !important;
}

/* Efeito de clique mais visível */
.category-item-mobile:active {
    transform: scale(0.95) !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%) !important;
}

/* Estados de foco para acessibilidade */
.category-item-mobile:focus {
    outline: 2px solid #3b82f6 !important;
    outline-offset: 2px !important;
    border-color: #3b82f6 !important;
}


/* Responsividade para telas muito pequenas (até 360px) - 4 colunas */
@media (max-width: 360px) {
    .categories-grid-mobile {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 0.5rem !important;
        padding: 0.5rem !important;
    }
    
    .category-item-mobile {
        padding: 0.375rem 0.125rem !important;
        aspect-ratio: 1/1.2 !important;
        min-height: 75px !important;
    }
    
    .category-icon-mobile {
        width: 20px !important;
        height: 20px !important;
        margin-bottom: 0.25rem !important;
    }
    
    .category-text-mobile {
        font-size: 0.55rem !important;
        line-height: 1.0 !important;
        max-height: 1.1rem !important;
        -webkit-line-clamp: 2 !important;
        line-clamp: 2 !important;
        padding: 0.125rem 0.0625rem !important;
        overflow: visible !important;
    }
}

/* Responsividade para telas pequenas (até 480px) - 4 colunas */
@media (max-width: 480px) {
    .categories-grid-mobile {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 0.75rem !important;
        padding: 0.75rem !important;
    }
    
    .category-item-mobile {
        padding: 0.5rem 0.25rem !important;
        aspect-ratio: 1/1.25 !important;
        min-height: 80px !important;
    }
    
    .category-icon-mobile {
        width: 24px !important;
        height: 24px !important;
        margin-bottom: 0.25rem !important;
    }
    
    .category-text-mobile {
        font-size: 0.6rem !important;
        max-height: 1.32rem !important;
        -webkit-line-clamp: 2 !important;
        line-clamp: 2 !important;
        padding: 0.125rem 0.125rem !important;
        overflow: visible !important;
    }
}

/* Responsividade para tablets pequenos (481px a 640px) - 4 colunas */
@media (min-width: 481px) and (max-width: 640px) {
    .categories-grid-mobile {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 1rem !important;
        padding: 1rem !important;
    }
    
    .category-item-mobile {
        padding: 0.75rem !important;
        aspect-ratio: 1/1 !important;
    }
    
    .category-icon-mobile {
        width: 32px !important;
        height: 32px !important;
    }
    
    .category-text-mobile {
        font-size: 0.65rem !important;
    }
}

/* Correção para telas médias (641px a 768px) - 4 colunas */
@media (min-width: 641px) and (max-width: 768px) {
    .categories-grid-mobile {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 1rem !important;
        padding: 1rem !important;
    }
    
    .category-item-mobile {
        padding: 1rem !important;
        aspect-ratio: 1/1 !important;
    }
    
    .category-icon-mobile {
        width: 36px !important;
        height: 36px !important;
    }
    
    .category-text-mobile {
        font-size: 0.7rem !important;
    }
}

/* Estados de loading */
.category-item-mobile.loading {
    opacity: 0.6 !important;
    pointer-events: none !important;
}

/* Animações suaves */
@keyframes categorySlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.category-item-mobile {
    animation: categorySlideIn 0.3s ease-out !important;
}

/* Melhorias de performance */
.category-item-mobile,
.category-icon-mobile,
.category-text-mobile {
    will-change: transform !important;
}

/* Suporte para modo escuro */
@media (prefers-color-scheme: dark) {
    .category-item-mobile {
        background: #1f2937 !important;
        border-color: #374151 !important;
        color: #f9fafb !important;
    }
    
    .category-item-mobile:hover {
        background: linear-gradient(135deg, #374151 0%, #4b5563 100%) !important;
        border-color: #3b82f6 !important;
    }
    
    .category-text-mobile {
        color: #f9fafb !important;
    }
    
    .category-item-mobile:hover .category-text-mobile {
        color: #60a5fa !important;
    }
}

/* Correção para problemas de quebra de linha */
.category-text-mobile {
    white-space: normal !important;
    word-break: normal !important;
    overflow-wrap: normal !important;
}

/* Garantir que não haja overflow horizontal */
.categories-grid-mobile {
    max-width: 100vw !important;
    overflow-x: hidden !important;
}

/* Correção para problemas de altura */
.category-item-mobile {
    box-sizing: border-box !important;
}

/* Melhorias de acessibilidade */
.category-item-mobile:focus-visible {
    outline: 2px solid #3b82f6 !important;
    outline-offset: 2px !important;
}

/* Correção para touch targets */
@media (pointer: coarse) {
    .category-item-mobile {
        min-height: 44px !important;
        min-width: 44px !important;
    }
}

/* Correção para problemas de flexbox */
.category-item-mobile {
    flex: 1 1 auto !important;
    flex-shrink: 1 !important;
    flex-grow: 0 !important;
}

/* Garantir que as imagens não quebrem o layout */
.category-icon-mobile {
    max-width: 100% !important;
    height: auto !important;
    aspect-ratio: 1/1 !important;
}

/* Correção para problemas de texto longo */
.category-text-mobile {
    min-height: auto !important;
    max-height: none !important;
    height: auto !important;
}

/* CORREÇÃO CRÍTICA: Garantir que botões nunca fiquem pretos */
.category-item-mobile {
    background: #ffffff !important;
    color: #374151 !important;
}

.category-item-mobile:hover {
    background: #f8fafc !important;
    color: #1f2937 !important;
}

.category-item-mobile:active {
    background: #f1f5f9 !important;
    color: #0f172a !important;
}

.category-item-mobile:focus {
    background: #ffffff !important;
    color: #374151 !important;
}

/* Garantir que o texto seja sempre visível */
.category-text-mobile {
    color: #374151 !important;
    text-shadow: none !important;
}

.category-item-mobile:hover .category-text-mobile {
    color: #1f2937 !important;
}

.category-item-mobile:active .category-text-mobile {
    color: #0f172a !important;
}

/* Correção para overflow do texto */
.categories-grid-mobile {
    overflow: visible !important;
}

.category-item-mobile {
    overflow: visible !important;
}

/* Override de qualquer estilo Tailwind conflitante */
.categories-grid-mobile * {
    box-sizing: border-box !important;
}

/* Garantir que não haja margens ou paddings indesejados */
.category-item-mobile * {
    margin: 0 !important;
    padding: 0 !important;
}

.category-item-mobile > * {
    margin: 0 !important;
    padding: 0 !important;
}

/* Regra específica para evitar quebras em palavras compostas */
.category-text-mobile {
    /* Permitir quebras em palavras longas para evitar overflow */
    word-break: break-word !important;
    /* Permitir quebras apenas em espaços */
    white-space: normal !important;
    /* Garantir que o texto se ajuste sem quebrar palavras */
    overflow-wrap: break-word !important;
}

/* Correção específica para o ícone */
.category-icon-mobile {
    margin-bottom: 0.5rem !important;
    margin-top: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* Correção específica para o texto */
.category-text-mobile {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 0.25rem !important;
    padding-right: 0.25rem !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    /* Prevenir quebras de palavras específicas */
    word-spacing: normal !important;
    letter-spacing: normal !important;
    /* Forçar que palavras compostas não sejam quebradas */
    unicode-bidi: normal !important;
    direction: ltr !important;
}
