/**
 * FLUXOPLUS - MAIN LAYOUT MOBILE-FIRST
 * =====================================
 * Estilos do layout principal otimizados para mobile-first.
 * Base: Mobile → Tablet → Desktop
 *
 * @version 2.0.0
 * @author Saffos Tecnologia
 */

/* ========================================
   CSS VARIABLES
   ======================================== */
:root {
    --primary: #6366f1;
    --primary-light: #818cf8;
    --secondary: #8b5cf6;
    --accent: #06b6d4;
    --danger: #ef4444;
    --success: #10b981;
    --bg-light: #ffffff;
    --text-dark: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);

    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 16px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;

    /* Z-index */
    --z-navbar: 100;
    --z-modal: 1000;
    --z-floating: 9999;
}

/* ========================================
   MOBILE BASE (320px+)
   ======================================== */

/* Navbar Container - Mobile First */
.navbar-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: var(--z-navbar);
    transition: transform 0.3s ease;
    /* CRÍTICO: Permitir cliques nos filhos */
    pointer-events: auto !important;
}

.navbar-container.hidden {
    transform: translateY(-100%);
}

/* Navbar Reveal Zone - NUNCA bloquear cliques */
.navbar-reveal-zone {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 50px;
    z-index: calc(var(--z-navbar) - 1);
    /* CRÍTICO: Esta zona NÃO deve capturar eventos */
    pointer-events: none !important;
}

/* Navbar Premium */
.navbar-premium {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: var(--shadow-md);
    border-bottom: 1px solid var(--border-color);
    padding: var(--spacing-sm) 0;
}

/* Navbar Content */
.navbar-content {
    max-width: 100%;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-md);
}

/* ========================================
   BRAND (MOBILE)
   ======================================== */
.brand-container {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    text-decoration: none;
    flex-shrink: 0;
    /* CRÍTICO: Deve ser clicável */
    pointer-events: auto !important;
    touch-action: manipulation !important;
    cursor: pointer;
}

.brand-logo-wrapper {
    position: relative;
    width: 40px;
    height: 40px;
}

.brand-logo {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
    transition: transform 0.2s;
}

.brand-text h1 {
    font-size: 1.25rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
    line-height: 1;
}

.brand-text p {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin: 0;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* ========================================
   MOBILE MENU (DEFAULT - VISÍVEL NO MOBILE)
   ======================================== */

/* Menu Button - Sempre visível no mobile */
.mobile-menu-btn {
    display: flex;
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(139, 92, 246, 0.1));
    border: none;
    border-radius: 10px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
    transition: all 0.2s;
    /* CRÍTICO: Deve ser clicável */
    pointer-events: auto !important;
    touch-action: manipulation !important;
}

.mobile-menu-btn span {
    width: 20px;
    height: 2px;
    background: var(--primary);
    border-radius: 2px;
    transition: all 0.3s;
}

.mobile-menu-btn:active {
    transform: scale(0.95);
}

.mobile-menu-btn.active span:nth-child(1) {
    transform: rotate(45deg) translateY(7px);
}

.mobile-menu-btn.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-btn.active span:nth-child(3) {
    transform: rotate(-45deg) translateY(-7px);
}

/* Overlay */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: calc(var(--z-modal) - 1);
    opacity: 0;
    transition: opacity 0.3s;
    /* CRÍTICO: Overlay deve capturar cliques para fechar */
    pointer-events: auto !important;
    touch-action: manipulation !important;
}

.mobile-overlay.active {
    display: block;
    opacity: 1;
}

/* Mobile Menu */
.mobile-menu {
    position: fixed;
    top: 0;
    right: -100%;
    width: 85vw;
    max-width: 320px;
    height: 100vh;
    background: white;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.2);
    z-index: var(--z-modal);
    transition: right 0.3s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    /* Menu deve permitir interação */
    pointer-events: auto !important;
}

.mobile-menu.active {
    right: 0;
}

.mobile-menu-header {
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.mobile-menu-close {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(139, 92, 246, 0.1));
    border: none;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--primary);
    transition: all 0.2s;
    /* CRÍTICO: Botão fechar deve funcionar */
    pointer-events: auto !important;
    touch-action: manipulation !important;
}

.mobile-menu-close:active {
    transform: scale(0.95);
}

.mobile-menu-content {
    padding: var(--spacing-lg);
}

.mobile-nav-section {
    margin-bottom: var(--spacing-lg);
}

.mobile-nav-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: var(--spacing-md);
}

.mobile-nav-item {
    margin-bottom: var(--spacing-xs);
}

.mobile-nav-link {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    color: var(--text-dark);
    text-decoration: none;
    border-radius: 10px;
    font-weight: 600;
    font-size: 16px;
    transition: all 0.2s;
    /* CRÍTICO: Links devem funcionar */
    pointer-events: auto !important;
    touch-action: manipulation !important;
    min-height: 48px;
}

.mobile-nav-link:active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(139, 92, 246, 0.1));
    transform: scale(0.98);
}

.mobile-nav-link.active {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
}

.mobile-user-section {
    padding: var(--spacing-lg);
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

/* ========================================
   DESKTOP NAVIGATION (OCULTO NO MOBILE)
   ======================================== */
.nav-main {
    display: none; /* Oculto por padrão no mobile */
}

.user-actions {
    display: none; /* Oculto por padrão no mobile */
}

/* ========================================
   MAIN CONTENT (MOBILE)
   ======================================== */
.main-content-premium {
    padding-top: 70px; /* Espaço para navbar fixa */
    min-height: 100vh;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    transition: padding-top 0.3s;
}

.main-content-premium.fullscreen {
    padding-top: 20px;
}

/* ========================================
   FLOATING MENU BUTTON (MOBILE)
   ======================================== */
.floating-menu-btn {
    position: fixed;
    top: var(--spacing-md);
    right: var(--spacing-md);
    width: 52px;
    height: 52px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
    z-index: var(--z-floating);
    transition: all 0.3s;
    opacity: 0;
    visibility: hidden;
    transform: scale(0.8);
    color: white;
    font-size: 1.3rem;
    /* CRÍTICO: Deve ser clicável */
    pointer-events: auto !important;
    touch-action: manipulation !important;
}

.floating-menu-btn.visible {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
}

.floating-menu-btn:active {
    transform: scale(0.95);
}

/* ========================================
   USER CARD (MOBILE - SIMPLIFICADO)
   ======================================== */
.user-card-premium {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-sm) var(--spacing-md);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(139, 92, 246, 0.08));
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 50px;
    transition: all 0.2s;
    cursor: pointer;
    touch-action: manipulation !important;
    pointer-events: auto !important;
}

.user-avatar-premium {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 800;
    font-size: 0.85rem;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
    flex-shrink: 0;
}

.user-info-premium {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.user-name-premium {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-dark);
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--primary);
}

/* ========================================
   BUTTONS (MOBILE)
   ======================================== */
.btn-logout-premium {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md) var(--spacing-lg);
    background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
    color: white;
    text-decoration: none;
    border-radius: 10px;
    font-weight: 600;
    font-size: 16px;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
    border: none;
    width: 100%;
    min-height: 48px;
    /* CRÍTICO: Botão deve funcionar */
    pointer-events: auto !important;
    touch-action: manipulation !important;
}

.btn-logout-premium:active {
    transform: scale(0.98);
}

/* ========================================
   FOOTER (MOBILE)
   ======================================== */
.footer-premium {
    position: fixed;
    bottom: var(--spacing-md);
    right: var(--spacing-md);
    left: var(--spacing-md);
    padding: var(--spacing-sm) var(--spacing-md);
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    z-index: 50;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}

.footer-premium strong {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 800;
}

/* ========================================
   MEDIA QUERIES - TABLET (≥ 768px)
   ======================================== */
@media (min-width: 768px) {
    .brand-logo-wrapper {
        width: 48px;
        height: 48px;
    }

    .brand-logo {
        font-size: 1.3rem;
    }

    .brand-text h1 {
        font-size: 1.5rem;
    }

    .brand-text p {
        font-size: 0.7rem;
    }

    .main-content-premium {
        padding-top: 100px;
    }

    .footer-premium {
        position: fixed;
        bottom: var(--spacing-lg);
        right: var(--spacing-lg);
        left: auto;
        padding: var(--spacing-md) var(--spacing-lg);
        font-size: 0.85rem;
    }
}

/* ========================================
   MEDIA QUERIES - DESKTOP (≥ 1024px)
   ======================================== */
@media (min-width: 1024px) {
    /* Mostrar navegação desktop */
    .nav-main {
        display: flex;
        align-items: center;
        gap: var(--spacing-md);
        flex: 1;
        list-style: none;
        margin: 0;
        padding: 0;
    }

    .user-actions {
        display: flex;
        align-items: center;
        gap: var(--spacing-md);
    }

    /* Esconder menu mobile */
    .mobile-menu-btn {
        display: none;
    }

    .mobile-menu,
    .mobile-overlay {
        display: none !important;
    }

    /* Nav Links Desktop */
    .nav-item {
        position: relative;
    }

    .nav-link {
        display: flex;
        align-items: center;
        text-align: center;
        gap: var(--spacing-sm);
        padding: 12px 20px;
        color: var(--text-dark);
        text-decoration: none;
        font-weight: 600;
        font-size: 0.95rem;
        border-radius: 12px;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        white-space: nowrap;
        cursor: pointer;
        touch-action: manipulation !important;
        pointer-events: auto !important;
    }

        .nav-link:hover {
            background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(139, 92, 246, 0.15));
            color: var(--primary);
            align-items: center;
            text-align: center;
            padding: 12px 20px;
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
        }

    /* Dropdown Desktop */
    .nav-link.has-dropdown::after {
        content: '\f107';
        font-family: 'Font Awesome 5 Free';
        font-weight: 900;
        margin-left: 4px;
        font-size: 0.8rem;
        transition: transform 0.3s;
    }

    .nav-item:hover .nav-link.has-dropdown::after {
        transform: rotate(180deg);
    }

    .dropdown-menu-custom {
        position: absolute;
        top: calc(100% + 8px);
        left: 0;
        min-width: 220px;
        background: white;
        border-radius: 12px;
        box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
        border: 1px solid var(--border-color);
        padding: var(--spacing-sm);
        opacity: 0;
        visibility: hidden;
        transform: translateY(-10px);
        transition: all 0.3s;
        z-index: 1000;
        pointer-events: auto !important;
    }

    .nav-item:hover .dropdown-menu-custom {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }

    .dropdown-item-custom {
        display: flex;
        align-items: center;
        gap: var(--spacing-md);
        padding: 12px 16px;
        color: var(--text-dark);
        text-decoration: none;
        border-radius: 10px;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        font-size: 0.9rem;
        font-weight: 500;
        pointer-events: auto !important;
        touch-action: manipulation !important;
    }

    .dropdown-item-custom:hover {
        background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(139, 92, 246, 0.15));
        color: var(--primary);
        transform: translateX(4px);
        box-shadow: 0 2px 8px rgba(99, 102, 241, 0.15);
    }

    /* User Card Desktop */
    .user-name-premium {
        font-size: 0.9rem;
    }

    .user-role-badge {
        font-size: 0.7rem;
    }

    /* Logout Button Desktop */
    .btn-logout-premium {
        width: auto;
        padding: 10px 18px;
        font-size: 0.9rem;
    }

    .btn-logout-premium:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
    }

    /* Toggle navbar button */
    .toggle-navbar-btn {
        width: 40px;
        height: 40px;
        background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(139, 92, 246, 0.1));
        border: none;
        border-radius: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: all 0.2s;
        color: var(--primary);
        pointer-events: auto !important;
        touch-action: manipulation !important;
    }

    .toggle-navbar-btn:hover {
        background: linear-gradient(135deg, var(--primary), var(--secondary));
        color: white;
    }

    .navbar-content {
        max-width: 1600px;
        padding: 0 var(--spacing-lg);
        gap: var(--spacing-xl);
    }
}

/* ========================================
   RIPPLE EFFECT (TODOS OS TAMANHOS)
   ======================================== */
.ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
    transform: scale(0);
    animation: ripple-animation 0.6s ease-out;
    pointer-events: none !important;
}

@keyframes ripple-animation {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus visible para teclado */
button:focus-visible,
a:focus-visible,
[role="button"]:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
