/* Chat Windows Container */
#chat-windows-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: flex-end;
}

/* Chat Window */
.chat-window {
    width: 350px;
    height: 500px;
    background: var(--white-d);
    border-radius: var(--radius-m);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s ease;
    border: 1px solid var(--color-9);
}

.chat-window.minimized {
    height: 60px;
    width: 250px;
}

.chat-window-header {
    background: var(--color-1);
    color: var(--white);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    user-select: none;
}

.chat-window-header:hover {
    background: var(--color-1);
    opacity: 0.95;
}

.chat-window-header .chat-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-weight: var(--bold);
    font-size: 0.875rem;
    flex-shrink: 0;
    position: relative;
}

.chat-window-header .chat-user-avatar .chat-user-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--color-1);
    position: absolute;
    bottom: -2px;
    right: -2px;
    background-color: #9e9e9e;
}

.chat-window-header .chat-user-avatar .chat-user-status.online {
    background-color: #4CAF50;
}

.chat-window-header .chat-user-avatar .chat-user-status.away {
    background-color: #FFC107;
}

.chat-window-header .chat-user-info {
    flex: 1;
    min-width: 0;
}

.chat-window-header .chat-user-name {
    font-size: 0.875rem;
    font-weight: var(--bold);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-window-header .chat-user-status-text {
    font-size: 0.75rem;
    opacity: 0.9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-window-header .chat-window-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.chat-window-header .chat-window-action-btn {
    background: none;
    border: none;
    color: var(--white);
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--semiradius);
    transition: background 0.3s;
    opacity: 0.8;
}

.chat-window-header .chat-window-action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    opacity: 1;
}

.chat-window-header .chat-window-action-btn i {
    font-size: 1rem;
}

.chat-window-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-window.minimized .chat-window-body {
    display: none;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background: var(--white);
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: var(--color-7);
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--color-9);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-d);
}

.chat-message {
    display: flex;
    gap: 0.5rem;
    max-width: 80%;
    animation: messageSlideIn 0.3s ease;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.sent {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-message.received {
    align-self: flex-start;
}

.chat-message-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--color-1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-weight: var(--bold);
    font-size: 0.75rem;
    flex-shrink: 0;
}

.chat-message-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.chat-message-bubble {
    padding: 0.625rem 0.875rem;
    border-radius: var(--radius);
    word-wrap: break-word;
    font-size: 0.875rem;
    line-height: 1.4;
}

.chat-message.sent .chat-message-bubble {
    background: var(--color-1);
    color: var(--white);
    border-bottom-right-radius: 4px;
}

.chat-message.received .chat-message-bubble {
    background: var(--color-7);
    color: var(--text);
    border-bottom-left-radius: 4px;
}

.chat-message-time {
    font-size: 0.7rem;
    color: var(--text-d);
    padding: 0 0.5rem;
}

.chat-message-status {
    font-size: 0.7rem;
    color: var(--text-d);
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-top: 0.25rem;
}

.chat-message-status i {
    font-size: 0.75rem;
}

.chat-input-container {
    padding: 0.75rem;
    border-top: 1px solid var(--color-9);
    background: var(--white);
}

.chat-input-wrapper {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.chat-input-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.chat-input-action-btn {
    width: 32px;
    height: 32px;
    background: var(--color-7);
    color: var(--text);
    border: 1px solid var(--color-9);
    border-radius: var(--semiradius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    flex-shrink: 0;
}

.chat-input-action-btn:hover {
    background: var(--color-9);
    border-color: var(--text);
}

.chat-input-action-btn i {
    font-size: 1rem;
}

.chat-attachments-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    padding: 0.5rem;
    background: var(--color-7);
    border-radius: var(--semiradius);
}

.chat-attachment-preview {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: var(--white);
    border: 1px solid var(--color-9);
    border-radius: var(--semiradius);
    font-size: 0.75rem;
}

.chat-attachment-preview .attachment-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-attachment-preview .attachment-remove {
    background: none;
    border: none;
    color: var(--text-d);
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--semiradius);
    transition: all 0.3s;
}

.chat-attachment-preview .attachment-remove:hover {
    background: var(--color-9);
    color: var(--text);
}

.chat-download-reference {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: var(--color-7);
    border-left: 3px solid var(--color-1);
    border-radius: var(--semiradius);
    margin: 0.5rem 0;
    font-size: 0.875rem;
}

.chat-download-reference i {
    color: var(--color-1);
    font-size: 1.25rem;
}

.chat-download-reference-info {
    flex: 1;
    min-width: 0;
}

.chat-download-reference-name {
    font-weight: var(--bold);
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-download-reference-link {
    color: var(--color-1);
    text-decoration: none;
    font-size: 0.75rem;
}

.chat-download-reference-link:hover {
    text-decoration: underline;
}

.chat-message-attachment {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: var(--color-7);
    border: 1px solid var(--color-9);
    border-radius: var(--semiradius);
    margin-top: 0.5rem;
    text-decoration: none;
    color: var(--text);
    transition: all 0.3s;
}

.chat-message-attachment:hover {
    background: var(--color-9);
    border-color: var(--text);
}

.chat-message-attachment i {
    color: var(--color-1);
    font-size: 1.25rem;
}

.chat-message-attachment-info {
    flex: 1;
    min-width: 0;
}

.chat-message-attachment-name {
    font-weight: var(--regular);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-message-attachment-size {
    font-size: 0.75rem;
    color: var(--text-d);
}

.chat-message-mentioned {
    background: rgba(74, 175, 80, 0.1);
    color: var(--color-1);
    padding: 0.125rem 0.375rem;
    border-radius: var(--semiradius);
    font-weight: var(--bold);
    font-size: 0.875rem;
}

.chat-mention-dropdown {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    max-height: 200px;
    overflow-y: auto;
    background: var(--white-d);
    border: 1px solid var(--color-9);
    border-radius: var(--radius);
    box-shadow: var(--box-shadow);
    z-index: 10;
    margin-bottom: 0.5rem;
    display: none;
}

.chat-mention-dropdown.active {
    display: block;
}

.chat-mention-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    transition: background 0.3s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chat-mention-item:hover {
    background: var(--color-7);
}

.chat-mention-item .chat-user-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--color-1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-weight: var(--bold);
    font-size: 0.75rem;
    flex-shrink: 0;
}

.chat-download-dropdown {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    max-height: 200px;
    overflow-y: auto;
    background: var(--white-d);
    border: 1px solid var(--color-9);
    border-radius: var(--radius);
    box-shadow: var(--box-shadow);
    z-index: 10;
    margin-bottom: 0.5rem;
    display: none;
}

.chat-download-dropdown.active {
    display: block;
}

.chat-download-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    transition: background 0.3s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chat-download-item:hover {
    background: var(--color-7);
}

.chat-download-item i {
    color: var(--color-1);
    font-size: 1rem;
}

.chat-download-item-info {
    flex: 1;
    min-width: 0;
}

.chat-download-item-name {
    font-weight: var(--regular);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.875rem;
}

.chat-download-item-size {
    font-size: 0.75rem;
    color: var(--text-d);
}

.chat-input {
    flex: 1;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--color-9);
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-family: var(--font);
    color: var(--text);
    background: var(--white);
    resize: none;
    max-height: 100px;
    min-height: 40px;
    transition: border 0.3s;
}

.chat-input:focus {
    outline: none;
    border: 1px solid var(--color-1);
}

.chat-send-btn {
    width: 40px;
    height: 40px;
    background: var(--color-1);
    color: var(--white);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    flex-shrink: 0;
}

.chat-send-btn:hover {
    background: var(--color-1);
    opacity: 0.9;
    transform: scale(1.05);
}

.chat-send-btn:active {
    transform: scale(0.95);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-send-btn i {
    font-size: 1.125rem;
}

.chat-typing-indicator {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    color: var(--text-d);
    font-style: italic;
}

.chat-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-d);
    font-size: 0.875rem;
    text-align: center;
    padding: 2rem;
}

/* Animación de notificación */
.chat-window.new-message {
    animation: chatPulse 0.5s ease;
}

@keyframes chatPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.02);
    }
}

/* Responsive */
@media (max-width: 768px) {
    .chat-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 100px);
        max-height: 600px;
    }
    
    #chat-windows-container {
        right: 10px;
        bottom: 10px;
    }
}

