/* ============================================================
   Lunara App — layout chat (sidebar + main)
   ============================================================ */

.app-shell {
  display: grid;
  grid-template-columns: 292px 1fr;
  height: 100vh;
  overflow: hidden;
}

.side-veil { display: none; }
.main { min-width: 0; }

/* ---------------- sidebar ---------------- */

.sidebar {
  background: var(--paper-2);
  border-right: 1.5px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-top {
  padding: 18px 18px 14px;
  border-bottom: 1.5px dashed var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 9px;
  font-family: var(--font-display); font-size: 19px; font-weight: 600;
  text-decoration: none;
}
.sidebar-logo .spark { color: var(--orange); font-size: 14px; }
.home-link { color: var(--ink-3); text-decoration: none; font-size: 12px; font-family: var(--font-mono); }
.home-link:hover { color: var(--orange); }

.side-scroll { flex: 1; overflow-y: auto; padding: 14px 14px 20px; }
.side-scroll::-webkit-scrollbar { width: 8px; }
.side-scroll::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 4px; }

.side-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 18px 6px 10px;
  display: flex; align-items: center; justify-content: space-between;
}
.side-label:first-child { margin-top: 2px; }
.icon-btn {
  border: 1.5px solid var(--line-strong);
  background: var(--paper);
  width: 24px; height: 24px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px; line-height: 1;
  display: grid; place-items: center;
  color: var(--ink-2);
  transition: all .2s var(--ease-spring);
}
.icon-btn:hover { border-color: var(--ink); transform: rotate(90deg); color: var(--ink); }

.agent-item {
  display: flex; align-items: center; gap: 11px;
  width: 100%;
  padding: 9px 10px;
  border: 1.5px solid transparent;
  border-radius: 13px;
  background: none;
  cursor: pointer;
  text-align: left;
  font-family: var(--font-body);
  transition: all .18s;
  margin-bottom: 2px;
}
.agent-item:hover { background: var(--paper-3); }
.agent-item.on { background: var(--paper-3); border-color: var(--ink); box-shadow: 2px 3px 0 rgba(0,0,0,.75); }
.agent-item .mini-ava {
  flex: none;
  width: 34px; height: 34px;
  border-radius: 11px;
  display: grid; place-items: center;
  font-size: 17px;
  border: 1.5px solid var(--ink);
}
.agent-item .ai-name { font-weight: 600; font-size: 14px; line-height: 1.2; }
.agent-item .ai-tag { font-size: 11px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 170px; }

.chat-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%;
  padding: 9px 10px;
  border: none;
  border-radius: 11px;
  background: none;
  cursor: pointer;
  text-align: left;
  font: 500 13.5px var(--font-body);
  color: var(--ink-2);
  transition: background .15s;
  margin-bottom: 1px;
}
.chat-item:hover { background: var(--paper-3); }
.chat-item.on { background: var(--paper-3); color: var(--ink); font-weight: 600; }
.chat-item .ci-emoji { flex: none; font-size: 14px; }
.chat-item .ci-title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .ci-del {
  flex: none; opacity: 0; border: none; background: none; cursor: pointer;
  color: var(--ink-3); font-size: 14px; padding: 2px 5px; border-radius: 6px;
}
.chat-item:hover .ci-del { opacity: 1; }
.chat-item .ci-del:hover { color: var(--orange); background: var(--pink-soft); }

.side-empty { font-size: 12.5px; color: var(--ink-3); padding: 4px 8px 10px; line-height: 1.5; }

.sidebar-user {
  border-top: 1.5px dashed var(--line);
  padding: 14px;
  display: flex; align-items: center; gap: 11px;
}
.user-ava {
  color: var(--on-accent);
  width: 38px; height: 38px;
  border-radius: 13px;
  background: var(--yellow);
  border: 1.5px solid var(--ink);
  display: grid; place-items: center;
  font-weight: 700; font-size: 15px;
  box-shadow: 2px 3px 0 rgba(0,0,0,.8);
}
.user-name { font-weight: 600; font-size: 14px; line-height: 1.25; }
.user-email { font-size: 11px; color: var(--ink-3); max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logout-btn {
  margin-left: auto;
  border: 1.5px solid var(--line-strong);
  background: var(--paper);
  border-radius: 10px;
  padding: 7px 11px;
  cursor: pointer;
  font-size: 13px;
  transition: all .2s;
  color: var(--ink-2);
}
.logout-btn:hover { border-color: var(--orange); color: var(--orange); transform: rotate(-3deg); }

/* ---------------- main chat ---------------- */

.main { display: flex; flex-direction: column; overflow: hidden; position: relative; }

.chat-head {
  display: flex; align-items: center; gap: 13px;
  padding: 14px 26px;
  border-bottom: 1.5px solid var(--line);
  background: color-mix(in srgb, var(--paper) 80%, transparent);
  backdrop-filter: blur(10px);
  z-index: 5;
}
.chat-head .big-ava {
  width: 44px; height: 44px;
  border-radius: 14px;
  display: grid; place-items: center;
  font-size: 22px;
  border: 1.5px solid var(--ink);
  box-shadow: 2px 3px 0 rgba(0,0,0,.8);
}
.chat-head h2 { font-size: 20px; }
.chat-head .ch-tag { font-size: 12.5px; color: var(--ink-3); margin-top: 1px; }
.ch-tools { display: flex; gap: 6px; margin-left: 6px; }
.ch-tools span {
  font-family: var(--font-mono); font-size: 10px;
  padding: 3px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--ink-2);
  background: var(--paper-2);
}
.ch-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.ch-actions .btn { padding: 9px 16px; font-size: 13px; }

.provider-pill {
  font-family: var(--font-mono); font-size: 10.5px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  color: var(--ink-3);
}
.provider-pill.live { color: var(--green); border-color: color-mix(in srgb, var(--green) 40%, transparent); background: var(--green-soft); }
.provider-pill.demo { color: var(--orange); border-color: color-mix(in srgb, var(--orange) 40%, transparent); background: var(--orange-soft); }

.hamburger { display: none; }

/* --- area pesan --- */

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 30px 0 12px;
  scroll-behavior: smooth;
}
.messages::-webkit-scrollbar { width: 9px; }
.messages::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 5px; }
.msg-col { width: min(760px, calc(100% - 44px)); margin-inline: auto; display: flex; flex-direction: column; gap: 22px; }

.msg { display: flex; gap: 12px; animation: msg-in .35s var(--ease-out); }
@keyframes msg-in { from { opacity: 0; transform: translateY(12px); } }

.msg .m-ava {
  flex: none;
  width: 36px; height: 36px;
  border-radius: 12px;
  display: grid; place-items: center;
  font-size: 17px;
  border: 1.5px solid var(--ink);
}

.msg .m-bubble {
  max-width: 82%;
  background: var(--paper-2);
  border: 1.5px solid var(--line);
  border-radius: 18px 18px 18px 5px;
  padding: 13px 17px;
  font-size: 15px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.msg .m-bubble code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: var(--paper-3);
  border: 1px solid var(--line);
  padding: 1px 6px;
  border-radius: 6px;
}
.msg .m-bubble strong { font-weight: 700; }

.msg.user { justify-content: flex-end; }
.msg.user .m-bubble {
  background: var(--ink);
  color: var(--paper-2);
  border-color: var(--ink);
  border-radius: 18px 18px 5px 18px;
}

.m-tools { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 9px; }
.m-tools .tool-chip.done::before { animation: none; }

.m-caret { display: inline-block; width: 9px; height: 1.15em; vertical-align: -0.2em; background: var(--orange); border-radius: 2px; animation: blink .8s steps(1) infinite; }

.typing-dots { display: inline-flex; gap: 4px; padding: 4px 2px; }
.typing-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); animation: tdot 1.2s ease-in-out infinite; }
.typing-dots i:nth-child(2) { animation-delay: .15s; }
.typing-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes tdot { 30% { transform: translateY(-5px); background: var(--orange); } }

/* --- empty state --- */

.empty-state {
  margin: 7vh auto 0;
  text-align: center;
  width: min(560px, calc(100% - 44px));
}
.empty-state .big-emoji {
  font-size: 58px;
  display: inline-block;
  animation: floaty 5s ease-in-out infinite;
  filter: drop-shadow(3px 4px 0 rgba(0,0,0,.2));
}
.empty-state h2 { font-size: clamp(26px, 3.4vw, 36px); margin: 18px 0 10px; }
.empty-state p { color: var(--ink-2); font-size: 15px; }
.empty-state .empty-how {
  margin-top: 14px;
  display: inline-block;
  font-size: 13px;
  color: var(--ink-3);
  background: var(--paper-2);
  border: 1.5px dashed var(--line-strong);
  border-radius: 999px;
  padding: 8px 16px;
}
.empty-suggests { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 26px; }

/* --- composer --- */

.composer-wrap { padding: 12px 0 22px; }
.composer {
  width: min(760px, calc(100% - 44px));
  margin-inline: auto;
  background: var(--paper-2);
  border: 1.5px solid var(--ink);
  border-radius: 20px;
  box-shadow: var(--shadow-soft);
  padding: 12px 12px 10px 18px;
  transition: box-shadow .25s var(--ease-spring), transform .25s var(--ease-spring);
}
.composer:focus-within { box-shadow: var(--shadow-hard); transform: translate(-2px, -2px); }
.composer textarea {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  font: 500 15.5px/1.55 var(--font-body);
  color: var(--ink);
  max-height: 180px;
}
.composer textarea::placeholder { color: var(--ink-3); }
.composer-bar { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.composer-hint { font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); }
.composer-hint kbd {
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 5px;
  background: var(--paper-3);
  font-size: 10px;
}
.send-btn {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 8px;
  border: 1.5px solid var(--ink);
  background: var(--orange);
  color: #fff;
  border-radius: 13px;
  padding: 10px 18px;
  font: 700 14px var(--font-body);
  cursor: pointer;
  transition: all .2s var(--ease-spring);
  box-shadow: 2px 3px 0 rgba(0,0,0,.85);
}
.send-btn:hover:not(:disabled) { transform: translate(-1px, -2px) rotate(-1deg); box-shadow: 3px 5px 0 rgba(0,0,0,.85); }
.send-btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.send-btn .arr { transition: transform .2s var(--ease-spring); }
.send-btn:hover:not(:disabled) .arr { transform: translateX(3px); }

/* ---------------- modal agent ---------------- */

.modal-veil {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  display: none;
  place-items: center;
  z-index: 200;
  padding: 20px;
}
.modal-veil.open { display: grid; }
.modal {
  width: min(560px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  background: var(--paper-2);
  border: 1.5px solid var(--ink);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lift), 10px 12px 0 rgba(0,0,0,.25);
  padding: 34px 34px 30px;
  animation: modal-in .35s var(--ease-spring);
}
@keyframes modal-in { from { opacity: 0; transform: translateY(26px) rotate(-1deg) scale(.97); } }
.modal h2 { font-size: 28px; margin-bottom: 4px; }
.modal .m-sub { color: var(--ink-2); font-size: 14px; margin-bottom: 24px; }

.emoji-row, .color-row { display: flex; gap: 8px; flex-wrap: wrap; }
.emoji-pick {
  width: 44px; height: 44px;
  font-size: 22px;
  border: 1.5px solid var(--line-strong);
  border-radius: 13px;
  background: var(--paper);
  cursor: pointer;
  transition: all .18s var(--ease-spring);
}
.emoji-pick:hover { transform: translateY(-3px) rotate(-4deg); }
.emoji-pick.on { border-color: var(--ink); background: var(--yellow-soft); box-shadow: 2px 3px 0 rgba(0,0,0,.8); }

.color-pick {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  cursor: pointer;
  transition: transform .18s var(--ease-spring);
}
.color-pick:hover { transform: scale(1.12); }
.color-pick.on { box-shadow: 0 0 0 3px var(--paper-2), 0 0 0 5.5px var(--ink); }

.tool-toggle {
  display: flex; align-items: center; gap: 12px;
  border: 1.5px solid var(--line);
  border-radius: 13px;
  padding: 11px 14px;
  cursor: pointer;
  transition: all .18s;
  margin-bottom: 8px;
  background: var(--paper);
}
.tool-toggle:hover { border-color: var(--line-strong); }
.tool-toggle.on { border-color: var(--ink); background: var(--green-soft); box-shadow: 2px 3px 0 rgba(0,0,0,.7); }
.tool-toggle .tt-ico { font-size: 18px; }
.tool-toggle b { font-size: 14px; display: block; }
.tool-toggle small { font-size: 11.5px; color: var(--ink-3); }
.tool-toggle .tt-check {
  margin-left: auto;
  width: 22px; height: 22px;
  border-radius: 7px;
  border: 1.5px solid var(--line-strong);
  display: grid; place-items: center;
  font-size: 12px;
  color: transparent;
  transition: all .18s;
}
.tool-toggle.on .tt-check { background: var(--green); border-color: var(--green); color: #fff; }

.modal-btns { display: flex; gap: 10px; margin-top: 24px; }
.modal-btns .btn { flex: 1; justify-content: center; }
.modal-btns .btn.btn-danger { --btn-bg: var(--pink-soft); --btn-fg: #8c2f49; border-color: var(--pink); }

/* ---------------- agent strip (mobile) ---------------- */

.agent-strip { display: none; }

.nc-plus { display: none; }

/* ---------------- responsive ---------------- */

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 300px;
    z-index: 150;
    transform: translateX(-102%);
    transition: transform .3s var(--ease-out);
    box-shadow: 12px 0 40px rgba(0,0,0,.25);
  }
  .sidebar.open { transform: none; }
  .side-veil {
    position: fixed; inset: 0; z-index: 140;
    background: rgba(0,0,0,.4);
    display: none;
  }
  .side-veil.open { display: block; }

  /* --- header dirampingin --- */
  .chat-head { padding: 10px 14px; gap: 10px; }
  .chat-head .big-ava { width: 38px; height: 38px; font-size: 19px; border-radius: 12px; }
  .chat-head h2 { font-size: 17px; }
  .chat-head .ch-tag { display: none; }
  .hamburger {
    display: grid; place-items: center;
    width: 40px; height: 40px;
    border: 1.5px solid var(--ink);
    border-radius: 12px;
    background: var(--paper-2);
    font-size: 17px;
    cursor: pointer;
  }
  .nc-full { display: none; }
  .nc-plus { display: inline; font-size: 18px; }
  #newChatBtn { padding: 10px 14px; }

  /* --- strip agen: ganti teman ngobrol tanpa buka sidebar --- */
  .agent-strip {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding: 10px 14px 12px;
    border-bottom: 1.5px solid var(--line);
    background: var(--paper);
    scrollbar-width: none;
    flex: none;
  }
  .agent-strip::-webkit-scrollbar { display: none; }
  .strip-item {
    flex: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    font-family: var(--font-body);
    padding: 2px;
  }
  .strip-item .mini-ava {
    width: 48px; height: 48px;
    border-radius: 16px;
    display: grid; place-items: center;
    font-size: 23px;
    border: 1.5px solid var(--ink);
    transition: transform .2s var(--ease-spring), outline .15s;
  }
  .strip-item small {
    font-size: 10px;
    font-weight: 600;
    max-width: 58px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--ink-3);
  }
  .strip-item.on .mini-ava {
    outline: 2.5px solid var(--yellow);
    outline-offset: 2px;
    transform: translateY(-2px);
    box-shadow: 2px 4px 0 rgba(0,0,0,.5);
  }
  .strip-item.on small { color: var(--ink); }

  /* --- pesan & composer nyaman di jempol --- */
  .messages { padding: 18px 0 8px; }
  .msg-col { width: calc(100% - 24px); gap: 16px; }
  .msg .m-bubble { max-width: 88%; font-size: 15px; }
  .composer-wrap { padding: 10px 0 calc(12px + env(safe-area-inset-bottom)); }
  .composer { width: calc(100% - 24px); border-radius: 18px; }
  .composer-hint { display: none; }
  .send-btn { padding: 12px 20px; font-size: 15px; }
  .empty-state { margin-top: 4vh; }
  .empty-suggests .suggest-chip { font-size: 14px; padding: 10px 16px; }
}
