/* ========== MOBILE UX ENHANCEMENTS ========== */

/* Улучшенные размеры тач-таргетов */
@media (max-width: 768px) {
    /* Минимальные размеры для тач-элементов */
    a:not(.exchange-reverse), button:not(.exchange-reverse), input, select, textarea, .clickable {
        min-height: 44px;
        min-width: 44px;
    }

    /* Исключение для кнопки реверса */
    .exchange-reverse {
        min-height: unset !important;
        min-width: unset !important;
    }

    /* Увеличенные отступы для лучшего тапа */
    .nav-link,
    .footer-links a,
    .currency-option {
        padding: 16px 0;
    }

    /* Безопасная зона для устройств с вырезами */
    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }

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

    .footer {
        padding-bottom: calc(30px + env(safe-area-inset-bottom));
    }
}

/* ========== LOADING INDICATORS ========== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-top-color: #000;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ========== SKELETON LOADERS ========== */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
}

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

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

.skeleton-title {
    height: 24px;
    margin-bottom: 16px;
    border-radius: 4px;
    width: 60%;
}

/* ========== BOTTOM SHEET ========== */
.bottom-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: white;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    padding: 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1001;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.1);
}

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

.bottom-sheet-handle {
    width: 40px;
    height: 4px;
    background-color: #e0e0e0;
    border-radius: 2px;
    margin: 0 auto 20px;
}

/* ========== TOAST NOTIFICATIONS (Улучшенные) ========== */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background-color: #000;
    color: white;
    padding: 16px 24px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 10000;
    max-width: calc(100% - 32px);
    text-align: center;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.error {
    background-color: #f44336;
}

.toast.success {
    background-color: #000;
}

/* ========== PULL TO REFRESH INDICATOR ========== */
.pull-to-refresh {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    padding: 10px 20px;
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    border-radius: 20px;
    font-size: 12px;
    z-index: 999;
    transition: transform 0.3s ease;
}

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

/* ========== FLOATING ACTION BUTTON ========== */
.fab {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 56px;
    height: 56px;
    background-color: #000;
    color: white;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 998;
}

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

.fab:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

/* ========== PROGRESS INDICATORS ========== */
.progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background-color: #000;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s ease;
    z-index: 10001;
}

.progress-bar.loading {
    animation: progress 1.5s ease-in-out infinite;
}

@keyframes progress {
    0% { transform: scaleX(0); }
    50% { transform: scaleX(0.5); }
    100% { transform: scaleX(1); }
}

/* ========== RIPPLE EFFECT ========== */
.ripple {
    position: relative;
    overflow: hidden;
}

.ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.1);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.ripple:active::after {
    width: 300px;
    height: 300px;
}

/* ========== EMPTY STATES ========== */
.empty-state-icon {
    font-size: 64px;
    opacity: 0.3;
    margin-bottom: 16px;
}

.empty-state-text {
    color: #666;
    font-size: 16px;
    margin-bottom: 24px;
}

/* ========== STICKY FOOTER BUTTON ========== */
@media (max-width: 768px) {
    .sticky-footer-action {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 16px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
        background-color: white;
        border-top: 1px solid #e0e0e0;
        z-index: 997;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    }

    .sticky-footer-action .submit-button {
        width: 100%;
        margin: 0;
    }
}

/* ========== INPUT FOCUS HELPERS ========== */
.input-focused {
    position: relative;
}

.input-focused::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background-color: #000;
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.input-focused.active::after {
    transform: scaleX(1);
}

/* ========== CARD SWIPE ACTIONS ========== */
.swipeable-card {
    position: relative;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.swipeable-card.swiping-left {
    transform: translateX(-80px);
}

.swipeable-card.swiping-right {
    transform: translateX(80px);
}

.swipe-action {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
}

.swipe-action.left {
    right: 0;
    background-color: #f44336;
}

.swipe-action.right {
    left: 0;
    background-color: #4caf50;
}

/* ========== OFFLINE INDICATOR ========== */
.offline-indicator {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    background-color: #f44336;
    color: white;
    padding: 12px;
    text-align: center;
    font-size: 14px;
    z-index: 1000;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

.offline-indicator.show {
    transform: translateY(0);
}

/* ========== SCROLL SHADOWS ========== */
.scroll-shadow-top {
    box-shadow: inset 0 10px 10px -10px rgba(0, 0, 0, 0.1);
}

.scroll-shadow-bottom {
    box-shadow: inset 0 -10px 10px -10px rgba(0, 0, 0, 0.1);
}

/* ========== MOMENTUM SCROLLING ========== */
.smooth-scroll {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* ========== ACCESSIBILITY IMPROVEMENTS ========== */
@media (prefers-reduced-motion: reduce) {
    .ripple::after,
    .toast,
    .bottom-sheet,
    .swipeable-card,
    * {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* Увеличенный текст для доступности */
@media (prefers-contrast: high) {
    body {
        font-weight: 500;
    }

    .border,
    .form-input,
    .exchange-card {
        border-width: 2px;
    }
}

/* ========== KEYBOARD NAVIGATION ========== */
*:focus-visible {
    outline: 2px solid #000;
    outline-offset: 2px;
}

button:focus-visible,
a:focus-visible {
    outline: 2px solid #000;
    outline-offset: 4px;
}
