/*--------------------
Body
--------------------*/
*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    margin: 0;
}

body {
    background: linear-gradient(135deg, #0f8300, #94ca00);
    background-size: cover;
    font-family: 'Open Sans', sans-serif;
    font-size: 12px;
    line-height: 1.3;
    overflow: hidden;
}

.bg {
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    z-index: 1;
    background: url('https://images.unsplash.com/photo-1451186859696-371d9477be93?crop=entropy&fit=crop&fm=jpg&h=975&ixjsv=2.1.0&ixlib=rb-0.3.5&q=80&w=1925') no-repeat center center;
    background-size: cover;
    filter: blur(80px);
    transform: scale(1.2);
}

/*--------------------
Chat
--------------------*/
.chat {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%; 
    max-width: 500px; 
    height: 80vh;
    max-height: 500px;
    z-index: 2;
    overflow: hidden;
    box-shadow: 0 5px 30px rgba(0, 0, 0, .2);
    background: rgba(0, 0, 0, 0.5);
    border-radius: 20px;
    display: flex;
    justify-content: space-between;
    flex-direction: column;
}

/*--------------------
Chat Title
--------------------*/
.chat-title {
    flex: 0 1 45px;
    position: relative;
    font-family: Audiowide;
    z-index: 2;
    background: rgba(0, 0, 0, 0.2);
    color: #fff;
    text-transform: uppercase;
    text-align: left;
    padding: 10px 10px 10px 50px;
}

.chat-title h1 {
    font-weight: normal;
    font-size: 12px;
    margin: 0;
    padding: 0;
}

.chat-title h2 {
    color: rgba(255, 255, 255, .5);
    font-size: 10px;
    letter-spacing: 1px;
    margin: 0;
}

.chat-title .avatar {
    position: absolute;
    z-index: 1;
    top: 8px;
    left: 9px;
    border-radius: 30px;
    width: 30px;
    height: 30px;
    overflow: hidden;
    margin: 0;
    padding: 0;
    border: 2px solid rgba(255, 255, 255, 0.24);
}

.chat-title .avatar img {
    width: 100%;
    height: auto;
}

/*--------------------
Messages
--------------------*/
.messages {
    flex: 1 1 auto;
    color: rgb(255, 255, 255);
    overflow-y: auto;
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
}

.messages-content {
    padding: 10px;
    display: flex;
    flex-direction: column;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message {
    padding: 6px 10px 7px;
    border-radius: 10px;
    background: rgba(0, 0, 0, .3);
    margin: 8px 0;
    font-size: 11px;
    line-height: 1.4;
    position: relative;
    text-shadow: 0 1px 1px rgba(0, 0, 0, .2);
    animation: fadeIn 0.3s ease;
    max-width: 75%;
}

/* Switched alignment: received messages are now on the right */
/* Styles for received messages */
.message.message-received {
    align-self: flex-start; /* Align to the left */
    margin-left: 35px; /* Margin for received messages */
    background: rgba(0, 0, 0, .3); /* Background color for received messages */
    text-align: left; /* Align text to the left */
    color: #fff; /* Text color */
}

/* Styles for personal (sent) messages */
.message.message-personal {
    align-self: flex-end; /* Align to the right */
    margin-right: 35px; /* Margin for sent messages */
    background: linear-gradient(120deg, #248A52, #257287); /* Background color for sent messages */
    text-align: right; /* Align text to the right */
    color: #fff; /* Text color */
}

.message .timestamp {
    position: absolute;
    bottom: -15px;
    font-size: 9px;
    color: rgba(255, 255, 255, .3);
}

.message::before {
    content: '';
    position: absolute;
    bottom: -6px;
    border-top: 6px solid rgba(0, 0, 0, .3);
    left: 0;
    border-right: 7px solid transparent;
}

.message:hover {
    transform: scale(1.02);
    transition: transform 0.2s;
}

.message:hover .timestamp {
    color: rgba(255, 255, 255, .6);
}

/* Typing Effect */
.typing-indicator {
    display: flex;
    align-items: center;
    margin-left: 35px; /* Align with personal messages */
}

.typing-indicator span {
    display: inline-block;
    width: 6px;
    height: 6px;
    margin: 0 2px;
    background: #fff;
    border-radius: 50%;
    opacity: 0.3;
    animation: typingEffect 1s infinite alternate;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingEffect {
    0% {
        opacity: 0.3;
        transform: translateY(0);
    }
    100% {
        opacity: 1;
        transform: translateY(-3px);
    }
}

/*--------------------
Message Box
--------------------*/
.message-box {
    flex: 0 1 40px;
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    padding: 10px;
    position: relative;
}

.message-input {
    background: none;
    border: none;
    outline: none !important;
    color: rgba(255, 255, 255, .7);
    font-size: 12px;
    width: 100%;
    padding-right: 50px;
}

.message-submit {
    position: absolute;
    top: 9px;
    right: 10px;
    color: #fff;
    border: none;
    background: #248A52;
    font-size: 12px;
    text-transform: uppercase;
    line-height: 1;
    padding: 6px 12px;
    border-radius: 10px;
    cursor: pointer;
    outline: none !important;
    transition: background .2s ease;
}

.message-submit:hover {
    background: #1D7745;
}

footer {
    background-color: #282c34;
    color: rgb(0, 211, 0);
    padding: 10px;
    text-align: center;
    position: relative;
    bottom: 0;
    width: 100%;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.5);
}

@media (max-width: 768px) {
    body {
        font-size: 10px;
    }
    .chat {
        width: 95%;
    }
    .chat-title h1 {
        font-size: 10px;
    }
    .chat-title h2 {
        font-size: 8px;
    }
    .message {
        font-size: 9px;
    }
    .message-input {
        font-size: 10px;
    }
    .message-submit {
        font-size: 10px;
    }
}
