:root {

    /* =========================
       TELEGRAM COLOR SYSTEM
       ========================= */

    --tg-bg: #e7ebf0;
    --tg-surface: #ffffff;

    --tg-incoming: #ffffff;
    --tg-outgoing: #d9fdd3;

    --tg-primary: #3390ec;
    --tg-online: #31d158;

    --tg-text: #0f172a;
    --tg-muted: #6b7280;

    --tg-border: #e6e6e6;

    --tg-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

/* =========================
   GLOBAL
   ========================= */

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--tg-text);
}

/* =========================
   LAYOUT
   ========================= */

.layout {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--tg-bg);
    max-width: 1000px;
    border-left: 1px solid var(--tg-border);
    border-right: 1px solid var(--tg-border);
}

.layout-container {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.screens-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.screens {
    flex: 1;
    overflow: hidden;
    background: var(--tg-bg);
}

/* =========================
   TOPBAR
   ========================= */

.topbar {
    background: var(--tg-surface);
    border-bottom: 1px solid var(--tg-border);
    box-shadow: var(--tg-shadow);
    z-index: 10;
}

/* avatar */
.topbar .rounded-circle {
    box-shadow: var(--tg-shadow);
}

/* online */
.text-success {
    color: var(--tg-online) !important;
}

/* =========================
   CHAT AREA
   ========================= */

.chat {
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

.chat-scroll-down {
    position: absolute;
    bottom: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--tg-surface);
    border: 1px solid var(--tg-border);
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    color: var(--tg-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: opacity .2s;
}

.chat-bodies {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 10px;

    background:
            radial-gradient(rgba(0,0,0,0.02) 1px, transparent 1px);
    background-size: 18px 18px;
}

/* message rows */
.message {
    display: flex;
    margin-bottom: 8px;
}

.message-in {
    justify-content: flex-start;
}

.message-out {
    justify-content: flex-end;
}

/* =========================
   BUBBLES (REAL TELEGRAM COLORS)
   ========================= */

.bubble {
    max-width: 78%;
    padding: 9px 12px 7px 12px;
    border-radius: 16px;
    font-size: 14.5px;
    line-height: 1.35;
    word-break: break-word;
    box-shadow: var(--tg-shadow);
}

/* incoming */
.message-in .bubble {
    background: var(--tg-incoming);
    color: var(--tg-text);

    border-top-left-radius: 6px;
    border-top-right-radius: 16px;
    border-bottom-right-radius: 16px;
    border-bottom-left-radius: 16px;

    border: 1px solid rgba(0,0,0,0.04);
}

/* outgoing */
.message-out .bubble {
    background: var(--tg-outgoing);
    color: var(--tg-text);

    border-top-right-radius: 6px;
    border-top-left-radius: 16px;
    border-bottom-right-radius: 16px;
    border-bottom-left-radius: 16px;

    border: 1px solid rgba(0,0,0,0.03);
}

/* timestamp */
.time {
    font-size: 10px;
    color: var(--tg-muted);
    text-align: right;
    margin-top: 4px;
}

/* date label */
.chat-group {
    position: relative;
}

.chat-date-label {
    display: flex;
    justify-content: center;
    margin: 12px 0 8px;
    position: sticky;
    top: 0;
    z-index: 1;
}

.chat-date-label span {
    background: rgb(255, 255, 255);
    color: var(--tg-muted);
    font-size: 13px;
    padding: 3px 10px;
    border-radius: 50px;
}

/* =========================
   MESSAGE INPUT
   ========================= */

.message-input-container {
    background: var(--tg-surface);
    border-top: 1px solid var(--tg-border);
    padding: 8px 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.message-input-container input {
    border: 1px solid var(--tg-border);
    border-radius: 999px;
    padding: 10px 14px;
    font-size: 14px;
    box-shadow: none;
}

.message-input-container input:focus {
    border-color: var(--tg-primary);
    outline: none;
}

/* buttons */
.message-input-container .btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* =========================
   BOTTOM NAVBAR
   ========================= */

.navbar {
    background: var(--tg-surface);
    border-top: 1px solid var(--tg-border);
    height: 70px;
    padding: 0;
}

.navbar a {
    flex: 1;
    text-align: center;
    text-decoration: none;
    color: var(--tg-muted);
    font-size: 13px;
}

.navbar a i {
    display: block;
    font-size: 24px;
    margin-bottom: 3px;
}

.navbar a.active {
    color: var(--tg-primary);
}

.navbar a.active i {
    color: var(--tg-primary);
}

/* =========================
   TOPBAR ACTIONS
   ========================= */

.topbar .btn-link {
    color: var(--tg-muted);
}

.topbar .btn-link:hover {
    color: var(--tg-primary);
}

/* =========================
   MOBILE
   ========================= */

@media (max-width: 768px) {

    .bubble {
        max-width: 85%;
        font-size: 13.5px;
    }

    .message-input-container {
        padding: 6px 8px;
    }

    .navbar {
        height: 70px;
    }
}


.screen {
    display: none;
    height: 100%;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

/* chat list */
.chat-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: white;
    border-radius: 12px;
    cursor: pointer;
}

.chat-item .avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #3390ec;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-info .name {
    font-weight: 600;
}

.chat-info .preview {
    font-size: 12px;
    color: #6b7280;
}

/* =========================
   CONTACTS
   ========================= */

.contacts-screen{
    display:flex;
    flex-direction:column;
    height:100%;
    position:relative;
}

.contacts-header{
    background:var(--tg-surface);
    border-bottom:1px solid var(--tg-border);
}

.contacts-list{
    flex:1;
    overflow-y:auto;
    padding:8px;
}

.contact-item{
    display:flex;
    align-items:center;
    gap:14px;

    padding:12px;

    margin-bottom:6px;

    background:var(--tg-surface);

    border-radius:16px;

    color:var(--tg-text);

    transition:.15s;
}

.contact-item:hover{
    background:#f8fafc;
}

.contact-avatar{

    width:52px;
    height:52px;

    border-radius:50%;

    background:var(--tg-primary);
    color:#fff;

    font-weight:600;
    font-size:18px;

    display:flex;
    align-items:center;
    justify-content:center;

    flex-shrink:0;

}

.contact-content{
    flex:1;
}

.contact-name{
    font-weight:600;
    margin-bottom:3px;
}

.contact-status{
    font-size:12px;
}

.contact-status i{
    font-size:7px;
    margin-right:4px;
}

.contact-action{
    color:var(--tg-muted);
}

/* =========================
   FLOATING ACTION BUTTON
   ========================= */

.contact-fab{

    position:absolute;

    right:20px;
    bottom:20px;

    width:58px;
    height:58px;

    border-radius:50%;

    display:flex;
    align-items:center;
    justify-content:center;

    font-size:20px;

    z-index:100;

}








.contacts-add-screen {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--tg-bg, #f4f6f8);
}

/* =========================
   SEARCH HEADER
   ========================= */

.contacts-search-header {
    padding: 10px;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
}

.contacts-search-input {
    border: none;
    box-shadow: none !important;
}

.contacts-search-input:focus {
    box-shadow: none !important;
}

.contacts-search-input {
    box-shadow: none !important;
    /* Chrome, Safari, Edge, Opera */
    &::-webkit-outer-spin-button,
    &::-webkit-inner-spin-button {
        -webkit-appearance: none;
        margin: 0;
    }
    /* Firefox */
    -moz-appearance: textfield;
}

/* =========================
   RESULTS AREA
   ========================= */

.contacts-search-results {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* =========================
   RESULT ITEM (optional base)
   ========================= */

.contact-result-item {
    display: flex;
    align-items: center;
    gap: 12px;

    padding: 12px;
    border-radius: 14px;

    background: #fff;

    cursor: pointer;
}

.contact-result-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;

    background: #3390ec;
    color: #fff;

    display: flex;
    align-items: center;
    justify-content: center;

    font-weight: 600;
}

.contact-result-name {
    font-weight: 600;
}

.contact-result-meta {
    font-size: 12px;
    color: #6b7280;
}

/* =========================
   USER SCREEN
   ========================= */

.user-screen {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--tg-bg);
}

.user-screen-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 20px 24px;
    gap: 12px;
    background: var(--tg-surface);
    border-radius: 16px;
    margin: 16px 12px 0;
}

.user-screen-body .contact-avatar {
    width: 80px;
    height: 80px;
    font-size: 28px;
}

.user-info {
    text-align: center;
}

.user-chat-btn {
    margin-top: 8px;
    border-radius: 999px;
    padding: 8px 24px;
}

.user-details {
    width: 100%;
    text-align: center;
}

.user-detail-row {
    padding: 6px 16px;
}

.user-detail-label {
    font-size: 11px;
    color: var(--tg-muted);
    margin-top: 2px;
}

/* =========================
   PROFILE SCREEN
   ========================= */

.profile-screen {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--tg-bg);
}

.profile-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 20px;
    gap: 12px;
    background: var(--tg-surface);
    border-radius: 16px;
    margin: 16px 12px 0;
}

.profile-avatar {
    width: 80px;
    height: 80px;
    font-size: 28px;
    border-radius: 50%;
    background: var(--tg-primary);
    color: #fff;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.profile-fields {
    width: 80%;
}

.profile-field {
    padding: 6px 16px;
    text-align: left;
}

.profile-field input,
.profile-field textarea {
    border: none;
    background: transparent;
    box-shadow: none !important;
    padding: 0;
    width: 100%;
    font-size: 14px;
    color: var(--tg-text);
    outline: none;
    resize: none;
}

.profile-field input:focus,
.profile-field textarea:focus {
    outline: none;
    box-shadow: none !important;
}

.profile-field-label {
    font-size: 11px;
    color: var(--tg-muted);
    margin-top: 2px;
}

.profile-logout-btn {
    margin-top: 8px;
    border-radius: 999px;
    padding: 8px 24px;
}

