/**
 * ShiftSwap Pro - Mobile Touch Enhancements
 * Optimized touch interactions and mobile-first design
 */

/* ==========================================================================
   MOBILE-FIRST FOUNDATION
   ========================================================================== */

/* Enhanced touch targets - minimum 48px for accessibility */
.btn, .button, .touch-target, 
button, input[type="submit"], input[type="button"],
.card-clickable, .shift-card, .action-button {
    min-height: 48px;
    min-width: 48px;
    padding: 12px 16px;
    position: relative;
    cursor: pointer;
    border-radius: 12px;
    transition: all 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
}

/* Touch feedback with haptic-style animation */
.touch-target:active, .btn:active, button:active,
.card-clickable:active, .shift-card:active {
    transform: scale(0.98);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
}

/* Enhanced focus states for keyboard navigation */
.touch-target:focus-visible, .btn:focus-visible, button:focus-visible {
    outline: 3px solid #2563eb;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

/* ==========================================================================
   SWIPE GESTURE SUPPORT
   ========================================================================== */

.swipe-container {
    position: relative;
    overflow: hidden;
    touch-action: pan-x;
}

.swipe-content {
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    will-change: transform;
}

.swipe-actions {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    display: flex;
    align-items: center;
    background: linear-gradient(90deg, #10b981, #059669);
    padding: 0 20px;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.swipe-container.swiping .swipe-actions {
    transform: translateX(0);
}

.swipe-action {
    color: white;
    background: none;
    border: none;
    padding: 8px 12px;
    border-radius: 8px;
    margin: 0 4px;
    min-height: 40px;
    min-width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.swipe-action:hover {
    background: rgba(255, 255, 255, 0.1);
}

.swipe-action.danger {
    background: #ef4444;
}

.swipe-action.danger:hover {
    background: #dc2626;
}

/* ==========================================================================
   ENHANCED SHIFT CARDS WITH MOBILE OPTIMIZATION
   ========================================================================== */

.shift-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
    touch-action: manipulation;
}

.shift-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.shift-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #2563eb, #3b82f6);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.shift-card:active::before,
.shift-card.selected::before {
    opacity: 1;
}

.shift-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.shift-position {
    font-size: 18px;
    font-weight: 600;
    color: #1e293b;
    margin: 0 0 4px 0;
}

.shift-employee {
    font-size: 14px;
    color: #64748b;
    margin: 0;
}

.shift-status {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.shift-status.available {
    background: #dcfce7;
    color: #166534;
}

.shift-status.pending {
    background: #fef3c7;
    color: #92400e;
}

.shift-status.taken {
    background: #fee2e2;
    color: #991b1b;
}

.shift-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 16px 0;
}

.shift-detail {
    display: flex;
    align-items: center;
    font-size: 14px;
    color: #475569;
}

.shift-detail-icon {
    width: 20px;
    height: 20px;
    margin-right: 8px;
    color: #64748b;
}

.shift-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #f1f5f9;
}

.shift-action-btn {
    flex: 1;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.shift-action-btn.primary {
    background: #2563eb;
    color: white;
}

.shift-action-btn.primary:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.shift-action-btn.secondary {
    background: #f8fafc;
    color: #475569;
    border: 1px solid #e2e8f0;
}

.shift-action-btn.secondary:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

/* ==========================================================================
   MOBILE NAVIGATION ENHANCEMENTS
   ========================================================================== */

.mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid #e2e8f0;
    padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
    z-index: 1000;
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.1);
}

.mobile-nav-list {
    display: flex;
    justify-content: space-around;
    list-style: none;
    margin: 0;
    padding: 0;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 12px;
    min-width: 64px;
    min-height: 56px;
    border-radius: 12px;
    transition: all 0.2s ease;
    text-decoration: none;
    color: #64748b;
    touch-action: manipulation;
}

.mobile-nav-item:hover,
.mobile-nav-item.active {
    background: #eff6ff;
    color: #2563eb;
    transform: translateY(-2px);
}

.mobile-nav-icon {
    width: 24px;
    height: 24px;
    margin-bottom: 4px;
}

.mobile-nav-label {
    font-size: 11px;
    font-weight: 500;
    text-align: center;
}

/* ==========================================================================
   PULL-TO-REFRESH INDICATOR
   ========================================================================== */

.pull-refresh-container {
    position: relative;
    overflow: hidden;
    touch-action: pan-y;
}

.pull-refresh-indicator {
    position: absolute;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    opacity: 0;
    z-index: 100;
}

.pull-refresh-indicator.pulling {
    opacity: 1;
    transform: translateX(-50%) translateY(60px);
}

.pull-refresh-indicator.refreshing {
    opacity: 1;
    transform: translateX(-50%) translateY(60px);
}

.pull-refresh-icon {
    width: 20px;
    height: 20px;
    color: #2563eb;
    transition: transform 0.3s ease;
}

.pull-refresh-indicator.refreshing .pull-refresh-icon {
    animation: spin 1s linear infinite;
}

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

/* ==========================================================================
   MOBILE-SPECIFIC IMPROVEMENTS
   ========================================================================== */

/* Improved form inputs for mobile */
input[type="text"], input[type="email"], input[type="password"],
input[type="tel"], input[type="search"], select, textarea {
    min-height: 48px;
    padding: 12px 16px;
    border-radius: 12px;
    border: 2px solid #e2e8f0;
    font-size: 16px; /* Prevents zoom on iOS */
    transition: all 0.2s ease;
    width: 100%;
    box-sizing: border-box;
    background: white;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

/* Mobile-optimized modals */
.modal-mobile {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-radius: 24px 24px 0 0;
    padding: 24px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    z-index: 1000;
}

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

.modal-handle {
    width: 40px;
    height: 4px;
    background: #cbd5e1;
    border-radius: 2px;
    margin: 0 auto 20px;
    cursor: grab;
}

/* Floating Action Button */
.fab {
    position: fixed;
    bottom: calc(80px + env(safe-area-inset-bottom));
    right: 20px;
    width: 56px;
    height: 56px;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    z-index: 999;
}

.fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.5);
}

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

.fab-icon {
    width: 24px;
    height: 24px;
}

/* ==========================================================================
   LOADING STATES AND ANIMATIONS
   ========================================================================== */

.loading-shimmer {
    background: linear-gradient(
        90deg,
        #f1f5f9 25%,
        #e2e8f0 50%,
        #f1f5f9 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite ease-in-out;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.loading-dots {
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: center;
}

.loading-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #2563eb;
    animation: loading-bounce 1.4s infinite ease-in-out both;
}

.loading-dot:nth-child(1) { animation-delay: -0.32s; }
.loading-dot:nth-child(2) { animation-delay: -0.16s; }
.loading-dot:nth-child(3) { animation-delay: 0s; }

@keyframes loading-bounce {
    0%, 80%, 100% { 
        transform: scale(0.7);
        opacity: 0.5;
    }
    40% { 
        transform: scale(1);
        opacity: 1;
    }
}

/* ==========================================================================
   SAFE AREA SUPPORT (iPhone notch, etc.)
   ========================================================================== */

.safe-area-padding {
    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);
}

/* Header with safe area */
.header-mobile {
    padding-top: calc(16px + env(safe-area-inset-top));
    background: white;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid #e2e8f0;
}

/* Bottom navigation with safe area */
.mobile-nav {
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
}

/* ==========================================================================
   RESPONSIVE UTILITIES
   ========================================================================== */

/* Hide on mobile */
@media (max-width: 768px) {
    .hide-mobile { display: none !important; }
    .show-desktop { display: none !important; }
}

/* Hide on desktop */
@media (min-width: 769px) {
    .hide-desktop { display: none !important; }
    .show-mobile { display: none !important; }
}

/* ==========================================================================
   ACCESSIBILITY ENHANCEMENTS
   ========================================================================== */

/* High contrast mode support */
@media (prefers-contrast: high) {
    .shift-card {
        border: 2px solid #1e293b;
    }
    
    .btn, .button {
        border: 2px solid currentColor;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .shift-card {
        background: #1e293b;
        border-color: #334155;
        color: #f8fafc;
    }
    
    .shift-position {
        color: #f8fafc;
    }
    
    .shift-employee {
        color: #cbd5e1;
    }
    
    .mobile-nav {
        background: #1e293b;
        border-color: #334155;
    }
    
    .mobile-nav-item {
        color: #cbd5e1;
    }
    
    .mobile-nav-item:hover,
    .mobile-nav-item.active {
        background: #334155;
        color: #60a5fa;
    }
}
