/* ============================================================
   GameSell VPN — Встроенная система переписки со службой поддержки
   ============================================================ */

:root {
    --sup-primary: #6c5ce7;
    --sup-primary-hover: #5a49df;
    --sup-primary-grad: linear-gradient(135deg, #6c5ce7 0%, #a29bfe 100%);
    --sup-bg-dark: #0f1322;
    --sup-bg-card: rgba(22, 27, 46, 0.95);
    --sup-bg-bubble-support: rgba(255, 255, 255, 0.07);
    --sup-border: rgba(255, 255, 255, 0.1);
    --sup-text-main: #f8f9fa;
    --sup-text-muted: #8e95ab;
    --sup-accent-green: #00b894;
    --sup-accent-red: #ff4757;
}

/* Кнопка в шапке личного кабинета */
.btn-support-head {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(108, 92, 231, 0.12);
    border: 1px solid rgba(108, 92, 231, 0.35);
    color: #c7c1ff;
    padding: 0 14px;
    height: 36px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    text-decoration: none;
    position: relative;
    user-select: none;
}

.btn-support-head:hover {
    background: rgba(108, 92, 231, 0.25);
    border-color: var(--sup-primary);
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.25);
}

.btn-support-head svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

.btn-support-head .support-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--sup-accent-red);
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #0d111e;
    box-shadow: 0 0 10px rgba(255, 71, 87, 0.6);
    animation: supPulse 2s infinite;
}

@keyframes supPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); box-shadow: 0 0 16px rgba(255, 71, 87, 0.9); }
}

/* Модальное окно чата поддержки */
.support-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(4, 7, 15, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 99990;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.25s ease;
    padding: 16px;
}

.support-modal-overlay.active {
    display: flex;
    opacity: 1;
}

.support-modal-window {
    background: var(--sup-bg-card);
    border: 1px solid var(--sup-border);
    border-radius: 20px;
    width: 100%;
    max-width: 680px;
    height: 680px;
    max-height: calc(100vh - 40px);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.95) translateY(10px);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
}

.support-modal-overlay.active .support-modal-window {
    transform: scale(1) translateY(0);
}

/* Шапка чата */
.support-modal-header {
    background: linear-gradient(135deg, rgba(108, 92, 231, 0.2) 0%, rgba(22, 27, 46, 0.95) 100%);
    padding: 16px 20px;
    border-bottom: 1px solid var(--sup-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.support-agent-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.support-agent-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--sup-primary-grad);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-weight: 700;
    font-size: 16px;
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.4);
    position: relative;
    flex-shrink: 0;
}

.support-online-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--sup-accent-green);
    border: 2px solid #161b2e;
    box-shadow: 0 0 6px var(--sup-accent-green);
}

.support-agent-text h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--sup-text-main);
    line-height: 1.2;
}

.support-agent-text p {
    margin: 3px 0 0;
    font-size: 12px;
    color: var(--sup-accent-green);
    display: flex;
    align-items: center;
    gap: 4px;
}

.support-close-btn {
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: var(--sup-text-muted);
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s ease;
}

.support-close-btn:hover {
    background: rgba(255, 255, 255, 0.18);
    color: #ffffff;
    transform: scale(1.05);
}

/* Область сообщений */
.support-messages-wrap {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overscroll-behavior: contain;
    background: radial-gradient(circle at 50% 10%, rgba(108, 92, 231, 0.03) 0%, transparent 60%);
}

#supportMessagesList {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.support-messages-wrap::-webkit-scrollbar {
    width: 6px;
}

.support-messages-wrap::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

/* Приветственный блок */
.support-welcome-card {
    background: rgba(108, 92, 231, 0.08);
    border: 1px dashed rgba(108, 92, 231, 0.3);
    border-radius: 14px;
    padding: 14px 16px;
    font-size: 13px;
    color: #d1d5e5;
    line-height: 1.5;
    text-align: center;
    margin-bottom: 6px;
}

.support-welcome-card strong {
    color: #ffffff;
    display: block;
    margin-bottom: 4px;
    font-size: 14px;
}

/* Дата разделитель */
.support-date-divider {
    align-self: center;
    font-size: 11px;
    color: var(--sup-text-muted);
    background: rgba(255, 255, 255, 0.05);
    padding: 3px 10px;
    border-radius: 12px;
    margin: 6px 0;
    font-weight: 500;
}

/* Пузырь сообщения */
.support-msg-row {
    display: flex;
    flex-direction: column;
    max-width: 84%;
    position: relative;
}

.support-msg-row.user {
    margin-left: auto;
    align-self: flex-end;
    align-items: flex-end;
}

.support-msg-row.support {
    margin-right: auto;
    align-self: flex-start;
    align-items: flex-start;
}

.support-msg-sender-name {
    font-size: 11px;
    color: var(--sup-text-muted);
    margin-bottom: 3px;
    padding: 0 4px;
}

.support-msg-bubble {
    padding: 11px 15px;
    font-size: 14px;
    line-height: 1.45;
    word-break: break-word;
    border-radius: 16px;
    position: relative;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.support-msg-row.user .support-msg-bubble {
    background: #252a40;
    border: 1px solid rgba(108, 92, 231, 0.4);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.support-msg-row.support .support-msg-bubble {
    background: var(--sup-bg-bubble-support);
    color: #f1f3f9;
    border: 1px solid var(--sup-border);
    border-bottom-left-radius: 4px;
}

/* Ссылки в сообщениях */
.support-msg-bubble a {
    color: #ffffff;
    text-decoration: underline;
    text-underline-offset: 2px;
    font-weight: 600;
    word-break: break-all;
    transition: opacity 0.2s;
}

.support-msg-row.support .support-msg-bubble a {
    color: #a29bfe;
}

.support-msg-bubble a:hover {
    opacity: 0.8;
}

/* Изображения в сообщениях */
.support-msg-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.support-msg-img-wrap {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: #090c14;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    max-width: 220px;
    max-height: 220px;
}

.support-msg-img-wrap:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.support-msg-img-wrap img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    max-height: 220px;
}

/* Время сообщения */
.support-msg-time {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: flex-end;
}

.support-read-ticks {
    display: inline-flex;
    align-items: center;
    line-height: 1;
    margin-left: 5px;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 5px;
    border-radius: 4px;
    text-transform: lowercase;
}

.support-read-ticks.read {
    color: #00ffb0;
    background: rgba(0, 255, 176, 0.12);
    border: 1px solid rgba(0, 255, 176, 0.3);
}

.support-read-ticks.unread {
    color: #b2bec3;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.support-msg-row.support .support-msg-time {
    color: var(--sup-text-muted);
}

/* Индикатор набора текста (Typing indicator) */
.support-typing-row {
    align-self: flex-start;
    display: none;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--sup-border);
    padding: 8px 14px;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    font-size: 12px;
    color: var(--sup-text-muted);
    animation: fadeInTyping 0.3s ease;
}

.support-typing-row.active {
    display: flex;
}

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

.support-typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
}

.support-typing-dots span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--sup-primary-light);
    display: inline-block;
    animation: supBounce 1.4s infinite ease-in-out both;
}

.support-typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.support-typing-dots span:nth-child(2) { animation-delay: -0.16s; }
.support-typing-dots span:nth-child(3) { animation-delay: 0; }

@keyframes supBounce {
    0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* Превью прикрепленного изображения перед отправкой */
.support-preview-bar {
    display: none;
    padding: 8px 16px;
    background: rgba(10, 14, 26, 0.8);
    border-top: 1px solid var(--sup-border);
    align-items: center;
    gap: 10px;
}

.support-preview-bar.active {
    display: flex;
}

.support-preview-thumb-box {
    position: relative;
    width: 48px;
    height: 48px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(108, 92, 231, 0.4);
    background: #000;
}

.support-preview-thumb-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.support-preview-info {
    flex: 1;
    min-width: 0;
}

.support-preview-name {
    font-size: 12px;
    color: var(--sup-text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.support-preview-size {
    font-size: 11px;
    color: var(--sup-text-muted);
}

.support-preview-remove-btn {
    background: rgba(255, 71, 87, 0.15);
    border: 1px solid rgba(255, 71, 87, 0.3);
    color: var(--sup-accent-red);
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.support-preview-remove-btn:hover {
    background: var(--sup-accent-red);
    color: #ffffff;
}

/* Подвал и поле ввода */
.support-input-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--sup-border);
    background: rgba(15, 19, 34, 0.9);
    display: flex;
    align-items: flex-end;
    gap: 8px;
    flex-shrink: 0;
}

.support-attach-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--sup-border);
    color: var(--sup-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.support-attach-btn:hover {
    background: rgba(108, 92, 231, 0.2);
    border-color: var(--sup-primary);
    color: #ffffff;
    transform: scale(1.04);
}

.support-attach-btn svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.support-textarea-wrap {
    flex: 1;
    position: relative;
}

.support-input-field {
    width: 100%;
    min-height: 40px;
    max-height: 120px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 9px 14px;
    color: #ffffff;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    line-height: 1.4;
    transition: border-color 0.2s, background 0.2s;
    box-sizing: border-box;
}

.support-input-field:focus {
    border-color: var(--sup-primary);
    background: rgba(255, 255, 255, 0.08);
}

.support-input-field::placeholder {
    color: rgba(255, 255, 255, 0.35);
}

.support-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--sup-primary-grad);
    border: none;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(108, 92, 231, 0.3);
}

.support-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 18px rgba(108, 92, 231, 0.45);
}

.support-send-btn:active {
    transform: scale(0.95);
}

.support-send-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
    transform: translateX(1px);
}

/* Полноэкранный Lightbox для просмотра картинок */
.support-lightbox-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(8px);
    z-index: 100000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.support-lightbox-overlay.active {
    display: flex;
}

.support-lightbox-img {
    max-width: 92vw;
    max-height: 92vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
    animation: zoomInLight 0.25s ease;
}

@keyframes zoomInLight {
    from { transform: scale(0.85); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.support-lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #ffffff;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.support-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Мобильная адаптивность для модального чата */
@media (max-width: 640px) {
    .support-modal-overlay {
        padding: 0;
    }

    .support-modal-window {
        height: 100%;
        max-height: 100%;
        width: 100%;
        max-width: 100%;
        border-radius: 0;
        border: none;
    }

    .support-modal-header {
        padding-top: max(16px, env(safe-area-inset-top));
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
    }

    .support-input-footer {
        padding-bottom: max(14px, env(safe-area-inset-bottom));
        padding-left: max(14px, env(safe-area-inset-left));
        padding-right: max(14px, env(safe-area-inset-right));
    }
}
