/**
 * FLUXOPLUS - MOBILE-FIRST CSS
 * =====================================
 * Sistema de estilos mobile-first para garantir
 * que todos os botões e elementos interativos funcionem
 * perfeitamente em tablets e celulares.
 *
 * @version 2.0.0
 * @author Saffos Tecnologia
 * @approach Mobile First - Estilos base para mobile, depois desktop
 */

/* ========================================
   RESET E BASE (MOBILE)
   ======================================== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px; /* Base para rem */
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Garantir scroll em mobile */
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    height: 100%;
}

body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    line-height: 1.6;
    color: #1e293b;
    background: #f8fafc;
    /* Garantir scroll em mobile */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 100vh;
    /* CRÍTICO: Permitir toques em todo o body */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* ========================================
   ELEMENTOS INTERATIVOS (MOBILE-FIRST)
   ======================================== */

/* TODOS os elementos clicáveis DEVEM ter estas propriedades */
button,
a,
input,
textarea,
select,
[role="button"],
[role="link"],
[onclick],
[data-bs-toggle],
.btn,
.card[onclick],
.clickable,
.mobile-clickable {
    /* CRÍTICO: Permitir toques */
    touch-action: manipulation !important;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    cursor: pointer;
    /* CRÍTICO: Garantir que elementos recebam eventos */
    pointer-events: auto !important;
    /* Mínimo de área de toque (44x44px - Apple HIG) */
    min-height: 44px;
    min-width: 44px;
}

/* Botões devem ter padding adequado para toque */
button,
.btn,
[role="button"] {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 16px; /* Evita zoom no iOS */
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
    text-decoration: none;
    -webkit-appearance: none;
    appearance: none;
}

/* Links devem ser facilmente clicáveis */
a {
    color: #006bb7;
    text-decoration: none;
    padding: 4px;
    margin: -4px;
    border-radius: 4px;
    transition: background 0.2s;
}

a:hover,
a:active {
    background: rgba(0, 107, 183, 0.1);
}

/* ========================================
   INPUTS E FORMS (MOBILE-FIRST)
   ======================================== */
input,
textarea,
select,
[contenteditable="true"] {
    /* Garantir que inputs possam receber foco */
    -webkit-user-select: text !important;
    user-select: text !important;
    touch-action: manipulation !important;
    pointer-events: auto !important;
    /* Prevenir zoom automático no iOS */
    font-size: 16px;
    padding: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    width: 100%;
    max-width: 100%;
    background: white;
    -webkit-appearance: none;
    appearance: none;
}

input:focus,
textarea:focus,
select:focus {
    outline: 2px solid #006bb7;
    outline-offset: 2px;
    border-color: #006bb7;
}

/* ========================================
   SCROLL E OVERFLOW (MOBILE-FIRST)
   ======================================== */
.scrollable,
.overflow-auto,
[style*="overflow-y: auto"],
[style*="overflow: auto"] {
    -webkit-overflow-scrolling: touch !important;
    /* Permitir scroll vertical */
    touch-action: pan-y !important;
    overflow-y: auto;
}

/* Containers de conteúdo */
.container,
.container-fluid {
    width: 100%;
    padding-right: 16px;
    padding-left: 16px;
    margin-right: auto;
    margin-left: auto;
}

/* ========================================
   CARDS E CONTAINERS CLICÁVEIS
   ======================================== */
.card {
    background: white;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-bottom: 16px;
    /* Se tiver onclick, deve ser clicável */
    touch-action: manipulation;
}

.card[onclick],
.card[role="button"],
.clickable-card {
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.card[onclick]:active,
.card[role="button"]:active,
.clickable-card:active {
    transform: scale(0.98);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

/* ========================================
   MODAIS E OVERLAYS (MOBILE-FIRST)
   ======================================== */
.modal,
.modal-backdrop,
.overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    -webkit-overflow-scrolling: touch;
    overflow-y: auto;
}

.modal-backdrop {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-dialog {
    margin: 16px;
    max-width: calc(100% - 32px);
}

.modal-content {
    border-radius: 16px;
    border: none;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

/* ========================================
   NAVBAR E MENU (MOBILE-FIRST)
   ======================================== */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: white;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    z-index: 100;
    padding: 12px 16px;
}

/* Garantir que menu mobile seja clicável */
.mobile-menu-btn,
.navbar-toggler {
    width: 44px;
    height: 44px;
    padding: 0;
    border: none;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation !important;
    pointer-events: auto !important;
}

/* Menu mobile */
.mobile-menu {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 85vw;
    max-width: 320px;
    background: white;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    z-index: 1001;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.mobile-menu.active {
    transform: translateX(0);
}

/* Links do menu */
.nav-link,
.mobile-nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: #1e293b;
    text-decoration: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    touch-action: manipulation !important;
    pointer-events: auto !important;
    min-height: 44px;
}

.nav-link:active,
.mobile-nav-link:active {
    background: rgba(0, 0, 0, 0.05);
}

/* ========================================
   TABELAS (MOBILE-FIRST)
   ======================================== */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

/* Botões em tabelas */
table button,
table a.btn {
    min-height: 36px;
    min-width: 36px;
    padding: 8px 12px;
    font-size: 14px;
}

/* ========================================
   GRID SYSTEM (MOBILE-FIRST)
   ======================================== */
.row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -8px;
    margin-left: -8px;
}

[class*="col-"] {
    padding-right: 8px;
    padding-left: 8px;
    width: 100%;
}

/* ========================================
   UTILITIES (MOBILE-FIRST)
   ======================================== */
.d-none {
    display: none !important;
}

.d-block {
    display: block !important;
}

.d-flex {
    display: flex !important;
}

.text-center {
    text-align: center !important;
}

.mb-1 { margin-bottom: 4px !important; }
.mb-2 { margin-bottom: 8px !important; }
.mb-3 { margin-bottom: 16px !important; }
.mb-4 { margin-bottom: 24px !important; }
.mb-5 { margin-bottom: 32px !important; }

.mt-1 { margin-top: 4px !important; }
.mt-2 { margin-top: 8px !important; }
.mt-3 { margin-top: 16px !important; }
.mt-4 { margin-top: 24px !important; }
.mt-5 { margin-top: 32px !important; }

.p-1 { padding: 4px !important; }
.p-2 { padding: 8px !important; }
.p-3 { padding: 16px !important; }
.p-4 { padding: 24px !important; }
.p-5 { padding: 32px !important; }

/* ========================================
   FIX ESPECÍFICO: NAVBAR REVEAL ZONE
   ======================================== */
/* Esta zona NÃO DEVE bloquear cliques */
.navbar-reveal-zone {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 50px;
    z-index: 99;
    /* CRÍTICO: NÃO bloquear pointer events */
    pointer-events: none !important;
}

/* Botões flutuantes DEVEM estar acima de tudo */
.floating-menu-btn,
.floating-btn {
    position: fixed;
    z-index: 9999;
    /* CRÍTICO: Permitir cliques */
    pointer-events: auto !important;
    touch-action: manipulation !important;
}

/* ========================================
   MEDIA QUERIES - TABLET (≥ 640px)
   ======================================== */
@media (min-width: 640px) {
    .container {
        max-width: 640px;
    }

    .col-sm-6 {
        width: 50%;
    }

    .col-sm-12 {
        width: 100%;
    }
}

/* ========================================
   MEDIA QUERIES - DESKTOP PEQUENO (≥ 768px)
   ======================================== */
@media (min-width: 768px) {
    html {
        font-size: 18px;
    }

    .container {
        max-width: 768px;
    }

    .col-md-4 {
        width: 33.333333%;
    }

    .col-md-6 {
        width: 50%;
    }

    .col-md-8 {
        width: 66.666667%;
    }

    .col-md-12 {
        width: 100%;
    }

    /* Desktop: Áreas de toque podem ser menores */
    button:not(.mobile-menu-btn),
    .btn,
    [role="button"] {
        min-height: 38px;
        min-width: auto;
        padding: 10px 18px;
    }
}

/* ========================================
   MEDIA QUERIES - DESKTOP MÉDIO (≥ 1024px)
   ======================================== */
@media (min-width: 1024px) {
    .container {
        max-width: 1024px;
    }

    .col-lg-2 {
        width: 16.666667%;
    }

    .col-lg-3 {
        width: 25%;
    }

    .col-lg-4 {
        width: 33.333333%;
    }

    .col-lg-6 {
        width: 50%;
    }

    .col-lg-8 {
        width: 66.666667%;
    }

    .col-lg-12 {
        width: 100%;
    }

    /* Desktop: Esconder menu mobile */
    .mobile-menu-btn {
        display: none;
    }
}

/* ========================================
   MEDIA QUERIES - DESKTOP GRANDE (≥ 1280px)
   ======================================== */
@media (min-width: 1280px) {
    .container {
        max-width: 1280px;
    }
}

/* ========================================
   MEDIA QUERIES - DESKTOP XL (≥ 1536px)
   ======================================== */
@media (min-width: 1536px) {
    .container {
        max-width: 1536px;
    }
}

/* ========================================
   HOVER SUPPORT - Apenas para desktop com mouse
   ======================================== */
@media (hover: hover) and (pointer: fine) {
    button:hover,
    .btn:hover,
    a:hover,
    [role="button"]:hover {
        opacity: 0.9;
    }

    .card[onclick]:hover,
    .clickable-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    }
}

/* ========================================
   ANIMAÇÕES E TRANSIÇÕES
   ======================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ========================================
   DEBUG - Remover em produção
   ======================================== */
.debug-touch {
    outline: 2px dashed red !important;
}

.debug-clickable::before {
    content: "CLICKABLE";
    position: absolute;
    top: 0;
    left: 0;
    background: red;
    color: white;
    padding: 2px 4px;
    font-size: 10px;
    z-index: 99999;
}
