﻿*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg-primary: #f2f2f7;
    --bg-secondary: #ffffff;
    --bg-sidebar: #ffffff;
    --bubble-me: #EEF2FF;
    --bubble: #6E6E6E;
    --bubble-btnSend: #007aff;
    --bubble-me-online: #007aff;
    --bubble-me-text: #000;
    --bubble-other: #e9e9eb;
    --bubble-other-text: #1c1c1e;
    --text-primary: #1c1c1e;
    --text-secondary: #8e8e93;
    --text-tertiary: #aeaeb2;
    --divider: #e5e5ea;
    --active-bg: #e8f0fe;
    --active-indicator: #007aff;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --borderCard: rgba(0,0,0,0.08);
    --radius-bubble: 18px;
    --radius-card: 14px;
    --input-bg: #f2f2f7;
    --online: #34c759;
    --shadow-Card: 0 12px 40px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.06);
    --textConver: #1a1a1a;
    --mutedConver: #888;
    --bg3: #BCBCD4;
    --bg4: #26262e;
}

/* body {
            font-family: -apple-system, 'SF Pro Text', 'Helvetica Neue', sans-serif;
            background: var(--bg-primary);
            height: 100vh;
            display: flex;
            overflow: hidden;
            color: var(--text-primary);
        }*/

/* ─── SIDEBAR ─── */
.sidebar-chat {
    
    width: 320px;
    min-width: 280px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--divider);
    display: flex;
    flex-direction: column;
    height: 90vh;
}

.sidebar-chat-header {
    padding: 20px 16px 12px;
    border-bottom: 1px solid var(--divider);
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 0px 10px;
    padding-bottom: 10px !important;
}

.sidebar-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.4px;
    margin-bottom: 12px;
}

.search-box {
    position: relative;
}

    .search-box input {
        width: 100%;
        background: var(--input-bg);
        border: none;
        border-radius: 10px;
        padding: 8px 12px 8px 34px;
        font-size: 15px;
        color: var(--text-primary);
        outline: none;
        transition: background 0.2s;
    }

        .search-box input::placeholder {
            color: var(--text-tertiary);
        }

.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    font-size: 14px;
}

.conversation-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
}

    .conversation-list::-webkit-scrollbar {
        width: 4px;
    }

    .conversation-list::-webkit-scrollbar-track {
        background: transparent;
    }

    .conversation-list::-webkit-scrollbar-thumb {
        background: var(--divider);
        border-radius: 4px;
    }

.conversation-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.15s;
    position: relative;
}

    .conversation-item:hover {
        background: var(--bg-primary);
    }

    .conversation-item.active {
        background: #e8f4ff;
    }

        .conversation-item.active::before {
            content: '';
            position: absolute;
            left: 0;
            top: 8px;
            bottom: 8px;
            width: 3px;
            background: var(--active-indicator);
            border-radius: 0 3px 3px 0;
        }

.avatar-chat {
    position: relative;
    flex-shrink: 0;
}

.avatar-chat-img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
    color: white;
    flex-shrink: 0;
}

.avatar-chat-badge {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 13px;
    height: 13px;
    background: var(--online);
    border-radius: 50%;
    border: 2px solid white;
}

.conv-info {
    flex: 1;
    min-width: 0;
}

.conv-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 2px;
}

.conv-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-time {
    font-size: 12px;
    color: var(--text-tertiary);
    flex-shrink: 0;
    margin-left: 8px;
}

.conv-preview {
    font-size: 13.5px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.unread-dot {
    width: 9px;
    height: 9px;
    background: var(--bubble-me-online);
    border-radius: 50%;
    flex-shrink: 0;
}

/* ─── CHAT MAIN ─── */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg-secondary);
    height: 90vh
}

.chat-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--divider);
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255,255,255,0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.chat-header-info {
    flex: 1;
}

.chat-header-name {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.2px;
}

.chat-header-status {
    font-size: 12px;
    color: var(--online);
    font-weight: 500;
}

.header-actions {
    display: flex;
    gap: 4px;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--input-bg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--bubble-me);
    font-size: 16px;
    transition: background 0.15s, transform 0.1s;
}

    .icon-btn:hover {
        background: #dde8ff;
        transform: scale(1.05);
    }

/* ─── MESSAGES ─── */
.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: #f9f9fb;
}

    .messages-area::-webkit-scrollbar {
        width: 5px;
    }

    .messages-area::-webkit-scrollbar-track {
        background: transparent;
    }

    .messages-area::-webkit-scrollbar-thumb {
        background: var(--divider);
        border-radius: 4px;
    }

.date-divider {
    text-align: center;
    font-size: 12px;
    color: var(--text-tertiary);
    font-weight: 500;
    margin: 14px 0 8px;
}

.msg-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 4px;
}

    .msg-group.me {
        align-items: flex-end;
    }

    .msg-group.other {
        align-items: flex-start;
    }

.msg-row {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    max-width: 70%;
}

.msg-group.me .msg-row {
    flex-direction: row-reverse;
}

.msg-group.other .msg-row {
    flex-direction: row;
}

.msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
    margin-bottom: 2px;
}

.msg-group.me .msg-avatar {
    display: none;
}

.bubble {
    padding: 9px 14px;
    border-radius: var(--radius-bubble);
    font-size: 15px;
    line-height: 1.45;
    position: relative;
    word-break: break-word;
    transition: transform 0.1s;
}

    .bubble:active {
        transform: scale(0.97);
    }

.msg-group.me .bubble {
    background: var(--bubble-me);
    color: var(--bubble-me-text);
    border-bottom-right-radius: 5px;
}

.msg-group.other .bubble {
    background: var(--bubble-other);
    color: var(--bubble-other-text);
    border-bottom-left-radius: 5px;
}

/* tail tweaks for consecutive messages */
.msg-group.me .msg-row:not(:last-child) .bubble {
    border-bottom-right-radius: var(--radius-bubble);
}

.msg-group.other .msg-row:not(:last-child) .bubble {
    border-bottom-left-radius: var(--radius-bubble);
}

.msg-group.other .msg-row:not(:last-child) .msg-avatar {
    visibility: hidden;
}

.msg-time {
    font-size: 11px;
    color: var(--text-tertiary);
    padding: 0 2px;
    align-self: flex-end;
    flex-shrink: 0;
}

.msg-group.me .msg-time {
    text-align: right;
}

/* typing indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 0;
}

.typing-dots {
    background: var(--bubble-other);
    border-radius: var(--radius-bubble);
    padding: 10px 14px;
    display: flex;
    gap: 4px;
    align-items: center;
}

.dot {
    width: 7px;
    height: 7px;
    background: var(--text-tertiary);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

    .dot:nth-child(2) {
        animation-delay: 0.2s;
    }

    .dot:nth-child(3) {
        animation-delay: 0.4s;
    }

@@keyframes bounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-5px);
    }
}

/* ─── INPUT ─── */
.input-area {
    padding: 12px 16px;
    border-top: 1px solid var(--divider);
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(20px);
}

.input-extra-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    background: var(--input-bg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--bubble-me);
    font-size: 18px;
    flex-shrink: 0;
    transition: background 0.15s;
}

    .input-extra-btn:hover {
        background: #dde8ff;
    }

.input-wrapper {
    flex: 1;
    background: var(--input-bg);
    border-radius: 20px;
    padding: 8px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1.5px solid transparent;
    transition: border-color 0.2s;
}

    .input-wrapper:focus-within {
        border-color: var(--bubble-me);
        background: white;
        box-shadow: 0 0 0 3px rgba(0,122,255,0.12);
    }

#messageInput {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 15px;
    color: var(--text-primary);
    outline: none;
    resize: none;
    max-height: 120px;
    line-height: 1.4;
    font-family: inherit;
}

    #messageInput::placeholder {
        color: var(--text-tertiary);
    }

.emoji-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    opacity: 0.7;
    transition: opacity 0.15s, transform 0.15s;
}

    .emoji-btn:hover {
        opacity: 1;
        transform: scale(1.15);
    }

.send-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    background: var(--bubble-btnSend);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 15px;
    flex-shrink: 0;
    transition: background 0.15s, transform 0.1s;
}

    .send-btn:hover {
        background: #0066dd;
    }

    .send-btn:active {
        transform: scale(0.92);
    }

    .send-btn:disabled {
        background: var(--divider);
        cursor: default;
        transform: none;
    }

/* ─── EMPTY STATE ─── */
.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 56px;
    opacity: 0.3;
}

.empty-text {
    font-size: 17px;
    font-weight: 500;
}

.empty-sub {
    font-size: 14px;
    color: var(--text-tertiary);
}

/* ─── RESPONSIVE ─── */
@@media (max-width: 640px) {
    .sidebar {
        width: 100%;
        position: absolute;
        z-index: 10;
    }

        .sidebar.hidden {
            display: none;
        }
}

/* ─── ANIMATIONS ─── */
.bubble-enter {
    animation: bubbleIn 0.22s cubic-bezier(0.34, 1.36, 0.64, 1);
}

@@keyframes bubbleIn {
    from {
        transform: scale(0.85);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}
.heightCenter{
    height: 100%;
    display: flex;
    align-items: center;
}

.att-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--input-bg);
    border: 1px solid var(--divider);
    border-radius: 10px;
    padding: 5px 10px 5px 8px;
    font-size: 12.5px;
    color: var(--text-primary);
    max-width: 200px;
    animation: bubbleIn 0.2s ease;
}

.att-chip-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.att-chip-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 130px;
}

.att-chip-size {
    font-size: 11px;
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.att-chip-remove {
    background: var(--text-tertiary);
    border: none;
    color: white;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-left: 2px;
    transition: background 0.15s;
}

    .att-chip-remove:hover {
        background: #e24b4a;
    }

.att-img-thumb {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
}
.bubble-file {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-bubble);
    background: var(--bubble-other);
    max-width: 260px;
    cursor: pointer;
    transition: opacity 0.15s;
}

    .bubble-file:hover {
        opacity: 0.85;
    }

.msg-group.me .bubble-file {
    background: #005ecb;
    color: white;
    border-bottom-right-radius: 5px;
}

.bubble-file-icon {
    font-size: 28px;
    flex-shrink: 0;
}

.bubble-file-info {
    min-width: 0;
}

.bubble-file-name {
    font-size: 13.5px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
}

.bubble-file-size {
    font-size: 11px;
    opacity: 0.65;
    margin-top: 2px;
}

.bubble-img {
    max-width: 240px;
    max-height: 200px;
    border-radius: 14px;
    display: block;
    cursor: pointer;
    object-fit: cover;
    transition: opacity 0.15s;
}

    .bubble-img:hover {
        opacity: 0.9;
    }
.quick-actions-bar {
    padding: 8px 16px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    background: rgba(255,255,255,0.95);
    padding-bottom: 6px
}

.quick-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border-radius: 20px;
    border: 1.5px solid var(--divider);
    background: white;
    font-size: 12.5px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s, transform 0.1s;
    white-space: nowrap;
    font-family: inherit;
}
    .quick-action-btn:hover {
        border-color: var(--bubble-me);
        color: var(--bubble-me);
        background: #f0f6ff;
        transform: translateY(-1px);
    }

    .quick-action-btn:active {
        transform: scale(0.96);
    }

    .quick-action-btn .qa-icon {
        font-size: 13px;
    }
/* From Uiverse.io by ryota1231 */
.animated-button {
    position: relative;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 30px;
    border: 4px solid;
    border-color: transparent;
    font-size: 16px;
    border-radius: 100px;
    font-weight: 600;
    color: #1f387e;
    box-shadow: 0 0 0 2px #ffffff;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.6s cubic-bezier(0.23, 1, 0.32, 1);
    margin-top: 10px
}

    .animated-button svg {
        position: absolute;
        width: 24px;
        fill: #1f387e;
        z-index: 9;
        transition: all 0.8s cubic-bezier(0.23, 1, 0.32, 1);
    }

    .animated-button .arr-1 {
        right: 16px;
    }

    .animated-button .arr-2 {
        left: -25%;
    }

    .animated-button .circle {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 20px;
        height: 20px;
        background-color: #c5e5e4;
        border-radius: 50%;
        opacity: 0;
        transition: all 0.8s cubic-bezier(0.23, 1, 0.32, 1);
    }

    .animated-button .text {
        position: relative;
        z-index: 1;
        transform: translateX(-12px);
        transition: all 0.8s cubic-bezier(0.23, 1, 0.32, 1);
        font-size: 15px
    }

    .animated-button:hover {
        box-shadow: 0 0 0 12px transparent;
        color: #212121;
        border-radius: 12px;
    }

        .animated-button:hover .arr-1 {
            right: -25%;
        }

        .animated-button:hover .arr-2 {
            left: 16px;
        }

        .animated-button:hover .text {
            transform: translateX(12px);
        }

        .animated-button:hover svg {
            fill: #1f387e;
        }

    .animated-button:active {
        scale: 0.95;
        box-shadow: 0 0 0 4px greenyellow;
    }

    .animated-button:hover .circle {
        width: 220px;
        height: 220px;
        opacity: 1;
    }
.unread-badge {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: #34c759;
    border-radius: 10px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11.5px;
    font-weight: 700;
    color: white;
    letter-spacing: -0.3px;
}
.popup-overlayChat {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100;
}

    .popup-overlayChat.open {
        display: block;
    }
.popup-Conversation {
    position: absolute;
    top: 75px;
    right: 70px;
    width: 340px;
    background: var(--bg-secondary);
    border-radius: var(--radius-card);
    border: 1px solid var(--borderCard);
    box-shadow: var(--shadow-Card);
    overflow: hidden;
    animation: popIn .2s cubic-bezier(.22,.68,0,1.2);
    transform-origin: top right;
}
.itemConversation {
    left: -355px !important;
    width: 400px;
    height: 300px;
}

.popupConver-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 10px 0px;
    border-bottom: 1px solid var(--border);
}

    .popupConver-header h3 {
        font-size: 15px;
        font-weight: 600;
    }

.closeConver-btn {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: none;
    background: #f9f8f5;
    cursor: pointer;
    font-size: 14px;
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
}

    .closeConver-btn:hover {
        background: var(--borderCard);
    }
.popupConver-search {
    margin: 10px 12px 8px;
    display: flex;
    align-items: center;
    gap: 7px;
    background: #f9f8f5;
    border: 1px solid var(--borderCard);
    border-radius: 10px;
    padding: 7px 12px;
}
.popupConver-search svg {
    width: 13px;
    height: 13px;
    opacity: 0.35;
    flex-shrink: 0;
}

.popupConver-search input {
    border: none;
    background: transparent;
    font-size: 13px;
    color: var(--textConver);
    font-family: inherit;
    outline: none;
    width: 100%;
}

    .popupConver-search input::placeholder {
        color: var(--mutedConver);
    }

.popupConver-footer {
    padding: 10px 14px;
    border-top: 1px solid var(--borderCard);
    text-align: center;
}

    .popupConver-footer a {
        font-size: 13px;
        color: #378ADD;
        text-decoration: none;
        font-weight: 500;
    }

        .popupConver-footer a:hover {
            text-decoration: underline;
        }

.member-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 8px;
    scrollbar-width: thin;
    scrollbar-color: var(--bg4) transparent;
}

.member-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 10px;
    cursor: pointer;
    transition: background .12s;
    margin-bottom: 2px;
}
    .member-item:hover {
        background: var(--bg3);
    }

.m-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 600;
    flex-shrink: 0;
    position: relative;
}
.m-info {
    flex: 1;
    min-width: 0;
}
.m-badge {
    font-size: 9px;
    font-weight: 600;
    padding: 2px 5px;
    border-radius: 4px;
    flex-shrink: 0;
}

.badge-admin {
    background: rgba(62,207,142,0.15);
    color: #3ecf8e;
}
.add-btn {
    width: 100%;
    padding: 7px;
    border-radius: var(--r-sm);
    background: transparent;
    border: 0.5px solid var(--border2);
    color: var(--text2);
    font-size: 12px;
    cursor: pointer;
    font-family: 'DM Sans',sans-serif;
    transition: background .15s,color .15s;
}

    .add-btn:hover {
        background: var(--bg3);
        color: var(--text);
    }