/**
 * DomRiaDom Telegram — Chat Widget
 * Панель в стиле модала «Вход»: снизу на мобиле, по центру на десктопе.
 */

/* ================================================================
   КНОПКА-ХВОСТИК (прилипает к правому краю)
   ================================================================ */

.drd-tg-tab {
    position: fixed;
    right: -6px;
    bottom: 18px;
    z-index: 9990;
    width: 45px;
    height: 45px;
    padding: 0;
    margin: 0;
    border: none;
    background: var(--drd-tg-color, #0088cc);
    border-radius: 20px;
    cursor: pointer;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: -2px 2px 10px rgba(0, 0, 0, 0.18);
    transition: transform 0.25s ease, box-shadow 0.25s ease, opacity 0.3s ease;
}

.drd-tg-tab:hover {
    transform: translateX(-4px);
    box-shadow: -3px 3px 14px rgba(0, 0, 0, 0.25);
}

.drd-tg-tab:active {
    transform: translateX(-2px);
}

.drd-tg-tab__icon {
    width: 22px;
    height: 22px;
    color: #fff;
    flex-shrink: 0;
    margin-left: -3px;
}

/* Бейдж непрочитанных */
.drd-tg-chat__badge {
    position: absolute;
    top: -6px;
    left: -8px;
    background: #e74c3c;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    box-sizing: border-box;
    line-height: 1;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
    z-index: 2;
}

/* Скрыть кнопку когда панель открыта */
.drd-tg-tab--hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateX(40px);
}

/* ================================================================
   ОВЕРЛЕЙ
   ================================================================ */

.drd-tg-overlay {
    --glass-color: #bbbbbc;
    --glass-light: #fff;
    --glass-dark: #000;
    --glass-reflex-light: 1;
    --glass-reflex-dark: 1;

    position: fixed;
    inset: 0;
    z-index: 99996;
    background-color: color-mix(in srgb, var(--glass-color) 18%, transparent);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
}

.drd-tg-overlay--active {
    opacity: 1;
    pointer-events: auto;
}

/* ================================================================
   ПАНЕЛЬ (фрейм и анимация как у модала «Вход»)
   ================================================================ */

.drd-tg-panel {
    position: fixed;
    z-index: 99998;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: transform .35s cubic-bezier(.32, .72, 0, 1), opacity .2s ease;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;

    /* Liquid glass card */
    background-color: color-mix(in srgb, #fff 72%, transparent);
    backdrop-filter: blur(16px) saturate(200%);
    -webkit-backdrop-filter: blur(16px) saturate(200%);
    box-shadow:
        inset 0 0 0 1px color-mix(in srgb, #fff 14%, transparent),
        inset 1.8px 3px 0px -2px color-mix(in srgb, #fff 80%, transparent),
        inset -2px -2px 0px -2px color-mix(in srgb, #fff 70%, transparent),
        inset -3px -8px 1px -6px color-mix(in srgb, #fff 50%, transparent),
        inset -0.3px -1px 4px 0px color-mix(in srgb, #000 10%, transparent),
        inset -1.5px 2.5px 0px -2px color-mix(in srgb, #000 14%, transparent),
        inset 0px 3px 4px -2px color-mix(in srgb, #000 14%, transparent),
        0px 2px 8px 0px color-mix(in srgb, #000 8%, transparent),
        0px 12px 40px 0px color-mix(in srgb, #000 12%, transparent);
}

.drd-tg-panel--active {
    opacity: 1;
    pointer-events: auto;
}

@media (max-width: 599px) {
    .drd-tg-panel {
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-height: 90vh;
        border-radius: 20px 20px 0 0;
        transform: translateY(100%);
        overflow: hidden;
    }

    .drd-tg-panel--active {
        transform: translateY(0);
    }
}

/* Десктоп: по центру */
@media (min-width: 600px) {
    .drd-tg-panel {
        top: 50%;
        left: 50%;
        transform: translate(-50%, -38%);
        width: 440px;
        border-radius: 20px;
        max-height: 80vh;
        overflow: hidden;
    }

    .drd-tg-panel--active {
        transform: translate(-50%, -50%);
    }
}

/* ================================================================
   КНОПКА ЗАКРЫТИЯ
   ================================================================ */

/* Обёртка — скрываем старую логику выдвигания влево */
.drd-tg-panel__close-wrap {
    position: absolute;
    top: 16px;
    right: 16px;
    left: auto;
    z-index: 3;
    transform: none !important;
}

.drd-tg-panel__close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #f5f5f5;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333;
    transition: background .15s;
    padding: 0;
    box-shadow: none;
}

.drd-tg-panel__close:hover {
    background: #e8e8e8;
    color: #333;
    box-shadow: none;
}

/* ================================================================
   ЗАГОЛОВОК ПАНЕЛИ
   ================================================================ */

.drd-tg-panel__header {
    display: flex;
    align-items: center;
    padding: 32px 24px 20px;
    border-bottom: 1px solid #f0f0f0;
    flex-shrink: 0;
}



.drd-tg-panel__header strong {
    display: block;
    font-size: 18px;
    font-weight: 700;
    color: #1a1a1a;
}

.drd-tg-panel__header small {
    display: block;
    font-size: 13px;
    color: #999;
    margin-top: 2px;
}

/* ================================================================
   ФОРМА КОНТАКТОВ
   ================================================================ */

.drd-tg-panel__contacts {
    padding: 24px;
}

.drd-tg-panel__contacts p {
    margin: 0 0 14px;
    font-size: 14px;
    color: #555;
}

.drd-tg-panel__contacts input {
    width: 100%;
    padding: 14px 16px;
    border: 1.5px solid color-mix(in srgb, #000 10%, transparent);
    background: color-mix(in srgb, #fff 85%, transparent);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border-radius: 12px;
    font-size: 15px;
    margin-bottom: 10px;
    box-sizing: border-box;
    transition: border-color .2s, box-shadow .2s;
    outline: none;
    font-family: inherit;
    -webkit-appearance: none;
    color: #1a1a1a;
}

.drd-tg-panel__contacts input:focus {
    border-color: #1F9356;
}

.drd-tg-panel__btn {
    width: 100%;
    padding: 15px 20px;
    background: #1F9356;
    color: #fff;
    border: none;
    border-radius: 50px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s, transform .1s;
    font-family: inherit;
    margin-top: 4px;
}

.drd-tg-panel__btn:hover {
    background: #177a45;
}

.drd-tg-panel__btn:active {
    transform: scale(.98);
}

/* ================================================================
   ОБЛАСТЬ СООБЩЕНИЙ
   ================================================================ */

.drd-tg-panel__messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    background: transparent;
    min-height: 200px;
}

@media (min-width: 600px) {
    .drd-tg-panel__messages {
        max-height: calc(80vh - 200px);
    }
}

.drd-tg-panel__messages::-webkit-scrollbar {
    width: 4px;
}
.drd-tg-panel__messages::-webkit-scrollbar-track {
    background: transparent;
}
.drd-tg-panel__messages::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 2px;
}

/* ================================================================
   СООБЩЕНИЯ
   ================================================================ */

.drd-tg-msg {
    margin-bottom: 10px;
    display: flex;
    animation: drdTgMsgIn .3s ease;
}

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

.drd-tg-msg--incoming  { justify-content: flex-end; }
.drd-tg-msg--outgoing  { justify-content: flex-start; }
.drd-tg-msg--system    { justify-content: center; }

.drd-tg-msg__bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 16px;
    word-break: break-word;
    font-size: 14px;
    line-height: 1.45;
}

.drd-tg-msg--incoming .drd-tg-msg__bubble {
    background: var(--drd-tg-color, #0088cc);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.drd-tg-msg--outgoing .drd-tg-msg__bubble {
    background: #fff;
    color: #333;
    border: 1px solid #e1e4ed;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .04);
}

.drd-tg-msg--system .drd-tg-msg__bubble {
    background: transparent;
    color: #999;
    font-size: 12px;
    padding: 4px 10px;
}

.drd-tg-msg__time {
    font-size: 11px;
    margin-top: 4px;
    opacity: .6;
}

.drd-tg-msg--incoming .drd-tg-msg__time {
    text-align: right;
    color: rgba(255,255,255,.7);
}

.drd-tg-msg--outgoing .drd-tg-msg__time {
    text-align: left;
    color: #aaa;
}

/* ================================================================
   ПОЛЕ ВВОДА
   ================================================================ */

.drd-tg-panel__input-area {
    display: flex;
    align-items: flex-end;
    padding: 14px 20px;
    border-top: 1px solid color-mix(in srgb, #000 10%, transparent);
    background: transparent;
    flex-shrink: 0;
    gap: 10px;
}

.drd-tg-panel__input {
    flex: 1;
    border: 1.5px solid color-mix(in srgb, #000 10%, transparent);
    background: color-mix(in srgb, #fff 85%, transparent);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border-radius: 12px;
    padding: 10px 16px;
    font-size: 14px;
    line-height: 1.4;
    resize: none;
    max-height: 100px;
    overflow-y: auto;
    outline: none;
    font-family: inherit;
    transition: border-color .2s, box-shadow .2s;
    -webkit-appearance: none;
}

.drd-tg-panel__input:focus {
    border-color: #1F9356;
}

.drd-tg-panel__send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #1F9356;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background .2s, transform .15s;
}

.drd-tg-panel__send:hover {
    background: #177a45;
}

.drd-tg-panel__send:active {
    transform: scale(.95);
}

/* ================================================================
   БЛОКИРОВКА ПРОКРУТКИ
   ================================================================ */

body.drd-tg-no-scroll {
    overflow: hidden;
    height: 100vh;
}

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

@media (max-width: 768px) {
    .drd-tg-tab {
        width: 40px;
        height: 40px;
        border-radius: 12px;
    }

    .drd-tg-tab__icon {
        width: 18px;
        height: 18px;
    }
}
