/* agti_app/static/css/balance_widget.css */
/* Модуль: balance_widget.css */
/* Назначение: Стили для виджета баланса KNL в header с автообновлением */
/* Версия: 2.4 */
/* Дата: 2026-06-02 */
/*
 * v2.4 | 2026-09-11
 * - Колонка действий в таблице балансов: пополнение и вывод (заглушка).
 *   Подсказка расширена с 320 до 380px - иначе колонка ужимает цифры
 *
 * v2.3 | 2026-09-11
 * - Баланс вернулся на мобильные: блок в сайдбаре (в топбаре виджет скрыт до
 *   768px, и на телефоне баланс не был виден нигде). Таблица валют - общая
 *   с подсказкой хедера: .balance-table вместо popover-специфичных имён
 * - Убрано правило, прятавшее .balance-widget / .balance-widget-compact:
 *   таких классов в разметке нет, реальный виджет носит .topbar-balance
 *
 * v2.2 | 2026-09-11
 * - Кнопка обновления снова прозрачная: белый фон и рамка приходили отсюда
 *   по ID-селектору и перебивали общий .topbar-icon-btn (там background: none)
 * - Подсказка со всеми валютами кошелька по наведению на сумму
 *
 * v2.1 | 2026-06-02
 * - Цвет резерва унифицирован с карточкой дашборда: #e67700
 * v2.0 | 2026-04-15
 * - Приведён заголовок к стандарту проекта
 */

/* SECTION: Виджет баланса - десктоп */
.balance-widget {
    min-width: 200px;
}

.balance-widget a:hover {
    opacity: 0.85;
    transition: opacity 0.2s;
}

.balance-free {
    color: #198754;
    font-size: 0.95rem;
    line-height: 1.2;
}

.balance-reserved {
    color: #e67700;
    font-weight: 700;
    font-size: 0.75rem;
    line-height: 1;
}

/* Фон и рамку задаёт общий .topbar-icon-btn (background: none) - здесь только
   то, чего в нём нет. Раньше ID-селектор перекрывал его белым фоном, и кнопка
   выделялась плашкой на фоне хедера. */
#refreshBalanceBtn {
    transition: all 0.3s ease;
    position: relative;
}

#refreshBalanceBtn:hover {
    transform: scale(1.1);
}

#refreshBalanceBtn:disabled {
    opacity: 0.8;
    cursor: not-allowed;
}

/* Анимация вращения иконки обновления - БЕСКОНЕЧНАЯ */
@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.rotating {
    animation: rotate 1s linear infinite !important;
}

/* Успешное обновление - зеленая галочка */
.refresh-success {
    color: #28a745 !important;
    animation: successPulse 0.6s ease;
}

@keyframes successPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.3);
    }
}

/* SECTION: Мобильная версия - скрыт */
/* SECTION: Мобильный виджет баланса */
.mobile-balance-widget {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, #E8F5E9 0%, #C8E6C9 100%);
    border-left: 4px solid #4CAF50;
    border-radius: 8px;
    padding: 12px 16px;
    margin: 0 0 16px 0;
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.15);
}

.mobile-balance-link {
    flex: 1;
    text-decoration: none;
    color: inherit;
}

.mobile-balance-link:hover {
    opacity: 0.9;
}

.balance-content {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.balance-icon {
    font-size: 1.25rem;
}

.balance-main {
    font-size: 1.1rem;
    font-weight: 700;
    color: #2E7D32;
}

.balance-reserved {
    font-size: 0.9rem;
    color: #e67700;
    font-weight: 600;
}

.btn-mobile-refresh {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid #4CAF50;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
    position: relative;
}

.btn-mobile-refresh:hover {
    background: #4CAF50;
    color: white;
    transform: scale(1.1);
}

.btn-mobile-refresh:active {
    transform: scale(0.95);
}

.btn-mobile-refresh i {
    font-size: 1.1rem;
    transition: transform 0.5s ease;
}

/* Анимация мобильной кнопки при обновлении */
.btn-mobile-refresh.refreshing i {
    animation: rotate 1s linear infinite;
}

/* Успешное обновление мобильной кнопки */
.btn-mobile-refresh.refresh-success {
    background: #28a745;
    border-color: #28a745;
    color: white;
}

/* Скрыть на десктопе (>=992px) */
@media (min-width: 992px) {
    .mobile-balance-widget {
        display: none !important;
    }
}

/* SECTION: Десктопный виджет - обновленный формат */
.balance-widget .balance-content {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.balance-widget .balance-icon {
    font-size: 1.25rem;
}

.balance-widget .balance-free {
    font-size: 0.95rem;
}

.balance-widget .balance-reserved {
    font-size: 0.85rem;
}

/* SECTION: Анимации изменения баланса */

/* Анимация при ПОПОЛНЕНИИ баланса - зеленое мигание */
@keyframes balanceIncrease {
    0% {
        background-color: transparent;
        transform: scale(1);
    }
    25% {
        background-color: rgba(76, 175, 80, 0.3);
        transform: scale(1.1);
    }
    50% {
        background-color: rgba(76, 175, 80, 0.5);
        transform: scale(1.15);
    }
    75% {
        background-color: rgba(76, 175, 80, 0.3);
        transform: scale(1.1);
    }
    100% {
        background-color: transparent;
        transform: scale(1);
    }
}

.balance-increase {
    animation: balanceIncrease 2s ease-in-out;
    padding: 2px 6px;
    border-radius: 4px;
}

/* Анимация при СПИСАНИИ баланса - желтое мигание */
@keyframes balanceDecrease {
    0% {
        background-color: transparent;
        transform: scale(1);
    }
    25% {
        background-color: rgba(255, 193, 7, 0.3);
        transform: scale(1.05);
    }
    50% {
        background-color: rgba(255, 193, 7, 0.5);
        transform: scale(1.08);
    }
    75% {
        background-color: rgba(255, 193, 7, 0.3);
        transform: scale(1.05);
    }
    100% {
        background-color: transparent;
        transform: scale(1);
    }
}

.balance-decrease {
    animation: balanceDecrease 2s ease-in-out;
    padding: 2px 6px;
    border-radius: 4px;
}

/* SECTION: Подсказка со всеми валютами кошелька */
/* Разметка приходит с сервером, показ - чистый :hover без JS: запрос при
   наведении был бы лишним, данные уже в DOM */
.balance-widget-hover {
    position: relative;
}

.balance-popover {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 1080;
    min-width: 380px;
    padding: 10px 12px;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
    cursor: default;
}

/* Показываем и при наведении на подсказку - иначе она закрывается,
   пока курсор идёт к ней через зазор */
.balance-widget-hover:hover .balance-popover,
.balance-popover:hover {
    display: block;
}

.balance-popover-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 6px;
}

.balance-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
}

.balance-table th {
    font-weight: 600;
    color: #6c757d;
    text-align: right;
    padding: 2px 0 4px 10px;
    border-bottom: 1px solid #f0f0f0;
}

.balance-table th:first-child {
    text-align: left;
    padding-left: 0;
}

.balance-table td {
    padding: 3px 0 3px 10px;
    white-space: nowrap;
}

.balance-table-token {
    font-weight: 600;
    color: #212529;
    padding-left: 0 !important;
}

/* Моноширинные цифры: 8 знаков в столбик читаются только выровненными */
.balance-table-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color: #198754;
}

.balance-table-reserved {
    color: #e67700;
}

/* SECTION: Баланс в сайдбаре (мобильные) */
/* Список раскрыт сразу: подсказка по наведению на тач-экране недоступна */
.sidebar-balance {
    padding: 10px 12px 12px;
    margin-bottom: 6px;
    background: linear-gradient(135deg, #E8F5E9 0%, #C8E6C9 100%);
    border-left: 4px solid #4CAF50;
}

.sidebar-balance-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.sidebar-balance-link {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #2E7D32;
    text-decoration: none;
}

.sidebar-balance-link:hover {
    color: #1B5E20;
    text-decoration: none;
}

/* Кнопка мельче, чем в старом полноширинном виджете: сайдбар узкий */
.sidebar-balance .btn-mobile-refresh {
    width: 30px;
    height: 30px;
}

.sidebar-balance .btn-mobile-refresh i {
    font-size: 0.95rem;
}

/* На белом фоне подсказки таблица без фона, здесь - на плашке */
.sidebar-balance .balance-table {
    background: rgba(255, 255, 255, 0.75);
    border-radius: 6px;
    padding: 6px 8px;
}

/* SECTION: Действия по токену в таблице балансов */
.balance-table-actions {
    text-align: right;
    white-space: nowrap;
    padding-left: 12px !important;
}

.balance-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 5px;
    color: #198754;
    text-decoration: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.balance-action:hover {
    background-color: rgba(25, 135, 84, 0.12);
    color: #146c43;
    text-decoration: none;
}

.balance-action i {
    font-size: 0.9rem;
}

/* Вывод средств пока не реализован: место занято, действие недоступно.
   Курсор «нельзя», а не «рука» - иначе выглядит как рабочая кнопка */
.balance-action-disabled {
    color: #adb5bd;
    cursor: not-allowed;
}

.balance-action-disabled:hover {
    background-color: transparent;
    color: #adb5bd;
}
