/* ========================================
   APP MOBILE - Experiência Nativa
   ======================================== */

/* ---- Safe Area para notch/barra do celular ---- */
:root {
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --bottom-nav-height: 64px;
}

/* ---- Body ajuste para bottom nav ---- */
body.app-mode {
    padding-bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + 8px);
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    overscroll-behavior-y: contain;
}

/* ---- Status Bar Overlay (standalone) ---- */
@media all and (display-mode: standalone) {
    body.app-mode {
        padding-top: var(--safe-top);
    }
    
    .header {
        padding-top: calc(0.5rem + var(--safe-top)) !important;
    }
}

/* ---- Bottom Navigation Bar ---- */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--bottom-nav-height) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: var(--bg-primary, #ffffff);
    border-top: 1px solid var(--border, #e5e7eb);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 9999;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s ease;
}

[data-theme="dark"] .bottom-nav {
    background: #1a1a2e;
    border-top-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
}

.bottom-nav.hidden {
    transform: translateY(100%);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--text-secondary, #6b7280);
    font-size: 10px;
    font-weight: 500;
    gap: 2px;
    padding: 6px 12px;
    border-radius: 12px;
    transition: all 0.2s ease;
    position: relative;
    min-width: 56px;
    -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item:active {
    transform: scale(0.92);
}

.bottom-nav-item.active {
    color: var(--primary, #6366f1);
}

.bottom-nav-item.active .nav-icon {
    background: linear-gradient(135deg, var(--primary, #6366f1), var(--secondary, #ec4899));
    color: white;
    border-radius: 14px;
    padding: 4px 16px;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
}

.nav-icon {
    font-size: 22px;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 10px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-label {
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.nav-badge {
    position: absolute;
    top: 0;
    right: 4px;
    background: var(--danger, #ef4444);
    color: white;
    font-size: 9px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    box-shadow: 0 1px 3px rgba(239, 68, 68, 0.4);
}

/* ---- FAB - Floating Action Button ---- */
.fab-new-chamado {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + 16px);
    right: 16px;
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--primary, #6366f1), var(--secondary, #ec4899));
    color: white;
    border: none;
    font-size: 28px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.fab-new-chamado:active {
    transform: scale(0.9);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

/* ---- Pull to Refresh Indicator ---- */
.pull-indicator {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%) translateY(-100%);
    background: var(--primary);
    color: white;
    padding: 8px 20px;
    border-radius: 0 0 16px 16px;
    font-size: 13px;
    font-weight: 500;
    z-index: 10000;
    transition: transform 0.3s ease;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.pull-indicator.visible {
    transform: translateX(-50%) translateY(0);
}

/* ---- Page Transition ---- */
.page-transition {
    animation: pageSlideIn 0.3s ease forwards;
}

@keyframes pageSlideIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---- Header compacto mobile ---- */
@media (max-width: 768px) {
    .header {
        padding: 0.6rem 0 !important;
    }

    .header-content {
        padding: 0 1rem !important;
        gap: 0.5rem !important;
    }

    .header h1 {
        font-size: 16px !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .user-info {
        gap: 0.5rem !important;
    }

    .user-name {
        display: none !important;
    }

    .btn-logout {
        padding: 4px 10px !important;
        font-size: 12px !important;
    }

    /* Container sem padding lateral excessivo */
    .container {
        padding: 0 !important;
    }

    .content {
        padding: 0.5rem !important;
    }

    /* Welcome section compacta */
    .welcome-section {
        padding: 1rem !important;
        margin-bottom: 0.5rem !important;
    }

    .welcome-content h1 {
        font-size: 18px !important;
    }

    .welcome-content p {
        font-size: 13px !important;
        margin-bottom: 0.75rem !important;
    }

    /* Quick actions em grid 3 colunas */
    .quick-actions {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 8px !important;
    }

    .quick-action-btn {
        font-size: 12px !important;
        padding: 10px 6px !important;
        text-align: center !important;
        border-radius: 12px !important;
        flex-direction: column !important;
        display: flex !important;
        align-items: center !important;
        gap: 2px !important;
    }

    /* Cards de chamados */
    .chamado-card, .ticket-card {
        margin: 0 0 8px 0 !important;
        border-radius: 12px !important;
    }

    /* Sidebar filtros como drawer */
    .sidebar {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 85% !important;
        max-width: 320px !important;
        height: 100vh !important;
        z-index: 10000 !important;
        transform: translateX(-100%) !important;
        transition: transform 0.3s ease !important;
        background: var(--bg-primary) !important;
        box-shadow: 4px 0 20px rgba(0,0,0,0.15) !important;
        overflow-y: auto !important;
        padding: 1rem !important;
    }

    .sidebar.open {
        transform: translateX(0) !important;
    }

    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 9999;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }

    .sidebar-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    /* Mobile action bar esconder (bottom nav substitui) */
    .mobile-action-bar {
        display: none !important;
    }

    /* Esconder botão PWA install se já instalado */
    @media all and (display-mode: standalone) {
        #pwa-install-btn {
            display: none !important;
        }
    }

    /* Formulários mobile */
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px !important; /* Evita zoom no iOS */
        border-radius: 10px !important;
    }

    /* Botões touch-friendly */
    .btn, button, .quick-action-btn, a.btn {
        min-height: 44px;
    }
}

/* ---- Animações de toque ---- */
.touch-ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(99, 102, 241, 0.15);
    transform: scale(0);
    animation: ripple 0.5s ease-out;
    pointer-events: none;
}

@keyframes ripple {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* ---- Toast Notifications Mobile ---- */
.toast-mobile {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + 20px);
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #1f2937;
    color: white;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    z-index: 10001;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 90vw;
    text-align: center;
}

.toast-mobile.show {
    transform: translateX(-50%) translateY(0);
}

/* ---- Skeleton Loading ---- */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
}

[data-theme="dark"] .skeleton {
    background: linear-gradient(90deg, #2a2a3e 25%, #3a3a4e 50%, #2a2a3e 75%);
    background-size: 200% 100%;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* ---- Swipe Action Hint ---- */
.swipe-hint {
    position: absolute;
    right: -60px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--primary);
    color: white;
    padding: 8px;
    border-radius: 8px;
    font-size: 18px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

/* ---- Empty State Mobile ---- */
.empty-state-mobile {
    text-align: center;
    padding: 3rem 1.5rem;
}

.empty-state-mobile .empty-icon {
    font-size: 64px;
    margin-bottom: 1rem;
    opacity: 0.6;
}

.empty-state-mobile h3 {
    font-size: 18px;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.empty-state-mobile p {
    color: var(--text-secondary);
    font-size: 14px;
}
