/**
 * Mobile-specific CSS utilities for RailScanPro PWA
 * Includes safe area support for iPhone notch/Dynamic Island
 */

/* ============================================
   Safe Area Utilities (iPhone notch support)
   ============================================ */

/* Safe area padding - works with env() for modern browsers */
.safe-area-top {
    padding-top: env(safe-area-inset-top, 0px);
}

.safe-area-bottom {
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.safe-area-left {
    padding-left: env(safe-area-inset-left, 0px);
}

.safe-area-right {
    padding-right: env(safe-area-inset-right, 0px);
}

.safe-area-all {
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
}

/* ============================================
   Mobile Touch Targets
   ============================================ */

/* Minimum 48x48px touch targets per WCAG 2.1 AA */
.touch-target {
    min-width: 48px;
    min-height: 48px;
}

.touch-target-lg {
    min-width: 56px;
    min-height: 56px;
}

/* ============================================
   Mobile Bottom Navigation Styling
   ============================================ */

.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* ============================================
   Mobile-specific overrides
   ============================================ */

@media (max-width: 767px) {
    /* Larger tap targets on mobile */
    button,
    a,
    [role="button"] {
        min-height: 44px;
    }

    /* Prevent zoom on input focus (iOS) */
    input,
    select,
    textarea {
        font-size: 16px;
    }

    /* Hide desktop-only elements on mobile */
    .desktop-only {
        display: none !important;
    }

    /* Ensure proper scrolling on iOS */
    .scroll-container {
        -webkit-overflow-scrolling: touch;
        overflow-y: auto;
    }

    /* Prevent body scroll when modal is open */
    body.modal-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
        height: 100%;
    }

    /* Full-width cards on mobile */
    .mobile-full-width {
        width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        border-radius: 0 !important;
    }

    /* Horizontal scroll for filter chips */
    .filter-chips-container {
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        gap: 0.5rem;
        padding-bottom: 0.5rem;
    }

    .filter-chips-container::-webkit-scrollbar {
        display: none;
    }

    /* Sticky search bar */
    .mobile-sticky-search {
        position: sticky;
        top: 56px; /* Height of mobile header */
        z-index: 40;
        background: var(--surface-primary);
        padding: 0.75rem 1rem;
        border-bottom: 1px solid var(--border-secondary);
    }
}

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

.pull-to-refresh-indicator {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%) translateY(-100%);
    transition: transform 0.2s ease-out;
    z-index: 100;
    padding: 1rem;
}

.pull-to-refresh-indicator.active {
    transform: translateX(-50%) translateY(0);
}

/* ============================================
   Floating Action Button (FAB)
   ============================================ */

.fab {
    position: fixed;
    bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px)); /* Above bottom nav */
    right: 1rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 45;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.fab:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

.fab:active {
    transform: scale(0.95);
}

/* Hide FAB on desktop */
@media (min-width: 768px) {
    .fab.mobile-only {
        display: none;
    }
}

/* ============================================
   Mobile Card Layout
   ============================================ */

.mobile-card {
    background: var(--surface-secondary);
    border-radius: 0.75rem;
    padding: 1rem;
    margin-bottom: 0.75rem;
}

.mobile-card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.mobile-card-thumbnail {
    width: 48px;
    height: 48px;
    border-radius: 0.5rem;
    object-fit: cover;
    background: var(--surface-tertiary);
}

.mobile-card-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-emphasis);
}

.mobile-card-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ============================================
   Mobile List Item
   ============================================ */

.mobile-list-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-secondary);
}

.mobile-list-item:active {
    background: var(--surface-tertiary);
}

/* ============================================
   Swipe Actions (future)
   ============================================ */

.swipeable-row {
    position: relative;
    overflow: hidden;
}

.swipe-action-left,
.swipe-action-right {
    position: absolute;
    top: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 80px;
}

.swipe-action-left {
    left: 0;
    background: var(--status-success);
}

.swipe-action-right {
    right: 0;
    background: var(--status-error);
}

/* ============================================
   PWA Install Prompt
   ============================================ */

.pwa-install-prompt {
    position: fixed;
    bottom: calc(5rem + env(safe-area-inset-bottom, 0px));
    left: 1rem;
    right: 1rem;
    background: var(--surface-secondary);
    border: 1px solid var(--border-secondary);
    border-radius: 1rem;
    padding: 1rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    z-index: 60;
    animation: slideUp 0.3s ease-out;
}

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