* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

.container {
    width: 100%;
    max-width: 1200px;
}

.chat-wrapper {
    display: flex;
    height: 600px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: #f8f9fa;
    border-right: 1px solid #e9ecef;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-align: center;
}

.sidebar-header h1 {
    font-size: 24px;
    font-weight: 700;
}

.login-section {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.login-section input,
.login-section select {
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
}

.login-section input:focus,
.login-section select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.user-info {
    padding: 20px;
    background: #e7f3ff;
    border-left: 4px solid #667eea;
}

.user-info p {
    margin: 8px 0;
    font-size: 14px;
}

.user-info strong {
    color: #667eea;
}

.rooms-section {
    padding: 20px;
    flex: 1;
}

.rooms-section h3 {
    font-size: 14px;
    font-weight: 600;
    color: #666;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.rooms-list {
    list-style: none;
}

.room-item {
    padding: 12px;
    margin: 5px 0;
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    font-weight: 500;
    color: #495057;
}

.room-item:hover {
    background: #f0f1f3;
    border-color: #667eea;
}

.room-item.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
}

/* Buttons */
.btn {
    padding: 12px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: #e9ecef;
    color: #495057;
    width: 100%;
    margin-top: 10px;
}

.btn-secondary:hover {
    background: #dee2e6;
}

.btn-send {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 10px 20px;
}

.btn-send:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

/* Main Chat Area */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chat-header {
    padding: 20px;
    background: white;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h2 {
    font-size: 20px;
    color: #333;
    margin: 0;
}

.online-count {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #666;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #28a745;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #fff;
}

.welcome-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #999;
    text-align: center;
}

.welcome-message h3 {
    font-size: 24px;
    margin-bottom: 10px;
    color: #666;
}

/* Message styles */
.message {
    display: flex;
    margin-bottom: 12px;
    animation: slideIn 0.3s ease;
}

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

.message.system {
    justify-content: center;
}

.message.system .message-content {
    background: #e9ecef;
    color: #666;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-style: italic;
    max-width: 60%;
}

.message.own {
    justify-content: flex-end;
}

.message.own .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.message.other .message-content {
    background: #f1f3f5;
    color: #333;
}

.message-content {
    max-width: 60%;
    padding: 12px 16px;
    border-radius: 12px;
    word-wrap: break-word;
    word-break: break-word;
}

.message-username {
    font-size: 12px;
    font-weight: 600;
    color: #667eea;
    margin-bottom: 4px;
    padding: 0 16px;
}

.message-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
}

.message.own .message-time {
    color: rgba(0, 0, 0, 0.4);
}

/* Chat input area */
.chat-input-area {
    padding: 15px 20px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
}

#messageForm {
    display: flex;
    gap: 10px;
}

#messageInput {
    flex: 1;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
}

#messageInput:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Responsive */
@media (max-width: 768px) {
    .chat-wrapper {
        height: 100vh;
        border-radius: 0;
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid #e9ecef;
        max-height: 200px;
    }

    .messages-container {
        max-width: 100%;
    }

    .message.other .message-content,
    .message.own .message-content {
        max-width: 85%;
    }
}

/* Scrollbar styling */
.messages-container::-webkit-scrollbar,
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.messages-container::-webkit-scrollbar-track,
.sidebar::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.messages-container::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.messages-container::-webkit-scrollbar-thumb:hover,
.sidebar::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* AI Panel Styles */
.ai-panel {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 500px;
    height: 550px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    border: 2px solid #667eea;
}

.ai-header {
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 600;
    border-radius: 10px 10px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-btn {
    background: rgba(255, 255, 255, 0.3);
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.5);
}

.ai-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ai-message {
    padding: 12px;
    border-radius: 8px;
    animation: slideIn 0.3s ease;
}

.ai-message.user {
    background: #667eea;
    color: white;
    margin-left: auto;
    max-width: 80%;
}

.ai-message.ai {
    background: white;
    color: #333;
    border: 1px solid #e0e0e0;
    max-width: 80%;
}

.ai-message.loading {
    background: #f0f0f0;
    color: #666;
    font-style: italic;
}

.ai-message.error {
    background: #ffe0e0;
    color: #c00;
    border-left: 4px solid #c00;
}

#aiForm {
    display: flex;
    gap: 10px;
    padding: 15px;
    background: white;
    border-top: 1px solid #e9ecef;
    border-radius: 0 0 10px 10px;
}

#aiForm input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
}

#aiForm input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.btn-ai {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    padding: 10px 14px;
}

.btn-ai:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(40, 167, 69, 0.4);
}

.btn-ai:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

@media (max-width: 768px) {
    .ai-panel {
        width: 90vw;
        height: 50vh;
        bottom: 10px;
        right: 10px;
        left: 10px;
    }
}
