/* Otimizações específicas para tablets */

/* Configurações Fullscreen Globais */
html {
    height: 100vh;
    overflow: hidden;
    position: fixed;
    width: 100vw;
}

body {
    height: 100vh;
    overflow: hidden;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    margin: 0;
    padding: 0;
}

/* Configurações gerais para tablets */
@media (min-width: 768px) and (max-width: 1366px) {
    /* Otimização de toque para tablets */
    * {
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }
    
    /* Permitir seleção de texto em elementos específicos */
    input, textarea, .selectable {
        -webkit-user-select: text;
        -moz-user-select: text;
        -ms-user-select: text;
        user-select: text;
    }
    
    /* Melhor responsividade ao toque */
    .module-card, button, .interactive-element {
        min-height: 44px; /* Tamanho mínimo recomendado para toque */
        min-width: 44px;
        touch-action: manipulation;
    }
    
    /* Feedback visual aprimorado para toque */
    .module-card:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
    
    /* Otimização de scrolling */
    .scrollable {
        -webkit-overflow-scrolling: touch;
    }
}

/* Suporte específico para stylus */
@media (pointer: fine) {
    /* Quando um stylus ou mouse preciso está disponível */
    .drawing-area, .tracing-area {
        cursor: crosshair;
    }
    
    /* Melhor precisão para elementos pequenos */
    .precision-element {
        min-height: 20px;
        min-width: 20px;
    }
    
    /* Hover effects mais sutis para stylus */
    .module-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    }
}

@media (pointer: coarse) {
    /* Quando apenas toque grosso está disponível (dedo) */
    .touch-target {
        min-height: 48px;
        min-width: 48px;
        padding: 12px;
    }
    
    /* Elementos maiores para toque com dedo */
    .module-card {
        min-height: 120px;
        padding: 20px;
    }
    
    /* Espaçamento maior entre elementos tocáveis */
    .main-menu {
        gap: 20px;
    }
}

/* Otimizações para orientação landscape em tablets */
@media (orientation: landscape) and (min-width: 768px) and (max-width: 1366px) {
    .container {
        display: flex;
        flex-direction: row;
        align-items: flex-start;
        gap: 30px;
        max-width: 1200px;
        margin: 0 auto;
        padding: 20px;
    }
    
    .main-content {
        flex: 2;
    }
    
    .sidebar {
        flex: 1;
        max-width: 300px;
    }
    
    .main-menu {
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
    }
    
    .header {
        margin-bottom: 20px;
    }
    
    .progress-area {
        position: sticky;
        top: 20px;
    }
}

/* Otimizações para orientação portrait em tablets */
@media (orientation: portrait) and (min-width: 768px) and (max-width: 1024px) {
    .container {
        max-width: 600px;
        margin: 0 auto;
        padding: 20px;
    }
    
    .main-menu {
        grid-template-columns: repeat(2, 1fr);
        gap: 25px;
    }
    
    .module-card {
        min-height: 160px;
        padding: 25px;
    }
    
    .module-icon {
        font-size: 3.5rem;
        margin-bottom: 15px;
    }
    
    .module-title {
        font-size: 1.2rem;
    }
}

/* Animações otimizadas para tablets */
@media (min-width: 768px) {
    .module-card {
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .module-card:hover {
        transform: translateY(-4px) scale(1.02);
        box-shadow: 0 12px 30px rgba(0,0,0,0.15);
    }
    
    .module-card:active {
        transform: translateY(-2px) scale(1.01);
        transition: all 0.1s ease;
    }
    
    /* Animação de entrada escalonada */
    .module-card {
        animation: slideInUp 0.6s ease-out backwards;
    }
    
    .module-card:nth-child(1) { animation-delay: 0.1s; }
    .module-card:nth-child(2) { animation-delay: 0.2s; }
    .module-card:nth-child(3) { animation-delay: 0.3s; }
    .module-card:nth-child(4) { animation-delay: 0.4s; }
    .module-card:nth-child(5) { animation-delay: 0.5s; }
    .module-card:nth-child(6) { animation-delay: 0.6s; }
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Otimizações de performance para tablets */
@media (min-width: 768px) {
    .module-card, .progress-circle, .mascot {
        will-change: transform;
        backface-visibility: hidden;
        perspective: 1000px;
    }
    
    /* Otimização de renderização */
    .animated-element {
        transform: translateZ(0);
    }
}

/* Suporte para tablets com alta densidade de pixels */
@media (min-width: 768px) and (-webkit-min-device-pixel-ratio: 2) {
    .module-icon {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
    
    /* Bordas mais nítidas */
    .module-card {
        border: 0.5px solid rgba(255,255,255,0.1);
    }
}

/* Configurações específicas para iPad */
@supports (-webkit-touch-callout: none) {
    @media (min-width: 768px) and (max-width: 1024px) {
        .container {
            padding: 20px;
            padding-bottom: 40px; /* Espaço extra para o indicador home */
        }
        
        /* Otimização para Safari no iPad */
        .module-card {
            -webkit-transform: translateZ(0);
            transform: translateZ(0);
        }
        
        /* Melhor suporte para multitoque */
        .interactive-element {
            touch-action: pan-x pan-y;
        }
        
        .drawing-area {
            touch-action: none; /* Previne scroll durante desenho */
        }
    }
}

/* Configurações para tablets Android */
@media (min-width: 768px) and (max-width: 1366px) {
    .android-optimization {
        /* Otimizações específicas para Android tablets */
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
    
    /* Melhor performance de scroll */
    .scrollable-content {
        transform: translate3d(0, 0, 0);
    }
}

/* Modo escuro para tablets (se suportado) */
@media (min-width: 768px) and (prefers-color-scheme: dark) {
    .container {
        background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
        color: #ffffff;
    }
    
    .module-card {
        background: rgba(255, 255, 255, 0.1);
        border: 1px solid rgba(255, 255, 255, 0.2);
        backdrop-filter: blur(10px);
    }
    
    .module-card:hover {
        background: rgba(255, 255, 255, 0.15);
    }
}

/* Configurações de acessibilidade para tablets */
@media (min-width: 768px) {
    /* Suporte para usuários com dificuldades motoras */
    @media (prefers-reduced-motion: reduce) {
        .module-card {
            transition: none;
            animation: none;
        }
        
        .floating-animation {
            animation: none;
        }
    }
    
    /* Melhor contraste para usuários com dificuldades visuais */
    @media (prefers-contrast: high) {
        .module-card {
            border: 2px solid #000;
            background: #fff;
            color: #000;
        }
        
        .module-icon {
            filter: contrast(2);
        }
    }
}

/* Otimizações para tablets com stylus ativo */
.stylus-active {
    .drawing-canvas {
        touch-action: none;
        cursor: crosshair;
    }
    
    .precision-mode {
        cursor: none; /* Esconder cursor quando stylus está ativo */
    }
    
    /* Feedback visual para stylus */
    .stylus-cursor {
        position: absolute;
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: #4CAF50;
        pointer-events: none;
        z-index: 1000;
        transform: translate(-50%, -50%);
        opacity: 0.8;
    }
}

/* Configurações para tablets em modo split-screen */
@media (min-width: 400px) and (max-width: 600px) {
    .split-screen-mode .container {
        padding: 10px;
    }
    
    .split-screen-mode .main-menu {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .split-screen-mode .module-card {
        min-height: 80px;
        padding: 15px;
        display: flex;
        align-items: center;
    }
    
    .split-screen-mode .module-icon {
        font-size: 2rem;
        margin-right: 15px;
        margin-bottom: 0;
    }
}