/* Chat Widget Styles */

/* Chat toggle button */
.chat-toggle-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #004A99 0%, #0066cc 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 74, 153, 0.4);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.chat-toggle-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 25px rgba(0, 74, 153, 0.5);
}

.chat-toggle-btn.dragging {
    transform: scale(1.1);
    box-shadow: 0 8px 30px rgba(0, 74, 153, 0.6);
    cursor: grabbing;
    opacity: 0.9;
}

.chat-toggle-btn:not(.dragging) {
    cursor: grab;
}

.chat-toggle-btn svg {
    width: 28px;
    height: 28px;
    fill: white;
    stroke: white;
}

.chat-toggle-btn .unread-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #e74c3c;
    color: white;
    font-size: 12px;
    font-weight: 600;
    min-width: 22px;
    height: 22px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Chat widget container */
.chat-widget {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 380px;
    height: 520px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.chat-widget.open {
    display: flex;
    animation: chatSlideIn 0.3s ease-out;
}

@keyframes chatSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Chat header */
.chat-header {
    background: linear-gradient(135deg, #004A99 0%, #0066cc 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.chat-header-title {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
}

.chat-header-title img {
    height: 24px;
    width: auto;
}

.chat-header-title svg {
    width: 20px;
    height: 20px;
    stroke: white;
    fill: none;
}

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

.chat-header-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

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

.chat-header-btn svg {
    width: 18px;
    height: 18px;
    stroke: white;
}

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

/* Chat views */
.chat-view {
    display: none;
    flex-direction: column;
    height: 100%;
}

.chat-view.active {
    display: flex;
}

/* Conversations list view */
.conversations-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.conversation-item {
    display: flex;
    align-items: center;
    padding: 12px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s;
    gap: 12px;
}

.conversation-item:hover {
    background: #f5f7fa;
}

.conversation-item.unread {
    background: #e3f2fd;
}

.conversation-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #004A99 0%, #0066cc 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 18px;
    flex-shrink: 0;
}

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

.conversation-name {
    font-weight: 600;
    color: #2c3e50;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.conversation-name .online-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4CAF50;
}

.conversation-preview {
    color: #7f8c8d;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

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

.conversation-time {
    font-size: 11px;
    color: #95a5a6;
}

.conversation-unread-badge {
    background: #004A99;
    color: white;
    font-size: 11px;
    font-weight: 600;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
}

/* New chat button */
.new-chat-btn {
    margin: 12px;
    padding: 14px;
    background: linear-gradient(135deg, #004A99 0%, #0066cc 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.new-chat-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 74, 153, 0.4);
}

.new-chat-btn svg {
    width: 18px;
    height: 18px;
}

/* Users list view */
.users-search {
    padding: 12px;
    border-bottom: 1px solid #e1e8ed;
}

.users-search input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #e1e8ed;
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.users-search input:focus {
    border-color: #004A99;
}

.users-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.user-item {
    display: flex;
    align-items: center;
    padding: 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s;
    gap: 12px;
}

.user-item:hover {
    background: #f5f7fa;
}

.user-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #004A99 0%, #0066cc 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 16px;
    position: relative;
}

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

.user-avatar .status-indicator.online {
    background: #4CAF50;
}

.user-avatar .status-indicator.away {
    background: #ff9800;
}

.user-avatar .status-indicator.offline {
    background: #95a5a6;
}

.user-info {
    flex: 1;
}

.user-name {
    font-weight: 600;
    color: #2c3e50;
    font-size: 14px;
}

.user-email {
    color: #7f8c8d;
    font-size: 12px;
    margin-top: 2px;
}

/* Message view */
.message-view-header {
    padding: 12px 16px;
    border-bottom: 1px solid #e1e8ed;
    display: flex;
    align-items: center;
    gap: 12px;
}

.back-to-list {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.back-to-list:hover {
    background: #f5f7fa;
}

.back-to-list svg {
    width: 20px;
    height: 20px;
    stroke: #7f8c8d;
}

.message-view-user {
    flex: 1;
}

.message-view-name {
    font-weight: 600;
    color: #2c3e50;
    font-size: 15px;
}

.message-view-status {
    font-size: 12px;
    color: #4CAF50;
}

.message-view-status.offline {
    color: #95a5a6;
}

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

.message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.message.own {
    align-self: flex-end;
    background: linear-gradient(135deg, #004A99 0%, #0066cc 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.other {
    align-self: flex-start;
    background: #f5f7fa;
    color: #2c3e50;
    border-bottom-left-radius: 4px;
}

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

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

.message-date-divider {
    text-align: center;
    color: #95a5a6;
    font-size: 12px;
    margin: 16px 0;
    position: relative;
}

.message-date-divider::before,
.message-date-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 30%;
    height: 1px;
    background: #e1e8ed;
}

.message-date-divider::before {
    left: 0;
}

.message-date-divider::after {
    right: 0;
}

/* Message input */
.message-input-container {
    padding: 12px 16px;
    border-top: 1px solid #e1e8ed;
    display: flex;
    align-items: center;
    gap: 10px;
}

.message-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e1e8ed;
    border-radius: 24px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    resize: none;
    max-height: 100px;
}

.message-input:focus {
    border-color: #004A99;
}

.send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #004A99 0%, #0066cc 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, opacity 0.2s;
    flex-shrink: 0;
}

.send-btn:hover {
    transform: scale(1.05);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.send-btn svg {
    width: 20px;
    height: 20px;
    fill: white;
    stroke: white;
}

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

.chat-empty-state svg {
    width: 64px;
    height: 64px;
    stroke: #bdc3c7;
    margin-bottom: 16px;
}

.chat-empty-state h3 {
    font-size: 16px;
    color: #2c3e50;
    margin-bottom: 8px;
}

.chat-empty-state p {
    font-size: 14px;
}

/* Loading state */
.chat-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.chat-loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e1e8ed;
    border-top-color: #004A99;
    border-radius: 50%;
    animation: chatSpin 0.8s linear infinite;
}

@keyframes chatSpin {
    to {
        transform: rotate(360deg);
    }
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .chat-widget {
        width: calc(100% - 32px);
        height: calc(100% - 140px);
        bottom: 90px;
        right: 16px;
        left: 16px;
    }

    .chat-toggle-btn {
        width: 54px;
        height: 54px;
        bottom: 20px;
        right: 20px;
    }
}
