app/(default-layout)/conversation/components/message/Message.module.scss
@use '/app/scss/mixins.scss' as *;

.wrapper {
    width: 100%;
    margin: 12px 0;
    --empty-space-left: 48px;
    position: relative;
    display: flex;
    flex-direction: column-reverse;

    @include respond-to('mobile') {
        margin: 8px 0;
    }
}

.message {
    display: flex;
    position: relative;

    .avatar {
        margin-right: 12px;
        cursor: pointer;

        min-width: 36px;
        min-height: 36px;
        width: 36px;
        height: 36px;

        @include respond-to('mobile') {
            margin-right: 8px;
            min-width: 30px;
            min-height: 30px;
            width: 30px;
            height: 30px;
        }
    }
}

.message.hasReply {
    top: -12px;
}

.m-text {
    max-width: 60%;
    width: fit-content;
    padding: 12px;
    border: var(--solid-border);
    border-top-right-radius: 12px;
    border-bottom-right-radius: 12px;
    border-bottom-left-radius: 12px;
    box-shadow: var(--box-shadow);
    background-color: var(--background);
    word-break: break-word;
    @include font-default;
    font-size: 1.6rem;

    @include respond-to('mobile') {
        font-size: 1.4rem;
        padding: 8px 12px;
    }
}

.m-file,
.m-video,
.m-audio,
.m-call {
    max-width: 60%;
}

.m-audio {
}

@keyframes scaleOut {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

.highlight {
    border: 2px solid var(--red) !important;
    box-shadow: var(--red) 3px 3px !important;
    animation: scaleOut 0.7s cubic-bezier(0.785, 0.135, 0.15, 0.86);
}

.delete-message {
    box-shadow: var(--box-shadow);
    background-color: var(--delete-message-color) !important;
    word-break: break-word;
}

.imagesStack {
    max-width: 200px;
    height: fit-content;
}

.m-image {
    max-width: 200px;
    max-height: 200px;
    min-height: 200px;
    min-width: 200px;
    width: 100%;
    height: 100%;
    border-radius: 12px;
    border: var(--solid-border);
    box-shadow: var(--box-shadow);
    background-color: var(--white);
    object-fit: contain !important;
    cursor: pointer;

    &:hover {
        filter: grayscale(0.6);
    }

    @include respond-to('mobile') {
        max-width: 150px;
        min-width: 150px;
        max-height: 150px;
        min-height: 150px;
    }
}

.imagesStack2 {
    max-width: 300px;
    width: 100%;
    display: flex;
    flex-direction: column;
    .m-image:first-child {
    }
    .m-image:nth-child(2) {
        position: relative;
        bottom: 24px;
        left: 20%;
    }

    @include respond-to('mobile') {
        max-width: 200px;
    }
}

.imagesStack3 {
    max-width: 300px;
    width: 100%;
    display: flex;
    flex-direction: column;
    .m-image:first-child {
    }
    .m-image:nth-child(2) {
        position: relative;
        bottom: 24px;
        left: 20%;
    }
    .m-image:nth-child(3) {
        position: relative;
        bottom: 48px;
        left: 0;
    }

    @include respond-to('mobile') {
        max-width: 200px;
    }
}

.imagesStack4 {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-width: unset;
    max-width: 60%;

    .m-image {
        max-width: 80px;
        max-height: 80px;
        min-height: 80px;
        min-width: 80px;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}
.time {
    background-color: var(--white);
    @include center-align;
    @include font-default;
    font-size: 1.2rem;
    opacity: 0;
    height: 24px;
    width: fit-content;
    color: var(--text-color);
    padding: 4px 8px;
    border-radius: 6px;
    position: absolute;
    top: -20px;
    left: var(--empty-space-left);
    box-shadow: rgba(0, 0, 0, 0.35) 0px 5px 15px;
    animation: fadeIn 0.2s ease-in-out;
    animation-delay: 0.3s;
    animation-fill-mode: forwards;
    z-index: 10;
}

.tools {
    display: flex;
    flex: 1;
    justify-content: flex-start;
    align-items: center;
    margin: 0 6px;

    .tool-icon {
        width: 28px;
        height: 28px;
        border-radius: 50%;
        cursor: pointer;

        &:hover {
            background-color: var(--gray-color);
        }
    }
}

.icon-wrapper {
    width: fit-content;
}

.reactions {
    position: absolute;
    bottom: -16px;
    left: var(--empty-space-left);
}

.imageReactions2 {
    bottom: 8px;
    left: 20%;
}

.imageReactions3 {
    bottom: 32px;
}

// sender message
.isSender {
    .message {
        justify-content: flex-end;
        flex-direction: row-reverse;
    }

    .m-text {
        border-top-right-radius: 0px;
        border-top-left-radius: 12px;
        border-bottom-right-radius: 12px;
        border-bottom-left-radius: 12px;
        background-color: var(--bg-match-color);
    }

    .tools {
        flex-direction: row-reverse;
    }

    .time {
        right: 0;
        left: unset;
    }

    .reactions {
        right: 0;
        left: unset;
    }

    .imagesStack2 {
        align-items: flex-end;
        .m-image:nth-child(2) {
            position: relative;
            left: unset;
            right: 20%;
        }
        // .m-image: {
        //     position: relative;
        //     top: 24px;
        //     right: 20%;
        // }
    }

    .imagesStack3 {
        align-items: flex-end;

        .m-image:nth-child(2) {
            position: relative;
            left: -20%;
        }
    }

    .imagesStack4 {
        justify-content: flex-end;
    }

    .reply-message {
        align-items: flex-end;
        left: unset;

        .reply-content {
            border-top-right-radius: 0px;
            border-top-left-radius: 12px;
            border-bottom-right-radius: 12px;
            border-bottom-left-radius: 12px;
            word-break: break-word;
        }
    }

    .imageReactions2 {
        bottom: 16px;
        left: unset;
        right: 12%;
    }
}

// more menu
.more-menu {
    display: flex;
    flex-direction: column;
    padding: 4px 0;
    background-color: var(--white);
    border: 1px solid #818181;
    border-radius: 8px;
    box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px;

    .more-item {
        @include font-default;
        font-size: 1.4rem;
        cursor: pointer;
        padding: 8px 12px;
        margin: 0 4px;
        font-weight: 500;
        border-radius: 4px;
    }

    .more-item:hover {
        background-color: var(--gray-color);
    }
}

// reply message

.reply-message {
    display: flex;
    flex-direction: column;
    margin-left: 48px;

    .reply-content {
        background-color: var(--reply-message-color);
        max-width: 50%;
        width: fit-content;
        padding: 12px;
        padding-bottom: 24px;
        @include font-default;
        color: #333;
        border: var(--solid-border);
        border-top-right-radius: 12px;
        border-bottom-right-radius: 12px;
        border-bottom-left-radius: 12px;
        box-shadow: var(--reply-box-box-shadow);
        word-break: break-word;
        cursor: pointer;
    }

    .reply-label {
        width: fit-content;
        @include font-default;
        margin-bottom: 4px;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    .reply-icon {
        font-size: 1.4rem;
    }

    @include respond-to('mobile') {
        margin-left: 38px;
    }
}

// read user

.read-users {
    display: flex;
    justify-content: flex-end;
    margin-top: 20px;
    gap: 4px;
}

// call message

.call-message {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    background-color: var(--white);
    border-radius: 8px;
    padding: 12px;
    border: var(--solid-border);
    gap: 8px;

    .call-icon {
        height: 32px;
        width: 32px;
        min-height: 32px;
        min-width: 32px;
        @include center-align;
        border-radius: 10rem;
        background-color: #4caf50;
        color: #fff;

        &.isMissed {
            background-color: var(--red); // đỏ cho missed
        }
    }

    .call-text {
        white-space: pre-wrap;
        word-break: break-word;
        @include font-default;
        font-weight: 500;
    }
}
