/* General styles */
body {
    font-family: Arial, sans-serif;
    height: 100vh;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-size: cover;
    background-repeat: no-repeat;
    overflow: hidden;
    position: relative;
}

/* Hidden class */
.hidden {
    display: none !important;
}

/* Chat app container */
.chat-app-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100vh;
    position: relative;
    overflow: hidden;
    transition: opacity 0.5s;
}

/* Chat container */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 0;
    box-sizing: border-box;
    position: relative;
}

/* Message panel */
.message-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.2);
}

/* Chat messages */
.chat {
    flex: 1;
    border: 1px solid #ccc;
    padding: 10px;
    overflow-y: auto;
    background: transparent;
    scroll-behavior: smooth;
    max-height: calc(100vh - 50px);
    position: relative;
    z-index: 1;
    scrollbar-width: none;
    -ms-overflow-style: none;
    margin-bottom: 50px;
}

.chat::-webkit-scrollbar {
    display: none;
}

/* User panel */
.panel {
    width: 250px;
    border-left: 1px solid #ccc;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255, 255, 255, 0.8);
    height: auto;
    max-height: 100%;
    overflow-y: auto;
    position: fixed;
    top: 0;
    right: 0;
    left: auto;
    z-index: 2;
    box-shadow: -2px 0 5px rgba(0, 0, 0, 0.2);
}

/* Ensure buttons are interactive */
.panel button, .panel input {
    touch-action: auto;
    pointer-events: auto;
    z-index: 5;
}

/* User list */
.user-list {
    flex-grow: 1;
    overflow-y: auto;
    width: 100%;
    max-height: calc(100% - 200px);
    display: block;
}

/* Profile image */
.profile-img {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    vertical-align: middle;
    margin-right: 5px;
    object-fit: cover;
}

/* Cam button */
.cam-button {
    width: 20px;
    height: 20px;
    margin-left: 5px;
    cursor: pointer;
    vertical-align: middle;
    object-fit: contain;
}

/* Webcam container */
.webcam-container {
    position: relative;
    width: 100%;
    margin: 0;
    z-index: 1000;
}

/* Remote video */
.remote-video {
    position: absolute;
    background: #000;
    border: 2px solid #fff;
    z-index: 1000;
}

/* Video close button */
.video-close-button {
    position: absolute;
    top: 5px;
    right: 5px;
    background: red;
    color: white;
    border: none;
    cursor: pointer;
    padding: 2px 6px;
    font-size: 12px;
}

/* Video resize handle */
.video-resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    background: yellow;
    cursor: nwse-resize;
}

/* Panel controls */
.panel-controls {
    display: flex;
    justify-content: space-around;
    width: 100%;
    margin-bottom: 10px;
    z-index: 3;
}

.panel-controls button {
    width: 40px;
    height: 40px;
    font-size: 20px;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid #ccc;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s, background-color 0.3s;
    z-index: 4;
}

.panel-controls button:hover {
    background-color: rgba(240, 240, 240, 0.9);
}

.panel-controls button:active {
    transform: scale(0.95);
}

/* Sound toggle button */
#soundToggle {
    position: relative;
}

/* Sound toggle button muted state */
#soundToggle.muted::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 2px;
    background: red;
    transform: rotate(45deg);
    top: 50%;
    left: 0;
}

/* Panel restore button */
.panel-restore {
    position: fixed;
    top: 10px;
    right: 10px;
    font-size: 20px;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid #ccc;
    border-radius: 50%;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    z-index: 3;
    transition: transform 0.3s;
}

.panel-restore:hover {
    background-color: rgba(240, 240, 240, 0.9);
}

.panel-restore:active {
    transform: scale(0.95);
}

/* Message */
.message {
    margin-bottom: 5px;
    word-wrap: break-word;
}

/* Chat input container */
.chat-input-container {
    width: 100%;
    padding: 0;
    background: rgba(255, 255, 255, 0.8);
    box-sizing: border-box;
    z-index: 1000;
    display: flex;
    height: 50px;
    min-height: 50px;
    border-top: 1px solid #ccc;
    transition: background-color 0.3s;
    align-items: center;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
}

/* Chat input */
.chat-input {
    flex: 1;
    padding: 5px;
    border: 1px solid #ccc;
    background: #808080;
    margin-right: 2px;
    color: #000000;
    height: 100%;
    box-sizing: border-box;
    resize: none;
}

/* Send button */
#sendMessage {
    padding: 5px 8px;
    border: 1px solid #ccc;
    background: #007bff;
    color: white;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.3s;
    height: 100%;
    box-sizing: border-box;
}

/* Emoji button */
#emojiButton {
    padding: 5px;
    border: 1px solid #ccc;
    background: #ffff00;
    color: black;
    cursor: pointer;
    font-size: 16px;
    width: 30px;
    height: 100%;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    text-indent: -9999px;
}

#emojiButton::after {
    content: '🙂';
    position: absolute;
    text-indent: 0;
}

#emojiButton:hover::after {
    content: '😛';
}

#emojiButton.sixty::after {
    content: '😉';
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 20;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.4);
    padding-top: 60px;
    transition: opacity 0.5s;
}

/* Modal content */
.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 500px;
    transition: opacity 0.3s;
}

/* Close button */
.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    transition: color 0.3s;
}

.close:hover,
.close:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

/* Actions menu */
#actionsMenu {
    display: none;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #ccc;
    padding: 10px;
    margin-top: 5px;
    border-radius: 5px;
    z-index: 3;
}

#actionsMenu button {
    display: block;
    width: 100%;
    padding: 8px;
    margin: 5px 0;
    border: none;
    background: #007bff;
    color: white;
    cursor: pointer;
    border-radius: 3px;
    transition: background-color 0.3s;
}

#actionsMenu button:hover {
    background-color: #0056b3;
}

/* Emoji picker */
.emoji-picker {
    position: absolute;
    bottom: 60px;
    right: 10px;
    background: #fff;
    border: 1px solid #ccc;
    padding: 5px;
    display: none;
    z-index: 1001;
}

.emoji-option {
    font-size: 18px;
    padding: 2px 5px;
    border: none;
    background: none;
    cursor: pointer;
}

.emoji-option:hover {
    background-color: #f0f0f0;
}

/* Hidden input */
.hidden-input {
    display: none;
}

/* Media queries for mobile */
@media (max-width: 768px) {
    .chat-container {
        height: 100vh;
    }
    .message-panel {
        height: 100%;
    }
    .chat {
        padding: 8px;
        max-height: calc(100vh - 100px); /* Updated to move chat above input field */
        box-sizing: border-box;
        -webkit-overflow-scrolling: touch;
    }
    .panel {
        width: 200px;
        top: 0;
        right: 0;
        left: auto;
    }
    .panel-restore {
        top: 10px;
        right: 10px;
    }
    .webcam-container {
        margin: 5px 0;
    }
    .panel-controls button {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }
    .chat-input-container {
        display: flex !important;
        width: 100%;
        z-index: 1000;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
    }
    .remote-video {
        width: 150px;
        height: 112.5px;
    }
    .emoji-picker {
        bottom: 60px;
        right: 10px;
    }
}