﻿/* ===== ریست کامل ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #0e1621;
    color: #ffffff;
    direction: rtl;
    position: fixed;
    width: 100%;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

/* ===== کانتینر اصلی ===== */
.telegram-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    max-width: 900px;
    margin: 0 auto;
    background: #0e1621;
    position: relative;
    overflow: hidden;
}

/* ===== هدر ===== */
.chat-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: #17212b;
    border-bottom: 1px solid #2c3e50;
    flex-shrink: 0;
    z-index: 10;
}

.header-back {
    color: #64b5f6;
    cursor: pointer;
    padding: 8px;
    margin-left: 8px;
    display: flex;
    align-items: center;
}

.header-info {
    flex: 1;
}

.header-title {
    font-size: 17px;
    font-weight: 600;
    color: #ffffff;
}

.header-status {
    font-size: 13px;
    color: #7ecb8a;
}

.header-actions {
    color: #64b5f6;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
}

/* ===== صفحه ورود ===== */
.login-section {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 20px;
}

.login-box {
    background: #17212b;
    padding: 40px;
    border-radius: 16px;
    text-align: center;
    width: 100%;
    max-width: 400px;
    border: 1px solid #2c3e50;
}

    .login-box h2 {
        margin-bottom: 24px;
        color: #ffffff;
        font-weight: 600;
    }

    .login-box input {
        width: 100%;
        padding: 14px 16px;
        border: 2px solid #2c3e50;
        border-radius: 10px;
        background: #0e1621;
        color: #ffffff;
        font-size: 16px;
        margin-bottom: 16px;
        transition: border-color 0.3s;
    }

        .login-box input:focus {
            outline: none;
            border-color: #64b5f6;
        }

        .login-box input::placeholder {
            color: #6b7a88;
        }

.btn-join {
    width: 100%;
    padding: 14px;
    background: #64b5f6;
    color: #ffffff;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

    .btn-join:hover {
        background: #42a5f5;
    }

/* ===== بخش چت ===== */
.chat-section {
    display: none;
    flex-direction: column;
    flex: 1;
    height: 100%;
    overflow: hidden;
}

/* ===== پیام خطا ===== */
#errorMessage {
    background: #e74c3c;
    color: #ffffff;
    padding: 10px 16px;
    margin: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    display: none;
    flex-shrink: 0;
}

    #errorMessage.show {
        display: block;
    }

/* ===== لیست پیام‌ها ===== */
.messages-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: #061529;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}

    .messages-list::-webkit-scrollbar {
        width: 6px;
    }

    .messages-list::-webkit-scrollbar-track {
        background: transparent;
    }

    .messages-list::-webkit-scrollbar-thumb {
        background: #2c3e50;
        border-radius: 3px;
    }

/* ============================================================
   ===== پیام‌ها =====
   ============================================================ */

.message-wrapper {
    display: flex;
    flex-direction: column;
    animation: fadeInUp 0.3s ease;
    width: 100%;
    margin-bottom: 2px;
}

.message-mine {
    align-items: flex-end;
    direction: rtl;
}

    .message-mine .message-content {
        background: #daeccb;
        color: #ffffff;
        border-bottom-left-radius: 4px;
        border-bottom-right-radius: 12px;
        width: 100%;
        margin-left: 17px;
    }

.message-theirs {
    align-items: flex-start;
    direction: ltr;
}

    .message-theirs .message-content {
        background: #ffffff;
        color: #ffffff;
        border-bottom-right-radius: 4px;
        border-bottom-left-radius: 12px;
        width: 100%;
        margin-right: 17px;
    }

.message-content {
    max-width: 95%;
    padding: 8px 14px;
    border-radius: 12px;
    position: relative;
    word-wrap: break-word;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* ===== نام کاربر ===== */
.message-sender {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 3px;
}

.message-mine .message-sender {
    color: #204c10;
    text-align: right;
}

.message-theirs .message-sender {
    color: #204c10;
    text-align: left;
}

/* ===== متن پیام ===== */
.message-text {
    font-size: 15px;
    line-height: 1.6;
    color: #0b0b0b;
    direction: rtl;
}

/* ============================================================
   ===== عکس در پیام =====
   ============================================================ */

.image-container {
    position: relative;
    display: inline-block;
    border-radius: 8px;
    overflow: hidden;
    margin: 4px auto;
    max-width: 280px;
    background: transparent;
    line-height: 0;
}

    .image-container .message-image {
        width: 100%;
        max-height: 350px;
        border-radius: 8px;
        display: block;
        cursor: pointer;
        transition: transform 0.3s ease, filter 0.3s ease;
    }

    .image-container::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: linear-gradient(135deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0.05) 40%, rgba(255, 255, 255, 0.02) 60%, rgba(255, 255, 255, 0.1) 100%);
        pointer-events: none;
        z-index: 1;
        border-radius: 8px;
        transition: opacity 0.3s ease;
    }

    .image-container:hover::before {
        opacity: 0.5;
    }

    .image-container:hover .message-image {
        transform: scale(1.02);
        filter: brightness(1.05);
    }

    /* ============================================================
   ===== دکمه دانلود روی عکس =====
   ============================================================ */

    .image-container .download-btn {
        position: absolute;
        bottom: 8px;
        right: 8px;
        width: 36px;
        height: 36px;
        border-radius: 50%;
        background: rgba(0, 0, 0, 0.7);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        border: 2px solid rgba(255, 255, 255, 0.25);
        color: #ffffff;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.3s ease;
        z-index: 2;
        opacity: 0;
        transform: scale(0.8);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }

    .image-container:hover .download-btn {
        opacity: 1;
        transform: scale(1);
    }

    .image-container .download-btn:hover {
        background: rgba(100, 181, 246, 0.85);
        border-color: #64b5f6;
        transform: scale(1.15) !important;
        box-shadow: 0 4px 12px rgba(100, 181, 246, 0.4);
    }

    .image-container .download-btn svg {
        width: 18px;
        height: 18px;
        fill: none;
        stroke: #ffffff;
        stroke-width: 2.5;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    .image-container .download-btn.downloaded {
        background: rgba(46, 125, 50, 0.85);
        border-color: #4caf50;
        opacity: 1 !important;
        transform: scale(1) !important;
    }

        .image-container .download-btn.downloaded svg {
            stroke: #4caf50;
            stroke-width: 3;
        }

        .image-container .download-btn.downloaded:hover {
            background: rgba(46, 125, 50, 0.95);
            transform: scale(1.1) !important;
        }

    .image-container .download-btn.loading {
        animation: downloadPulse 0.5s ease infinite;
        background: rgba(100, 181, 246, 0.7);
    }

/* ============================================================
   ===== فیلم در پیام =====
   ============================================================ */
.video-container {
    position: relative;
    display: inline-block;
    border-radius: 8px;
    overflow: hidden;
    margin: 4px auto;
    max-width: 280px;
    background: #000;
    line-height: 0;
}

    .video-container video {
        width: 100%;
        max-height: 350px;
        border-radius: 8px;
        display: block;
        background: #000;
        outline: none;
    }

    .video-container .download-btn {
        position: absolute;
        bottom: 8px;
        right: 8px;
        width: 36px;
        height: 36px;
        border-radius: 50%;
        background: rgba(0, 0, 0, 0.7);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        border: 2px solid rgba(255, 255, 255, 0.25);
        color: #ffffff;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.3s ease;
        z-index: 2;
        opacity: 0;
        transform: scale(0.8);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }

    .video-container:hover .download-btn {
        opacity: 1;
        transform: scale(1);
    }

    .video-container .download-btn:hover {
        background: rgba(100, 181, 246, 0.85);
        border-color: #64b5f6;
        transform: scale(1.15) !important;
        box-shadow: 0 4px 12px rgba(100, 181, 246, 0.4);
    }

    .video-container .download-btn svg {
        width: 18px;
        height: 18px;
        fill: none;
        stroke: #ffffff;
        stroke-width: 2.5;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    .video-container .download-btn.downloaded {
        background: rgba(46, 125, 50, 0.85);
        border-color: #4caf50;
        opacity: 1 !important;
        transform: scale(1) !important;
    }

        .video-container .download-btn.downloaded svg {
            stroke: #4caf50;
            stroke-width: 3;
        }

        .video-container .download-btn.downloaded:hover {
            background: rgba(46, 125, 50, 0.95);
            transform: scale(1.1) !important;
        }

    .video-container .download-btn.loading {
        animation: downloadPulse 0.5s ease infinite;
        background: rgba(100, 181, 246, 0.7);
    }

/* ============================================================
   ===== فایل در پیام =====
   ============================================================ */
.file-container {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    margin: 4px 0;
    cursor: pointer;
    transition: all 0.3s ease;
    max-width: 280px;
}

    .file-container:hover {
        background: rgba(255, 255, 255, 0.1);
        border-color: #64b5f6;
    }

.file-icon {
    font-size: 28px;
    flex-shrink: 0;
}

.file-info {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-size: 14px;
    font-weight: 500;
    color: #000;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-size {
    font-size: 11px;
    color: #08273f;
}

.file-download-btn {
    background: none;
    border: none;
    color: #64b5f6;
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

    .file-download-btn:hover {
        background: rgba(100, 181, 246, 0.1);
        transform: scale(1.1);
    }

    .file-download-btn svg {
        width: 20px;
        height: 20px;
        fill: none;
        stroke: #64b5f6;
        stroke-width: 2;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    .file-download-btn.downloaded {
        color: #4caf50;
    }

        .file-download-btn.downloaded svg {
            stroke: #4caf50;
        }

/* ============================================================
   ===== انیمیشن دانلود =====
   ============================================================ */
@keyframes downloadPulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.3);
    }

    100% {
        transform: scale(1);
    }
}

/* ============================================================
   ===== تاریخ و زمان =====
   ============================================================ */
.message-time {
    font-size: 11px;
    opacity: 0.8;
    margin-top: 4px;
    color: rgb(0, 0, 0);
    direction: ltr;
    text-align: left;
}

/* ============================================================
   ===== باکس ریپلای =====
   ============================================================ */
.reply-box {
    background: rgba(98, 190, 36, 0.12);
    border-right: 3px solid #64b5f6;
    padding: 4px 10px;
    margin-bottom: 5px;
    border-radius: 4px;
    font-size: 13px;
    max-width: 100%;
    cursor: pointer;
    transition: background 0.2s;
}

    .reply-box:hover {
        background: rgba(100, 181, 246, 0.2);
    }

.reply-user {
    color: #1c4a02;
    font-weight: 600;
}

.reply-text {
    color: #1c4a02;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
    display: inline-block;
}

.message-mine .reply-box {
    border-right-color: #5d8801;
}

.message-mine .reply-user {
    color: #1c4a02;
}

/* ============================================================
   ===== دکمه‌های اکشن (ریپلای) =====
   ============================================================ */
.message-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
    opacity: 0;
    transition: opacity 0.2s;
    justify-content: flex-end;
}

.message-theirs .message-actions {
    justify-content: flex-start;
}

.message-wrapper:hover .message-actions {
    opacity: 1;
}

.action-btn {
    background: none;
    border: none;
    color: #0851ff;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

    .action-btn:hover {
        color: #64b5f6;
        background: rgba(100, 181, 246, 0.1);
    }

/* ===== پیام سیستمی ===== */
.system-message {
    text-align: center;
    color: #8a9ba8;
    font-size: 13px;
    padding: 6px 12px;
    margin: 6px 0;
    background: rgba(30, 41, 59, 0.4);
    border-radius: 8px;
    align-self: center;
    max-width: 80%;
}

/* ===== انیمیشن ===== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================================
   ===== نوار پایین (ورودی) - اصلاح برای موبایل =====
   ============================================================ */
.chat-input-area {
    flex-shrink: 0;
    padding: 8px 12px 12px 12px;
    background: #17212b;
    border-top: 1px solid #2c3e50;
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
}

#replyIndicator {
    background: rgba(100, 181, 246, 0.08);
    padding: 6px 12px;
    border-right: 3px solid #64b5f6;
    margin-bottom: 4px;
    border-radius: 4px;
    font-size: 13px;
    color: #8a9ba8;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #1e2b36;
    border-radius: 12px;
    padding: 4px 8px;
    border: 1px solid #2c3e50;
    position: relative;
    min-height: 48px;
}

/* ============================================================
   ===== منوی گیره =====
   ============================================================ */
.pin-menu-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.pin-btn {
    background: none;
    border: none;
    color: #64b5f6;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    transition: transform 0.2s;
    font-size: 22px;
    line-height: 1;
}

    .pin-btn:hover {
        transform: scale(1.1);
    }

.pin-menu {
    display: none;
    position: absolute;
    bottom: 60px;
    right: 0;
    background: #1e2b36;
    border-radius: 14px;
    padding: 6px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
    border: 1px solid #2c3e50;
    z-index: 100;
    min-width: 180px;
}

    .pin-menu.show {
        display: block;
        animation: menuFadeIn 0.2s ease;
    }

@keyframes menuFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.pin-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border: none;
    background: none;
    color: #e0e0e0;
    cursor: pointer;
    border-radius: 10px;
    transition: all 0.2s ease;
    width: 100%;
    font-size: 14px;
    font-weight: 500;
}

    .pin-menu-item:hover {
        background: rgba(100, 181, 246, 0.12);
        color: #ffffff;
    }

    .pin-menu-item .icon {
        font-size: 20px;
        width: 28px;
        text-align: center;
    }

    .pin-menu-item .label {
        white-space: nowrap;
    }

    .pin-menu-item .badge {
        background: rgba(100, 181, 246, 0.15);
        color: #64b5f6;
        font-size: 10px;
        padding: 2px 8px;
        border-radius: 10px;
        margin-right: auto;
        font-weight: 600;
    }

/* ===== دکمه‌های مخفی ===== */
.hidden-input {
    display: none !important;
}

/* ===== ورودی متن ===== */
.input-wrapper input[type="text"] {
    flex: 1;
    padding: 10px 12px;
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 15px;
    outline: none;
    min-width: 0;
    height: 40px;
}

    .input-wrapper input[type="text"]::placeholder {
        color: #6b7a88;
    }

.send-btn {
    background: #64b5f6;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #ffffff;
    transition: background 0.3s;
    flex-shrink: 0;
}

    .send-btn:hover {
        background: #42a5f5;
    }

    .send-btn:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

/* ============================================================
   ===== اوورلی بزرگنمایی عکس =====
   ============================================================ */
.image-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.3s ease;
}

.image-overlay-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

    .image-overlay-content img {
        max-width: 100%;
        max-height: 85vh;
        border-radius: 8px;
        object-fit: contain;
    }

.image-close {
    position: absolute;
    top: -40px;
    right: -40px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #ffffff;
    font-size: 24px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transition: background 0.3s;
}

    .image-close:hover {
        background: rgba(255, 255, 255, 0.25);
    }

.overlay-download-btn {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    padding: 10px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
    margin-top: 16px;
}

    .overlay-download-btn:hover {
        background: rgba(100, 181, 246, 0.7);
    }

    .overlay-download-btn svg {
        width: 20px;
        height: 20px;
        fill: none;
        stroke: #ffffff;
        stroke-width: 2;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    .overlay-download-btn.downloaded {
        background: rgba(46, 125, 50, 0.7);
        border-color: #4caf50;
        cursor: default;
        opacity: 0.8;
    }

        .overlay-download-btn.downloaded:hover {
            background: rgba(46, 125, 50, 0.7);
            transform: none !important;
        }

        .overlay-download-btn.downloaded svg {
            stroke: #4caf50;
        }

    .overlay-download-btn:disabled {
        cursor: not-allowed;
        opacity: 0.7;
    }

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* ============================================================
   ===== Toast Message =====
   ============================================================ */
.toast-container {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}

.toast-message {
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #ffffff;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: toastIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    display: flex;
    align-items: center;
    gap: 10px;
    pointer-events: auto;
    min-width: 150px;
    justify-content: center;
}

    .toast-message.success {
        border-color: rgba(76, 175, 80, 0.5);
    }

        .toast-message.success .toast-icon {
            color: #4caf50;
        }

    .toast-message.error {
        border-color: rgba(231, 76, 60, 0.5);
    }

        .toast-message.error .toast-icon {
            color: #e74c3c;
        }

.toast-icon {
    font-size: 20px;
}

.toast-message.hide {
    animation: toastOut 0.3s ease forwards;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }

    to {
        opacity: 0;
        transform: translateY(30px) scale(0.9);
    }
}

/* ============================================================
   ===== واکنش‌گرایی - موبایل =====
   ============================================================ */
@media (max-width: 600px) {
    .telegram-container {
        max-width: 100%;
        height: 100dvh;
    }

    .message-content {
        max-width: 88%;
    }

    .image-container {
        max-width: 200px;
    }

        .image-container .message-image {
            max-height: 280px;
        }

    .video-container {
        max-width: 200px;
    }

        .video-container video {
            max-height: 280px;
        }

    .login-box {
        padding: 24px;
    }

    .reply-text {
        max-width: 120px;
    }

    .download-btn {
        width: 32px;
        height: 32px;
        bottom: 6px;
        right: 6px;
    }

        .download-btn svg {
            width: 16px;
            height: 16px;
        }

    .image-close {
        top: -35px;
        right: -35px;
        width: 32px;
        height: 32px;
        font-size: 18px;
    }

    .toast-message {
        padding: 10px 18px;
        font-size: 13px;
        min-width: 120px;
    }

    .pin-menu {
        min-width: 160px;
        right: 0;
        left: auto;
    }

    .chat-input-area {
        padding: 6px 8px 12px 8px;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    .input-wrapper {
        padding: 2px 6px;
        min-height: 44px;
    }

        .input-wrapper input[type="text"] {
            padding: 8px 10px;
            font-size: 14px;
            height: 36px;
        }

    .send-btn {
        width: 36px;
        height: 36px;
    }

        .send-btn svg {
            width: 20px;
            height: 20px;
        }

    .pin-btn {
        font-size: 20px;
        padding: 6px;
    }
}

/* ===== برای موبایل‌های با ناچ (Notch) ===== */
@supports (padding: max(0px)) {
    .chat-input-area {
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }
}

/* ===== برای مرورگرهایی که dvh پشتیبانی نمی‌کنند ===== */
@supports not (height: 100dvh) {
    .telegram-container {
        height: 100vh;
    }
}




/* ============================================================
   ===== Progress Bar برای آپلود =====
   ============================================================ */
.upload-progress-container {
    display: none;
    margin: 8px 0;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    direction: ltr;
}

    .upload-progress-container.show {
        display: block;
        animation: fadeIn 0.3s ease;
    }

.upload-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
    font-size: 12px;
    color: #8a9ba8;
}

.upload-progress-filename {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70%;
}

.upload-progress-percent {
    font-weight: 600;
    color: #64b5f6;
}

.upload-progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.upload-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #64b5f6, #42a5f5);
    border-radius: 2px;
    transition: width 0.3s ease;
}

    .upload-progress-fill.complete {
        background: linear-gradient(90deg, #4caf50, #66bb6a);
    }

    .upload-progress-fill.error {
        background: linear-gradient(90deg, #e74c3c, #ef5350);
    }

.upload-progress-cancel {
    background: none;
    border: none;
    color: #e74c3c;
    cursor: pointer;
    font-size: 16px;
    padding: 0 4px;
    transition: transform 0.2s;
}

    .upload-progress-cancel:hover {
        transform: scale(1.2);
    }

/* ===== آیکون‌های وضعیت ===== */
.upload-status-icon {
    font-size: 16px;
    margin-right: 8px;
}

    .upload-status-icon.uploading {
        animation: spin 1s linear infinite;
    }

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}






/* ============================================================
   ===== باکس آپلود (در حال ارسال) =====
   ============================================================ */
.uploading-message {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 12px 16px;
    margin: 4px 0;
    border: 1px solid rgba(255, 255, 255, 0.08);
    animation: fadeInUp 0.3s ease;
    max-width: 280px;
    align-self: flex-end;
}

    .uploading-message .upload-icon {
        font-size: 28px;
        flex-shrink: 0;
    }

    .uploading-message .upload-info {
        flex: 1;
        min-width: 0;
    }

    .uploading-message .upload-filename {
        font-size: 14px;
        color: #e0e0e0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .uploading-message .upload-status-text {
        font-size: 12px;
        color: #8a9ba8;
        margin-top: 2px;
    }

    .uploading-message .upload-progress-bar {
        width: 100%;
        height: 3px;
        background: rgba(255, 255, 255, 0.1);
        border-radius: 2px;
        margin-top: 4px;
        overflow: hidden;
    }

    .uploading-message .upload-progress-fill {
        height: 100%;
        width: 0%;
        background: linear-gradient(90deg, #64b5f6, #42a5f5);
        border-radius: 2px;
        transition: width 0.3s ease;
    }

        .uploading-message .upload-progress-fill.complete {
            background: linear-gradient(90deg, #4caf50, #66bb6a);
        }

        .uploading-message .upload-progress-fill.error {
            background: linear-gradient(90deg, #e74c3c, #ef5350);
        }

    .uploading-message .upload-cancel-btn {
        background: none;
        border: none;
        color: #e74c3c;
        cursor: pointer;
        font-size: 18px;
        padding: 0 4px;
        transition: transform 0.2s;
        flex-shrink: 0;
    }

        .uploading-message .upload-cancel-btn:hover {
            transform: scale(1.2);
        }




/* ============================================================
   ===== استایل تیک‌های وضعیت =====
   ============================================================ */
.message-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    margin-top: 2px;
}

.message-status {
    font-size: 12px;
    font-weight: 600;
    margin-left: 2px;
    direction: ltr;
    letter-spacing: -1px;
}

    .message-status.seen {
        color: #64b5f6;
    }

    .message-status.delivered {
        color: #8a9ba8;
    }

    .message-status.sent {
        color: #8a9ba8;
    }

/* ===== آپلود تکه‌تکه ===== */
.uploading-message .upload-progress-fill {
    transition: width 0.5s ease;
}

.upload-progress-fill {
    height: 100%;
    border-radius: 2px;
    background: linear-gradient(90deg, #64b5f6, #42a5f5);
    transition: width 0.3s ease;
}