/* ============================================
   УЛУЧШЕННЫЕ АНИМАЦИИ ДЛЯ МИНИ-ПРИЛОЖЕНИЯ
   ============================================ */

:root {
    /* Современные easing функции */
    --ease-out-expo: cubic-bezier(0.19, 1, 0.22, 1);
    --ease-in-out-expo: cubic-bezier(0.87, 0, 0.13, 1);
    --ease-out-back: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-in-out-back: cubic-bezier(0.68, -0.6, 0.32, 1.6);
    --ease-spring: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    
    /* Скорости анимаций */
    --anim-fast: 0.15s;
    --anim-medium: 0.3s;
    --anim-slow: 0.5s;
    --anim-slower: 0.8s;
}

/* ============================================
   БАЗОВЫЕ АНИМАЦИИ ПОЯВЛЕНИЯ
   ============================================ */

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes scaleInBounce {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideInUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

@keyframes slideInDown {
    from {
        transform: translateY(-100%);
    }
    to {
        transform: translateY(0);
    }
}

@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

/* ============================================
   АНИМАЦИИ HOVER И ИНТЕРАКТИВНОСТИ
   ============================================ */

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.9;
    }
}

@keyframes pulseGlow {
    0%, 100% {
        box-shadow: 0 0 10px rgba(0, 191, 255, 0.5);
    }
    50% {
        box-shadow: 0 0 20px rgba(0, 191, 255, 0.8), 0 0 30px rgba(0, 191, 255, 0.4);
    }
}

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

@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(4);
        opacity: 0;
    }
}

/* Ripple эффект для кнопок (через JS) */
.btn-ripple {
    position: relative;
    overflow: hidden;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

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

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* ============================================
   АНИМАЦИИ ДЛЯ КАРТОЧЕК
   ============================================ */

.card {
    /* Убрана автоматическая анимация для устранения мерцания */
    transition: all var(--anim-medium) var(--ease-out-expo);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3), 0 0 12px rgba(0, 191, 255, 0.15);
}

.card:active {
    transform: translateY(0);
    transition: all var(--anim-fast) var(--ease-out-expo);
}

/* Staggered animation для списка карточек - отключено для устранения мерцания */
/* .card:nth-child(1) { animation-delay: 0.05s; } */
/* .card:nth-child(2) { animation-delay: 0.1s; } */
/* .card:nth-child(3) { animation-delay: 0.15s; } */
/* .card:nth-child(4) { animation-delay: 0.2s; } */
/* .card:nth-child(5) { animation-delay: 0.25s; } */
/* .card:nth-child(6) { animation-delay: 0.3s; } */
/* .card:nth-child(n+7) { animation-delay: 0.35s; } */

/* ============================================
   АНИМАЦИИ ДЛЯ КНОПОК
   ============================================ */

.btn {
    position: relative;
    overflow: hidden;
    transition: all var(--anim-fast) var(--ease-out-expo);
    transform-origin: center;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width var(--anim-slow) var(--ease-out-expo), 
                height var(--anim-slow) var(--ease-out-expo);
    pointer-events: none;
}

.btn:active::before {
    width: 300px;
    height: 300px;
}

.btn:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3), 0 0 15px rgba(0, 191, 255, 0.4);
}

.btn:active {
    transform: translateY(0) scale(0.98);
    transition: all var(--anim-fast) var(--ease-out-expo);
}

.btn-primary:hover {
    box-shadow: 0 8px 16px rgba(0, 191, 255, 0.4), 0 0 20px rgba(0, 191, 255, 0.3);
}

.btn-success:hover {
    box-shadow: 0 8px 16px rgba(40, 167, 69, 0.4), 0 0 20px rgba(40, 167, 69, 0.3);
}

.btn-danger:hover {
    box-shadow: 0 8px 16px rgba(220, 53, 69, 0.4), 0 0 20px rgba(220, 53, 69, 0.3);
}

/* Shimmer эффект для акцентных кнопок */
.btn-shimmer {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.2) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
}

/* ============================================
   АНИМАЦИИ ДЛЯ ФОРМ
   ============================================ */

.form-control,
.form-select {
    transition: all var(--anim-medium) var(--ease-out-expo);
}

.form-control:focus,
.form-select:focus {
    transform: scale(1.02);
    box-shadow: 0 0 0 3px rgba(0, 191, 255, 0.25), 
                0 4px 12px rgba(0, 191, 255, 0.2);
}

.form-control:invalid:not(:focus):not(:placeholder-shown) {
    animation: shake var(--anim-medium) var(--ease-out-expo);
}

/* Floating label анимация */
.form-floating > label {
    transition: all var(--anim-medium) var(--ease-out-expo);
}

.form-floating > .form-control:focus ~ label,
.form-floating > .form-control:not(:placeholder-shown) ~ label {
    transform: scale(0.85) translateY(-0.5rem) translateX(0.15rem);
}

/* ============================================
   АНИМАЦИИ ДЛЯ ТАБЛИЦ
   ============================================ */

.table tbody tr {
    /* Убрана автоматическая анимация для устранения мерцания */
    transition: all var(--anim-fast) var(--ease-out-expo);
}

/* Staggered animation для строк таблицы - отключено */
/* .table tbody tr:nth-child(1) { animation-delay: 0.05s; } */
/* .table tbody tr:nth-child(2) { animation-delay: 0.1s; } */
/* .table tbody tr:nth-child(3) { animation-delay: 0.15s; } */
/* .table tbody tr:nth-child(4) { animation-delay: 0.2s; } */
/* .table tbody tr:nth-child(5) { animation-delay: 0.25s; } */
/* .table tbody tr:nth-child(n+6) { animation-delay: 0.3s; } */

.table tbody tr:hover {
    transform: translateX(2px);
    box-shadow: -2px 0 6px rgba(0, 191, 255, 0.15);
}

/* ============================================
   АНИМАЦИИ ДЛЯ АЛЕРТОВ И УВЕДОМЛЕНИЙ
   ============================================ */

.alert {
    animation: slideInRight var(--anim-medium) var(--ease-out-back);
    transition: all var(--anim-medium) var(--ease-out-expo);
}

.alert:hover {
    transform: translateX(-4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.alert-dismissible .btn-close {
    transition: all var(--anim-fast) var(--ease-out-expo);
}

.alert-dismissible .btn-close:hover {
    transform: rotate(90deg) scale(1.2);
}

/* Toast уведомления */
.toast {
    animation: slideInUp var(--anim-medium) var(--ease-out-back);
}

.toast.showing {
    animation: slideInUp var(--anim-medium) var(--ease-out-back);
}

.toast.hiding {
    animation: slideInDown var(--anim-medium) var(--ease-out-expo);
}

/* ============================================
   АНИМАЦИИ ДЛЯ МОДАЛЬНЫХ ОКОН
   ============================================ */

.modal {
    animation: fadeIn var(--anim-medium) var(--ease-out-expo);
}

.modal-dialog {
    animation: scaleInBounce var(--anim-slow) var(--ease-out-back);
}

.modal-backdrop {
    animation: fadeIn var(--anim-medium) var(--ease-out-expo);
}

/* ============================================
   АНИМАЦИИ ДЛЯ САЙДБАРА
   ============================================ */

.sidebar {
    transition: transform var(--anim-medium) var(--ease-out-expo),
                width var(--anim-medium) var(--ease-out-expo);
}

.sidebar-nav-item {
    transition: all var(--anim-fast) var(--ease-out-expo);
    position: relative;
    overflow: hidden;
}

.sidebar-nav-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 3px;
    background: var(--primary-neon);
    transform: scaleY(0);
    transition: transform var(--anim-fast) var(--ease-out-expo);
}

.sidebar-nav-item:hover {
    transform: translateX(4px);
    background: rgba(0, 191, 255, 0.1);
}

.sidebar-nav-item.active::before {
    transform: scaleY(1);
}

.sidebar-nav-item.active {
    background: rgba(0, 191, 255, 0.15);
    box-shadow: inset 0 0 10px rgba(0, 191, 255, 0.2);
}

/* ============================================
   АНИМАЦИИ ДЛЯ ЗАГРУЗКИ
   ============================================ */

/* Skeleton loader */
.skeleton {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.05) 0%,
        rgba(255, 255, 255, 0.1) 50%,
        rgba(255, 255, 255, 0.05) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: 4px;
}

/* Spinner улучшенный */
.spinner-border {
    animation: rotate 0.75s linear infinite;
}

.spinner-grow {
    animation: pulse 1.5s ease-in-out infinite;
}

/* Progress bar */
.progress-bar {
    transition: width var(--anim-slow) var(--ease-out-expo);
    position: relative;
    overflow: hidden;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    animation: shimmer 2s infinite;
}

/* ============================================
   АНИМАЦИИ ДЛЯ БАДЖЕЙ И ИНДИКАТОРОВ
   ============================================ */

.badge {
    animation: scaleIn var(--anim-fast) var(--ease-out-back);
    transition: all var(--anim-fast) var(--ease-out-expo);
}

.badge:hover {
    transform: scale(1.1);
}

.badge-pulse {
    animation: pulseGlow 2s ease-in-out infinite;
}

/* ============================================
   АНИМАЦИИ ДЛЯ ИКОНОК
   ============================================ */

.bi {
    transition: all var(--anim-fast) var(--ease-out-expo);
}

.btn:hover .bi,
.card:hover .bi {
    transform: scale(1.2);
}

.bi-spin {
    animation: rotate 1s linear infinite;
}

.bi-bounce {
    animation: bounce 1s ease-in-out infinite;
}

.bi-pulse {
    animation: pulse 1.5s ease-in-out infinite;
}

.bi-float {
    animation: float 3s ease-in-out infinite;
}

/* ============================================
   АНИМАЦИИ ДЛЯ ПЕРЕХОДОВ МЕЖДУ СТРАНИЦАМИ
   ============================================ */

#contentWrapper {
    position: relative;
    min-height: 100px;
}

#contentWrapper.page-enter {
    animation: fadeInUp var(--anim-medium) var(--ease-out-expo);
}

#contentWrapper.page-exit {
    animation: fadeOutDown var(--anim-fast) var(--ease-out-expo);
}

.page-transition-enter {
    animation: fadeInUp var(--anim-medium) var(--ease-out-expo);
}

.page-transition-exit {
    animation: fadeOutDown var(--anim-fast) var(--ease-out-expo);
}

@keyframes fadeOutDown {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(20px);
    }
}

/* Плавный переход для контента при навигации - отключено для устранения мерцания */
/* #contentWrapper > * {
    animation: fadeInUp var(--anim-medium) var(--ease-out-expo);
} */

/* ============================================
   АНИМАЦИИ ДЛЯ СПИСКОВ
   ============================================ */

.list-group-item {
    /* Убрана автоматическая анимация для устранения мерцания */
    transition: all var(--anim-fast) var(--ease-out-expo);
}

/* Staggered animation для списка - отключено */
/* .list-group-item:nth-child(1) { animation-delay: 0.05s; } */
/* .list-group-item:nth-child(2) { animation-delay: 0.1s; } */
/* .list-group-item:nth-child(3) { animation-delay: 0.15s; } */
/* .list-group-item:nth-child(4) { animation-delay: 0.2s; } */
/* .list-group-item:nth-child(5) { animation-delay: 0.25s; } */
/* .list-group-item:nth-child(n+6) { animation-delay: 0.3s; } */

.list-group-item:hover {
    transform: translateX(4px);
    box-shadow: -2px 0 6px rgba(0, 191, 255, 0.15);
}

/* ============================================
   АНИМАЦИИ ДЛЯ ДРОПДАУНОВ
   ============================================ */

.dropdown-menu {
    animation: fadeInDown var(--anim-fast) var(--ease-out-back);
    transform-origin: top;
}

.dropdown-item {
    transition: all var(--anim-fast) var(--ease-out-expo);
}

.dropdown-item:hover {
    transform: translateX(4px);
    background: rgba(0, 191, 255, 0.1);
}

/* ============================================
   АНИМАЦИИ ДЛЯ TOOLTIPS И POPOVERS
   ============================================ */

.tooltip {
    animation: fadeIn var(--anim-fast) var(--ease-out-expo);
}

.popover {
    animation: scaleIn var(--anim-fast) var(--ease-out-back);
}

/* ============================================
   АНИМАЦИИ ДЛЯ АККОРДЕОНОВ
   ============================================ */

.accordion-item {
    transition: all var(--anim-medium) var(--ease-out-expo);
}

.accordion-button {
    transition: all var(--anim-fast) var(--ease-out-expo);
}

.accordion-button:not(.collapsed) {
    transform: scale(1.02);
}

.accordion-collapse {
    transition: height var(--anim-medium) var(--ease-out-expo);
}

/* ============================================
   АНИМАЦИИ ДЛЯ TABS
   ============================================ */

.nav-tabs .nav-link {
    transition: all var(--anim-fast) var(--ease-out-expo);
    position: relative;
}

.nav-tabs .nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--primary-neon);
    transition: width var(--anim-medium) var(--ease-out-expo);
}

.nav-tabs .nav-link.active::after {
    width: 100%;
}

.nav-tabs .nav-link:hover {
    transform: translateY(-2px);
}

/* ============================================
   УТИЛИТЫ ДЛЯ АНИМАЦИЙ
   ============================================ */

.animate-on-scroll {
    opacity: 0;
    transform: translateY(30px);
    transition: all var(--anim-slow) var(--ease-out-expo);
}

.animate-on-scroll.animated {
    opacity: 1;
    transform: translateY(0);
}

/* Отключение анимаций для пользователей с prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Ограничения для Telegram WebApp - отключаем transform на hover */
body.tg-webapp .card:hover,
body.tg-webapp .btn:hover,
body.tg-webapp .list-group-item:hover,
body.tg-webapp .table tbody tr:hover {
    transform: none !important;
}

/* Но оставляем другие эффекты (box-shadow, background) */
body.tg-webapp .card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 0 20px rgba(0, 191, 255, 0.2) !important;
}

body.tg-webapp .btn:hover {
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3), 0 0 15px rgba(0, 191, 255, 0.4) !important;
}

/* ============================================
   СПЕЦИАЛЬНЫЕ ЭФФЕКТЫ
   ============================================ */

/* Glow эффект */
.glow {
    animation: pulseGlow 2s ease-in-out infinite;
}

/* Shake при ошибке */
.shake {
    animation: shake var(--anim-medium) var(--ease-out-expo);
}

/* Bounce для привлечения внимания */
.bounce {
    animation: bounce 1s ease-in-out;
}

/* Float для декоративных элементов */
.float {
    animation: float 3s ease-in-out infinite;
}

/* Rotate для иконок загрузки */
.rotate {
    animation: rotate 1s linear infinite;
}

