/* Telegram Style - RTL Optimized */
:root {
    --primary-color: #3390ec;
    --bg-color: #87a3b3;
    --sidebar-bg: #fff;
    --msg-in: #fff;
    --msg-out: #effdde;
    --border-color: #dfe1e5;
}

body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    direction: rtl;
    text-align: right;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#tlc-fullscreen-app {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
.tlc-sidebar {
    width: 400px;
    background: #fff;
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.tlc-header {
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.tlc-search-bar {
    flex: 1;
}

.tlc-search-bar input {
    width: 100%;
    padding: 8px 16px;
    border-radius: 20px;
    border: none;
    background: #f1f1f1;
    font-size: 15px;
    outline: none;
}

.tlc-contact-list {
    flex: 1;
    overflow-y: auto;
}

.tlc-contact-item {
    display: flex;
    padding: 12px 16px;
    gap: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.tlc-contact-item:hover {
    background: #f4f4f5;
}

.tlc-contact-item.active {
    background: var(--primary-color);
    color: #fff;
}

.tlc-avatar img {
    width: 54px;
    height: 54px;
    border-radius: 50%;
}

.tlc-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
}

.tlc-name {
    font-weight: bold;
    font-size: 16px;
    margin-bottom: 2px;
}

.tlc-last-msg {
    font-size: 14px;
    color: #707579;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tlc-contact-item.active .tlc-last-msg {
    color: rgba(255,255,255,0.8);
}

/* Chat Area */
.tlc-chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-color);
    background-image: url('https://telegram.org/img/t_bg.png');
    position: relative;
}

.tlc-chat-header {
    height: 56px;
    background: #fff;
    display: flex;
    align-items: center;
    padding: 0 16px;
    border-bottom: 1px solid var(--border-color);
    z-index: 10;
}

.tlc-messages-container {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tlc-message {
    display: flex;
    width: 100%;
}

.tlc-message.sent {
    justify-content: flex-start;
}

.tlc-message.received {
    justify-content: flex-end;
}

.tlc-bubble {
    max-width: 85%;
    padding: 6px 12px;
    position: relative;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
}

.tlc-message.sent .tlc-bubble {
    background: var(--msg-out);
    border-radius: 15px 15px 0 15px;
}

.tlc-message.received .tlc-bubble {
    background: var(--msg-in);
    border-radius: 15px 15px 15px 0;
}

.tlc-time {
    font-size: 11px;
    margin-top: -2px;
    align-self: flex-end;
}

.tlc-message.sent .tlc-time { color: #4fae4e; }
.tlc-message.received .tlc-time { color: #a2acb4; }

.tlc-input-area {
    padding: 8px 16px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 700px;
    margin: 0 auto;
    width: 100%;
}

.tlc-input-wrapper {
    flex: 1;
    background: #fff;
    border-radius: 26px;
    padding: 4px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.tlc-reply-preview {
    display: none;
    background: rgba(255,255,255,0.95);
    padding: 8px 16px;
    border-right: 4px solid var(--primary-color);
    margin: 0 16px 8px;
    border-radius: 12px;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.tlc-reply-preview.active {
    display: flex;
}

.tlc-reply-preview-content {
    flex: 1;
    overflow: hidden;
    text-align: right;
}

.tlc-reply-title {
    font-size: 12px;
    font-weight: bold;
    color: var(--primary-color);
}

#tlc-reply-preview-text {
    font-size: 13px;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tlc-cancel-reply {
    background: none;
    border: none;
    font-size: 18px;
    color: #707579;
    cursor: pointer;
}

.tlc-reply-box {
    background: rgba(0,0,0,0.05);
    padding: 4px 8px;
    border-right: 3px solid var(--primary-color);
    border-radius: 4px;
    margin-bottom: 4px;
    font-size: 13px;
    color: #555;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 768px) {
    .tlc-back-btn {
        display: block;
    }
}

/* Responsive */
@media (max-width: 1024px) {
    .tlc-sidebar {
        width: 320px;
    }
}

@media (max-width: 768px) {
    #tlc-fullscreen-app {
        flex-direction: column;
    }
    
    .tlc-sidebar {
        width: 100%;
        height: 100%;
        border-left: none;
    }
    
    .tlc-chat-area {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: white;
        z-index: 20;
        display: none; /* Controlled by JS */
    }
    
    .tlc-chat-area.active {
        display: flex;
    }

    .tlc-input-area {
        padding-bottom: 12px;
    }
}

.tlc-attach-btn, .tlc-emoji-btn {
    background: none;
    border: none;
    font-size: 22px;
    color: #707579;
    cursor: pointer;
    padding: 4px;
}

.tlc-send-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--primary-color);
    border: none;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    font-size: 20px;
}
