/**
 * Chat CSS - Estilos personalizados para el sistema de chat
 * Compatible con Bootstrap 5 y el tema actual del sistema
 */

/* === Variables CSS === */
:root {
    --chat-primary-color: #0d6efd;
    --chat-secondary-color: #6c757d;
    --chat-success-color: #198754;
    --chat-danger-color: #dc3545;
    --chat-warning-color: #ffc107;
    --chat-info-color: #0dcaf0;
    
    --chat-bg-primary: #ffffff;
    --chat-bg-secondary: #f8f9fa;
    --chat-bg-tertiary: #e9ecef;
    
    --chat-border-color: #dee2e6;
    --chat-border-radius: 0.5rem;
    --chat-border-radius-sm: 0.25rem;
    
    --chat-text-primary: #212529;
    --chat-text-secondary: #6c757d;
    --chat-text-danger: #e01e1e;
    --chat-text-muted: #868e96;
    
    --chat-shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --chat-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    --chat-shadow-lg: 0 1rem 3rem rgba(0, 0, 0, 0.175);
    
    --chat-widget-width: 380px;
    --chat-widget-height: 600px;
    --chat-widget-bottom: 20px;
    --chat-widget-right: 20px;
    
    --chat-z-index-widget: 1050;
    --chat-z-index-modal: 1055;
    --chat-z-index-tooltip: 1060;
}

/* === Tema Oscuro === */
[data-bs-theme="dark"] {
    --chat-bg-primary: #212529;
    --chat-bg-secondary: #343a40;
    --chat-bg-tertiary: #495057;
    
    --chat-text-primary: #ffffff;
    --chat-text-secondary: #adb5bd;
    --chat-text-muted: #6c757d;
    
    --chat-border-color: #495057;
}

/* Dark mode adjustments for conversation types */
[data-bs-theme="dark"] .conversation-item.conversation-universal {
    background: rgba(255, 193, 7, 0.1);
}

[data-bs-theme="dark"] .conversation-item.conversation-group {
    background: rgba(13, 110, 253, 0.1);
}

[data-bs-theme="dark"] .conversation-icon .member-count {
    background: var(--chat-bg-primary);
    border: 2px solid var(--chat-bg-primary);
}

/* === Chat Widget Principal === */
.chat-widget {
    position: fixed;
    bottom: var(--chat-widget-bottom);
    right: var(--chat-widget-right);
    width: var(--chat-widget-width);
    height: auto;
    z-index: var(--chat-z-index-widget);
    font-family: inherit;
}

.chat-widget .chat-toggle-btn {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 60px;
    height: 60px;
    background: var(--chat-primary-color);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: var(--chat-shadow-lg);
    transition: all 0.3s ease;
    z-index: 1;
}

.chat-widget .chat-toggle-btn:hover {
    background: #0b5ed7;
    transform: scale(1.05);
}

.chat-widget .chat-toggle-btn:active {
    transform: scale(0.95);
}

.chat-widget .chat-unread-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--chat-danger-color);
    color: white;
    border-radius: 50%;
    min-width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    border: 2px solid white;
}

/* === Chat Panel === */
.chat-widget .chat-panel {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 100%;
    height: var(--chat-widget-height);
    background: var(--chat-bg-primary);
    border-radius: var(--chat-border-radius);
    box-shadow: var(--chat-shadow-lg);
    border: 1px solid var(--chat-border-color);
    display: none;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(100%) scale(0.8);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.chat-widget.chat-widget-open .chat-panel {
    display: flex;
    transform: translateY(0) scale(1);
}

.chat-widget.chat-widget-open .chat-toggle-btn {
    opacity: 0.8;
    transform: rotate(45deg);
}

/* === Chat Header === */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: var(--chat-bg-secondary);
    border-bottom: 1px solid var(--chat-border-color);
    min-height: 60px;
}

.chat-header-title {
    display: flex;
    align-items: center;
    font-weight: 600;
    color: var(--chat-text-primary);
    flex: 1;
}

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.chat-header-actions .btn {
    padding: 0.25rem 0.5rem;
    color: var(--chat-text-secondary);
}

.chat-header-actions .btn:hover {
    color: var(--chat-text-primary);
    background: var(--chat-bg-tertiary);
}

/* === Connection Status === */
.connection-status {
    display: flex;
    align-items: center;
    font-size: 0.75rem;
    color: var(--chat-text-secondary);
}

.connection-status.connected {
    color: var(--chat-success-color);
}

.connection-status.disconnected {
    color: var(--chat-danger-color);
}

.connection-status i {
    font-size: 0.5rem;
    margin-right: 0.25rem;
}

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

.chat-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* === Loading State === */
.chat-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: var(--chat-text-secondary);
}

/* === Conversations Tab === */
.chat-search {
    padding: 1rem;
    border-bottom: 1px solid var(--chat-border-color);
}

.chat-conversations {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.chat-online-users {
    border-top: 1px solid var(--chat-border-color);
    padding: 0.5rem;
    background: var(--chat-bg-secondary);
}

.section-header {
    margin-bottom: 0.5rem;
    padding: 0 0.5rem;
}

/* === Conversation Item === */
.conversation-item {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    margin-bottom: 0.25rem;
    border-radius: var(--chat-border-radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.conversation-item:hover {
    background: var(--chat-bg-secondary);
}

.conversation-item:active {
    background: var(--chat-bg-tertiary);
}

.conversation-item.active {
    background: var(--chat-primary-color);
    color: white;
}

.conversation-item.has-unread {
    background: rgba(var(--bs-primary-rgb), 0.05);
    border-left: 3px solid var(--chat-primary-color);
}

/* === Avatar Container === */
.avatar-container {
    position: relative;
    margin-right: 0.75rem;
}

.conversation-avatar .avatar-img,
.message-avatar .avatar-img,
.online-user-item .avatar-img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--chat-border-color);
}

.conversation-avatar .avatar-img {
    width: 48px;
    height: 48px;
}

/* === Presence Indicators === */
.presence-indicator {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--chat-bg-primary);
}

.presence-indicator.presence-online {
    background-color: var(--chat-success-color);
}

.presence-indicator.presence-away {
    background-color: var(--chat-warning-color);
}

.presence-indicator.presence-busy {
    background-color: var(--chat-danger-color);
}

.presence-indicator.presence-offline {
    background-color: var(--chat-text-secondary);
}

/* === Member Count (Groups) === */
.member-count {
    position: absolute;
    bottom: -2px;
    right: -2px;
    background: var(--chat-primary-color);
    color: white;
    font-size: 0.6rem;
    padding: 1px 4px;
    border-radius: 8px;
    min-width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

/* === Conversation Type Styling === */
.conversation-item.conversation-universal {
    border-left: 3px solid var(--chat-warning-color);
    background: rgba(255, 193, 7, 0.05);
}

.conversation-item.conversation-group {
    border-left: 3px solid var(--chat-primary-color);
    background: rgba(13, 110, 253, 0.05);
}

.conversation-item.conversation-direct:hover {
    background: var(--chat-bg-secondary);
}

/* === Conversation Icons === */
.conversation-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    font-size: 1.5rem;
    color: white;
}

.conversation-icon-universal {
    background: linear-gradient(135deg, var(--chat-warning-color), #fd7e14);
    border: 2px solid var(--chat-warning-color);
}

.conversation-icon-group {
    background: linear-gradient(135deg, var(--chat-primary-color), var(--chat-info-color));
    border: 2px solid var(--chat-primary-color);
}

.conversation-icon .member-count {
    position: absolute;
    bottom: -2px;
    right: -2px;
    background: var(--chat-bg-primary);
    color: var(--chat-primary-color);
    border: 2px solid var(--chat-primary-color);
    font-size: 0.65rem;
    min-width: 18px;
    height: 18px;
    font-weight: 700;
}

/* === Conversation Name Wrapper === */
.conversation-name-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
}

.conversation-name-wrapper .conversation-name {
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* === Type Icons === */
.conversation-type-icon {
    font-size: 0.8rem;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.conversation-item:hover .conversation-type-icon {
    transform: scale(1.1);
}

/* === Conversation Content === */
.conversation-content {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.conversation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
}

.conversation-name {
    font-weight: 600;
    color: var(--chat-text-primary);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.9rem;
}

.conversation-time {
    font-size: 0.75rem;
    color: var(--chat-text-secondary);
    white-space: nowrap;
}

.conversation-preview {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.last-message-container {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.last-message-author {
    font-weight: 600;
    color: var(--chat-text-secondary);
    font-size: 0.8rem;
}

.last-message {
    font-size: 0.8rem;
    color: var(--chat-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    transition: all 0.2s ease;
}

/* Estilos para diferentes tipos de mensajes */
.last-message.new-message {
    color: var(--chat-text-primary);
    font-weight: 600;
    opacity: 1;
}

.last-message.old-message {
    color: var(--chat-text-muted);
    font-weight: 400;
    opacity: 0.8;
}

.last-message.empty {
    display: none;
}

/* === Conversation Indicators === */
.conversation-indicators {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-top: 0.25rem;
}

.conversation-type-icon,
.pinned-icon,
.muted-icon {
    font-size: 0.75rem;
    color: var(--chat-text-secondary);
}

.pinned-icon {
    color: var(--chat-warning-color);
}

.muted-icon {
    color: var(--chat-text-muted);
}

/* === Unread Count === */
.unread-count {
    background: var(--chat-primary-color);
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 0.7rem;
    font-weight: 600;
    min-width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 0.5rem;
}

.unread-count.hide {
    display: none;
}

.unread-count.show {
    display: flex;
}

/* === Conversation Actions === */
.conversation-actions {
    position: absolute;
    right: 0.75rem;
    top: 12px;
    transform: translateY(-50%);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.conversation-item:hover .conversation-actions {
    opacity: 1;
}

.action-buttons {
    display: flex;
    gap: 0.25rem;
}

.action-buttons .btn {
    padding: 0.25rem;
    font-size: 0.75rem;
    color: var(--chat-text-secondary);
}

/* === Chat View === */
.chat-view {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: calc(var(--chat-widget-height) - 60px);
    overflow: hidden;
}

.chat-view-header {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--chat-border-color);
    background: var(--chat-bg-secondary);
}

.chat-participant-info {
    flex: 1;
    margin: 0 0.5rem;
}

.chat-view-actions {
    display: flex;
    gap: 0.25rem;
}

/* === Messages Container === */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

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

.chat-messages::-webkit-scrollbar-track {
    background: var(--chat-bg-secondary);
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--chat-text-secondary);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--chat-text-primary);
}

/* === Message Item === */
.message-item {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: var(--chat-border-radius-sm);
    transition: background-color 0.2s ease;
    position: relative;
}

.message-item:hover {
    background: var(--chat-bg-secondary);
}

.message-item.message-own {
    flex-direction: row-reverse;
}

.message-item.message-own .message-content {
    background: var(--chat-primary-color);
    color: white;
    border-radius: 1rem 1rem 0.25rem 1rem;
}

.message-item.message-other .message-content {
    background: var(--chat-bg-secondary);
    color: var(--chat-text-primary);
    border-radius: 1rem 1rem 1rem 0.25rem;
}

/* === Message Content === */
.message-content {
    flex: 1;
    padding: 0.4rem;
    word-wrap: break-word;
    max-width: calc(100% - 60px);
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
    opacity: 1;
    transition: opacity 0.2s ease;
}

.message-item:hover .message-header {
    opacity: 1;
}

.message-user {
    font-weight: 600;
    font-size: 0.8rem;
}

.message-time {
    font-size: 0.7rem;
    opacity: 0.7;
}

.message-actions {
    display: flex;
    gap: 0.25rem;
}

.message-delete{
    color: var(--chat-text-danger);
}

/* Estilos para mensajes eliminados */
.deleted-message {
    font-style: italic;
    color: var(--bs-text-muted);
    opacity: 0.7;
}

.message-deleted {
    opacity: 0.6;
}

.message-actions .btn {
    padding: 0.125rem 0.25rem;
    font-size: 0.7rem;
    opacity: 0.7;
}

.message-actions .btn:hover {
    opacity: 1;
}

.message-body {
    margin-bottom: 0.25rem;
    line-height: 1.4;
}

.message-body a {
    color: inherit;
    text-decoration: underline;
}

.message-status {
    font-size: 0.7rem;
    opacity: 0.7;
    text-align: right;
}

/* === Typing Indicators === */
/* Typing indicators CSS removido para optimizar rendimiento */

/* === Online Users === */
.online-users-list {
    max-height: 200px;
    overflow-y: auto;
}

.online-user-item {
    display: flex;
    align-items: center;
    padding: 0.5rem;
    border-radius: var(--chat-border-radius-sm);
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.online-user-item:hover {
    background: var(--chat-bg-tertiary);
}

.online-user-item .user-avatar {
    margin-right: 0.5rem;
}

.online-user-item .user-info {
    flex: 1;
    min-width: 0;
}

.online-user-item .user-name {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--chat-text-primary);
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.online-user-item .user-status {
    font-size: 0.75rem;
    color: var(--chat-text-secondary);
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.online-user-item .start-chat {
    opacity: 0;
    transition: opacity 0.2s ease;
}

.online-user-item:hover .start-chat {
    opacity: 1;
}

/* === Empty States === */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
    color: var(--chat-text-secondary);
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: var(--chat-text-muted);
}

.empty-state h6 {
    margin-bottom: 0.5rem;
    color: var(--chat-text-secondary);
}

.empty-state p {
    margin-bottom: 1rem;
    color: var(--chat-text-muted);
}

/* === Error State === */
.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
    color: var(--chat-text-secondary);
}

.error-state .error-icon {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: var(--chat-warning-color);
}

/* === Conversation Filters === */
.conversation-filters {
    margin-bottom: 0.5rem;
}

.conversation-filters .btn-group .btn {
    font-size: 0.8rem;
    padding: 0.5rem 0.75rem;
    border-color: var(--chat-border-color);
}

.conversation-filters .btn-outline-primary {
    color: var(--chat-text-secondary);
    border-color: var(--chat-border-color);
}

.conversation-filters .btn-outline-primary:hover,
.conversation-filters .btn-outline-primary.active {
    background-color: var(--chat-primary-color);
    border-color: var(--chat-primary-color);
    color: white;
}

.filter-count {
    font-size: 0.6rem !important;
}

/* === Toast Notifications === */
.chat-toast {
    max-width: 350px;
}

.chat-toast .toast-header {
    padding: 0.5rem 0.75rem;
}

.chat-toast .toast-body {
    padding: 0.75rem;
}

/* === Message Input Styles === */
.message-input-container {
    border-top: 1px solid var(--chat-border-color);
    background: var(--chat-bg-primary);
}

.message-form {
    padding: 0.75rem;
}

.message-input-wrapper {
    position: relative;
    flex: 1;
}

.message-input {
    resize: none;
    min-height: 38px;
    max-height: 120px;
    padding: 0.5rem 3rem 0.5rem 1rem;
    border: 1px solid var(--chat-border-color) !important;
}

.message-input:focus {
    border-color: var(--chat-primary-color);
    box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.25);
}

.character-count {
    position: absolute;
    right: 8px;
    bottom: 4px;
    font-size: 0.65rem;
    pointer-events: none;
}

.reply-preview,
.edit-preview,
.file-preview {
    background: var(--chat-bg-secondary);
    border: 1px solid var(--chat-border-color);
    border-bottom: none;
    border-radius: 0.375rem 0.375rem 0 0;
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
}

.reply-header,
.edit-header {
    display: flex;
    align-items: center;
    color: var(--chat-text-secondary);
    margin-bottom: 0.25rem;
}

.reply-message,
.edit-content {
    color: var(--chat-text-primary);
    font-style: italic;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* === File Preview === */
.file-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.file-icon {
    font-size: 1.2rem;
    color: var(--chat-text-secondary);
}

.file-details {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-weight: 500;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-size {
    font-size: 0.7rem;
}

.file-preview-image {
    margin-top: 0.5rem;
}

.file-preview-image img {
    max-width: 150px;
    max-height: 100px;
    border-radius: var(--chat-border-radius-sm);
}

/* === Emoji Picker === */
.emoji-picker {
    position: absolute;
    bottom: 100%;
    right: 50px;
    width: 300px;
    background: var(--chat-bg-primary);
    border: 1px solid var(--chat-border-color);
    border-radius: var(--chat-border-radius);
    box-shadow: var(--chat-shadow);
    z-index: var(--chat-z-index-tooltip);
}

.emoji-categories {
    display: flex;
    border-bottom: 1px solid var(--chat-border-color);
    padding: 0.25rem;
}

.emoji-category {
    border: none;
    background: none;
    padding: 0.5rem;
    border-radius: var(--chat-border-radius-sm);
    cursor: pointer;
    font-size: 1.1rem;
}

.emoji-category:hover {
    background: var(--chat-bg-secondary);
}

.emoji-category.active {
    background: var(--chat-primary-color);
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 0.25rem;
    padding: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
}

.emoji-item {
    border: none;
    background: none;
    padding: 0.5rem;
    border-radius: var(--chat-border-radius-sm);
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.emoji-item:hover {
    background: var(--chat-bg-secondary);
}

/* === Drag and Drop === */
.message-input-container.dragover {
    background: rgba(var(--bs-primary-rgb), 0.1);
    border-color: var(--chat-primary-color);
}

/* === Responsive Design === */
@media (max-width: 768px) {
    .chat-widget {
        --chat-widget-width: 100vw;
        --chat-widget-height: 100vh;
        --chat-widget-bottom: 0;
        --chat-widget-right: 0;
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
    }
    
    .chat-widget .chat-panel {
        border-radius: 0;
        height: 100vh;
    }
    
    .chat-widget .chat-toggle-btn {
        bottom: 20px;
        right: 20px;
        position: fixed;
    }
    
    .chat-widget.chat-widget-open .chat-toggle-btn {
        top: 20px;
        bottom: auto;
        right: 20px;
        z-index: var(--chat-z-index-modal);
    }
}

@media (max-width: 480px) {
    .conversation-item .conversation-name {
        font-size: 0.85rem;
    }
    
    .conversation-item .last-message {
        font-size: 0.75rem;
    }
    
    .message-content {
        max-width: calc(100% - 50px);
        padding: 0.5rem 0.75rem;
    }
    
    .message-input {
        font-size: 0.9rem;
    }
    
    .emoji-picker {
        width: 280px;
        right: 0;
    }
}

/* === Accessibility === */
@media (prefers-reduced-motion: reduce) {
    .chat-widget,
    .chat-widget .chat-panel,
    .chat-widget .chat-toggle-btn,
    .conversation-item,
    .message-item {
        transition: none;
        animation: none;
    }
}

/* === Print Styles === */
@media print {
    .chat-widget {
        display: none !important;
    }
}

/* === High Contrast Mode === */
@media (prefers-contrast: high) {
    :root {
        --chat-border-color: #000000;
        --chat-text-secondary: #000000;
    }
    
    [data-bs-theme="dark"] {
        --chat-border-color: #ffffff;
        --chat-text-secondary: #ffffff;
    }
}

/* === Focus Styles para Accesibilidad === */
.conversation-item:focus,
.message-item:focus,
.online-user-item:focus {
    outline: 2px solid var(--chat-primary-color);
    outline-offset: 2px;
}

.chat-toggle-btn:focus {
    outline: 2px solid var(--chat-primary-color);
    outline-offset: 4px;
}

/* === Utilities === */
.chat-hidden { display: none !important; }
.chat-visible { display: block !important; }
.chat-loading { opacity: 0.6; }

/* === Animations adicionales === */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.animate-fade-in-up {
    animation: fadeInUp 0.3s ease;
}

.animate-slide-in-right {
    animation: slideInRight 0.3s ease;
}

/* === Reply Message Styles === */
.reply-reference {
    display: flex;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 0.375rem;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    overflow: hidden;
    max-width: 100%;
}

[data-bs-theme="dark"] .reply-reference {
    background: rgba(255, 255, 255, 0.1);
}

.reply-line {
    width: 3px;
    background: var(--chat-primary-color);
    flex-shrink: 0;
}

.reply-content {
    padding: 0.5rem 0.75rem;
    flex: 1;
    min-width: 0;
}

.reply-user {
    font-weight: 600;
    color: var(--chat-primary-color);
    font-size: 0.8rem;
    margin-bottom: 0.125rem;
    display: block;
}

.reply-text {
    color: var(--chat-text-secondary);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-style: italic;
}

/* Reply reference in own messages */
.message-item.message-own .reply-reference {
    background: rgba(255, 255, 255, 0.2);
}

.message-item.message-own .reply-user {
    color: rgba(255, 255, 255, 0.9);
}

.message-item.message-own .reply-text {
    color: rgba(255, 255, 255, 0.7);
}

/* Reply indicator icon */
.reply-icon {
    margin-right: 0.25rem;
    opacity: 0.7;
}

/* Hover effects for reply references */
.reply-reference:hover {
    background: rgba(0, 0, 0, 0.08);
    cursor: pointer;
}

[data-bs-theme="dark"] .reply-reference:hover {
    background: rgba(255, 255, 255, 0.15);
}

.message-item.message-own .reply-reference:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* === Click-to-Scroll Functionality === */

/* Resaltado temporal para mensajes */
.message-highlighted {
    background-color: rgba(var(--bs-primary-rgb), 0.1) !important;
    border-left: 3px solid var(--bs-primary) !important;
    transition: background-color 0.3s ease, border-left 0.3s ease;
}

/* Hover effect para referencias clickeables */
.reply-clickable:hover {
    background: rgba(0, 0, 0, 0.08) !important;
}

[data-bs-theme="dark"] .reply-clickable:hover {
    background: rgba(255, 255, 255, 0.15) !important;
}