/* --- thitruongthuoc Chat System Stylesheet --- */

/* 1. Inline Chat Button Style */
.btn-chat-inline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid var(--color-primary-medium);
    background-color: var(--color-primary-light);
    color: var(--color-primary);
    transition: var(--transition-smooth);
    margin-left: 8px;
    vertical-align: middle;
    outline: none;
    box-shadow: var(--shadow-sm);
}

.btn-chat-inline:hover {
    background-color: var(--color-primary);
    color: #ffffff !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px var(--color-primary-glow);
}

/* 2. Floating Chat Widget Style (Bottom-Right) */
.ttt-floating-chat {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 360px;
    height: 480px;
    background-color: var(--color-bg-card);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--color-border);
    display: none; /* Controlled by JS */
    flex-direction: column;
    overflow: hidden;
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
    transform: translateY(20px);
    opacity: 0;
}

.ttt-floating-chat.active {
    display: flex;
    transform: translateY(0);
    opacity: 1;
}

.ttt-floating-chat-header {
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    color: #ffffff;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.ttt-floating-chat-header-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 14px;
}

.ttt-floating-chat-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ttt-chat-header-btn {
    background: none;
    border: none;
    color: #ffffff;
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
    opacity: 0.8;
    transition: var(--transition-smooth);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
}

.ttt-chat-header-btn:hover {
    opacity: 1;
    background-color: rgba(255, 255, 255, 0.15);
}

.ttt-floating-chat-body {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: calc(100% - 48px);
    background-color: var(--color-bg-base);
}

/* 3. Messages List Area */
.ttt-chat-messages-container {
    flex-grow: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Custom Scrollbar for Chat */
.ttt-chat-messages-container::-webkit-scrollbar,
.ttt-chat-dashboard-sidebar::-webkit-scrollbar {
    width: 6px;
}
.ttt-chat-messages-container::-webkit-scrollbar-track,
.ttt-chat-dashboard-sidebar::-webkit-scrollbar-track {
    background: transparent;
}
.ttt-chat-messages-container::-webkit-scrollbar-thumb,
.ttt-chat-dashboard-sidebar::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 4px;
}
.ttt-chat-messages-container::-webkit-scrollbar-thumb:hover,
.ttt-chat-dashboard-sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--color-border-hover);
}

/* Bubble Styles */
.ttt-chat-msg-row {
    display: flex;
    width: 100%;
}

.ttt-chat-msg-row.msg-me {
    justify-content: flex-end;
}

.ttt-chat-msg-row.msg-partner {
    justify-content: flex-start;
}

.ttt-chat-bubble {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 13px;
    line-height: 1.5;
    position: relative;
    box-shadow: var(--shadow-sm);
}

.ttt-chat-msg-row.msg-me .ttt-chat-bubble {
    background-color: var(--color-primary);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.ttt-chat-msg-row.msg-partner .ttt-chat-bubble {
    background-color: #ffffff;
    color: var(--color-text-dark);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--color-border);
}

.ttt-chat-msg-meta {
    font-size: 10px;
    color: var(--color-text-muted);
    margin-top: 4px;
    display: block;
    opacity: 0.7;
}

.ttt-chat-msg-row.msg-me .ttt-chat-msg-meta {
    text-align: right;
    color: rgba(255, 255, 255, 0.8);
}

/* Input Panel Styles */
.ttt-chat-input-panel {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    background-color: #ffffff;
    border-top: 1px solid var(--color-border);
    gap: 10px;
}

.ttt-chat-input-panel textarea {
    flex-grow: 1;
    border: 1px solid var(--color-border);
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 13px;
    outline: none;
    resize: none;
    max-height: 80px;
    transition: var(--transition-smooth);
    background-color: var(--color-bg-base);
}

.ttt-chat-input-panel textarea:focus {
    border-color: var(--color-primary);
    background-color: #ffffff;
    box-shadow: 0 0 0 3px var(--color-primary-glow);
}

#ttt-chat-send-btn {
    background-color: var(--color-primary);
    color: #ffffff;
    border: none;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-smooth);
    flex-shrink: 0;
    box-shadow: 0 2px 6px var(--color-primary-glow);
}

#ttt-chat-send-btn:hover {
    background-color: hsl(240, 100%, 47%);
    transform: scale(1.05);
}

/* 4. Dashboard Chat Tab layout (2 Column Inbox) */
.ttt-chat-dashboard-container {
    display: flex;
    background-color: #ffffff;
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    height: 600px;
    overflow: hidden;
    margin-top: 16px;
    box-shadow: var(--shadow-sm);
}

.ttt-chat-dashboard-sidebar {
    width: 320px;
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    background-color: #ffffff;
    flex-shrink: 0;
}

.ttt-chat-sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--color-border);
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 16px;
    color: var(--color-text-dark);
}

.ttt-chat-thread-list {
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.ttt-chat-thread-item {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    transition: var(--transition-smooth);
    gap: 12px;
}

.ttt-chat-thread-item:hover {
    background-color: var(--color-bg-base);
}

.ttt-chat-thread-item.active {
    background-color: var(--color-primary-light);
    border-left: 4px solid var(--color-primary);
    padding-left: 12px;
}

.ttt-thread-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary-medium), var(--color-secondary));
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.ttt-thread-info {
    flex-grow: 1;
    min-width: 0;
}

.ttt-thread-name-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 4px;
    gap: 8px;
}

.ttt-thread-name {
    font-weight: 700;
    font-size: 13px;
    color: var(--color-text-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ttt-thread-time {
    font-size: 10px;
    color: var(--color-text-muted);
    flex-shrink: 0;
}

.ttt-thread-msg-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.ttt-thread-last-msg {
    font-size: 12px;
    color: var(--color-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-grow: 1;
}

.ttt-chat-thread-item.unread .ttt-thread-last-msg {
    font-weight: 700;
    color: var(--color-text-dark);
}

.ttt-thread-unread-badge {
    background-color: var(--color-danger);
    color: #ffffff;
    font-size: 10px;
    font-weight: 700;
    border-radius: var(--radius-full);
    min-width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    flex-shrink: 0;
}

/* Dashboard Chat Body Layout */
.ttt-chat-dashboard-body {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--color-bg-base);
    height: 100%;
}

.ttt-chat-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--color-text-muted);
    gap: 16px;
    padding: 40px;
    text-align: center;
}

.ttt-chat-empty-icon {
    font-size: 64px;
    color: var(--color-border-hover);
}

.ttt-chat-dashboard-partner-header {
    background-color: #ffffff;
    border-bottom: 1px solid var(--color-border);
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.ttt-partner-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ttt-partner-header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--color-bg-secondary);
    color: var(--color-primary);
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
}

.ttt-partner-header-name {
    font-weight: 700;
    font-size: 14px;
    color: var(--color-text-dark);
}

.ttt-partner-header-subtext {
    font-size: 11px;
    color: var(--color-text-muted);
    margin-top: 2px;
}

.ttt-partner-header-actions {
    display: flex;
    gap: 8px;
}

.btn-chat-partner-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    border: 1px solid var(--color-border);
    background-color: #ffffff;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.btn-chat-partner-action:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background-color: var(--color-primary-light);
}

/* Dashboard Chat view specifics */
.ttt-chat-dashboard-body .ttt-chat-messages-container {
    height: calc(100% - 128px);
}

/* Mobile responsive layout for Chat Dashboard */
@media (max-width: 768px) {
    .ttt-chat-dashboard-container {
        position: relative;
        height: 500px;
    }
    
    .ttt-chat-dashboard-sidebar {
        width: 100%;
        height: 100%;
        position: absolute;
        top: 0;
        left: 0;
        z-index: 10;
        transition: transform 0.3s ease;
    }
    
    .ttt-chat-dashboard-container.chat-active .ttt-chat-dashboard-sidebar {
        transform: translateX(-100%);
    }
    
    .ttt-chat-dashboard-body {
        width: 100%;
        height: 100%;
        position: absolute;
        top: 0;
        left: 0;
        z-index: 5;
        transition: transform 0.3s ease;
        transform: translateX(100%);
    }
    
    .ttt-chat-dashboard-container.chat-active .ttt-chat-dashboard-body {
        transform: translateX(0);
    }
}

/* 5. Product Preview inside Chat Bubble */
.ttt-chat-product-preview-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    background-color: var(--color-bg-base);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    text-decoration: none !important;
    margin-bottom: 8px;
    transition: var(--transition-smooth);
}

.msg-me .ttt-chat-product-preview-card {
    background-color: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.25);
}

.ttt-chat-product-preview-card:hover {
    background-color: var(--color-bg-hover);
    border-color: var(--color-accent);
}

.msg-me .ttt-chat-product-preview-card:hover {
    background-color: rgba(255, 255, 255, 0.25);
}

.ttt-chat-product-thumb {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.ttt-chat-product-thumb-placeholder {
    width: 40px;
    height: 40px;
    background-color: var(--color-border);
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.ttt-chat-product-preview-info {
    flex-grow: 1;
    min-width: 0;
}

.ttt-chat-product-preview-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--color-text-dark);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.msg-me .ttt-chat-product-preview-title {
    color: #ffffff;
}

.ttt-chat-product-preview-price {
    font-size: 11px;
    color: var(--color-accent);
    font-weight: 600;
}

.msg-me .ttt-chat-product-preview-price {
    color: #ffe082;
}

/* 6. Mentions Suggestion Dropdown */
.ttt-chat-input-panel {
    position: relative;
}

.ttt-chat-mention-dropdown {
    position: absolute;
    bottom: 100%;
    left: 12px;
    right: 12px;
    background-color: #ffffff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
    max-height: 200px;
    overflow-y: auto;
    z-index: 1200;
    margin-bottom: 8px;
}

.ttt-chat-mention-item {
    padding: 10px 14px;
    font-size: 13px;
    color: var(--color-text-dark);
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid #f1f5f9;
}

.ttt-chat-mention-item:last-child {
    border-bottom: none;
}

.ttt-chat-mention-item:hover,
.ttt-chat-mention-item.selected {
    background-color: var(--color-primary-light);
    color: var(--color-primary);
}

.ttt-chat-mention-icon {
    font-size: 16px;
    color: var(--color-text-muted);
}
