@font-face {
  font-family: "Sanzu";
  src: url("https://raw.githubusercontent.com/heysanzu/sanzu/main/fonts/comic_sans_regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}


:root {
  --black:      #0A0A0A;
  --white:      #FFFFFF;
  --g50:        #F7F7F7;
  --g100:       #F0F0F0;
  --g200:       #E2E2E2;
  --g300:       #C8C8C8;
  --g400:       #A0A0A0;
  --g500:       #717171;
  --g600:       #4A4A4A;
  --g700:       #2E2E2E;
  --g800:       #1A1A1A;
  --g900:       #111111;
  --sidebar-w:  268px;
  --header-h:   54px;
  --r:          9px;
  --t:          160ms ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: "Sanzu", "Comic Sans MS", cursive, sans-serif;
  background: var(--white);
  color: var(--black);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button  { font-family: inherit; cursor: pointer; border: none; background: none; }
textarea { font-family: inherit; resize: none; }
a { color: inherit; text-decoration: none; }


.app {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}


.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--g900);
  color: var(--white);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform var(--t);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 14px;
  border-bottom: 1px solid var(--g800);
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  letter-spacing: 0.01em;
  color: var(--white);
}

.brand svg { opacity: 0.85; }

.close-sidebar { display: none; color: var(--g400); }
.close-sidebar:hover { color: var(--white); }


.sidebar-section {
  padding: 10px 10px 0;
  flex-shrink: 0;
}

.new-chat-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 10px;
  border-radius: 7px;
  font-size: 13px;
  color: var(--g300);
  border: 1px solid var(--g800);
  transition: background var(--t), color var(--t), border-color var(--t);
}

.new-chat-btn:hover {
  background: var(--g800);
  color: var(--white);
  border-color: var(--g700);
}

.new-chat-btn svg { flex-shrink: 0; opacity: 0.7; }


.quick-actions {
  padding: 16px 10px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}

.nav-label {
  font-size: 10px;
  letter-spacing: 0.07em;
  color: var(--g600);
  padding: 0 6px;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.quick-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--g400);
  text-align: left;
  transition: background var(--t), color var(--t);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.quick-btn:hover { background: var(--g800); color: var(--white); }
.quick-btn svg   { flex-shrink: 0; opacity: 0.65; }


.history-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 16px 10px 0;
}

.history-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-bottom: 8px;
}

.history-list::-webkit-scrollbar { width: 3px; }
.history-list::-webkit-scrollbar-thumb { background: var(--g700); border-radius: 2px; }

.history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--g400);
  cursor: pointer;
  transition: background var(--t), color var(--t);
  overflow: hidden;
}

.history-item span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item:hover { background: var(--g800); color: var(--g200); }
.history-item.active { background: var(--g800); color: var(--white); }
.history-item svg { flex-shrink: 0; opacity: 0.5; }


.sidebar-footer {
  padding: 14px;
  border-top: 1px solid var(--g800);
  flex-shrink: 0;
}

.github-link {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12px;
  color: var(--g500);
  transition: color var(--t);
}

.github-link:hover { color: var(--white); }


.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  background: var(--white);
}


.chat-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  border-bottom: 1px solid var(--g200);
  flex-shrink: 0;
  gap: 12px;
}

.menu-btn { display: none; color: var(--g600); }
.menu-btn:hover { color: var(--black); }

.agent-identity {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  justify-content: center;
}

.agent-avatar-sm {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-logo {
  width: 20px;
  height: 20px;
  object-fit: contain;
  border-radius: 4px;
  flex-shrink: 0;
}

.avatar-logo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.agent-meta {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.agent-name { font-size: 14px; line-height: 1; }
.agent-sub  { font-size: 11px; color: var(--g400); line-height: 1; }

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--g500);
  transition: background var(--t), color var(--t);
  flex-shrink: 0;
}

.icon-btn:hover { background: var(--g100); color: var(--black); }


.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.messages::-webkit-scrollbar { width: 4px; }
.messages::-webkit-scrollbar-thumb { background: var(--g200); border-radius: 2px; }


.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 40px 20px;
  text-align: center;
  color: var(--g400);
}

.empty-state svg { opacity: 0.3; margin-bottom: 4px; }
.empty-state h2  { font-size: 16px; color: var(--g600); font-weight: 400; }
.empty-state p   { font-size: 13px; max-width: 320px; line-height: 1.6; }


.message {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  max-width: 680px;
  width: 100%;
  animation: msgIn 150ms ease;
}

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

.message.agent { align-self: flex-start; }
.message.user  { align-self: flex-end; flex-direction: row-reverse; }

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.message.agent .avatar { background: var(--black); color: var(--white); }
.message.user  .avatar { background: var(--g200);  color: var(--black); }


.bubble {
  padding: 11px 14px;
  border-radius: var(--r);
  font-size: 14px;
  line-height: 1.65;
  max-width: calc(100% - 42px);
  word-break: break-word;
}

.message.agent .bubble {
  background: var(--g100);
  color: var(--black);
  border-bottom-left-radius: 3px;
}

.message.user .bubble {
  background: var(--black);
  color: var(--white);
  border-bottom-right-radius: 3px;
}


.bubble strong { font-weight: 600; }
.bubble em     { font-style: italic; }
.bubble code {
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 12px;
  background: var(--g200);
  padding: 1px 5px;
  border-radius: 4px;
}

.message.user .bubble code {
  background: rgba(255,255,255,0.15);
}

.bubble ul {
  margin: 6px 0 0 18px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}


.msg-time {
  font-size: 10px;
  color: var(--g300);
  padding: 0 2px;
  flex-shrink: 0;
  align-self: flex-end;
  padding-bottom: 2px;
}


.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 13px 16px;
  background: var(--g100);
  border-radius: var(--r);
  border-bottom-left-radius: 3px;
  width: fit-content;
}

.typing-indicator span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--g400);
  animation: tdot 1.3s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.18s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.36s; }

@keyframes tdot {
  0%, 55%, 100% { transform: translateY(0);    opacity: 0.5; }
  27%            { transform: translateY(-5px); opacity: 1; }
}


.action-card {
  margin-top: 10px;
  border: 1px solid var(--g200);
  border-radius: 8px;
  overflow: hidden;
  background: var(--white);
  font-size: 13px;
}

.action-card-header {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--g50);
  padding: 7px 12px;
  font-size: 11px;
  color: var(--g500);
  border-bottom: 1px solid var(--g200);
}

.action-card-body {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.action-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.action-label {
  font-size: 11px;
  color: var(--g500);
  flex-shrink: 0;
  padding-top: 1px;
}

.action-value {
  font-size: 13px;
  color: var(--black);
  text-align: right;
}

.action-divider {
  height: 1px;
  background: var(--g200);
  margin: 2px 0;
}


.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 400;
}

.badge.shipped   { background: #e8f5e9; color: #2e7d32; }
.badge.pending   { background: #fff8e1; color: #f57f17; }
.badge.delivered { background: #e8eaf6; color: #303f9f; }
.badge.refunded  { background: #fce4ec; color: #c62828; }
.badge.cancelled { background: #f3e5f5; color: #6a1b9a; }
.badge.processing{ background: #e3f2fd; color: #1565c0; }


.error-card {
  margin-top: 10px;
  border: 1px solid #ffd6d6;
  border-radius: 8px;
  background: #fff5f5;
  padding: 10px 14px;
  font-size: 13px;
  color: #b91c1c;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.error-card svg { flex-shrink: 0; margin-top: 1px; }

.input-area {
  padding: 10px 14px 14px;
  border-top: 1px solid var(--g200);
  flex-shrink: 0;
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--g50);
  border: 1px solid var(--g200);
  border-radius: var(--r);
  padding: 9px 9px 9px 14px;
  transition: border-color var(--t), box-shadow var(--t);
}

.input-wrapper:focus-within {
  border-color: var(--g400);
  box-shadow: 0 0 0 3px var(--g100);
}

#userInput {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-size: 14px;
  color: var(--black);
  line-height: 1.5;
  max-height: 140px;
  overflow-y: auto;
}

#userInput::placeholder { color: var(--g300); }

.send-btn {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: var(--black);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity var(--t), transform var(--t);
}

.send-btn:disabled { opacity: 0.2; cursor: not-allowed; }
.send-btn:not(:disabled):hover { opacity: 0.75; }
.send-btn:not(:disabled):active { transform: scale(0.93); }

.input-hint {
  font-size: 11px;
  color: var(--g300);
  margin-top: 7px;
  text-align: center;
}


.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 10;
  backdrop-filter: blur(2px);
}


@media (max-width: 780px) {
  .sidebar {
    position: fixed;
    inset-y: 0;
    left: 0;
    z-index: 20;
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(0,0,0,0.3);
  }

  .sidebar.open   { transform: translateX(0); }
  .overlay.open   { display: block; }
  .close-sidebar  { display: flex; }
  .menu-btn       { display: flex; }

  .agent-identity { justify-content: flex-start; }
  .messages       { padding: 14px 12px; }
  .input-hint     { display: none; }
}

@media (max-width: 480px) {
  .bubble   { font-size: 13px; padding: 9px 12px; }
  .message  { max-width: 100%; }
}


button:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--black);
  outline-offset: 2px;
}


@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
