/* Mobile Utilities - Swipe and Touch Behaviors */
/* Provides safe swipe scrolling for mobile content */

/* ============================================================================
   SWIPEABLE HORIZONTAL SCROLL
   ============================================================================ */

.mobile-swipe-container {
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

.mobile-swipe-container::-webkit-scrollbar {
    display: none; /* Chrome/Safari/Opera */
}

/* Swipeable list items */
.mobile-swipe-list {
    display: flex;
    gap: 1rem;
    padding: 0.5rem 0;
}

.mobile-swipe-list > * {
    flex-shrink: 0;
}

/* ============================================================================
   VERTICAL SWIPE (for lists with swipe actions)
   ============================================================================ */

.mobile-swipe-item {
    position: relative;
    overflow: hidden;
    touch-action: pan-y;
}

.mobile-swipe-item-content {
    position: relative;
    background: var(--mobile-card-bg, #fff);
    transition: transform 0.2s ease;
    z-index: 2;
}

.mobile-swipe-item-actions {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0 0.75rem;
    z-index: 1;
}

.mobile-swipe-action-button {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.mobile-swipe-action-button.danger {
    background: #ef4444;
    color: white;
}

.mobile-swipe-action-button.primary {
    background: #3b82f6;
    color: white;
}

.mobile-swipe-action-button:active {
    transform: scale(0.95);
}

/* ============================================================================
   PULL TO REFRESH
   ============================================================================ */

.mobile-pull-to-refresh {
    position: relative;
    overflow: hidden;
}

.mobile-pull-indicator {
    position: absolute;
    top: -60px;
    left: 0;
    right: 0;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
    color: var(--mobile-text-secondary, #6b7280);
}

.mobile-pull-indicator.pulling {
    transform: translateY(60px);
}

.mobile-pull-indicator.refreshing {
    transform: translateY(60px);
}

.mobile-pull-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================================================
   SAFE AREA INSETS (for notched devices)
   ============================================================================ */

.mobile-safe-top {
    padding-top: env(safe-area-inset-top);
}

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

.mobile-safe-left {
    padding-left: env(safe-area-inset-left);
}

.mobile-safe-right {
    padding-right: env(safe-area-inset-right);
}

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

/* ============================================================================
   TOUCH-FRIENDLY INTERACTIONS
   ============================================================================ */

.mobile-touch-target {
    min-height: 44px; /* iOS minimum touch target */
    min-width: 44px;
}

.mobile-tap-highlight {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
}

.mobile-no-tap-highlight {
    -webkit-tap-highlight-color: transparent;
}

/* Prevent text selection during swipe */
.mobile-no-select {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* ============================================================================
   MOMENTUM SCROLLING (iOS)
   ============================================================================ */

.mobile-momentum-scroll {
    -webkit-overflow-scrolling: touch;
    overflow-scrolling: touch;
}

/* ============================================================================
   SNAP SCROLLING
   ============================================================================ */

.mobile-snap-x {
    scroll-snap-type: x mandatory;
    scroll-snap-stop: always;
}

.mobile-snap-y {
    scroll-snap-type: y mandatory;
    scroll-snap-stop: always;
}

.mobile-snap-start {
    scroll-snap-align: start;
}

.mobile-snap-center {
    scroll-snap-align: center;
}

.mobile-snap-end {
    scroll-snap-align: end;
}

/* ============================================================================
   EDGE FADE HINTS (for overflow indication)
   ============================================================================ */

.mobile-fade-left {
    position: relative;
}

.mobile-fade-left::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 40px;
    background: linear-gradient(to right, var(--mobile-bg, #fff), transparent);
    pointer-events: none;
    z-index: 10;
}

.mobile-fade-right {
    position: relative;
}

.mobile-fade-right::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 40px;
    background: linear-gradient(to left, var(--mobile-bg, #fff), transparent);
    pointer-events: none;
    z-index: 10;
}

/* ============================================================================
   RESPONSIVE GRID WITH SWIPE
   ============================================================================ */

.mobile-grid-swipe {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
    gap: 1rem;
    padding: 1rem 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.mobile-grid-swipe::-webkit-scrollbar {
    display: none;
}

.mobile-grid-swipe > * {
    flex: 0 0 auto;
    width: calc(100% - 3rem); /* Full width minus padding */
    scroll-snap-align: start;
}

@media (min-width: 640px) {
    .mobile-grid-swipe > * {
        width: calc(50% - 1.5rem); /* Half width on tablets */
    }
}

@media (min-width: 1024px) {
    .mobile-grid-swipe > * {
        width: calc(33.333% - 1rem); /* Third width on desktop */
    }
}

/* ============================================================================
   BOTTOM ACTION SHEET
   ============================================================================ */

.mobile-bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--mobile-card-bg, #fff);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    transform: translateY(100%);
    transition: transform 0.3s ease;
    z-index: 1000;
    max-height: 85vh;
    overflow-y: auto;
}

.mobile-bottom-sheet.open {
    transform: translateY(0);
}

.mobile-bottom-sheet-handle {
    width: 40px;
    height: 4px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 2px;
    margin: 12px auto;
}

/* ============================================================================
   RESPONSIVE BREAKPOINTS FOR TOUCH
   ============================================================================ */

@media (hover: none) and (pointer: coarse) {
    /* Touch device only styles */
    .mobile-hover-none .hover\\:opacity-80:hover {
        opacity: 1; /* Disable hover effects on touch */
    }

    /* Increase button sizes for touch */
    button:not(.btn-sm) {
        min-height: 44px;
        min-width: 44px;
    }
}

/* ============================================================================
   PREVENT OVERSCROLL BOUNCE (iOS Safari)
   ============================================================================ */

.mobile-no-bounce {
    overscroll-behavior: none;
}

.mobile-no-bounce-y {
    overscroll-behavior-y: none;
}

.mobile-no-bounce-x {
    overscroll-behavior-x: none;
}
