/**
 * PWA-Specific Enhancements for Mobile Experience
 */

/* PWA Status Bar Area - Safe Area Insets */
@supports (padding: max(0px)) {
    body {
        padding-top: max(env(safe-area-inset-top), 0px);
        padding-bottom: max(env(safe-area-inset-bottom), 0px);
    }
    
    header {
        padding-top: max(env(safe-area-inset-top), 0.5rem);
    }
}

/* PWA Standalone Mode Enhancements */
.pwa-standalone {
    /* Remove browser UI padding */
    padding-top: 0;
}

.pwa-standalone header {
    /* Better header in standalone mode */
    padding-top: max(env(safe-area-inset-top), 0.5rem);
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
    body {
        /* Prevent text selection on iOS */
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }
    
    input,
    textarea,
    [contenteditable] {
        -webkit-user-select: text;
        user-select: text;
    }
    
    /* Fix iOS input zoom */
    @media screen and (max-width: 768px) {
        input[type="text"],
        input[type="email"],
        input[type="password"],
        input[type="number"],
        input[type="tel"],
        input[type="url"],
        input[type="date"],
        input[type="datetime-local"],
        select,
        textarea {
            font-size: 16px !important;
        }
    }
}

/* Prevent pull-to-refresh on mobile */
@media (hover: none) and (pointer: coarse) {
    body {
        overscroll-behavior-y: none;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Better scrolling on mobile */
    main,
    .container {
        -webkit-overflow-scrolling: touch;
    }
}

/* App-like loading states */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* Smooth transitions for PWA */
* {
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* Better focus states for accessibility */
button:focus,
a:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Hide browser UI elements in standalone mode */
@media (display-mode: standalone) {
    .pwa-install-button {
        display: none !important;
    }
}

/* PWA Install Button Styles */
.pwa-install-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    padding: 1rem 1.5rem;
    font-size: 1rem;
    border-radius: 50px;
    animation: slideUp 0.3s ease-out;
    min-width: 44px;
    min-height: 44px;
}

.pwa-install-button:hover {
    transform: scale(1.05);
}

@keyframes slideUp {
    from {
        transform: translateY(100px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Better mobile scrolling */
@media (hover: none) and (pointer: coarse) {
    html {
        -webkit-overflow-scrolling: touch;
    }
    
    body {
        overflow-x: hidden;
    }
}

/* Status bar styling */
@media (display-mode: standalone) {
    body {
        background-color: #4CAF50;
    }
}
