/* ============================================
   LANGZ337 AI — Blue Clean Theme
   ============================================ */
:root {
  --bg:        #050810;
  --card:      rgba(255,255,255,0.03);
  --card-hi:   rgba(255,255,255,0.06);
  --border:    rgba(255,255,255,0.07);
  --border-hi: rgba(255,255,255,0.15);
  --text:      #eaeaf2;
  --muted:     #7a7d95;
  --blue:      #2563eb;
  --sky:       #3b82f6;
  --cyan:      #0ea5e9;
  --lime:      #a3e635;
  --radius:    16px;
  --font:      'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
}

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

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}

svg { display: block; flex-shrink: 0; }

/* ===== BACKGROUND ORBS — BIRU ===== */
.bg-orbs {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.18;
  animation: float 20s ease-in-out infinite;
}
.orb-1 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, #0ea5e9, transparent 70%);
  top: -120px; left: -120px;
}
.orb-2 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, #2563eb, transparent 70%);
  bottom: -180px; right: -180px;
  animation-delay: -7s;
}
.orb-3 {
  width: 350px; height: 350px;
  background: radial-gradient(circle, #0ea5e9, transparent 70%);
  top: 40%; left: 50%;
  animation-delay: -14s;
}
@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%      { transform: translate(60px, -40px) scale(1.1); }
  66%      { transform: translate(-40px, 60px) scale(0.95); }
}

/* ===== LAYOUT DESKTOP ===== */
.app {
  position: relative;
  z-index: 1;
  display: flex;
  height: 100vh;
  height: 100dvh;
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px;
  gap: 12px;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: 260px;
  background: rgba(8,12,22,0.75);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 2px;
}

.logo {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--cyan), var(--blue));
  display: grid; place-items: center;
  box-shadow: 0 0 18px rgba(37,99,235,0.35);
}
.logo svg {
  width: 14px; height: 14px;
  color: #fff;
  filter: drop-shadow(0 0 3px rgba(255,255,255,0.6));
}

.brand-text strong {
  display: block;
  font-family: var(--font);
  font-size: 13px;
  letter-spacing: 0.2px;
  font-weight: 600;
}
.brand-text span {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.btn-new {
  background: linear-gradient(135deg, var(--cyan), var(--blue));
  border: none;
  padding: 10px;
  border-radius: 10px;
  color: #fff;
  font-family: var(--font);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.25s ease;
  box-shadow: 0 3px 14px rgba(37,99,235,0.35);
}
.btn-new svg { width: 14px; height: 14px; }
.btn-new:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(14,165,233,0.5);
}

.chat-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin: 0 -4px;
  padding: 0 4px;
}
.chat-list::-webkit-scrollbar { width: 4px; }
.chat-list::-webkit-scrollbar-thumb {
  background: var(--border-hi);
  border-radius: 4px;
}

.chat-item {
  padding: 9px 12px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.2s;
  border: 1px solid transparent;
  position: relative;
}
.chat-item:hover {
  background: var(--card);
  color: var(--text);
}
.chat-item.active {
  background: linear-gradient(135deg, rgba(14,165,233,0.1), rgba(37,99,235,0.1));
  border-color: rgba(37,99,235,0.35);
  color: var(--text);
  font-weight: 500;
}
.chat-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 2px; height: 16px;
  background: linear-gradient(180deg, var(--cyan), var(--blue));
  border-radius: 4px;
  box-shadow: 0 0 8px var(--cyan);
}

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 8px;
  border-radius: 9px;
  font-size: 11.5px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
}
.btn-ghost svg { width: 12px; height: 12px; }
.btn-ghost:hover {
  color: var(--cyan);
  border-color: var(--cyan);
  background: rgba(14,165,233,0.08);
}
.sidebar-footer small {
  text-align: center;
  font-size: 9.5px;
  color: var(--muted);
  opacity: 0.55;
  letter-spacing: 0.4px;
}

/* ===== MAIN ===== */
.main {
  flex: 1;
  background: rgba(8,12,22,0.75);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(5,8,16,0.4);
}

.title-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 10px var(--lime);
  animation: blink 2s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}
.title {
  font-family: var(--font);
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ICON BUTTON */
.icon-btn {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  width: 34px; height: 34px;
  border-radius: 10px;
  cursor: pointer;
  display: grid; place-items: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.icon-btn svg { width: 14px; height: 14px; }
.icon-btn:hover {
  background: var(--card-hi);
  border-color: var(--border-hi);
}
.icon-btn.send {
  background: linear-gradient(135deg, var(--cyan), var(--blue));
  border: none;
  color: #fff;
  box-shadow: 0 3px 14px rgba(37,99,235,0.4);
}
.icon-btn.send svg { width: 13px; height: 13px; }
.icon-btn.send:hover {
  box-shadow: 0 5px 20px rgba(14,165,233,0.55);
}
.icon-btn.hidden { display: none; }
.icon-btn.stop {
  background: linear-gradient(135deg, #f43f5e, #dc2626);
  border: none;
  color: #fff;
}
.icon-btn.stop svg { width: 11px; height: 11px; }

/* ===== MODE SWITCH ===== */
.mode-switch {
  position: relative;
  display: flex;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
.mode {
  position: relative;
  z-index: 2;
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 6px 11px;
  border-radius: 7px;
  font-family: var(--font);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.3s;
  display: flex;
  align-items: center;
  gap: 5px;
}
.mode svg { width: 12px; height: 12px; }
.mode.active { color: #fff; }
.mode-slider {
  position: absolute;
  top: 3px;
  left: 3px;
  height: calc(100% - 6px);
  width: calc(50% - 2px);
  background: linear-gradient(135deg, var(--cyan), var(--blue));
  border-radius: 7px;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1;
  box-shadow: 0 2px 10px rgba(37,99,235,0.45);
}
.mode-switch[data-mode="image"] .mode-slider {
  transform: translateX(calc(100% + 1px));
}

/* ===== DROPDOWN ===== */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute;
  top: 42px; right: 0;
  background: rgba(12,18,32,0.98);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-hi);
  border-radius: 12px;
  padding: 5px;
  min-width: 180px;
  display: none;
  flex-direction: column;
  z-index: 100;
  box-shadow: 0 16px 40px rgba(0,0,0,0.7);
  animation: dropIn 0.18s ease;
}
@keyframes dropIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.dropdown-menu.show { display: flex; }
.dropdown-menu button {
  background: transparent;
  border: none;
  color: var(--text);
  padding: 9px 12px;
  text-align: left;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12.5px;
  font-family: inherit;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 9px;
}
.dropdown-menu button svg {
  width: 13px; height: 13px;
  color: var(--muted);
  transition: color 0.15s;
}
.dropdown-menu button:hover {
  background: linear-gradient(135deg, rgba(14,165,233,0.12), rgba(37,99,235,0.12));
  color: var(--cyan);
}
.dropdown-menu button:hover svg { color: var(--cyan); }

/* ===== MESSAGES ===== */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}
.messages::-webkit-scrollbar { width: 5px; }
.messages::-webkit-scrollbar-thumb {
  background: var(--border-hi);
  border-radius: 5px;
}

/* WELCOME */
.welcome {
  margin: auto;
  text-align: center;
  max-width: 460px;
  animation: fadeUp 0.5s ease;
  padding: 20px;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.welcome-logo {
  width: 46px; height: 46px;
  margin: 0 auto 16px;
  border-radius: 13px;
  background: linear-gradient(135deg, var(--cyan), var(--blue));
  display: grid; place-items: center;
  box-shadow: 0 0 26px rgba(37,99,235,0.5);
}
.welcome-logo svg {
  width: 20px; height: 20px;
  color: #fff;
  filter: drop-shadow(0 0 5px rgba(255,255,255,0.7));
}

.welcome h1 {
  font-family: var(--font);
  font-size: 21px;
  font-weight: 700;
  margin-bottom: 10px;
  letter-spacing: -0.3px;
}
.welcome h1 .grad {
  background: linear-gradient(135deg, var(--cyan), var(--sky), var(--blue));
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradShift 4s ease infinite;
}
@keyframes gradShift {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}

.welcome p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 20px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.chip {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 100px;
  font-size: 11.5px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}
.chip svg {
  width: 12px; height: 12px;
  color: var(--cyan);
  transition: color 0.2s;
}
.chip:hover {
  border-color: var(--blue);
  background: var(--card-hi);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(37,99,235,0.25);
}

/* MESSAGE BUBBLES */
.msg {
  display: flex;
  gap: 10px;
  max-width: 82%;
  animation: msgIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg.ai   { align-self: flex-start; }

.avatar {
  width: 28px; height: 28px;
  border-radius: 9px;
  display: grid; place-items: center;
  font-size: 9px; font-weight: 700;
  font-family: var(--font);
  flex-shrink: 0;
  letter-spacing: 0.3px;
}
.msg.user .avatar {
  background: linear-gradient(135deg, var(--cyan), var(--sky));
  color: #fff;
  box-shadow: 0 3px 12px rgba(14,165,233,0.4);
}
.msg.ai .avatar {
  background: linear-gradient(135deg, var(--sky), var(--blue));
  color: #fff;
  box-shadow: 0 3px 12px rgba(37,99,235,0.4);
}
.msg.ai .avatar svg {
  width: 14px; height: 14px;
  filter: drop-shadow(0 0 4px rgba(255,255,255,0.7));
}

.bubble {
  background: var(--card);
  border: 1px solid var(--border);
  padding: 11px 15px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.65;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.msg.user .bubble {
  background: linear-gradient(135deg, rgba(14,165,233,0.15), rgba(37,99,235,0.15));
  border-color: rgba(37,99,235,0.3);
  border-top-right-radius: 4px;
}
.msg.ai .bubble {
  background: linear-gradient(135deg, rgba(14,165,233,0.06), rgba(37,99,235,0.06));
  border-color: rgba(37,99,235,0.2);
  border-top-left-radius: 4px;
}

.bubble img {
  max-width: 100%;
  max-height: 320px;
  border-radius: 10px;
  margin-top: 8px;
  display: block;
  box-shadow: 0 6px 24px rgba(0,0,0,0.5);
  object-fit: contain;
}

/* TYPING DOTS */
.typing {
  display: flex;
  gap: 4px;
  padding: 3px 0;
}
.typing span {
  width: 5px; height: 5px;
  background: var(--cyan);
  border-radius: 50%;
  animation: typing 1.4s infinite;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%           { transform: translateY(-6px); opacity: 1; }
}

/* ===== COMPOSER ===== */
.composer {
  padding: 12px 16px 14px;
  border-top: 1px solid var(--border);
  background: rgba(5,8,16,0.4);
}
.attachments {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.attachment {
  position: relative;
  width: 56px; height: 56px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border-hi);
}
.attachment img {
  width: 100%; height: 100%;
  object-fit: cover;
}
.attachment button {
  position: absolute;
  top: 3px; right: 3px;
  background: rgba(0,0,0,0.8);
  border: none;
  color: #fff;
  width: 18px; height: 18px;
  border-radius: 50%;
  cursor: pointer;
  display: grid; place-items: center;
}
.attachment button svg { width: 9px; height: 9px; }
.attachment button:hover { background: var(--cyan); }

.input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

#input {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 11px 15px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px; /* WAJIB 16px biar iPhone gak auto-zoom */
  resize: none;
  max-height: 140px;
  outline: none;
  transition: all 0.2s;
  line-height: 1.5;
  min-width: 0;
}
#input:focus {
  border-color: var(--blue);
  background: var(--card-hi);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}
#input::placeholder { color: var(--muted); font-size: 14px; }

.hint {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
  font-size: 10.5px;
  color: var(--muted);
  opacity: 0.7;
}
.hint .dot {
  width: 3px; height: 3px;
  border-radius: 50%;
  background: var(--muted);
}

.attach { cursor: pointer; }

/* ===== OVERLAY ===== */
.overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 99;
}
.only-mobile { display: none !important; }

/* ============================================
   MOBILE — FULL SCREEN TANPA RONGGA
   ============================================ */
@media (max-width: 820px) {

  /* BODY FULL SCREEN */
  html, body {
    height: 100vh;
    height: 100dvh;
    width: 100%;
    overflow: hidden;
    position: fixed;
    inset: 0;
  }

  /* APP FULL — TANPA PADDING/GAP */
  .app {
    padding: 0 !important;
    gap: 0 !important;
    max-width: 100% !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    margin: 0 !important;
  }

  /* MAIN FULL — TANPA BORDER RADIUS */
  .main {
    border-radius: 0 !important;
    border: none !important;
    width: 100% !important;
    height: 100% !important;
    max-height: 100dvh !important;
  }

  /* SIDEBAR OFFCANVAS FULL HEIGHT */
  .sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    width: 280px !important;
    height: 100vh !important;
    height: 100dvh !important;
    border-radius: 0 !important;
    border-top: none !important;
    border-bottom: none !important;
    border-left: none !important;
    z-index: 100;
    transform: translateX(-115%);
  }
  .sidebar.open { transform: translateX(0); }

  .overlay.show { display: block; }
  .only-mobile { display: grid !important; }

  .topbar {
    padding: 10px 12px;
    gap: 8px;
    padding-top: calc(10px + env(safe-area-inset-top));
  }

  .msg { max-width: 90%; }

  .messages {
    padding: 14px 12px;
    gap: 14px;
  }

  .welcome { padding: 10px; }
  .welcome h1 { font-size: 19px; }
  .welcome-logo { width: 42px; height: 42px; border-radius: 12px; }
  .welcome-logo svg { width: 18px; height: 18px; }

  .mode { padding: 5px 9px; font-size: 10.5px; }
  .mode span { display: none; }
  .mode svg { width: 14px; height: 14px; }

  .composer {
    padding: 10px 12px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
  .icon-btn { width: 34px; height: 34px; }
  .icon-btn svg { width: 14px; height: 14px; }
  .icon-btn.send svg { width: 12px; height: 12px; }

  .bubble img { max-height: 260px; }

  .chips { gap: 6px; }
  .chip { padding: 7px 12px; font-size: 11px; }
  .chip svg { width: 11px; height: 11px; }
}

@media (max-width: 420px) {
  .mode span { display: none; }
  .chip span { display: none; }
  .chip { padding: 8px; }
}