* --- General Styles --- */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0; padding: 0;
    background-color: #e0e0e0; /* Light gray background */
    display: flex; justify-content: center; align-items: center;
    min-height: 100vh;
    color: #333; line-height: 1.6;
}

.app-container {
    width: 95%; max-width: 1200px;
    display: flex; justify-content: center; align-items: center;
    height: 90vh;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border-radius: 15px; overflow: hidden;
    background-color: #f5f5f5;
}

/* --- Authentication Container --- */
.auth-container {
    width: 100%; height: 100%;
    display: flex; justify-content: center; align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.auth-box {
    background-color: rgba(255, 255, 255, 0.95);
    padding: 40px 35px; border-radius: 15px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
    text-align: center; width: 90%; max-width: 450px;
    display: flex; flex-direction: column; align-items: center;
}

.auth-box h2 { margin-bottom: 10px; color: #4a4a4a; font-size: 28px; }
.auth-box p { margin-bottom: 25px; color: #666; font-size: 15px; }

.auth-box input {
    width: calc(100% - 24px); padding: 14px 12px; margin-bottom: 18px;
    border: 1px solid #ddd; border-radius: 8px; font-size: 16px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
.auth-box input:focus {
    outline: none; border-color: #667eea; box-shadow: 0 0 0 3px rgba(102, 126, 238, 0.3);
}

.auth-box button {
    width: 100%; padding: 14px 12px; margin-top: 10px;
    background-color: #667eea; color: white; border: none; border-radius: 8px;
    cursor: pointer; font-size: 17px; font-weight: 500;
    transition: background-color 0.3s ease, transform 0.2s ease;
}
.auth-box button:hover { background-color: #5a6fbf; transform: translateY(-2px); }

#register-button { background-color: #28a745; margin-top: 12px; }
#register-button:hover { background-color: #218838; }

.error-message { color: #dc3545; margin-top: 15px; font-size: 14px; min-height: 20px; font-weight: bold; }

/* --- Chat Container Styles --- */
.chat-container {
    height: 100%; display: flex; flex-direction: row;
}

.sidebar {
    width: 35%; min-width: 280px;
    border-right: 1px solid #e0e0e0;
    background-color: #ffffff;
    display: flex; flex-direction: column; overflow: hidden;
    box-shadow: 2px 0 10px rgba(0,0,0,0.05);
}

.sidebar-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 18px 20px; border-bottom: 1px solid #e0e0e0;
    background-color: #f8f9fa; font-weight: 500;
}

#current-user-info { font-size: 16px; color: #4a4a4a; }

#logout-button {
    padding: 8px 16px; background-color: #dc3545; color: white; border: none;
    border-radius: 6px; cursor: pointer; font-size: 13px;
    transition: background-color 0.3s ease;
}
#logout-button:hover { background-color: #c82333; }

#create-chat-button { /* دکمه ایجاد چت (اگر لازم شد) */
    padding: 8px 12px; background-color: #28a745; color: white; border: none;
    border-radius: 6px; cursor: pointer; font-size: 14px; margin-left: 10px;
    transition: background-color 0.3s ease;
}
#create-chat-button:hover { background-color: #218838; }

.sidebar h2 {
    padding: 15px 20px; margin: 0; font-size: 19px; font-weight: 600; color: #333;
    border-bottom: 1px solid #e0e0e0; background-color: #ffffff;
}

.chat-list { /* این بخش دیگه استفاده نمی‌شه ولی نگهش می‌داریم */
    flex-grow: 1; overflow-y: auto; padding: 5px 0;
}
.chat-list .placeholder-text { /* استایل برای پیام placeholder */
    text-align: center; color: #aaa; margin-top: 30px; font-size: 16px;
}

.main-chat-area {
    width: 65%; display: flex; flex-direction: column;
    background-color: #ffffff;
}

.chat-header {
    display: flex; align-items: center; padding: 15px 20px;
    border-bottom: 1px solid #e0e0e0; background-color: #ffffff;
    box-shadow: 0 1px 5px rgba(0,0,0,0.05);
}

.chat-header h2 {
    margin: 0; font-size: 19px; font-weight: 600; color: #4a4a4a;
}

.messages-container {
    flex-grow: 1; overflow-y: auto; padding: 25px;
    display: flex; flex-direction: column; gap: 18px;
    position: relative;
    background-color: #fdfdfd; /* کمی رنگ برای پس‌زمینه چت */
}

.messages-container .placeholder-text {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    color: #aaa; font-size: 18px; text-align: center;
    background-color: rgba(255, 255, 255, 0.8); padding: 15px 25px; border-radius: 10px;
}

.message {
    padding: 12px 18px; border-radius: 20px; max-width: 75%; word-wrap: break-word;
    position: relative; line-height: 1.5; font-size: 15px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.message p { margin: 0; }
.message .timestamp {
    font-size: 10px; color: rgba(0, 0, 0, 0.45);
    position: absolute; bottom: 6px; white-space: nowrap;
}

.message.sent {
    background-color: #90ee90; /* Light green */
    align-self: flex-end; margin-left: auto;
    border-bottom-right-radius: 7px; color: #2c3e50;
}
.message.sent .timestamp { right: 12px; }

.message.received {
    background-color: #ffffff; /* White message */
    align-self: flex-start; margin-right: auto;
    border-bottom-left-radius: 7px; color: #333;
    border: 1px solid #e0e0e0;
}
.message.received .timestamp { left: 12px; }

.message-input-area {
    display: flex; padding: 15px 20px;
    background-color: #ffffff;
    border-top: 1px solid #e0e0e0;
    align-items: center;
    box-shadow: 0 -1px 5px rgba(0,0,0,0.05);
}

#message-input {
    flex-grow: 1; padding: 12px 18px;
    border: 1px solid #e0e0e0; border-radius: 25px;
    margin-left: 10px; font-size: 15px;
    background-color: #f0f2f5;
}
#message-input:focus {
    outline: none; border-color: #667eea; box-shadow: 0 0 0 3px rgba(102, 126, 238, 0.3);
}

#send-button {
    min-width: 70px; padding: 12px 18px;
    background-color: #667eea; color: white; border: none; border-radius: 25px;
    cursor: pointer; font-size: 15px; font-weight: 500;
    transition: background-color 0.3s ease, transform 0.2s ease;
    margin-left: 10px; box-shadow: 0 2px 5px rgba(102, 126, 238, 0.4);
}
#send-button:hover { background-color: #5a6fbf; transform: translateY(-1px); }

/* --- Responsive Adjustments --- */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column; height: 100vh; border-radius: 0; box-shadow: none;
    }
    .auth-container { height: 100%; background: #ffffff; }
    .auth-box { width: 95%; padding: 30px 20px; }
    .auth-box h2 { font-size: 24px; }
    .auth-box input, .auth-box button { width: calc(100% - 16px); padding: 12px 8px; font-size: 15px; }

    .chat-container { flex-direction: column; height: 100%; border-radius: 0; }
    .sidebar, .main-chat-area { width: 100%; }
    .sidebar { height: 40%; border-right: none; border-bottom: 1px solid #e0e0e0; min-width: unset; }
    .main-chat-area { height: 60%; }
    .sidebar-header { padding: 15px 15px; }
    #current-user-info { font-size: 15px; }
    #logout-button { padding: 6px 12px; font-size: 12px; }

    .message { max-width: 85%; }
    .message .timestamp { font-size: 9px; }

    .chat-header { padding: 12px 15px; }
    .chat-header h2 { font-size: 18px; }

    .messages-container { padding: 15px; gap: 15px; }
    .message { font-size: 14px; }

    .message-input-area { padding: 10px 15px; }
    #message-input, #send-button { font-size: 14px; padding: 10px 15px; }
    #send-button { min-width: 50px; }
}
