/* PWA Mobile Optimizations */

/* Detect PWA mode */
@media all and (display-mode: standalone) {
    /* Hide browser-specific elements in PWA mode */
    .browser-only {
        display: none !important;
    }
    
    /* Fix white space issue - remove body margin/padding */
    body {
        margin: 0 !important;
        padding: 0 !important;
    }
    
    /* Navbar positioning for PWA - handle status bar */
    .navbar {
        position: fixed !important;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        margin: 0;
        padding-top: env(safe-area-inset-top, 0);
    }
    
    /* Adjust main content for fixed navbar */
    .main-content {
        margin-top: calc(70px + env(safe-area-inset-top, 0));
    }
    
    /* Alternative: adjust body padding */
    body {
        padding-top: calc(70px + env(safe-area-inset-top, 0)) !important;
    }
    
    /* Adjust footer for bottom safe area */
    .footer {
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    /* Better touch targets for mobile */
    .btn, button, a.nav-link {
        min-height: 44px;
        min-width: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* iOS specific adjustments */
@supports (-webkit-touch-callout: none) {
    /* iOS Safari specific styles - minimal changes */
    body {
        -webkit-tap-highlight-color: transparent;
        -webkit-overflow-scrolling: touch;
    }
}

/* Mobile-first responsive design */
@media (max-width: 768px) {
    /* Prevent iOS zoom on form inputs only */
    input, select, textarea {
        font-size: 16px !important;
    }
    
    /* Container spacing - maintain web defaults */
    
    /* Stack elements vertically on mobile */
    .hero-buttons {
        flex-direction: column;
        width: 100%;
    }
    
    .hero-buttons > * {
        width: 100%;
        margin: 0.5rem 0;
    }
    
    /* Keep only iOS zoom prevention for inputs */
    
    /* Better card layouts on mobile */
    .card {
        margin-bottom: 1rem;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }
    
    /* Optimize tables for mobile */
    table {
        font-size: 14px;
    }
    
    /* Hide non-essential elements on small screens */
    .mobile-hide {
        display: none !important;
    }
}

/* Landscape orientation adjustments */
@media (orientation: landscape) and (max-height: 500px) {
    .navbar {
        padding-bottom: 5px;
    }
    
    .hero-content {
        padding: 1rem;
    }
    
    .modern-hero {
        min-height: auto;
        padding: 2rem 0;
    }
}

/* Dark mode support removed - maintain consistent web styling */
/* Use existing brand colors from brand_style.css */

/* Pull-to-refresh uses brand colors */
.pull-to-refresh {
    position: fixed;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--brand-primary, #A20C33);
    color: white;
    padding: 15px 30px;
    border-radius: 0 0 20px 20px;
    transition: top 0.3s ease;
    z-index: 9999;
}

.pull-to-refresh.show {
    top: 0;
}

/* App-like navigation transitions */
.page-transition {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Bottom navigation for app-like experience */
.bottom-nav {
    display: none;
}

@media all and (display-mode: standalone) and (max-width: 768px) {
    .bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background-color: var(--brand-primary, #A20C33);
        padding: 8px 0;
        padding-bottom: calc(8px + env(safe-area-inset-bottom));
        justify-content: space-around;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
        z-index: 1000;
    }
    
    .bottom-nav a {
        color: #ffffff;
        text-decoration: none;
        display: flex;
        flex-direction: column;
        align-items: center;
        font-family: 'Helvetica Neue', Arial, sans-serif;
        font-size: 11px;
        font-weight: 400;
        padding: 5px;
        transition: all 0.2s ease;
        position: relative;
    }
    
    .bottom-nav a:hover,
    .bottom-nav a:active {
        color: var(--brand-primary-25, #DB9397);
        text-decoration: none;
        transform: scale(0.95);
    }
    
    .bottom-nav a.active {
        color: #ffffff;
        font-weight: 500;
    }
    
    .bottom-nav a.active::after {
        content: '';
        position: absolute;
        bottom: -8px;
        left: 50%;
        transform: translateX(-50%);
        width: 30px;
        height: 3px;
        background: #ffffff;
        border-radius: 2px;
    }
    
    /* Special styling for action buttons */
    .bottom-nav a[data-action="calculate"] {
        background: rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        margin: 0 2px;
    }
    
    .bottom-nav a[data-action="save"],
    .bottom-nav a[data-action="exportPdf"] {
        font-weight: 500;
    }
    
    .bottom-nav a[data-action="goBack"] i {
        font-size: 24px;
    }
    
    .bottom-nav i {
        font-size: 20px;
        margin-bottom: 3px;
        color: inherit;
    }
    
    /* Adjust main content for bottom nav */
    .main-content {
        padding-bottom: calc(60px + env(safe-area-inset-bottom));
    }
    
    /* Hide desktop footer in PWA mobile mode */
    .footer {
        display: none;
    }
}