/* Telegram — visual mobile */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --tg-blue: #517da2;
    --tg-blue-dark: #3d6a8f;
    --tg-accent: #3390ec;
    --tg-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --tg-page-bg: #99a2ad;
    --tg-bg: #ffffff;
    --tg-chat-bg: #d1dbe4;
    --tg-header-text: #ffffff;
    --tg-header-sub: rgba(255, 255, 255, 0.78);
    --tg-bubble-in: #ffffff;
    --tg-bubble-out: #eeffde;
    --tg-text: #000000;
    --tg-text-secondary: rgba(0, 0, 0, 0.45);
    --tg-btn-text: #3390ec;
    --tg-btn-border: rgba(51, 144, 236, 0.35);
}

html, body {
    height: 100%;
    overflow: hidden;
}

.telegram-page {
    background: var(--tg-page-bg);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    font-family: var(--tg-font);
    -webkit-font-smoothing: antialiased;
}

.telegram-app {
    width: 100%;
    max-width: 430px;
    height: 100vh;
    height: 100dvh;
    background: var(--tg-bg);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 24px rgba(0, 0, 0, 0.15);
}

/* ===== Header ===== */
.telegram-header {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 6px 4px 6px 0;
    background: linear-gradient(180deg, #6ba0c7 0%, var(--tg-blue) 100%);
    flex-shrink: 0;
    min-height: 56px;
}

.telegram-header-back {
    color: var(--tg-header-text);
    width: 40px;
    height: 40px;
}

.telegram-header-back svg { width: 22px; height: 22px; }

.telegram-header-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.telegram-avatar-wrap { flex-shrink: 0; }

.telegram-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.telegram-avatar-ph {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
    font-size: 16px;
    font-weight: 600;
}

.telegram-header .chat-header-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--tg-header-text);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.telegram-status {
    font-size: 13px;
    color: var(--tg-header-sub);
    line-height: 1.3;
}

.telegram-status.is-active {
    color: var(--tg-header-sub);
}

.telegram-header-actions {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    padding-right: 2px;
}

.telegram-header .chat-header-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: none;
    background: none;
    color: var(--tg-header-text);
    cursor: default;
    text-decoration: none;
}

.telegram-header .chat-header-btn.is-linked { cursor: pointer; }
.telegram-header .chat-header-btn.is-linked:active { opacity: 0.7; }
.telegram-header .chat-header-btn svg { width: 21px; height: 21px; }

.chat-header-back {
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    text-decoration: none;
    flex-shrink: 0;
}

.chat-header-back.is-linked { cursor: pointer; }

/* ===== Messages ===== */
.telegram-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    background-color: var(--tg-chat-bg);
    background-image:
        radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.12) 1px, transparent 1px),
        radial-gradient(circle at 70% 70%, rgba(255, 255, 255, 0.1) 1px, transparent 1px);
    background-size: 24px 24px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px 10px 8px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    -webkit-overflow-scrolling: touch;
}

.chat-date-divider {
    align-self: center;
    margin: 8px 0 10px;
    padding: 4px 10px;
    font-size: 13px;
    font-weight: 500;
    color: #fff;
    background: rgba(0, 0, 0, 0.22);
    border-radius: 14px;
}

.chat-msg {
    display: flex;
    flex-direction: column;
    max-width: 82%;
    margin-bottom: 2px;
    animation: tgFadeIn 0.2s ease;
}

.chat-msg-in { align-self: flex-start; }
.chat-msg-out { align-self: flex-end; }

@keyframes tgFadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-bubble {
    background: var(--tg-bubble-in);
    padding: 7px 11px 8px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.35;
    color: var(--tg-text);
    word-wrap: break-word;
    white-space: pre-wrap;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08);
}

.chat-msg-in .chat-bubble {
    border-bottom-left-radius: 4px;
}

.chat-msg-out .chat-bubble {
    background: var(--tg-bubble-out);
    border-bottom-right-radius: 4px;
}

.chat-media {
    max-width: 260px;
    max-height: 320px;
    border-radius: 12px;
    margin-bottom: 4px;
    object-fit: cover;
    display: block;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.chat-media-video {
    width: 260px;
    border-radius: 12px;
}

.chat-media-audio {
    width: 100%;
    max-width: 280px;
}

.chat-buttons {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 6px;
    width: 100%;
    min-width: 190px;
}

.chat-btn {
    background: var(--tg-bubble-in);
    border: 1px solid var(--tg-btn-border);
    padding: 9px 14px;
    border-radius: 8px;
    font-family: var(--tg-font);
    font-size: 14px;
    font-weight: 500;
    color: var(--tg-btn-text);
    cursor: pointer;
    text-align: center;
    transition: background 0.15s;
    width: 100%;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.06);
}

.chat-btn:hover:not(:disabled) { background: #f5f9ff; }
.chat-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.chat-typing-wrap {
    align-self: flex-start;
    padding: 4px 0;
}

.chat-typing {
    display: inline-flex;
    align-items: center;
    background: var(--tg-bubble-in);
    padding: 11px 14px;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08);
}

.typing-dots {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}

.typing-dots span {
    width: 7px;
    height: 7px;
    background: #8e959c;
    border-radius: 50%;
    animation: tgBounce 1.4s infinite ease-in-out both;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes tgBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ===== Composer ===== */
.telegram-composer {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    padding: 6px 8px 8px;
    background: var(--tg-bg);
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    flex-shrink: 0;
}

.telegram-composer-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 44px;
    border: none;
    background: none;
    color: var(--tg-text-secondary);
    flex-shrink: 0;
}

.telegram-composer-btn svg { width: 22px; height: 22px; }

.telegram-composer-field {
    flex: 1;
    min-width: 0;
}

.telegram-composer-input {
    width: 100%;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: var(--tg-bg);
    border-radius: 22px;
    font-family: var(--tg-font);
    font-size: 15px;
    color: var(--tg-text);
    outline: none;
    padding: 10px 14px;
}

.telegram-composer-input::placeholder {
    color: var(--tg-text-secondary);
}

.telegram-composer-send {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: var(--tg-accent);
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(51, 144, 236, 0.35);
}

.telegram-composer-send svg {
    width: 20px;
    height: 20px;
    margin-left: 2px;
}

.telegram-brand {
    text-align: center;
    padding: 6px;
    font-size: 10px;
    background: var(--tg-bg);
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.telegram-brand a {
    color: var(--tg-text-secondary);
    text-decoration: none;
}

@media (min-width: 768px) {
    .telegram-page { background: var(--tg-page-bg); }
    .telegram-app { box-shadow: 0 4px 24px rgba(0, 0, 0, 0.18); }
}
