/* Reset và base styles */
body {
    margin: 0;
    padding: 0;
    font-family: Arial, sans-serif;
}

/* Controls container fixed at bottom */
.controls-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: #f5f5f5;
    border-top: 1px solid #ccc;
    z-index: 1000;
    padding: 10px;
}

/* User and room controls */
.user-room-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 10px;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

.user-input {
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
}

.room-input {
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
}

.random-user-btn {
    padding: 4px 8px;
    background-color: #ff9800;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.random-user-btn:hover {
    background-color: #f57c00;
}

.connect-btn {
    padding: 6px 12px;
    background-color: #4caf50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.connect-btn:hover {
    background-color: #45a049;
}

.connect-btn.disconnected {
    background-color: #4caf50;
}

.connect-btn.connected {
    background-color: #f44336;
}

.connect-btn.connected:hover {
    background-color: #da190b;
}

/* Chat log area */
.chat-log {
    height: calc(100vh - 180px);
    overflow: auto;
    border: 1px solid #ccc;
    margin: 10px;
    margin-bottom: 190px;
    padding: 15px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Message input wrapper */
.message-input-wrapper {
    display: flex;
    gap: 10px;
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
}

/* Emoji button */
.emoji-btn {
    padding: 8px 12px;
    background-color: #ff9800;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
}

.emoji-btn:hover {
    background-color: #f57c00;
    transform: scale(1.05);
}

.emoji-btn.active {
    background-color: #e65100;
}

/* Emoji picker panel */
.emoji-picker {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background-color: white;
    border: 1px solid #ccc;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1002;
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 10px;
    transition: all 0.3s ease;
}

.emoji-picker.hidden {
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
}

.emoji-picker:not(.hidden) {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Emoji grid */
.emoji-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    gap: 5px;
    padding: 15px;
    max-height: 250px;
    overflow-y: auto;
}

/* Emoji items */
.emoji-item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    font-size: 20px;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
    user-select: none;
}

.emoji-item:hover {
    background-color: #f0f0f0;
    transform: scale(1.2);
}

.emoji-item:active {
    transform: scale(0.95);
}

.message-input {
    flex: 1;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
}

.message-input:focus {
    outline: none;
    border-color: #4caf50;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
}

.send-btn {
    padding: 8px 16px;
    background-color: #4caf50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.send-btn:hover {
    background-color: #45a049;
}

/* Floating users button */
.floating-users-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: #2196f3;
    color: white;
    border: none;
    font-size: 20px;
    cursor: pointer;
    z-index: 1001;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.floating-users-btn:hover {
    background-color: #1976d2;
    transform: scale(1.1);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

.floating-users-btn.active {
    background-color: #f44336;
}

.floating-users-btn.active:hover {
    background-color: #da190b;
}

/* User list section */
.user-list-container {
    position: fixed;
    top: 80px;
    right: 20px;
    width: 300px;
    max-height: 400px;
    padding: 15px;
    border: 1px solid #ccc;
    background-color: #f5f5f5;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    transition: all 0.3s ease;
    overflow-y: auto;
}

.user-list-container.hidden {
    opacity: 0;
    visibility: hidden;
    transform: translateY(-20px);
}

.user-list-container:not(.hidden) {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.user-list-title {
    font-weight: bold;
    color: #333;
}

.refresh-users-btn {
    padding: 4px 8px;
    font-size: 12px;
    background-color: #2196f3;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.refresh-users-btn:hover {
    background-color: #1976d2;
}

.user-list {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.user-badge {
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
    display: inline-block;
}

.user-badge.current-user {
    background-color: #2196f3;
}

.user-badge.other-user {
    background-color: #4caf50;
}

/* Message styles */
.message {
    margin: 2px 0;
    padding: 4px 8px;
    border-radius: 4px;
}

.message.own-message {
    background-color: #e3f2fd;
    border-left: 4px solid #2196f3;
    font-weight: bold;
    color: #1976d2;
}

.message.own-dm {
    background-color: #f3e5f5;
    border-left: 4px solid #9c27b0;
    font-weight: bold;
    color: #7b1fa2;
}

.message.other-message {
    background-color: #f5f5f5;
    border-left: 4px solid #9e9e9e;
}

.message.other-dm {
    background-color: #fff3e0;
    border-left: 4px solid #ff9800;
}

/* Read receipt styles */
.read-receipt {
    font-size: 11px;
    color: #666;
    margin-top: 4px;
    font-style: italic;
    opacity: 0.8;
    display: flex;
    align-items: center;
    gap: 4px;
    transform: translateX(-20px);
    opacity: 0;
    animation: slideInReadReceipt 0.5s ease-out forwards;
}

.read-receipt-icon {
    color: #4caf50;
    font-size: 12px;
    animation: bounceIn 0.6s ease-out;
    position: relative;
    display: inline-block;
}

.read-receipt-icon::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    background: radial-gradient(circle, rgba(76, 175, 80, 0.3) 0%, transparent 70%);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    animation: rippleEffect 0.8s ease-out;
    pointer-events: none;
}

@keyframes slideInReadReceipt {
    0% {
        transform: translateX(-20px);
        opacity: 0;
    }

    100% {
        transform: translateX(0);
        opacity: 0.8;
    }
}

@keyframes bounceIn {
    0% {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }

    50% {
        transform: scale(1.2) rotate(-90deg);
        opacity: 0.8;
    }

    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

@keyframes messageReadBounce {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.7);
    }

    50% {
        transform: scale(1.02);
        box-shadow: 0 0 0 8px rgba(76, 175, 80, 0.3);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0);
    }
}

@keyframes rippleEffect {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -50%) scale(2);
        opacity: 0;
    }
}

/* Typing indicator */
.typing-indicator {
    color: #666;
    font-style: italic;
    margin: 2px 0;
    padding: 4px 8px;
    background-color: #f9f9f9;
    border-radius: 4px;
}

/* Hidden class */
.hidden {
    display: none !important;
}

/* Responsive design */
@media (max-width: 768px) {
    .user-room-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .message-input-wrapper {
        flex-direction: column;
    }

    .user-list-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .chat-log {
        height: calc(100vh - 320px);
        margin: 5px;
        margin-bottom: 320px;
        padding: 10px;
    }

    .floating-users-btn {
        top: 10px;
        right: 10px;
        width: 45px;
        height: 45px;
        font-size: 18px;
    }

    .user-list-container {
        top: 65px;
        right: 10px;
        width: 280px;
        max-height: 300px;
        padding: 10px;
    }
}

@media (max-width: 480px) {
    .controls-container {
        padding: 5px;
    }

    .user-room-controls {
        margin-bottom: 5px;
    }

    .chat-log {
        height: calc(100vh - 370px);
        margin: 5px;
        margin-bottom: 370px;
        padding: 8px;
    }

    .floating-users-btn {
        top: 5px;
        right: 5px;
        width: 40px;
        height: 40px;
        font-size: 16px;
    }

    .user-list-container {
        top: 55px;
        right: 5px;
        width: 250px;
        max-height: 250px;
        padding: 8px;
    }
}