/**
 * APP Global Styles - MI FINCA EXPRESS
 * Estilos optimizados para experiencia de Web App / PWA
 */

/* Reset y Base */
* {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
}

/* Ocultar scrollbar en móvil pero mantener funcionalidad */
@media (max-width: 768px) {
    ::-webkit-scrollbar {
        width: 0px;
        background: transparent;
    }
}

/* Touch-friendly buttons */
button, .btn, a.button {
    min-height: 44px;
    min-width: 44px;
    touch-action: manipulation;
}

/* Prevenir zoom en inputs (iOS) */
input, select, textarea {
    font-size: 16px !important;
}

/* App Container */
.app-view {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* App Navigation Bar (Bottom) */
.app-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid #e2e8f0;
    padding: 0.5rem;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.25rem;
    z-index: 100;
    box-shadow: 0 -2px 16px rgba(0,0,0,0.1);
}

.nav-item-bottom {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem;
    text-decoration: none;
    color: #64748b;
    transition: all 0.3s;
    border-radius: 12px;
}

.nav-item-bottom.active {
    color: #667eea;
    background: rgba(102, 126, 234, 0.1);
}

.nav-item-icon {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.nav-item-label {
    font-size: 0.75rem;
    font-weight: 600;
}

/* Pull to refresh indicator */
.ptr-indicator {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%) translateY(-100%);
    background: white;
    padding: 1rem 2rem;
    border-radius: 0 0 16px 16px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    z-index: 1000;
    transition: transform 0.3s;
}

.ptr-indicator.active {
    transform: translateX(-50%) translateY(0);
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 8px;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-text {
    height: 1rem;
    margin: 0.5rem 0;
}

.skeleton-title {
    height: 1.5rem;
    width: 60%;
    margin: 0.5rem 0;
}

.skeleton-card {
    height: 200px;
    margin: 1rem 0;
}

/* Smooth transitions para navegación */
.page-transition {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Floating Action Button */
.fab {
    position: fixed;
    bottom: 80px;
    right: 1rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    font-size: 1.5rem;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
    cursor: pointer;
    transition: all 0.3s;
    z-index: 90;
}

.fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.fab:active {
    transform: scale(0.95);
}

/* Card styles app-like */
.card-app {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: all 0.3s;
    border: 1px solid transparent;
}

.card-app:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    border-color: #667eea;
}

/* App Header Styles */
.app-page-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.app-page-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
}

/* Bottom Safe Area (para notch de móviles) */
@supports (padding: max(0px)) {
    .app-bottom-nav {
        padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
    }
    
    body {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Optimize for iOS */
@supports (-webkit-overflow-scrolling: touch) {
    body {
        -webkit-overflow-scrolling: touch;
    }
}

/* Haptic feedback simulation */
@media (hover: none) and (pointer: coarse) {
    button:active, .btn:active {
        transform: scale(0.98);
    }
}

/* Toast Notifications (estilo app) */
.toast {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(0,0,0,0.9);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    font-weight: 600;
    z-index: 1000;
    transition: transform 0.3s;
    min-width: 200px;
    text-align: center;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.toast.success { background: rgba(16, 185, 129, 0.95); }
.toast.error { background: rgba(239, 68, 68, 0.95); }
.toast.info { background: rgba(59, 130, 246, 0.95); }

/* Disable text selection en elementos UI */
.nav-item-bottom,
.filter-btn,
.btn-continue,
button {
    user-select: none;
    -webkit-user-select: none;
}

/* Optimización de rendimiento */
.will-change-transform {
    will-change: transform;
}

.gpu-accelerated {
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

/* Status bar spacing (para cuando se instala como app) */
@media (display-mode: standalone) {
    body {
        padding-top: env(safe-area-inset-top);
    }
    
    .app-page-header {
        padding-top: calc(1rem + env(safe-area-inset-top));
    }
}

/* Esconder elementos del navegador en modo PWA */
@media (display-mode: standalone) {
    .hide-in-pwa {
        display: none !important;
    }
}

/* Responsive breakpoints para app */
@media (max-width: 640px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

/* Smooth animations */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

