/*
 * mod_tb_telegram_call — стили
 * Все цвета — через CSS-переменные / inherit (см. feedback_ux: dark theme сайта).
 * Жёсткие цвета — только для accent (--tbtg-accent), success, error.
 */

.tbtg {
    --tbtg-offset: 20px;
    --tbtg-radius: 14px;
    --tbtg-bg: rgba(20, 20, 20, 0.92);
    --tbtg-fg: #fff;
    --tbtg-muted: rgba(255, 255, 255, 0.6);
    --tbtg-accent: #25a4e0;          /* Telegram-blue */
    --tbtg-accent-fg: #fff;
    --tbtg-success: #28b463;
    --tbtg-error: #d94343;
    --tbtg-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);

    color: inherit;
    font-family: inherit;
    box-sizing: border-box;
}

.tbtg *,
.tbtg *::before,
.tbtg *::after {
    box-sizing: inherit;
}

/* === FAB режим === */
.tbtg--fab {
    position: fixed;
    z-index: 9998;
    pointer-events: none;
}

.tbtg--fab .tbtg-fab,
.tbtg--fab .tbtg-panel {
    pointer-events: auto;
}

.tbtg--pos-br { right: var(--tbtg-offset); bottom: var(--tbtg-offset); }
.tbtg--pos-bl { left:  var(--tbtg-offset); bottom: var(--tbtg-offset); }
.tbtg--pos-tr { right: var(--tbtg-offset); top:    var(--tbtg-offset); }
.tbtg--pos-tl { left:  var(--tbtg-offset); top:    var(--tbtg-offset); }

.tbtg-fab {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 0;
    background: var(--tbtg-accent);
    color: var(--tbtg-accent-fg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--tbtg-shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.tbtg-fab:hover { transform: translateY(-2px); }
.tbtg-fab:active { transform: translateY(0); }
.tbtg-fab:focus-visible { outline: 2px solid var(--tbtg-fg); outline-offset: 3px; }

.tbtg-panel {
    position: absolute;
    min-width: 240px;
    max-width: 86vw;
    background: var(--tbtg-bg);
    color: var(--tbtg-fg);
    border-radius: var(--tbtg-radius);
    box-shadow: var(--tbtg-shadow);
    padding: 12px;
    backdrop-filter: blur(8px);
    opacity: 0;
    transform: translateY(8px) scale(0.98);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.tbtg-panel[hidden] { display: none; }

.tbtg-panel.is-open {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.tbtg--pos-br .tbtg-panel { right: 0; bottom: 72px; }
.tbtg--pos-bl .tbtg-panel { left:  0; bottom: 72px; }
.tbtg--pos-tr .tbtg-panel { right: 0; top:    72px; }
.tbtg--pos-tl .tbtg-panel { left:  0; top:    72px; }

.tbtg-panel__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 2px 4px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 8px;
}

.tbtg-panel__title {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.tbtg-panel__close {
    appearance: none;
    background: transparent;
    color: var(--tbtg-muted);
    border: 0;
    font-size: 20px;
    line-height: 1;
    padding: 4px 8px;
    cursor: pointer;
    border-radius: 6px;
}

.tbtg-panel__close:hover { color: var(--tbtg-fg); background: rgba(255, 255, 255, 0.08); }

.tbtg-panel__body {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tbtg-panel .tbtg-btn {
    appearance: none;
    border: 0;
    background: rgba(255, 255, 255, 0.06);
    color: var(--tbtg-fg);
    text-align: left;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font: inherit;
    transition: background 0.15s ease, transform 0.05s ease;
}

.tbtg-panel .tbtg-btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.12); }
.tbtg-panel .tbtg-btn:active:not(:disabled) { transform: scale(0.98); }
.tbtg-panel .tbtg-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.tbtg-btn__icon {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    color: var(--tbtg-accent);
}

.tbtg-btn__icon svg {
    width: 1.1em;
    height: 1.1em;
}

.tbtg-btn__label {
    flex: 1 1 auto;
    line-height: 1.2;
}

.tbtg-panel__status,
.tbtg-inline__status {
    min-height: 0;
    font-size: 13px;
    margin-top: 8px;
    color: var(--tbtg-muted);
    transition: color 0.15s ease, min-height 0.15s ease;
}

.tbtg-panel__status.is-error,
.tbtg-inline__status.is-error { color: var(--tbtg-error); }

.tbtg-panel__status.is-success,
.tbtg-inline__status.is-success { color: var(--tbtg-success); }

/* === Inline режим === */
.tbtg--inline {
    width: 100%;
}

.tbtg-inline__title {
    font-size: 14px;
    opacity: 0.8;
    margin-bottom: 8px;
}

.tbtg-inline__body {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* В inline-режиме кнопки используют дефолтные классы фреймворка (uk-button / btn).
   Не перебиваем display/padding/line-height — даём UIkit разруливать самому.
   Только нормализуем иконку: правильный цвет + небольшой отступ от текста. */
.tbtg--inline .tbtg-btn__icon {
    display: inline-block;
    vertical-align: middle;
    width: auto;
    height: auto;
    color: inherit;
    margin-right: 0.4em;
}

.tbtg--inline .tbtg-btn__icon svg {
    display: inline-block;
    vertical-align: -0.15em;
    width: 1.1em;
    height: 1.1em;
}

.tbtg--inline .tbtg-btn__label {
    vertical-align: middle;
}

.tbtg--inline .tbtg-btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* Anchor-кнопка «Программа лояльности»: не должна иметь подчёркивание,
   и в FAB-панели — наследовать стилизацию обычной .tbtg-btn кнопки. */
a.tbtg-btn,
a.tbtg-btn:hover,
a.tbtg-btn:focus,
a.tbtg-btn:visited {
    text-decoration: none;
    color: inherit;
}

.tbtg-panel a.tbtg-btn {
    color: var(--tbtg-fg);
}

/* Состояния кнопок */
.tbtg-btn.is-loading {
    pointer-events: none;
    position: relative;
}
.tbtg-btn.is-loading .tbtg-btn__label::after {
    content: '…';
    margin-left: 4px;
    animation: tbtg-dots 1.2s steps(3, end) infinite;
}
.tbtg-btn.is-success {
    background: rgba(40, 180, 99, 0.18) !important;
}
.tbtg-btn.is-success .tbtg-btn__icon { color: var(--tbtg-success); }

@keyframes tbtg-dots {
    0%, 20%   { opacity: 0; }
    50%       { opacity: 1; }
    100%      { opacity: 0; }
}

/* Pulse на FAB при свежем уведомлении (когда что-то отправлено) */
.tbtg-fab.is-pulse::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid var(--tbtg-success);
    opacity: 0;
    animation: tbtg-pulse 1.2s ease-out 1;
}

@keyframes tbtg-pulse {
    0% { opacity: 0.8; transform: scale(0.9); }
    100% { opacity: 0; transform: scale(1.4); }
}

@media (max-width: 480px) {
    .tbtg-fab { width: 52px; height: 52px; }
    .tbtg-panel { min-width: 220px; }
}
