/* Chat Widget Styles */

.chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    z-index: 9999;
}

.chat-widget-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
    position: relative;
}

.chat-widget-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.chat-widget-button.active {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

.chat-unread-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ff6b6b;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.chat-widget-panel {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 500px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 5px 40px rgba(0, 0, 0, 0.16);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-widget-header {
    padding: 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 12px 12px 0 0;
}

.chat-widget-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.chat-close-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 20px;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s ease;
}

.chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.chat-widget-content {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Users Section */
.chat-users-section {
    width: 100%;
    display: flex;
    flex-direction: column;
    background: white;
}

.chat-search-wrapper {
    padding: 12px;
    border-bottom: 1px solid #e8e8e8;
}

.chat-search-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
}

.chat-search-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.chat-users-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.chat-user-item {
    padding: 12px 12px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
}

.chat-user-item:hover {
    background: #f9f9f9;
}

.chat-user-info {
    flex: 1;
    min-width: 0;
}

.chat-user-name {
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.chat-user-preview {
    font-size: 13px;
    color: #999;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 4px;
}

/* Messages Section */
.chat-messages-section {
    width: 100%;
    display: flex;
    flex-direction: column;
    background: white;
}

.chat-messages-header {
    padding: 12px 16px;
    background: #f9f9f9;
    border-bottom: 1px solid #e8e8e8;
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-back-btn {
    background: none;
    border: none;
    color: #667eea;
    cursor: pointer;
    font-size: 20px;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

.chat-back-btn:hover {
    color: #764ba2;
}

.chat-messages-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    flex: 1;
}

.chat-messages-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #f9f9f9;
}

.chat-message {
    display: flex;
    flex-direction: column;
    margin-bottom: 8px;
    animation: messageIn 0.3s ease;
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message-sent {
    align-items: flex-end;
}

.chat-message-received {
    align-items: flex-start;
}

.chat-message-content {
    padding: 10px 12px;
    border-radius: 12px;
    word-wrap: break-word;
    max-width: 70%;
    font-size: 14px;
}

.chat-message-sent .chat-message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px 2px 12px 12px;
}

.chat-message-received .chat-message-content {
    background: #e8e8e8;
    color: #333;
    border-radius: 2px 12px 12px 12px;
}

.chat-message-time {
    font-size: 12px;
    color: #999;
    margin-top: 4px;
    margin-left: 4px;
    margin-right: 4px;
}

.chat-messages-input {
    display: flex;
    gap: 8px;
    padding: 12px;
    background: white;
    border-top: 1px solid #e8e8e8;
}

.chat-message-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
    font-family: inherit;
}

.chat-message-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.chat-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

.chat-send-btn:hover {
    transform: scale(1.05);
}

.chat-send-btn:active {
    transform: scale(0.95);
}

/* Loading and Empty States */
.chat-loading,
.chat-empty,
.chat-error {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #999;
    font-size: 14px;
}

.chat-error {
    color: #ff6b6b;
}

/* Scrollbar Styling */
.chat-users-list::-webkit-scrollbar,
.chat-messages-list::-webkit-scrollbar {
    width: 6px;
}

.chat-users-list::-webkit-scrollbar-track,
.chat-messages-list::-webkit-scrollbar-track {
    background: transparent;
}

.chat-users-list::-webkit-scrollbar-thumb,
.chat-messages-list::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 3px;
}

.chat-users-list::-webkit-scrollbar-thumb:hover,
.chat-messages-list::-webkit-scrollbar-thumb:hover {
    background: #ccc;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .chat-widget-panel {
        width: calc(100vw - 40px);
        height: 60vh;
        bottom: 80px;
        right: 20px;
    }

    .chat-message-content {
        max-width: 85%;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .chat-widget-panel {
        background: #2a2a2a;
        color: white;
    }

    .chat-users-section {
        background: #2a2a2a;
    }

    .chat-user-item {
        border-bottom-color: #3a3a3a;
        color: #e0e0e0;
    }

    .chat-user-item:hover {
        background: #333;
    }

    .chat-user-name {
        color: #e0e0e0;
    }

    .chat-user-preview {
        color: #888;
    }

    .chat-messages-section {
        background: #2a2a2a;
    }

    .chat-messages-header {
        background: #333;
        border-bottom-color: #3a3a3a;
        color: #e0e0e0;
    }

    .chat-messages-list {
        background: #2a2a2a;
    }

    .chat-message-received .chat-message-content {
        background: #3a3a3a;
        color: #e0e0e0;
    }

    .chat-message-time {
        color: #888;
    }

    .chat-messages-input {
        background: #2a2a2a;
        border-top-color: #3a3a3a;
    }

    .chat-message-input {
        background: #333;
        border-color: #3a3a3a;
        color: #e0e0e0;
    }

    .chat-message-input:focus {
        border-color: #667eea;
    }

    .chat-search-input {
        background: #333;
        border-color: #3a3a3a;
        color: #e0e0e0;
    }

    .chat-search-input:focus {
        border-color: #667eea;
    }

    .chat-loading,
    .chat-empty,
    .chat-error {
        color: #888;
    }
}
