/* General Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    background-color: #f5f5f5;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Dark Theme */
body.dark-theme {
    background-color: #222;
    color: #eee;
}

body.dark-theme #chat-container {
    background-color: #333;
    border: 1px solid #444;
}

body.dark-theme #login-screen {
    background-color: #333;
}

body.dark-theme h2 {
    color: #fff;
}

body.dark-theme #login-form label {
    color: #ddd;
}

body.dark-theme input[type="text"] {
    background-color: #444;
    color: #fff;
    border: 1px solid #555;
}

body.dark-theme button {
    background-color: #4a7bcc;
}

body.dark-theme button:hover {
    background-color: #3a6bbb;
}

body.dark-theme #chat-header {
    background-color: #2a2a2a;
    border-bottom: 1px solid #444;
}

body.dark-theme #online-users {
    color: #aaa;
}

body.dark-theme .message.incoming .message-content {
    background-color: #3a3a3a;
    color: #fff;
}

body.dark-theme .message.outgoing .message-content {
    background-color: #2b5278;
    color: #fff;
}

body.dark-theme .message.system .message-content {
    background-color: #2e2e2e;
    color: #aaa;
}

body.dark-theme .user-name {
    color: #bbb;
}

body.dark-theme .message-timestamp {
    color: #888;
}

body.dark-theme #typing-indicator {
    color: #aaa;
}

body.dark-theme #chat-input {
    border-top: 1px solid #444;
    background-color: #2a2a2a;
}

body.dark-theme #message-input {
    background-color: #444;
    color: #fff;
    border: 1px solid #555;
}

body.dark-theme .pinned-message {
    background-color: #3e3e2a;
    border-left: 3px solid #aa8800;
    color: #eee;
}

/* Container */
#chat-container {
    width: 100%;
    height: 100%;
    max-width: 100%;
    background-color: white;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Login Screen */
#login-screen {
    width: 100%;
    height: 100%;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 10;
    background-color: white;
    transition: opacity 0.3s ease-out, visibility 0.3s;
}

#login-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

#login-screen h2 {
    margin-bottom: 20px;
    color: #333;
}

#login-form {
    width: 100%;
    max-width: 300px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: #555;
}

.form-group.checkbox {
    display: flex;
    align-items: center;
}

.form-group.checkbox label {
    margin-left: 8px;
    margin-bottom: 0;
}

input[type="text"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
}

button {
    background-color: #4a90e2;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    width: 100%;
    transition: background-color 0.2s;
}

button:hover {
    background-color: #3a80d2;
}

/* Chat Screen */
#chat-screen {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 5;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease-in;
}

#chat-screen.visible {
    opacity: 1;
    visibility: visible;
}

#chat-header {
    padding: 10px 15px;
    background-color: #f8f8f8;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#online-users {
    font-size: 14px;
    color: #666;
}

#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column-reverse;
}

.message {
    margin-bottom: 10px;
    max-width: 80%;
    clear: both;
}

.message-content {
    padding: 10px;
    border-radius: 18px;
    display: inline-block;
    position: relative;
    word-wrap: break-word;
}

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

.message.outgoing {
    align-self: flex-end;
}

.message.outgoing .message-content {
    background-color: #4a90e2;
    color: white;
    border-bottom-right-radius: 4px;
}

.message.incoming {
    align-self: flex-start;
}

.message.incoming .message-content {
    background-color: #e8e8e8;
    color: #333;
    border-bottom-left-radius: 4px;
}

.message.system {
    align-self: center;
    max-width: 100%;
}

.message.system .message-content {
    background-color: #f5f5f5;
    color: #666;
    font-style: italic;
    font-size: 14px;
}

.user-name {
    font-size: 12px;
    margin-bottom: 2px;
    color: #555;
    font-weight: bold;
}

#typing-indicator {
    padding: 5px 15px;
    font-size: 14px;
    font-style: italic;
    color: #666;
}

#chat-input {
    padding: 10px 15px;
    border-top: 1px solid #eee;
}

#message-form {
    display: flex;
}

#message-input {
    flex: 1;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

#send-btn {
    width: auto;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

/* Utility */
.hidden {
    display: none;
}

.pinned-message {
    background-color: #fff8e1;
    padding: 10px;
    margin-bottom: 10px;
    border-left: 3px solid #ffb300;
    font-size: 14px;
    border-radius: 4px;
}

/* Responsive design */
@media (max-width: 600px) {
    body {
        align-items: flex-start;
    }
    
    #chat-container {
        height: 100%;
        border-radius: 0;
        box-shadow: none;
    }
    
    .message {
        max-width: 90%;
    }
}
