/* ============================================
   CHAT WIDGET - Floating Chat Widget Styles
   ============================================ */

/* --- FAB (Floating Action Button) --- */
#chat-widget-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #53354A;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    z-index: 1045;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#chat-widget-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

#chat-widget-fab .ph {
    font-size: 26px;
}

/* Unread badge on FAB */
#chat-widget-fab-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    background: #E53935;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    line-height: 20px;
    font-family: 'Poppins', sans-serif;
}

/* --- Panel --- */
#chat-widget-panel {
    position: fixed;
    bottom: 90px;
    right: 24px;
    width: 380px;
    height: 520px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    z-index: 1045;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: cw-slideUp 0.25s ease-out;
    font-family: 'Poppins', sans-serif;
}

@keyframes cw-slideUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Header --- */
.chat-widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #28293D;
    color: #fff;
    min-height: 52px;
    flex-shrink: 0;
}

.chat-widget-header-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    flex: 1;
    text-align: center;
}

.chat-widget-header-btn {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background 0.15s;
}

.chat-widget-header-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.chat-widget-header-btn .ph {
    font-size: 20px;
}

.chat-widget-header-left {
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-widget-header-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* --- List View --- */
#chat-widget-list-view {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

/* Tabs */
.chat-widget-tabs {
    display: flex;
    border-bottom: 1px solid #E5E5E5;
    padding: 0 12px;
    flex-shrink: 0;
}

.chat-widget-tab {
    flex: 1;
    padding: 10px 4px;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    color: #777;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
    font-family: 'Poppins', sans-serif;
}

.chat-widget-tab:hover {
    color: #333;
}

.chat-widget-tab.active {
    color: #53354A;
    border-bottom-color: #53354A;
    font-weight: 600;
}

/* Search */
.chat-widget-search {
    padding: 8px 12px;
    flex-shrink: 0;
}

.chat-widget-search input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #E0E0E0;
    border-radius: 8px;
    font-size: 13px;
    outline: none;
    font-family: 'Poppins', sans-serif;
    transition: border-color 0.15s;
}

.chat-widget-search input:focus {
    border-color: #53354A;
}

/* Chat heads list */
#chat-widget-heads {
    flex: 1;
    overflow-y: auto;
    padding: 0 8px 8px;
}

.cw-chat-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
}

.cw-chat-head:hover {
    background: #F5F5F5;
}

.cw-chat-head.active {
    background: #F0EBF0;
}

.cw-chat-head-img {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}

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

.cw-chat-head-name {
    font-size: 14px;
    font-weight: 600;
    color: #28293D;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cw-chat-head-title {
    font-size: 12px;
    font-weight: 400;
    color: #777;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cw-chat-head-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.cw-chat-head-time {
    font-size: 11px;
    color: #999;
    white-space: nowrap;
}

.cw-chat-head-unread {
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    background: #53354A;
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 18px;
}

.cw-chat-head-unread.visible {
    display: flex;
}

/* Empty state */
.cw-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    color: #999;
}

.cw-empty-state .ph {
    font-size: 48px;
    color: #ccc;
    margin-bottom: 12px;
}

.cw-empty-state p {
    margin: 0;
    font-size: 14px;
}

/* Loading skeleton */
.cw-loading {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 8px;
}

.cw-loading-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 8px;
}

.cw-loading-avatar {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: cw-shimmer 1.5s infinite;
}

.cw-loading-lines {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cw-loading-line {
    height: 12px;
    border-radius: 4px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: cw-shimmer 1.5s infinite;
}

.cw-loading-line:first-child {
    width: 60%;
}

.cw-loading-line:last-child {
    width: 80%;
}

@keyframes cw-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* --- Conversation View --- */
#chat-widget-conv-view {
    display: none;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

/* Listing bar */
.chat-widget-listing-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-bottom: 1px solid #E5E5E5;
    background: #FAFAFA;
    flex-shrink: 0;
    cursor: pointer;
    transition: background 0.15s;
}

.chat-widget-listing-bar:hover {
    background: #F0F0F0;
}

.cw-listing-img {
    width: 44px;
    height: 44px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
}

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

.cw-listing-title {
    font-size: 13px;
    font-weight: 500;
    color: #28293D;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cw-listing-price {
    font-size: 12px;
    font-weight: 600;
    color: #53354A;
    margin: 0;
}

.cw-listing-arrow {
    color: #999;
    font-size: 18px;
    flex-shrink: 0;
}

/* Messages area */
#chat-widget-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: #fff;
}

/* Reuse existing design system message classes where possible */
#chat-widget-messages .message-section {
    margin-bottom: 2px;
}

#chat-widget-messages .message-section .message {
    max-width: 85%;
    font-size: 13px;
    padding: 8px 12px;
    line-height: 1.4;
    word-wrap: break-word;
}

#chat-widget-messages .message-time {
    font-size: 10px;
}

/* Date divider inside widget */
#chat-widget-messages .date-devider {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 12px 0 8px;
}

#chat-widget-messages .devider-line {
    flex: 1;
    height: 1px;
    background: #E5E5E5;
}

#chat-widget-messages .chat-date {
    font-size: 11px;
    color: #999;
    white-space: nowrap;
    font-weight: 500;
}

/* Input area */
.chat-widget-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-top: 1px solid #E5E5E5;
    background: #fff;
    flex-shrink: 0;
}

.chat-widget-input-area textarea {
    flex: 1;
    border: 1px solid #E0E0E0;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 13px;
    resize: none;
    outline: none;
    font-family: 'Poppins', sans-serif;
    max-height: 80px;
    line-height: 1.4;
    transition: border-color 0.15s;
}

.chat-widget-input-area textarea:focus {
    border-color: #53354A;
}

.chat-widget-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #53354A;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, transform 0.15s;
}

.chat-widget-send-btn:hover {
    background: #6B4560;
    transform: scale(1.05);
}

.chat-widget-send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.chat-widget-send-btn .ph {
    font-size: 18px;
}

/* --- Mobile Responsive --- */
@media (max-width: 480px) {
    #chat-widget-panel {
        width: calc(100vw - 16px);
        height: calc(100vh - 100px);
        right: 8px;
        bottom: 80px;
        border-radius: 12px;
    }

    #chat-widget-fab {
        bottom: 16px;
        right: 16px;
    }
}

/* --- Scrollbar styling --- */
#chat-widget-heads::-webkit-scrollbar,
#chat-widget-messages::-webkit-scrollbar {
    width: 4px;
}

#chat-widget-heads::-webkit-scrollbar-track,
#chat-widget-messages::-webkit-scrollbar-track {
    background: transparent;
}

#chat-widget-heads::-webkit-scrollbar-thumb,
#chat-widget-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 2px;
}

#chat-widget-heads::-webkit-scrollbar-thumb:hover,
#chat-widget-messages::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}
