/* ============================================
   Instant Chat Widget - Facebook Style
   ============================================ */

/* Header Icon */
.chat-header-icon-wrapper {
    position: relative;
    padding: 0 !important;
}

.navbar-expand-lg .navbar-nav .nav-link.chat-toggle-btn {
    position: relative;
    font-size: 20px;
    color: #999;
    padding: 8px 12px !important;
}

.navbar-expand-lg .navbar-nav .nav-link.chat-toggle-btn:hover {
    color: #007bff;
}

.chat-unread-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    background: #dc3545;
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    border: 2px solid white;
}

/* Chat Header Dropdown */
.chat-header-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    width: 360px;
    max-height: 500px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    z-index: 1050;
    margin-top: 8px;
    overflow: hidden;
}

.chat-header-dropdown.show {
    display: flex;
}

.chat-dropdown-header {
    padding: 12px 16px;
    border-bottom: 1px solid #e4e6eb;
    background: #f0f2f5;
}

.chat-dropdown-header h5 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #050505;
}

.chat-dropdown-content {
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
}

.chat-dropdown-content::-webkit-scrollbar {
    width: 6px;
}

.chat-dropdown-content::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chat-dropdown-content::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.chat-dropdown-content::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.chat-dropdown-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #e4e6eb;
    transition: background-color 0.2s;
    text-decoration: none;
    color: inherit;
}

.chat-dropdown-item:hover {
    background-color: #f0f2f5;
}

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

.chat-dropdown-avatar {
    position: relative;
    width: 56px;
    height: 56px;
    margin-right: 12px;
    flex-shrink: 0;
}

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

.chat-dropdown-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.chat-dropdown-name {
    font-size: 15px;
    font-weight: 600;
    color: #050505;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-dropdown-preview {
    font-size: 13px;
    color: #65676b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

.chat-dropdown-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    margin-left: 12px;
    flex-shrink: 0;
}

.chat-dropdown-time {
    font-size: 12px;
    color: #65676b;
    margin-bottom: 4px;
    white-space: nowrap;
}

.chat-dropdown-unread {
    background: #1877f2;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    min-width: 20px;
}

.chat-dropdown-loading,
.chat-dropdown-empty {
    padding: 24px;
    text-align: center;
    color: #65676b;
    font-size: 14px;
}

.chat-dropdown-footer {
    padding: 12px 16px;
    border-top: 1px solid #e4e6eb;
    background: #f0f2f5;
    text-align: center;
}

.chat-dropdown-see-all {
    color: #1877f2;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    display: block;
    padding: 8px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.chat-dropdown-see-all:hover {
    background-color: #e4e6eb;
    text-decoration: none;
    color: #1877f2;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .chat-header-dropdown {
        width: 320px;
        right: -10px;
    }
}

/* Chat Widget Container - Main messages list */
/* Disabled sticky widget - using full-page chat instead */
.instant-chat-widget {
    display: none !important; /* Hide sticky widget, use full-page chat */
}

/* When chat boxes are open, adjust main widget position */
/* Main widget can stay in place, chat boxes appear to its left */

.instant-chat-widget.active {
    display: flex;
}

.instant-chat-widget.minimized {
    height: 60px;
}

/* Chat Widget Header */
.chat-widget-header {
    background: #007bff;
    color: white;
    padding: 12px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    border-radius: 8px 8px 0 0;
}

.chat-widget-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 16px;
}

.chat-unread-count {
    background: #dc3545;
    color: white;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: bold;
    min-width: 20px;
    text-align: center;
}

.chat-widget-actions {
    display: flex;
    gap: 10px;
}

.chat-action-btn {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 5px;
    font-size: 14px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.chat-action-btn:hover {
    opacity: 1;
}

/* Chat Widget Body */
.chat-widget-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Conversations List */
.chat-conversations-list {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.chat-search-box {
    position: relative;
}

.chat-search-box input {
    width: 100%;
    padding: 10px 35px 10px 12px;
    border: 1px solid transparent;
    border-radius: 20px;
    font-size: 14px;
}
.chat-search-box input:focus {
    border-color: #e0e0e0;
    outline: none;
}

.chat-search-box i {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
}

.chat-conversations {
    flex: 1;
    overflow-y: auto;
    padding: 5px 0;
}

.chat-conversation-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s;
}

.chat-conversation-item:hover {
    background: #f5f5f5;
}

.chat-conversation-item.active {
    background: #e3f2fd;
}

.chat-conversation-avatar {
    position: relative;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    overflow: hidden;
    margin-right: 12px;
    flex-shrink: 0;
}

.chat-conversation-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

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

.chat-conversation-name {
    font-weight: 600;
    font-size: 14px;
    color: #333;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-conversation-preview {
    font-size: 13px;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-conversation-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.chat-conversation-time {
    font-size: 11px;
    color: #999;
}

.chat-conversation-unread {
    background: #007bff;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
}

/* Chat Boxes Container - Outside main widget (Facebook style) */
/* Chat Boxes Container - Disabled, using full-page chat instead */
.chat-boxes-container {
    display: none !important; /* Hide sticky chat boxes, use full-page chat */
    position: fixed;
    bottom: 0;
    right: 390px; /* Position to the left of main widget (360px width + 20px right + 10px gap) */
    width: auto;
    height: auto;
    max-width: calc(100vw - 400px); /* Prevent overflow */
    z-index: 10000;
    display: flex;
    flex-direction: row-reverse;
    gap: 10px;
    align-items: flex-end;
    pointer-events: none; /* Allow clicks to pass through empty areas */
    overflow-x: visible;
    overflow-y: visible;
}

.chat-boxes-container > * {
    pointer-events: auto; /* Re-enable clicks on chat boxes */
}

/* Individual Chat Box - Separate floating window */
.chat-box {
    width: 320px;
    height: 500px;
    background: white;
    border-radius: 8px 8px 0 0;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: relative;
    margin-right: 0;
}

.chat-box.minimized {
    height: 60px;
    width: 250px;
}

/* Chat Box Header */
.chat-box-header {
    background: #007bff;
    color: white;
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 8px 8px 0 0;
}

.chat-box-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.chat-box-avatar {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.chat-box-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-status-indicator {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid white;
}

.chat-status-online {
    background: #28a745;
}

.chat-status-away {
    background: #ffc107;
}

.chat-status-busy {
    background: #dc3545;
}

.chat-status-offline {
    background: #6c757d;
}

.chat-box-user-details {
    flex: 1;
    min-width: 0;
}

.chat-box-user-name {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-box-user-status {
    font-size: 11px;
    opacity: 0.9;
}

.chat-box-actions {
    display: flex;
    gap: 5px;
}

.chat-box-action-btn {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 5px;
    font-size: 12px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.chat-box-action-btn:hover {
    opacity: 1;
}

/* Chat Messages Area */
.chat-box-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: #f5f5f5;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-message {
    display: flex;
    margin-bottom: 10px;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-message.own {
    justify-content: flex-end;
}

.chat-message-content {
    max-width: 70%;
    padding: 10px 15px;
    border-radius: 18px;
    word-wrap: break-word;
    position: relative;
}

.chat-message.own .chat-message-content {
    background: #007bff;
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.other .chat-message-content {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.chat-message-time {
    font-size: 11px;
    margin-top: 4px;
    opacity: 0.7;
}

.chat-message.own .chat-message-time {
    text-align: right;
}

/* File Attachments in Messages */
.chat-attachment {
    margin-top: 8px;
    border-radius: 8px;
    overflow: hidden;
}

.chat-attachment-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    cursor: pointer;
}

.chat-attachment-file {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: rgba(0,0,0,0.05);
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
}

.chat-attachment-file:hover {
    background: rgba(0,0,0,0.1);
}

.chat-attachment-icon {
    font-size: 24px;
    color: #007bff;
}

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

.chat-attachment-name {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-attachment-size {
    font-size: 12px;
    color: #666;
    margin-top: 2px;
}

/* Typing Indicator */
.chat-typing-indicator {
    padding: 10px 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #666;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #999;
    animation: typing 1.4s infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-10px); }
}

/* Chat Input Area */
.chat-box-input {
    padding: 10px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
}

.chat-input-actions {
    display: flex;
    gap: 5px;
}

.chat-input-btn {
    background: transparent;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 5px;
    font-size: 16px;
    transition: color 0.2s;
}

.chat-input-btn:hover {
    color: #007bff;
}

.chat-message-input {
    flex: 1;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    padding: 8px 15px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.chat-message-input:focus {
    border-color: #007bff;
}

.chat-send-btn {
    background: #007bff;
    color: white;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.chat-send-btn:hover {
    background: #0056b3;
}

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

/* File Upload Preview */
.chat-file-preview {
    padding: 10px;
    border-top: 1px solid #e0e0e0;
    background: #f9f9f9;
    display: none;
}

.chat-file-preview.active {
    display: block;
}

.chat-file-preview-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    background: white;
    border-radius: 8px;
    margin-bottom: 8px;
}

.chat-file-preview-item:last-child {
    margin-bottom: 0;
}

.chat-file-preview-icon {
    font-size: 24px;
    color: #007bff;
}

.chat-file-preview-info {
    flex: 1;
    min-width: 0;
}

.chat-file-preview-name {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-file-preview-size {
    font-size: 12px;
    color: #666;
}

.chat-file-preview-remove {
    background: transparent;
    border: none;
    color: #dc3545;
    cursor: pointer;
    padding: 5px;
    font-size: 16px;
}

.chat-file-preview-image {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
}

/* Loading States */
.chat-loading,
.chat-messages-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #999;
    gap: 10px;
}

.chat-empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #999;
}

/* Responsive */
@media (max-width: 768px) {
    .instant-chat-widget {
        width: 100%;
        right: 0;
        height: 100vh;
        border-radius: 0;
    }

    .chat-box {
        width: 100%;
    }

    .chat-boxes-container {
        flex-direction: column;
    }
}

/* Scrollbar Styling */
.chat-conversations::-webkit-scrollbar,
.chat-box-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-conversations::-webkit-scrollbar-track,
.chat-box-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chat-conversations::-webkit-scrollbar-thumb,
.chat-box-messages::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.chat-conversations::-webkit-scrollbar-thumb:hover,
.chat-box-messages::-webkit-scrollbar-thumb:hover {
    background: #555;
}

