/* 📱 Advanced Mobile Optimizations for 물금 To Go */

/* Touch-friendly interactions */
.touch-target {
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Improved button press feedback */
.btn, .card, .list-group-item {
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn:active, .card:active, .list-group-item:active {
    transform: scale(0.98);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Enhanced loading states with skeleton screens */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
}

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

.skeleton-card {
    height: 200px;
    border-radius: 8px;
    margin-bottom: 16px;
}

.skeleton-text {
    height: 16px;
    border-radius: 4px;
    margin-bottom: 8px;
}

.skeleton-text:nth-child(even) {
    width: 80%;
}

/* Optimized images for mobile */
.responsive-image {
    width: 100%;
    height: auto;
    border-radius: 8px;
    transition: opacity 0.3s ease;
}

.responsive-image[data-src]:not([src]) {
    opacity: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 200px;
}

.responsive-image.loaded {
    opacity: 1;
}

/* Improved form inputs for mobile */
.form-control {
    font-size: 16px; /* Prevents zoom on iOS */
    border-radius: 8px;
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    transition: all 0.2s ease;
}

.form-control:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
    outline: none;
}

/* Bottom navigation for mobile */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid #e9ecef;
    display: flex;
    z-index: 1000;
    padding: 8px 0;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
}

.mobile-bottom-nav.hidden {
    transform: translateY(100%);
}

.mobile-nav-item {
    flex: 1;
    text-align: center;
    padding: 8px 4px;
    text-decoration: none;
    color: #6c757d;
    font-size: 12px;
    transition: color 0.2s ease;
}

.mobile-nav-item.active {
    color: #007bff;
}

.mobile-nav-item i {
    font-size: 20px;
    display: block;
    margin-bottom: 4px;
}

/* Safe area handling for iPhone X+ */
@supports(padding: max(0px)) {
    .mobile-bottom-nav {
        padding-bottom: max(8px, env(safe-area-inset-bottom));
    }
    
    .container-fluid {
        padding-left: max(15px, env(safe-area-inset-left));
        padding-right: max(15px, env(safe-area-inset-right));
    }
}

/* Improved modal for mobile */
.modal-dialog {
    margin: 16px;
    max-width: calc(100vw - 32px);
}

@media (max-width: 576px) {
    .modal-dialog {
        margin: 8px;
        max-width: calc(100vw - 16px);
    }
    
    .modal-content {
        border-radius: 12px;
    }
}

/* Pull-to-refresh indicator */
.pull-to-refresh {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #007bff;
    font-size: 14px;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

.pull-to-refresh.visible {
    transform: translateY(0);
}

.pull-to-refresh .spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #e9ecef;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 8px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Optimized card layout for mobile */
.mobile-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    padding: 16px;
}

@media (max-width: 576px) {
    .mobile-card-grid {
        grid-template-columns: 1fr;
        gap: 12px;
        padding: 12px;
    }
}

/* Floating action button */
.fab {
    position: fixed;
    bottom: 80px; /* Above mobile nav */
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #007bff;
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    z-index: 1000;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.fab:hover, .fab:focus {
    background: #0056b3;
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 123, 255, 0.6);
}

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

.fab-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #dc3545;
    color: white;
    border-radius: 50%;
    min-width: 20px;
    height: 20px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

/* Improved sticky header */
.sticky-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

/* Swipe gestures support */
.swipeable {
    touch-action: pan-y;
    transform: translateX(0);
    transition: transform 0.3s ease;
}

.swipeable.swiping {
    transition: none;
}

/* Improved search bar for mobile */
.mobile-search {
    position: relative;
    background: #f8f9fa;
    border-radius: 25px;
    padding: 0;
    border: none;
    overflow: hidden;
}

.mobile-search input {
    border: none;
    background: transparent;
    padding: 12px 16px 12px 48px;
    font-size: 16px;
}

.mobile-search .search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
}

/* Accessibility improvements */
@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) {
    .mobile-bottom-nav {
        background: #1a1a1a;
        border-top-color: #333;
    }
    
    .mobile-nav-item {
        color: #aaa;
    }
    
    .mobile-nav-item.active {
        color: #4dabf7;
    }
    
    .sticky-header {
        background: rgba(26, 26, 26, 0.95);
        border-bottom-color: rgba(255,255,255,0.1);
    }
}

/* Performance optimizations */
.will-change-transform {
    will-change: transform;
}

.will-change-opacity {
    will-change: opacity;
}

/* Remove will-change after animation */
.animation-complete {
    will-change: auto;
}

/* Improved error states */
.error-state {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
}

.error-state i {
    font-size: 48px;
    margin-bottom: 16px;
    color: #dc3545;
}

.error-state h4 {
    margin-bottom: 8px;
    color: #495057;
}

.error-state p {
    margin-bottom: 20px;
    font-size: 14px;
}
