* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f4f5f7;
  color: #1a1a1a;
}
.hidden { display: none !important; }

#login-screen {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-box {
  background: white;
  padding: 32px;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
  width: 280px;
  text-align: center;
}
.login-box h1 { font-size: 18px; margin-bottom: 16px; }
.login-box input {
  width: 100%;
  padding: 10px;
  margin-bottom: 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
}
.login-box button {
  width: 100%;
  padding: 10px;
  background: #2563eb;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}
.error { color: #dc2626; font-size: 13px; margin-top: 8px; }

#app {
  display: flex;
  height: 100vh;
}
#session-list-wrap {
  width: 320px;
  background: white;
  border-right: 1px solid #e5e7eb;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}
#sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid #eee;
  font-size: 12px;
}
#conn-status { color: #6b7280; }
#logout-btn {
  border: none; background: none; color: #6b7280; font-size: 12px;
  cursor: pointer; text-decoration: underline;
}
#session-list {
  overflow-y: auto;
  flex: 1;
}
.session-item {
  padding: 14px 16px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
}
.session-item:hover { background: #f9fafb; }
.session-item.active { background: #eff6ff; }
.session-item .top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.session-item .page-title { font-weight: 600; font-size: 14px; }
.session-item .page-url { font-size: 12px; color: #6b7280; word-break: break-all; }
.session-item .visitor-info { font-size: 12px; color: #2563eb; margin-top: 2px; font-weight: 500; }
.session-item .preview { font-size: 13px; color: #4b5563; margin-top: 4px; }
.session-item .status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #d1d5db; display: inline-block; margin-right: 6px;
}
.session-item .status-dot.online { background: #22c55e; }
.session-item .unread-badge {
  background: #dc2626; color: white; font-size: 11px;
  border-radius: 10px; padding: 1px 7px; min-width: 18px; text-align: center;
}

#chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
}
#chat-header {
  padding: 16px 20px;
  background: white;
  border-bottom: 1px solid #e5e7eb;
  font-weight: 600;
}
#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.msg {
  max-width: 60%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.4;
}
.msg.visitor { align-self: flex-start; background: #e5e7eb; border-bottom-left-radius: 4px; }
.msg.agent { align-self: flex-end; background: #2563eb; color: white; border-bottom-right-radius: 4px; }
.msg .ts { display: block; font-size: 10px; opacity: 0.6; margin-top: 4px; }

#chat-input-row {
  display: flex;
  gap: 10px;
  padding: 14px 20px;
  background: white;
  border-top: 1px solid #e5e7eb;
}
#chat-input {
  flex: 1;
  resize: none;
  height: 44px;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
}
#send-btn {
  padding: 0 20px;
  background: #2563eb;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
#send-btn:disabled, #chat-input:disabled { opacity: 0.5; cursor: not-allowed; }
