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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f5f5f5;
    color: #333;
}

/* Auth Section */
.auth-section {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.auth-container {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 400px;
}

.auth-container h1 {
    margin-bottom: 2rem;
    text-align: center;
    color: #667eea;
}

#login-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#login-form input {
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

#login-form button {
    padding: 0.75rem;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: background 0.3s;
}

#login-form button:hover,
#register-form button:hover {
    background: #5568d3;
}

.toggle-auth-btn {
    width: 100%;
    padding: 0.75rem;
    background: #f0f0f0;
    color: #333;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.3s;
    margin-top: 1rem;
}

.toggle-auth-btn:hover {
    background: #e0e0e0;
}

/* Main App */
.main-section {
    display: flex;
    min-height: 100vh;
}

.app-container {
    display: flex;
    width: 100%;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: #2f3136;
    color: white;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #202225;
}

.user-info {
    padding: 1rem;
    border-bottom: 1px solid #202225;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.username {
    font-weight: 600;
}

.logout-btn {
    background: #ed4245;
    color: white;
    border: none;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
}

.logout-btn:hover {
    background: #da2e2e;
}

.channels-section {
    padding: 1rem;
    flex: 1;
    overflow-y: auto;
}

.channels-section h3 {
    font-size: 0.9rem;
    text-transform: uppercase;
    color: #72767d;
    margin-bottom: 1rem;
}

.create-btn {
    width: 100%;
    padding: 0.5rem;
    background: #5865f2;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin-bottom: 1rem;
    transition: background 0.3s;
}

.create-btn:hover {
    background: #4752c4;
}

.channels-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.channel-item {
    padding: 0.75rem;
    background: #36393f;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
    border-left: 3px solid transparent;
}

.channel-item:hover {
    background: #40444b;
}

.channel-item.active {
    background: #40444b;
    border-left-color: #5865f2;
}

.channel-item.alert {
    border-left-color: #f04747;
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
}

.no-channel-msg {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #72767d;
    font-size: 1.1rem;
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

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

.chat-header h2 {
    font-size: 1.25rem;
    color: #2f3136;
}

.header-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.members-count {
    font-size: 0.9rem;
    color: #72767d;
}

.header-btn {
    padding: 0.5rem 1rem;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
}

.header-btn:hover {
    background: #e0e0e0;
}

/* Messages Area */
.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.message {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    animation: slideIn 0.3s ease-in;
}

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

.message-avatar {
    width: 40px;
    height: 40px;
    background: #5865f2;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    flex-shrink: 0;
}

.message-content {
    flex: 1;
}

.message-header {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.25rem;
}

.message-author {
    font-weight: 600;
    color: #2f3136;
}

.message-time {
    font-size: 0.85rem;
    color: #72767d;
}

.message-text {
    color: #2f3136;
    line-height: 1.4;
}

.message.alert .message-text,
.message.warning .message-text,
.message.error .message-text {
    padding: 0.5rem;
    border-radius: 4px;
    background: #f5f5f5;
    font-family: monospace;
}

.message.warning .message-text {
    border-left: 3px solid #f0ad4e;
    background: #fffbf0;
}

.message.error .message-text {
    border-left: 3px solid #f04747;
    background: #fff0f0;
}

.message.info .message-text {
    border-left: 3px solid #43b581;
    background: #f0fff5;
}

.system-message {
    text-align: center;
    font-size: 0.9rem;
    color: #72767d;
    margin: 1rem 0;
    font-style: italic;
}

/* Input Area */
.input-area {
    padding: 1rem;
    border-top: 1px solid #e0e0e0;
    background: #fafafa;
}

#message-form {
    display: flex;
    gap: 0.5rem;
}

#message-input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    resize: none;
}

#message-form button {
    padding: 0.75rem 1.5rem;
    background: #5865f2;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.3s;
}

#message-form button:hover {
    background: #4752c4;
}

/* Modals */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: white;
    padding: 2rem;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    position: relative;
}

.close {
    position: absolute;
    right: 1rem;
    top: 1rem;
    font-size: 2rem;
    cursor: pointer;
    color: #999;
}

.close:hover {
    color: #333;
}

.modal-content h2 {
    margin-bottom: 1.5rem;
    color: #2f3136;
}

#create-channel-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#create-channel-form input,
#create-channel-form textarea {
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    font-family: inherit;
}

#create-channel-form button {
    padding: 0.75rem;
    background: #5865f2;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
}

#create-channel-form button:hover {
    background: #4752c4;
}

#create-channel-form label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

#create-channel-form input[type="checkbox"] {
    width: auto;
}

/* Members List */
.members-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.member-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: #f5f5f5;
    border-radius: 4px;
}

.member-avatar {
    width: 40px;
    height: 40px;
    background: #5865f2;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
}

.member-info {
    flex: 1;
}

.member-name {
    font-weight: 600;
    color: #2f3136;
}

.member-badge {
    font-size: 0.8rem;
    background: #ffc107;
    color: #333;
    padding: 0.2rem 0.4rem;
    border-radius: 2px;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 200px;
    }

    .chat-header {
        flex-wrap: wrap;
    }

    .modal-content {
        width: 95%;
    }
}

/* Scrollbar styling */
.messages-area::-webkit-scrollbar,
.channels-section::-webkit-scrollbar {
    width: 8px;
}

.messages-area::-webkit-scrollbar-track,
.channels-section::-webkit-scrollbar-track {
    background: #f1f1f1;
}

/* Members List */
.members-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.member-item {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding: 1rem;
    background: #f5f5f5;
    border-radius: 4px;
    border-left: 3px solid #667eea;
}

.member-name {
    font-weight: 600;
    color: #333;
}

.member-email {
    font-size: 0.85rem;
    color: #666;
}

.member-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    background: #667eea;
    color: white;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 0.5rem;
    width: fit-content;
}

.messages-area::-webkit-scrollbar-thumb,
.channels-section::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.messages-area::-webkit-scrollbar-thumb:hover,
.channels-section::-webkit-scrollbar-thumb:hover {
    background: #555;
}
