* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    padding: 0;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
    overflow: hidden;
    background-color: #111b21;
    position: fixed;
    width: 100%;
}

#bg-video {
    position: fixed;
    right: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    object-fit: contain; /* Changed to contain to show the whole video */
    z-index: -1;
    filter: brightness(0.85);
    background: #000; /* Added black background to fill empty space */
}

.chat-container {
    position: fixed;
    display: flex;
    flex-direction: column;
    background: none;
    width: 100%;
    height: 100%;
    max-width: 100%;
    margin: 0;
    /* Align with video */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

@media (min-width: 768px) {
    .chat-container {
        width: 90%;
        max-width: 450px;
        height: auto;
        min-height: 600px;
        max-height: 90vh;
        background: none;
        border-radius: 12px;
        box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    }
}

.chat-header {
    background: none;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    height: 60px;
    border-bottom: 1px solid #374045;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.chat-header .avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: none;
    margin-right: 15px;
}

.chat-header .chat-info {
    flex: 1;
}

.chat-header .chat-info h2 {
    color: #e9edef;
    font-size: 16px;
    margin-bottom: 2px;
}

.chat-header .chat-info p {
    color: #8696a0;
    font-size: 13px;
}

.chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: transparent;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

.message {
    padding: 8px 12px;
    margin-bottom: 8px;
    border-radius: 7.5px;
    max-width: 85%;
    position: relative;
    font-size: 14.2px;
    line-height: 19px;
    color: #e9edef;
    word-wrap: break-word;
    -webkit-user-select: none;
    user-select: none;
}

@media (min-width: 768px) {
    .message {
        max-width: 65%;
    }
}

.message::before {
    content: '';
    position: absolute;
    top: 0;
    width: 12px;
    height: 12px;
    clip-path: polygon(0 0, 100% 0, 100% 100%);
}

.user1 {
    margin-right: auto;
    background: #202c33;
    border-top-left-radius: 0;
}

.user2 {
    margin-left: auto;
    background: #005c4b;
    border-top-right-radius: 0;
}

.message-time {
    font-size: 11px;
    color: #8696a0;
    float: right;
    margin-left: 8px;
    margin-top: 2px;
}

.chat-input-container {
    background: none;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    position: absolute;
    bottom: 20px;
    left: 0;
    right: 0;
    width: 100%;
}

.chat-input {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 90%;
    max-width: 800px;
    background: none;
    border-radius: 24px;
    padding: 9px 12px;
    margin: 0 auto;
    margin-bottom: env(safe-area-inset-bottom, 0px); /* Support for iPhone notch */
}

.chat-input input {
    flex: 1;
    background: none;
    border: none;
    color: #e9edef;
    font-size: 15px;
    padding: 0 8px;
    min-height: 24px;
    max-height: 100px;
    resize: none;
}

.chat-input input::placeholder {
    color: #8696a0;
}

.chat-input input:focus {
    outline: none;
}

.chat-input input:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

/* Style for images in messages */
.message img {
    display: block;
    margin: 5px 0;
    max-width: 200px;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.chat-input button {
    background: none;
    border: none;
    color: #8696a0;
    cursor: pointer;
    padding: 8px;
    transition: color 0.2s ease;
}

.chat-input button:hover {
    color: #00a884;
}

.chat-input button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #374045;
    border-radius: 3px;
}

.emoji-button, .attach-button {
    color: #8696a0;
    font-size: 24px;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0 8px;
    transition: color 0.2s ease;
}

.emoji-button:hover, .attach-button:hover {
    color: #00a884;
}

.emoji-picker {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 0;
    background: #2a3942;
    border-radius: 8px;
    padding: 8px;
    margin-bottom: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    grid-template-columns: repeat(5, 1fr);
    gap: 5px;
}

.emoji-picker.active {
    display: grid;
}

.emoji-picker button {
    background: none;
    border: none;
    font-size: 24px;
    padding: 5px;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.emoji-picker button:hover {
    background-color: #374045;
}
