/**
 * Mini Chat & Floating Dock Styles
 * Prefix: mcht_ for mini-chat
 *
 * Components:
 *   1. Chat list popup (header dropdown)
 *   2. Floating mini chat widget windows
 *   3. Minimized circle dock + compose button
 */


/* ============================================
   1. CHAT LIST POPUP (header dropdown)
   ============================================ */
.mcht_popup {
    width: 360px;
    right: 0;
    left: auto;
    z-index: 200;
    cursor: default;
}

.mcht_list_cnt {
    background: var(--surface);
    border: 1px solid var(--border-color);
    overflow: hidden;
    max-height: 520px;
    display: flex;
    flex-direction: column;
}

/* Header */
.mcht_list_hdr {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 8px;
}

.mcht_list_title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}

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

.mcht_hdr_ico {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-secondary);
    background: var(--elevated);
    font-size: 16px;
    transition: background 0.15s;
    text-decoration: none;
}

.mcht_hdr_ico:hover {
    background: var(--elevated-highlight);
    color: var(--text-primary);
}

/* Search */
.mcht_list_search {
    position: relative;
    padding: 4px 16px 8px;
}

.mcht_search_ico {
    position: absolute;
    left: 28px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    font-size: 14px;
    pointer-events: none;
}

.mcht_search_input {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 12px 8px 36px;
    border-radius: 20px;
    border: none;
    background: var(--elevated);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
}

.mcht_search_input::placeholder {
    color: var(--text-tertiary);
}

.mcht_search_input:focus {
    background: var(--elevated-highlight);
}

/* Tabs */
.mcht_list_tabs {
    display: flex;
    gap: 4px;
    padding: 4px 16px 8px;
}

.mcht_tab {
    padding: 6px 12px;
    border-radius: 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.mcht_tab:hover {
    background: var(--elevated);
}

.mcht_tab.active {
    background: var(--button-blue);
    color: var(--button-on-blue);
}

/* Chat list items */
.mcht_list_items {
    flex: 1;
    overflow-y: auto;
    padding: 0 8px;
}

.mcht_list_item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.12s;
}

.mcht_list_item:hover {
    background: var(--elevated);
}

.mcht_item_avatar {
    position: relative;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
}

.mcht_item_avatar img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}

.mcht_status_dot {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--surface);
    background: var(--text-tertiary);
}

.mcht_status_dot.online {
    background: var(--green);
}

.mcht_item_info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mcht_item_name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mcht_item_preview {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mcht_item_time {
    color: var(--text-tertiary);
}

.mcht_unread_dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--button-blue);
    flex-shrink: 0;
}

/* Footer */
.mcht_list_footer {
    padding: 10px 16px;
    text-align: center;
    border-top: 1px solid var(--border-color);
}

.mcht_see_all {
    font-size: 13px;
    font-weight: 600;
    color: var(--blue);
    text-decoration: none;
}

.mcht_see_all:hover {
    text-decoration: underline;
}


/* ============================================
   2. FLOATING MINI CHAT WIDGETS
   ============================================ */
.mcht_root {
    position: fixed;
    bottom: 0;
    right: 0;
    z-index: 150;
    display: flex;
    align-items: flex-end;
    pointer-events: none;
}

.mcht_root * {
    pointer-events: auto;
}

/* Open widget windows row (bottom-right, left of dock) */
.mcht_widgets_area {
    display: flex;
    flex-direction: row-reverse;
    align-items: flex-end;
    gap: 10px;
    margin-right: 10px;
    margin-bottom: 0;
}

/* Individual mini chat window */
.mcht_widget {
    width: 338px;
    height: 455px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-bottom: none;
    border-radius: 10px 10px 0 0;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -2px 12px var(--elevated-shadow-color);
    overflow: hidden;
    transition: height 0.2s ease;
}

.mcht_widget.minimized {
    /* When minimized, widget is removed from DOM and shown as circle in dock */
    display: none;
}

/* Widget header */
.mcht_widget_hdr {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    gap: 8px;
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    flex-shrink: 0;
    user-select: none;
}

.mcht_widget_hdr_avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
}

.mcht_widget_hdr_avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mcht_widget_hdr_avatar .mcht_status_dot {
    width: 8px;
    height: 8px;
    border-width: 1.5px;
    border-color: var(--surface);
}

.mcht_widget_hdr_name {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mcht_widget_hdr_actions {
    display: flex;
    gap: 2px;
    align-items: center;
}

.mcht_widget_hdr_actions i {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 16px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.12s;
}

.mcht_widget_hdr_actions i:hover {
    background: var(--elevated);
    color: var(--text-primary);
}

/* Messages area inside widget */
.mcht_widget_messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Contact info block at top of chat (shown for new / sparse conversations) */
.mcht_contact_block {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 10px 16px;
    gap: 8px;
}

.mcht_contact_avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    overflow: hidden;
}

.mcht_contact_avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mcht_contact_name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.mcht_contact_meta {
    font-size: 12px;
    color: var(--text-tertiary);
    text-align: center;
    line-height: 1.4;
}

/* Message bubble */
.mcht_msg {
    max-width: 80%;
    padding: 8px 12px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.4;
    word-break: break-word;
}

.mcht_msg.incoming {
    align-self: flex-start;
    background: var(--elevated);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.mcht_msg.outgoing {
    align-self: flex-end;
    background: var(--button-blue);
    color: var(--button-on-blue);
    border-bottom-right-radius: 4px;
}

/* Group chat: show author name on incoming messages */
.mcht_msg_author {
    font-size: 11px;
    font-weight: 700;
    color: var(--blue);
    margin-bottom: 2px;
}

/* Widget input area */
.mcht_widget_input {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    gap: 6px;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.mcht_widget_input input {
    flex: 1;
    border: none;
    background: var(--elevated);
    color: var(--text-primary);
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
}

.mcht_widget_input input::placeholder {
    color: var(--text-tertiary);
}

.mcht_widget_input_send {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--blue);
    cursor: pointer;
    font-size: 18px;
    flex-shrink: 0;
}


/* ============================================
   3. DOCK (circles + compose button)
   ============================================ */
.mcht_dock {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 0 16px 16px;
    position: relative;
}

/* Three-dot menu bubble (top of dock, visible on hover) */
.mcht_dock_menu_bubble {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--elevated);
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 18px;
    position: relative;
    box-shadow: 0 2px 8px var(--elevated-shadow-color);
    transition: background 0.15s;
}

.mcht_dock:hover .mcht_dock_menu_bubble {
    display: flex;
}

.mcht_dock_menu_bubble:hover {
    background: var(--elevated-highlight);
    color: var(--text-primary);
}

.mcht_dock_menu_dropdown {
    display: none;
    position: absolute;
    bottom: 48px;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 16px var(--elevated-shadow-color);
    min-width: 180px;
    overflow: hidden;
    z-index: 10;
}

.mcht_dock_menu_dropdown.show {
    display: block;
}

.mcht_dock_menu_item {
    padding: 10px 14px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.12s;
}

.mcht_dock_menu_item:hover {
    background: var(--elevated);
}

/* Overflow bubble (+N) */
.mcht_dock_overflow {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    position: relative;
    overflow: visible;
}

.mcht_dock_overflow_img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
    position: relative;
    background: var(--elevated);
}

.mcht_dock_overflow_img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Dark overlay with +N count */
.mcht_dock_overflow_count {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

/* Overflow tooltip (hover list of names) */
.mcht_overflow_tooltip {
    display: none;
    position: absolute;
    right: 56px;
    bottom: 0;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px var(--elevated-shadow-color);
    padding: 6px 0;
    min-width: 180px;
    z-index: 10;
}

.mcht_dock_overflow:hover .mcht_overflow_tooltip {
    display: block;
}

.mcht_overflow_tip_item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    gap: 8px;
}

.mcht_overflow_tip_name {
    font-size: 13px;
    color: var(--text-primary);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mcht_overflow_tip_close {
    font-size: 14px;
    color: var(--text-tertiary);
    cursor: pointer;
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.mcht_overflow_tip_close:hover {
    background: var(--elevated);
    color: var(--text-primary);
}

/* Minimized circles */
.mcht_dock_circles {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.mcht_dock_circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: visible;
    cursor: pointer;
    position: relative;
    box-shadow: 0 2px 8px var(--elevated-shadow-color);
    transition: transform 0.15s;
}

.mcht_dock_circle:hover {
    transform: scale(1.08);
}

.mcht_dock_circle img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

/* X dismiss button on hover */
.mcht_dock_circle_close {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--border-color);
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: var(--text-secondary);
    cursor: pointer;
    z-index: 2;
}

.mcht_dock_circle:hover .mcht_dock_circle_close {
    display: flex;
}

/* Compose / New Post button */
.mcht_compose_btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--button-blue);
    color: var(--button-on-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    cursor: pointer;
    box-shadow: 0 2px 12px var(--elevated-shadow-color);
    transition: opacity 0.15s, transform 0.15s;
}

.mcht_compose_btn:hover {
    opacity: 0.88;
    transform: scale(1.06);
}


/* ============================================
   4. RESPONSIVE
   ============================================ */

/* On the full chat page, hide the floating area */
.cht_body .mcht_root {
    display: none;
}

@media screen and (max-width: 768px) {
    .mcht_popup {
        width: 300px;
    }

    .mcht_widget {
        width: 300px;
        height: 400px;
    }
}

@media screen and (max-width: 480px) {
    /* On very small screens, mini chat takes full width */
    .mcht_widget {
        width: calc(100vw - 20px);
        height: 400px;
    }

    .mcht_widgets_area {
        flex-direction: column;
    }
}
