/**
 * Chat UX Enhancements CSS
 * Styling for search, filters, reactions, and read receipts
 */

/* ===== Search & Filter Styles ===== */
.chat-search-container {
    position: sticky;
    top: 0;
    z-index: 100;
    background: white;
    padding: 15px;
    border-bottom: 1px solid #e0e0e0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.chat-search-input {
    width: 100%;
    padding: 10px 15px 10px 40px;
    border: 1px solid #ddd;
    border-radius: 25px;
    font-size: 14px;
    transition: all 0.3s ease;
}

.chat-search-input:focus {
    outline: none;
    border-color: #4fc3f7;
    box-shadow: 0 0 0 3px rgba(79, 195, 247, 0.1);
}

.search-icon {
    position: absolute;
    left: 25px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    font-size: 18px;
}

#searchResults {
    position: absolute;
    top: 100%;
    left: 15px;
    right: 15px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    max-height: 400px;
    overflow-y: auto;
    display: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 101;
}

.search-results-list {
    padding: 10px;
}

.search-result-item {
    padding: 12px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.2s ease;
}

.search-result-item:hover {
    background: #f8f9fa;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.search-result-header strong {
    color: #333;
    font-size: 14px;
}

.search-result-time {
    font-size: 12px;
    color: #999;
}

.search-result-content {
    font-size: 13px;
    color: #666;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.no-results {
    padding: 20px;
    text-align: center;
    color: #999;
    font-size: 14px;
}

/* Filter buttons */
.chat-filters {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 6px 12px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-btn:hover {
    background: #f0f0f0;
    border-color: #bbb;
}

.filter-btn.active {
    background: #4fc3f7;
    color: white;
    border-color: #4fc3f7;
}

/* ===== Message Status & Read Receipts ===== */
.message-status {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    color: #999;
    margin-left: 5px;
}

.message-status.read {
    color: #4fc3f7;
}

.read-indicator {
    font-size: 12px;
    color: #999;
    margin-left: 5px;
}

.read-indicator.read {
    color: #4fc3f7;
}

.message.unread {
    background: #fffbe6;
    border-left: 3px solid #ffc107;
}

.message.unread::before {
    content: '';
    position: absolute;
    left: -10px;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    background: #ffc107;
    border-radius: 50%;
}

/* ===== Unread Count Badge ===== */
.unread-badge {
    display: inline-block;
    background: #f44336;
    color: white;
    font-size: 11px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    margin-left: 8px;
}

/* ===== User Presence Indicators ===== */
.user-status {
    position: relative;
    display: inline-block;
}

.user-status::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid white;
}

.user-status.online::after {
    background: #4caf50;
}

.user-status.away::after {
    background: #ff9800;
}

.user-status.busy::after {
    background: #f44336;
}

.user-status.offline::after {
    background: #9e9e9e;
}

.last-seen {
    font-size: 11px;
    color: #999;
    font-style: italic;
}

.status-message {
    font-size: 12px;
    color: #666;
    font-style: italic;
    margin-top: 2px;
}

/* ===== Message Reactions ===== */
.message-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 8px;
}

.reaction-item {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 4px 8px;
    background: #f0f0f0;
    border-radius: 12px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.reaction-item:hover {
    background: #e0e0e0;
    transform: scale(1.05);
}

.reaction-item.user-reacted {
    background: #e3f2fd;
    border-color: #4fc3f7;
}

.reaction-picker {
    position: absolute;
    bottom: 100%;
    left: 0;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    padding: 8px;
    display: flex;
    gap: 5px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 100;
    animation: slideUp 0.2s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.reaction-emoji {
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: background 0.2s ease;
}

.reaction-emoji:hover {
    background: #f0f0f0;
    transform: scale(1.2);
}

.add-reaction-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: #f0f0f0;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
    margin-left: 5px;
}

.add-reaction-btn:hover {
    background: #e0e0e0;
    transform: scale(1.1);
}

/* ===== Highlight Message (from search) ===== */
.highlight-message {
    animation: highlight 2s ease;
}

@keyframes highlight {
    0%, 100% {
        background: transparent;
    }
    50% {
        background: #fff3cd;
        border-left: 3px solid #ffc107;
    }
}

/* ===== Timestamp Styles ===== */
.message-time {
    font-size: 11px;
    color: #999;
    margin-left: 8px;
}

.message-date-separator {
    text-align: center;
    margin: 20px 0;
    position: relative;
}

.message-date-separator::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 1px;
    background: #e0e0e0;
    z-index: 0;
}

.message-date-separator span {
    display: inline-block;
    background: white;
    padding: 5px 15px;
    border-radius: 15px;
    font-size: 12px;
    color: #999;
    position: relative;
    z-index: 1;
    border: 1px solid #e0e0e0;
}

/* ===== Message Actions Menu ===== */
.message-actions {
    position: absolute;
    top: 5px;
    right: 5px;
    display: none;
    gap: 5px;
}

.chat-message:hover .message-actions {
    display: flex;
}

.message-action-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: white;
    border: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
}

.message-action-btn:hover {
    background: #f0f0f0;
    transform: scale(1.1);
}

/* ===== Online Users Panel ===== */
.online-users-panel {
    position: fixed;
    right: 20px;
    top: 80px;
    width: 250px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    max-height: 400px;
    overflow-y: auto;
}

.online-users-panel h4 {
    margin: 0 0 15px 0;
    font-size: 14px;
    color: #333;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 10px;
}

.online-user-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.online-user-item:hover {
    background: #f8f9fa;
}

.online-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #4fc3f7;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    position: relative;
}

.online-user-info {
    flex: 1;
}

.online-user-name {
    font-size: 13px;
    font-weight: 500;
    color: #333;
}

.online-user-status {
    font-size: 11px;
    color: #999;
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    .online-users-panel {
        display: none;
    }

    .chat-search-container {
        padding: 10px;
    }

    #searchResults {
        left: 10px;
        right: 10px;
    }

    .reaction-picker {
        left: 50%;
        transform: translateX(-50%);
    }
}

/* ===== Smooth Scrolling ===== */
.chat-messages-container {
    scroll-behavior: smooth;
}

/* ===== Loading States ===== */
.loading-indicator {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    color: #999;
    font-size: 14px;
}

.loading-spinner {
    border: 2px solid #f3f3f3;
    border-top: 2px solid #4fc3f7;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
    margin-right: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.5;
}

.empty-state-text {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 8px;
}

.empty-state-subtext {
    font-size: 13px;
}

/* ===== Accessibility ===== */
.chat-message:focus {
    outline: 2px solid #4fc3f7;
    outline-offset: 2px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}
