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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f5f5f7;
    height: 100vh;
    overflow: hidden;
}

.app {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: #1a1a2e;
    color: #fff;
    display: flex;
    flex-direction: column;
    padding: 16px;
}

.user-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #333;
    font-size: 13px;
}
.username-label { font-weight: 600; }
.logout-link { color: #bbb; text-decoration: none; }
.logout-link:hover { color: #fff; }

.model-select-label {
    display: block;
    font-size: 12px;
    color: #bbb;
    margin-bottom: 6px;
}
.model-select {
    width: 100%;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #444;
    background: #22223a;
    color: #fff;
    font-size: 13px;
    margin-bottom: 12px;
}

.new-chat-btn {
    background: #6c63ff;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 12px;
    font-size: 14px;
    cursor: pointer;
    margin-bottom: 16px;
}
.new-chat-btn:hover { background: #5a52e0; }

.conversation-list {
    flex: 1;
    overflow-y: auto;
}

.conversation-item {
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 6px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.conversation-item:hover { background: #2a2a4a; }
.conversation-item.active { background: #6c63ff; }

.conversation-item .delete-btn {
    background: none;
    border: none;
    color: #ccc;
    cursor: pointer;
    font-size: 14px;
}

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

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

.admin-link {
    text-decoration: none;
    color: #6c63ff;
    font-size: 14px;
    font-weight: 500;
}

.chat-box {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message {
    max-width: 70%;
    padding: 10px 16px;
    border-radius: 14px;
    line-height: 1.5;
    font-size: 15px;
    white-space: pre-wrap;
}

.message.user {
    align-self: flex-end;
    background: #6c63ff;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.message.assistant {
    align-self: flex-start;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 4px;
}

.message.loading {
    align-self: flex-start;
    background: #fff;
    border: 1px solid #e0e0e0;
    color: #999;
    font-style: italic;
}

.chat-form {
    display: flex;
    padding: 16px 24px;
    background: #fff;
    border-top: 1px solid #e0e0e0;
    gap: 12px;
}

#messageInput {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 24px;
    font-size: 15px;
    outline: none;
}
#messageInput:focus { border-color: #6c63ff; }

#sendBtn {
    background: #6c63ff;
    color: #fff;
    border: none;
    border-radius: 24px;
    padding: 0 24px;
    font-size: 15px;
    cursor: pointer;
}
#sendBtn:hover { background: #5a52e0; }
#sendBtn:disabled { background: #bbb; cursor: not-allowed; }

/* ---------- Halaman Login / Daftar (user) ---------- */
.auth-body {
    background: #f5f5f7;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
}

.auth-box {
    background: #fff;
    padding: 32px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    width: 100%;
    max-width: 360px;
}

.auth-box h2 {
    margin-bottom: 20px;
    text-align: center;
    font-size: 20px;
}

.auth-box label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin: 12px 0 6px;
    color: #333;
}

.auth-box input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
}
.auth-box input:focus { border-color: #6c63ff; outline: none; }

.auth-box button {
    width: 100%;
    margin-top: 20px;
    padding: 12px;
    background: #6c63ff;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    cursor: pointer;
}
.auth-box button:hover { background: #5a52e0; }

.auth-error {
    background: #fdecea;
    color: #d33;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 8px;
}

.auth-switch {
    margin-top: 16px;
    text-align: center;
    font-size: 13px;
    color: #666;
}
.auth-switch a { color: #6c63ff; text-decoration: none; font-weight: 600; }

@media (max-width: 700px) {
    .sidebar { width: 90px; }
    .conversation-item span { display: none; }
    .message { max-width: 85%; }
}
