/* ==========================================================================
   TALKMEETING - MOBILE.CSS (VERSÃO DEFINITIVA V8)
   Otimizações: Barra de Pesquisa + Layout Participantes + Performance
   ========================================================================== */

/* 1. RESET ESTRUTURAL (CRÍTICO PARA SCROLL) */
@media (max-width: 1024px) {
    html, body {
        width: 100%;
        height: auto !important;
        min-height: 100vh;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        position: relative;
    }

    .admin-main {
        display: block !important;
        width: 100% !important;
        margin-left: 0 !important;
        height: auto !important;
        min-height: 100vh;
        overflow: visible !important;
        position: relative;
        z-index: 1;
    }

    .admin-content {
        padding: 16px 12px 120px 12px !important;
        width: 100%;
        height: auto !important;
        overflow: visible !important;
        box-sizing: border-box;
    }

    .admin-sidebar {
        position: fixed;
        top: 60px;
        left: 0;
        bottom: 0;
        width: 260px;
        transform: translateX(-100%);
        z-index: 99999;
        transition: transform 0.3s ease;
        box-shadow: none;
    }
    
    .admin-sidebar.active {
        transform: translateX(0);
        box-shadow: 10px 0 30px rgba(0,0,0,0.5);
    }
}

/* 2. HEADER SUPERIOR (FIXO) */
@media (max-width: 768px) {
    body { padding-top: 60px !important; }

    .universal-header {
        height: 60px !important;
        padding: 0 16px !important;
        background: rgba(10, 10, 15, 0.98) !important;
        backdrop-filter: blur(20px);
        justify-content: flex-start !important;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        z-index: 10000;
        border-bottom: 1px solid rgba(255,255,255,0.1);
    }

    .universal-header .menu-toggle {
        order: -1 !important;
        display: flex !important;
        background: none;
        border: none;
        color: white;
        font-size: 24px;
        padding: 10px 16px 10px 0 !important;
        margin: 0 !important;
        cursor: pointer;
    }

    .universal-header .header-logo,
    .universal-header .nav-logo {
        order: 0 !important;
        display: flex;
        align-items: center;
        margin-right: auto !important;
    }

    .universal-header .logo-text {
        font-size: 18px !important;
        margin-left: 8px;
        letter-spacing: -0.5px;
        font-weight: 700;
    }

    .universal-header .header-actions {
        order: 1 !important;
        display: flex;
        gap: 10px;
    }

    .logo-subtitle, .user-name-small, .admin-badge {
        display: none !important;
    }
}

/* 3. CABEÇALHOS INTERNOS (NÃO FIXOS) */
@media (max-width: 768px) {
    .page-header {
        position: relative !important;
        top: auto !important;
        z-index: 1 !important;
        width: 100%;
        padding: 16px 0 !important;
        background: transparent !important;
        border-bottom: none !important;
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        margin-bottom: 10px;
    }

    .page-header h1 {
        font-size: 22px !important;
        margin-bottom: 5px;
        font-weight: 700;
    }

    .page-actions {
        display: flex;
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }

    .page-actions button {
        width: 100%;
        justify-content: center;
        padding: 14px;
        min-height: 48px;
        font-weight: 600;
    }
}

/* 4. CARTÕES, INPUTS E LAYOUT */
@media (max-width: 768px) {
    .glass-card, 
    .settings-card, 
    .checkin-card,
    .notification-form-card,
    .event-selector-card {
        padding: 16px !important;
        width: 100% !important;
        box-sizing: border-box;
        margin-bottom: 16px !important;
        border-radius: 16px;
        height: auto !important;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        width: 100% !important;
        box-sizing: border-box;
        padding: 14px !important;
        font-size: 16px !important;
        border-radius: 12px;
        min-height: 48px;
    }

    .form-row {
        display: flex !important;
        flex-direction: column !important;
        gap: 15px;
    }

    textarea {
        min-height: 120px;
        resize: vertical;
    }

    label {
        font-size: 14px;
        font-weight: 600;
        margin-bottom: 8px;
        display: block;
    }
}

/* 5. GRID DE ESTATÍSTICAS (2 COLUNAS) */
@media (max-width: 768px) {
    .stats-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 10px !important;
        width: 100%;
        margin-bottom: 20px;
    }

    .stat-card {
        padding: 14px 10px !important;
        flex-direction: column;
        text-align: center;
        align-items: center;
        gap: 8px;
        min-height: auto !important;
        border-radius: 14px;
        background: rgba(255, 255, 255, 0.03);
        border: 1px solid rgba(255, 255, 255, 0.08);
    }

    .stat-value {
        font-size: 1.3rem !important;
        font-weight: 700;
        word-break: break-word;
        line-height: 1.2;
    }
    
    .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 20px;
        margin: 0 auto;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .stat-label {
        font-size: 12px;
        color: var(--text-muted);
        font-weight: 500;
    }
}

/* 6. LISTA DE PARTICIPANTES - OTIMIZADA */
@media (max-width: 768px) {
    /* Container do cabeçalho dentro da tabela */
    #participantsTableContainer > div:first-child {
        display: flex !important;
        flex-direction: column !important;
        padding: 16px !important;
        gap: 14px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        background: rgba(255, 255, 255, 0.02);
        border-radius: 16px 16px 0 0;
    }

    #participantsTableContainer > div:first-child > div:first-child {
        width: 100% !important;
    }

    #participantsTableContainer h4 {
        font-size: 18px !important;
        margin: 0 0 6px 0 !important;
        font-weight: 700;
        line-height: 1.3;
    }

    #participantsTableContainer p {
        font-size: 13px !important;
        color: var(--text-muted) !important;
        margin: 0 !important;
    }

    /* Container de busca + CSV */
    #participantsTableContainer > div:first-child > div:last-child {
        display: flex !important;
        gap: 10px !important;
        width: 100% !important;
    }

    /* Barra de pesquisa */
    #localSearch {
        flex: 1 !important;
        padding: 12px 16px !important;
        font-size: 16px !important;
        border-radius: 12px !important;
        border: 1px solid rgba(255, 255, 255, 0.15) !important;
        background: rgba(255, 255, 255, 0.05) !important;
        color: white !important;
        height: 48px;
        box-sizing: border-box;
    }

    #localSearch:focus {
        outline: none !important;
        border-color: rgba(99, 102, 241, 0.6) !important;
        background: rgba(255, 255, 255, 0.08) !important;
        box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    }

    #localSearch::placeholder {
        color: rgba(255, 255, 255, 0.4) !important;
    }

    /* Botão CSV */
    #participantsTableContainer .btn-outline {
        flex-shrink: 0 !important;
        min-width: 70px !important;
        padding: 12px 16px !important;
        height: 48px !important;
        font-size: 14px !important;
        border-radius: 12px !important;
        background: rgba(99, 102, 241, 0.1) !important;
        border: 1px solid rgba(99, 102, 241, 0.3) !important;
        font-weight: 600;
    }
}

/* 7. ABAS DE EVENTOS (MENU HORIZONTAL) */
@media (max-width: 768px) {
    .events-tabs-menu,
    #participantsTabsMenu {
        padding: 12px 0 16px !important;
        margin: 0 0 20px 0 !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        -webkit-overflow-scrolling: touch;
        display: flex !important;
        gap: 10px;
        scroll-behavior: smooth;
    }

    .events-tabs-menu::before,
    .events-tabs-menu::after {
        display: none !important;
    }

    .event-tab-btn {
        padding: 12px 18px !important;
        font-size: 14px !important;
        border-radius: 12px !important;
        gap: 8px !important;
        flex-shrink: 0 !important;
        height: 48px;
        display: flex;
        align-items: center;
        font-weight: 600;
    }

    .tab-badge-count {
        padding: 4px 8px !important;
        font-size: 11px !important;
        font-weight: 700;
    }
}

/* 8. TABELA DE PARTICIPANTES */
@media (max-width: 768px) {
    .table-container {
        margin: 0 !important;
        border-radius: 0 0 16px 16px !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    .data-table {
        width: 100% !important;
    }

    .data-table thead {
        position: sticky !important;
        top: 0 !important;
        z-index: 10 !important;
        background: rgba(20, 20, 30, 0.98) !important;
    }

    .data-table thead th {
        padding: 12px 10px !important;
        font-size: 11px !important;
        text-transform: uppercase;
        font-weight: 700;
        letter-spacing: 0.5px;
    }

    .data-table tbody td {
        padding: 14px 10px !important;
        font-size: 13px !important;
        vertical-align: middle;
    }

    .data-table tbody td:first-child {
        min-width: 180px;
    }

    .data-table tbody td:first-child strong {
        display: block;
        font-size: 14px;
        font-weight: 600;
        margin-bottom: 4px;
    }

    .data-table tbody td:first-child small {
        font-size: 11px;
        color: var(--text-muted);
    }

    .badge {
        font-size: 11px !important;
        padding: 5px 10px !important;
        border-radius: 8px;
        font-weight: 600;
    }
}

/* 9. LISTAS E HISTÓRICO */
@media (max-width: 768px) {
    #notificationHistory, 
    .events-list,
    .solicitacoes-grid {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }
}

/* 10. MODAIS */
@media (max-width: 768px) {
    .modal {
        align-items: flex-start !important;
        padding: 20px 0 !important;
        overflow-y: auto !important;
        z-index: 11000;
    }

    .modal-content {
        width: 95% !important;
        margin: 0 auto 50px auto !important;
        max-height: none !important;
        border-radius: 20px;
    }

    .modal-header {
        padding: 20px !important;
    }

    .modal-header h2 {
        font-size: 20px;
        font-weight: 700;
    }

    .modal-body {
        padding: 0 20px 20px !important;
    }

    .modal-footer {
        flex-direction: column-reverse;
        gap: 10px;
        padding: 20px !important;
    }
    
    .modal-footer button {
        width: 100%;
        margin: 0;
        min-height: 48px;
    }
}

/* 11. SEÇÃO DE PARTICIPANTES */
@media (max-width: 768px) {
    #participants {
        padding: 0 !important;
    }

    #participants .section-header {
        padding: 16px 12px !important;
        margin-bottom: 12px;
        flex-direction: column;
        gap: 12px;
    }

    #participants .section-header h3 {
        font-size: 20px !important;
        font-weight: 700;
        margin: 0 !important;
    }

    #participants .section-actions {
        display: flex;
        gap: 8px;
        width: 100%;
    }

    #participants .section-actions button {
        flex: 1;
        padding: 12px !important;
        font-size: 14px !important;
        min-height: 48px;
    }

    #participants .glass-card {
        margin: 0 !important;
        padding: 0 !important;
        border-radius: 16px !important;
    }
}

/* 12. BOTÕES E INTERAÇÕES */
@media (max-width: 768px) {
    button, .btn {
        min-height: 48px !important;
        min-width: 48px !important;
        cursor: pointer;
        -webkit-tap-highlight-color: rgba(99, 102, 241, 0.2);
        transition: all 0.2s ease;
    }

    button:active, .btn:active {
        transform: scale(0.97);
    }

    .btn-primary {
        font-weight: 600;
        letter-spacing: 0.3px;
    }
}

/* 13. SCROLLBAR CUSTOMIZADO */
@media (max-width: 768px) {
    .events-tabs-menu::-webkit-scrollbar,
    .table-container::-webkit-scrollbar {
        height: 4px;
    }

    .events-tabs-menu::-webkit-scrollbar-track,
    .table-container::-webkit-scrollbar-track {
        background: rgba(255, 255, 255, 0.03);
    }

    .events-tabs-menu::-webkit-scrollbar-thumb,
    .table-container::-webkit-scrollbar-thumb {
        background: rgba(99, 102, 241, 0.4);
        border-radius: 2px;
    }
}

/* 14. ESTADOS VAZIOS */
@media (max-width: 768px) {
    .empty-state {
        padding: 40px 20px !important;
        text-align: center;
        font-size: 14px;
        color: var(--text-muted);
    }

    .empty-state div:first-child {
        font-size: 48px;
        margin-bottom: 12px;
    }
}

/* 15. LANDSCAPE MODE */
@media (max-width: 768px) and (orientation: landscape) {
    #participantsTableContainer > div:first-child {
        flex-direction: row !important;
        align-items: center;
    }

    #participantsTableContainer > div:first-child > div:last-child {
        width: auto !important;
        margin-left: auto;
    }
}

/* 16. PERFORMANCE E ACESSIBILIDADE */
@media (max-width: 768px) {
    * {
        -webkit-tap-highlight-color: transparent;
    }

    input:focus-visible,
    button:focus-visible {
        outline: 2px solid rgba(99, 102, 241, 0.6) !important;
        outline-offset: 2px;
    }

    .event-tab-btn,
    .data-table thead th {
        -webkit-user-select: none;
        user-select: none;
    }
}