/* Telegram Chat Styles */
.telegram-chat-page {
    font-family: 'Noto Sans Bengali', 'Segoe UI', sans-serif;
    background: #0e1621;
    color: #fff;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

.telegram-app {
    display: flex;
    height: 100vh;
    width: 100%;
    position: relative;
}

/* Sidebar Styles */
.telegram-sidebar {
    width: 350px;
    background: #17212b;
    border-right: 1px solid #0e1621;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 99;
}

.sidebar-header {
    padding: 10px 20px;
    background: #17212b;
    border-bottom: 1px solid #0e1621;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0088cc, #00a2ff);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.avatar-placeholder {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
}

.header-actions {
    display: flex;
    gap: 10px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: #6b7b8c;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.sidebar-search {
    padding: 15px 20px;
    background: #17212b;
    border-bottom: 1px solid #0e1621;
}

.search-container {
    position: relative;
    display: flex;
    align-items: center;
}

.search-container i {
    position: absolute;
    left: 15px;
    color: #6b7b8c;
    font-size: 14px;
}

.search-container input {
    width: 100%;
    padding: 12px 20px 12px 40px;
    background: #242f3d;
    border: none;
    border-radius: 20px;
    color: #fff;
    font-size: 14px;
    font-family: inherit;
}

.search-container input:focus {
    outline: none;
    background: #2b5278;
}

.sidebar-chats {
    flex: 1;
    overflow-y: auto;
    background: #17212b;
}

.chats-header {
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #17212b;
    border-bottom: 1px solid #0e1621;
}

.chats-header h4 {
    font-size: 14px;
    color: #6b7b8c;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.badge {
    background: #0088cc;
    color: #fff;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
}

.chats-list {
    padding: 0;
}

.chat-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.chat-item:hover {
    background: #202b36;
}

.chat-item.active {
    background: #2b5278;
}

.chat-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #0088cc;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    margin-right: 15px;
    flex-shrink: 0;
}

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

.chat-name {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-last-message {
    font-size: 13px;
    color: #6b7b8c;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-time {
    font-size: 12px;
    color: #6b7b8c;
}

.online-dot {
    width: 10px;
    height: 10px;
    background: #34b7f1;
    border-radius: 50%;
    margin-left: 5px;
    display: inline-block;
}

.sidebar-menu {
    background: #17212b;
    border-top: 1px solid #0e1621;
    padding: 15px 0;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 15px 25px;
    color: #6b7b8c;
    text-decoration: none;
    transition: all 0.2s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-size: 14px;
    cursor: pointer;
}

.menu-item i {
    margin-right: 15px;
    font-size: 16px;
    width: 20px;
}

.menu-item:hover {
    background: #202b36;
    color: #fff;
}

.menu-item.active {
    color: #0088cc;
    background: rgba(0, 136, 204, 0.1);
}

/* Main Chat Area */
.telegram-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #0e1621;
    position: relative;
}

/* Chat Header */
.chat-header-telegram {
    background: #17212b;
    border-bottom: 1px solid #0e1621;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.back-btn {
    display: none;
}

.chat-info-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0088cc, #00a2ff);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.chat-details {
    flex: 1;
}

.chat-details h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
}

.chat-details p {
    font-size: 13px;
    color: #34b7f1;
    margin: 0;
}

.header-right {
    display: flex;
    gap: 10px;
}

/* Messages Area */
.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #0e1621;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.date-separator {
    text-align: center;
    margin: 20px 0;
    position: relative;
}

.date-separator span {
    background: rgba(255, 255, 255, 0.1);
    color: #6b7b8c;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 12px;
    display: inline-block;
}

.message-wrapper {
    display: flex;
    max-width: 70%;
    animation: messageAppear 0.3s ease;
}

.message-wrapper.own {
    margin-left: auto;
    justify-content: flex-end;
}

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

.telegram-message {
    position: relative;
    padding: 8px 12px;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.4;
    font-size: 14px;
}

.telegram-message.received {
    background: #2b5278;
    color: #fff;
    border-bottom-left-radius: 4px;
}

.telegram-message.sent {
    background: #1e6e4c;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.telegram-message.system-message {
    background: rgba(255, 255, 255, 0.05);
    color: #6b7b8c;
    text-align: center;
    font-size: 13px;
    border-radius: 10px;
    max-width: 80%;
    margin: 0 auto;
}

.sender-info {
    display: flex;
    align-items: center;
    margin-bottom: 4px;
    padding: 0 4px;
}

.sender-name {
    font-weight: 600;
    font-size: 13px;
    color: #34b7f1;
}

.message-time {
    font-size: 11px;
    opacity: 0.7;
    margin-left: 8px;
}

.message-content {
    display: flex;
    align-items: flex-end;
    gap: 6px;
}

.message-text {
    flex: 1;
}

.message-status {
    font-size: 12px;
    display: flex;
    align-items: center;
    margin-left: 4px;
}

.message-status .read {
    color: #34b7f1;
}

/* Message Tail (Telegram style) */
.telegram-message.received:after {
    content: '';
    position: absolute;
    bottom: 0;
    left: -8px;
    width: 0;
    height: 0;
    border-right: 8px solid #2b5278;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
}

.telegram-message.sent:after {
    content: '';
    position: absolute;
    bottom: 0;
    right: -8px;
    width: 0;
    height: 0;
    border-left: 8px solid #1e6e4c;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
}

/* Typing Indicator */
.typing-indicator-telegram {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    background: rgba(0, 0, 0, 0.3);
    position: absolute;
    bottom: 70px;
    left: 20px;
    border-radius: 18px;
    backdrop-filter: blur(10px);
    animation: typingPulse 1.5s infinite;
}

.typing-indicator-telegram.active {
    display: flex;
}

@keyframes typingPulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots .dot {
    width: 8px;
    height: 8px;
    background: #34b7f1;
    border-radius: 50%;
    animation: typingDot 1.4s infinite ease-in-out both;
}

.typing-dots .dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dots .dot:nth-child(2) { animation-delay: -0.16s; }

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

/* Message Input */
.message-input-telegram {
    background: #17212b;
    border-top: 1px solid #0e1621;
    padding: 10px 20px;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    position: sticky;
    bottom: 0;
    z-index: 10;
}

.input-left, .input-right {
    flex-shrink: 0;
}

.input-center {
    flex: 1;
    min-width: 0;
}

.message-input-wrapper {
    display: flex;
    align-items: flex-end;
    background: #242f3d;
    border-radius: 20px;
    padding: 8px 15px;
    border: 1px solid transparent;
    transition: border-color 0.2s;
}

.message-input-wrapper:focus-within {
    border-color: #0088cc;
}

.message-input-wrapper textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    min-height: 20px;
    padding: 0;
    outline: none;
    line-height: 1.4;
}

.input-actions {
    margin-left: 10px;
}

.input-action-btn {
    width: 36px;
    height: 36px;
    font-size: 16px;
}

.char-count {
    font-size: 11px;
    color: #6b7b8c;
    text-align: right;
    padding: 4px 8px 0;
}

.send-btn {
    width: 48px;
    height: 48px;
    background: #0088cc;
    border: none;
    border-radius: 50%;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 18px;
}

.send-btn:hover {
    background: #0077b5;
}

.send-btn:disabled {
    background: #6b7b8c;
    cursor: not-allowed;
}

/* Recording Indicator */
.recording-indicator {
    display: none;
    position: absolute;
    bottom: 70px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(229, 62, 62, 0.9);
    color: white;
    padding: 12px 20px;
    border-radius: 20px;
    backdrop-filter: blur(10px);
    animation: recordingPulse 1s infinite;
}

.recording-indicator.active {
    display: block;
}

@keyframes recordingPulse {
    0%, 100% { transform: translateX(-50%) scale(1); }
    50% { transform: translateX(-50%) scale(1.05); }
}

.recording-content {
    display: flex;
    align-items: center;
    gap: 15px;
}

.recording-animation {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sound-wave {
    display: flex;
    align-items: center;
    gap: 2px;
    height: 20px;
}

.sound-wave .bar {
    width: 3px;
    background: white;
    border-radius: 2px;
    animation: soundWave 1s infinite ease-in-out;
}

.sound-wave .bar:nth-child(1) { height: 6px; animation-delay: 0.1s; }
.sound-wave .bar:nth-child(2) { height: 10px; animation-delay: 0.2s; }
.sound-wave .bar:nth-child(3) { height: 14px; animation-delay: 0.3s; }
.sound-wave .bar:nth-child(4) { height: 10px; animation-delay: 0.4s; }
.sound-wave .bar:nth-child(5) { height: 6px; animation-delay: 0.5s; }

@keyframes soundWave {
    0%, 100% { height: 6px; }
    50% { height: 14px; }
}

.cancel-record {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.cancel-record:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Emoji Picker */
.emoji-picker-telegram {
    position: absolute;
    bottom: 70px;
    right: 20px;
    background: #17212b;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    width: 320px;
    height: 300px;
    display: none;
    flex-direction: column;
    z-index: 1000;
    border: 1px solid #0e1621;
    overflow: hidden;
}

.emoji-picker-telegram.active {
    display: flex;
}

.emoji-categories {
    display: flex;
    background: #242f3d;
    padding: 10px;
    border-bottom: 1px solid #0e1621;
}

.emoji-category {
    flex: 1;
    background: transparent;
    border: none;
    color: #6b7b8c;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.emoji-category.active {
    background: #0088cc;
    color: white;
}

.emoji-category:hover {
    background: #2b5278;
    color: white;
}

.emoji-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 5px;
    padding: 15px;
    overflow-y: auto;
}

.emoji-item {
    font-size: 24px;
    text-align: center;
    padding: 5px;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s;
}

.emoji-item:hover {
    background: #242f3d;
}

/* Attachment Menu */
.attachment-menu {
    position: absolute;
    bottom: 70px;
    left: 20px;
    background: #17212b;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    width: 280px;
    padding: 15px;
    display: none;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    z-index: 1000;
    border: 1px solid #0e1621;
}

.attachment-menu.active {
    display: grid;
}

.attachment-option {
    background: transparent;
    border: none;
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 15px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s;
}

.attachment-option:hover {
    background: #242f3d;
}

.option-icon {
    width: 50px;
    height: 50px;
    background: #0088cc;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

/* Chat Menu */
.chat-menu {
    position: absolute;
    top: 60px;
    right: 20px;
    background: #17212b;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    width: 220px;
    padding: 10px 0;
    display: none;
    z-index: 1000;
    border: 1px solid #0e1621;
}

.chat-menu.active {
    display: block;
}

.menu-items {
    display: flex;
    flex-direction: column;
}

.menu-items .menu-item {
    padding: 12px 20px;
    color: #fff;
    font-size: 14px;
}

.menu-items .menu-item:hover {
    background: #242f3d;
}

.menu-items .menu-item.danger {
    color: #ff6b6b;
}

.menu-items .menu-item.danger:hover {
    background: rgba(255, 107, 107, 0.1);
}

/* Scrollbar Styling */
.messages-area::-webkit-scrollbar {
    width: 6px;
}

.messages-area::-webkit-scrollbar-track {
    background: transparent;
}

.messages-area::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.messages-area::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Responsive Design */
@media (max-width: 768px) {
    .telegram-sidebar {
        position: fixed;
        left: -350px;
        top: 0;
        bottom: 0;
        width: 85%;
        max-width: 350px;
        z-index: 1000;
        box-shadow: 2px 0 20px rgba(0, 0, 0, 0.3);
    }
    
    .telegram-sidebar.active {
        left: 0;
    }
    
    .sidebar-overlay.active {
        display: block;
    }
    
    .back-btn {
        display: flex;
    }
    
    .message-wrapper {
        max-width: 85%;
    }
    
    .emoji-picker-telegram {
        width: 280px;
        right: 10px;
    }
    
    .attachment-menu {
        width: 250px;
        left: 10px;
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .message-wrapper {
        max-width: 90%;
    }
    
    .chat-header-telegram {
        padding: 10px 15px;
    }
    
    .message-input-telegram {
        padding: 10px 15px;
    }
    
    .emoji-picker-telegram {
        width: 100%;
        right: 0;
        left: 0;
        bottom: 60px;
        border-radius: 0;
        height: 250px;
    }
    
    .attachment-menu {
        width: 90%;
        left: 5%;
    }
}