/* ========================================
   AppGold - Mobile Optimizations
   100% adaptado para mobile
   ======================================== */

/* ========================================
   Base Mobile Optimizations
   ======================================== */

/* Prevent text selection and callouts */
* {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Allow text selection in inputs */
input, textarea {
    -webkit-user-select: text;
    user-select: text;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Better touch targets */
button, a, .clickable {
    min-height: 44px;
    min-width: 44px;
}

/* ========================================
   Safe Area Support (iPhone X+)
   ======================================== */

.app-container {
    padding-top: env(safe-area-inset-top);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

.bottom-nav {
    padding-bottom: max(var(--space-sm), env(safe-area-inset-bottom));
}

.modal {
    padding-bottom: env(safe-area-inset-bottom);
}

/* ========================================
   Touch Feedback
   ======================================== */

.btn, .nav-item, .signal-card, .task-card, .strategy-card, .menu-item {
    transition: transform 0.1s ease, opacity 0.1s ease;
}

@media (hover: none) and (pointer: coarse) {
    .btn:active,
    .nav-item:active,
    .signal-card:active,
    .task-card:active,
    .strategy-card:active,
    .menu-item:active {
        transform: scale(0.97);
        opacity: 0.8;
    }
    
    /* Remove hover effects on touch devices */
    .btn:hover,
    .nav-item:hover,
    .signal-card:hover {
        transform: none;
    }
}

/* ========================================
   Pull to Refresh Indicator
   ======================================== */

.pull-indicator {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%) translateY(-100%);
    background: var(--bg-card);
    padding: var(--space-sm) var(--space-lg);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    box-shadow: var(--shadow-md);
    z-index: var(--z-modal);
    transition: transform 0.3s ease;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.pull-indicator.visible {
    transform: translateX(-50%) translateY(env(safe-area-inset-top));
}

.pull-indicator i {
    animation: spin 1s linear infinite;
}

/* ========================================
   Keyboard Handling
   ======================================== */

/* When keyboard is visible */
body.keyboard-visible .bottom-nav {
    display: none;
}

body.keyboard-visible .app-container {
    padding-bottom: 0;
}

/* Input focus states */
input:focus, textarea:focus, select:focus {
    font-size: 16px; /* Prevents zoom on iOS */
}

/* ========================================
   Scrollable Areas
   ======================================== */

.signals-container,
.marketplace-categories,
.filter-tabs {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
}

.signals-container > *,
.marketplace-categories > *,
.filter-tabs > * {
    scroll-snap-align: start;
}

.signals-container::-webkit-scrollbar,
.marketplace-categories::-webkit-scrollbar,
.filter-tabs::-webkit-scrollbar {
    display: none;
}

/* ========================================
   Modal Optimizations
   ======================================== */

.modal {
    max-height: calc(100vh - env(safe-area-inset-top));
    max-height: calc(100dvh - env(safe-area-inset-top));
}

.modal-content {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    max-height: calc(80vh - 80px);
}

/* Full screen modal on mobile */
@media (max-width: 480px) {
    .modal.modal-large {
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0;
    }
    
    .modal.modal-large .modal-content {
        max-height: calc(100vh - 60px);
        max-height: calc(100dvh - 60px);
    }
}

/* ========================================
   Navigation Optimizations
   ======================================== */

.bottom-nav {
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-xs) var(--space-sm);
    min-width: 60px;
}

.nav-item i {
    font-size: 1.25rem;
    margin-bottom: 2px;
}

.nav-item span {
    font-size: 0.65rem;
    font-weight: 500;
}

/* Center nav button */
.nav-center-btn {
    width: 52px;
    height: 52px;
    box-shadow: 0 -4px 20px rgba(245, 166, 35, 0.4);
}

/* ========================================
   Card Optimizations
   ======================================== */

.balance-card {
    margin: 0 -var(--space-md);
    border-radius: 0;
    border-left: none;
    border-right: none;
}

@media (min-width: 480px) {
    .balance-card {
        margin: 0;
        border-radius: var(--radius-xl);
        border: 1px solid var(--border);
    }
}

/* ========================================
   Form Optimizations
   ======================================== */

.input-wrapper input {
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 14px 48px 14px 48px;
}

.form-group {
    margin-bottom: var(--space-md);
}

/* ========================================
   Text Optimizations
   ======================================== */

/* Prevent font boosting on Android */
body {
    max-height: 999999px;
}

/* Readable font sizes */
.balance-amount .amount {
    font-size: clamp(2rem, 8vw, 2.5rem);
}

.section-title {
    font-size: clamp(1rem, 4vw, 1.125rem);
}

/* ========================================
   Performance Optimizations
   ======================================== */

/* Use GPU acceleration for smooth animations */
.animate-fadeIn,
.animate-fadeInUp,
.animate-scaleIn,
.modal,
.notification-panel,
.support-chat {
    will-change: transform, opacity;
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Reduce animations for battery saving */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ========================================
   Landscape Mode Handling
   ======================================== */

@media (orientation: landscape) and (max-height: 500px) {
    .splash-screen .logo-icon {
        width: 60px;
        height: 60px;
    }
    
    .splash-screen .logo-icon i {
        font-size: 30px;
    }
    
    .splash-screen .logo-text {
        font-size: 1.75rem;
    }
    
    .login-container {
        padding: var(--space-md);
        max-width: 600px;
    }
    
    .login-header {
        margin-bottom: var(--space-md);
    }
    
    .login-header .logo-icon {
        width: 60px;
        height: 60px;
    }
}

/* ========================================
   Small Screen Optimizations
   ======================================== */

@media (max-width: 360px) {
    :root {
        --space-md: 12px;
        --space-lg: 20px;
    }
    
    .balance-amount .amount {
        font-size: 1.75rem;
    }
    
    .quick-stats {
        grid-template-columns: repeat(3, 1fr);
        gap: var(--space-xs);
    }
    
    .stat-card {
        padding: var(--space-sm);
    }
    
    .stat-value {
        font-size: 1rem;
    }
    
    .nav-item span {
        font-size: 0.6rem;
    }
}

/* ========================================
   Large Screen (Tablet) Optimizations
   ======================================== */

@media (min-width: 768px) {
    .app-container {
        max-width: 768px;
        margin: 0 auto;
    }
    
    .bottom-nav {
        max-width: 768px;
        left: 50%;
        transform: translateX(-50%);
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }
    
    .quick-stats {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .signals-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .plans-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ========================================
   PWA Standalone Mode
   ======================================== */

@media (display-mode: standalone) {
    /* Hide browser UI hints */
    .install-banner {
        display: none !important;
    }
    
    /* Full height on PWA */
    body {
        height: 100vh;
        height: 100dvh;
        overflow: hidden;
    }
    
    .app-container {
        height: 100vh;
        height: 100dvh;
    }
    
    .main-content {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ========================================
   iOS Specific Fixes
   ======================================== */

@supports (-webkit-touch-callout: none) {
    /* iOS input styling */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="tel"],
    input[type="number"],
    textarea,
    select {
        -webkit-appearance: none;
        appearance: none;
        border-radius: var(--radius-md);
    }
    
    /* Fix iOS scroll bounce */
    .main-content {
        overscroll-behavior-y: contain;
    }
    
    /* Fix iOS 100vh issue */
    .app-container,
    .login-screen {
        min-height: -webkit-fill-available;
    }
}

/* ========================================
   Android Specific Fixes
   ======================================== */

@supports not (-webkit-touch-callout: none) {
    /* Android specific styles */
    .bottom-nav {
        padding-bottom: var(--space-sm);
    }
}

/* ========================================
   Dark Mode Status Bar
   ======================================== */

@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
    }
}

/* ========================================
   Haptic Feedback Indicators
   ======================================== */

.haptic-feedback {
    position: relative;
}

.haptic-feedback::after {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--primary);
    opacity: 0;
    border-radius: inherit;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

.haptic-feedback:active::after {
    opacity: 0.1;
}

/* ========================================
   Loading States for Mobile
   ======================================== */

.skeleton-mobile {
    background: linear-gradient(
        90deg,
        var(--bg-input) 0%,
        var(--bg-card-hover) 50%,
        var(--bg-input) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}

/* ========================================
   Offline Mode Styling
   ======================================== */

body.offline .main-content {
    opacity: 0.7;
}

body.offline .btn-primary,
body.offline .btn-gold {
    opacity: 0.5;
    pointer-events: none;
}

.offline-message {
    position: fixed;
    top: env(safe-area-inset-top);
    left: 0;
    right: 0;
    background: var(--warning);
    color: var(--bg-dark);
    text-align: center;
    padding: var(--space-xs) var(--space-md);
    font-size: 0.75rem;
    font-weight: 600;
    z-index: 9999;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

body.offline .offline-message {
    transform: translateY(0);
}

