:root {
  --bg-app: #09090b;
  --bg-sidebar: #121214;
  --bg-panel: #18181b;
  --bg-hover: #27272a;
  --border: #27272a;
  --text-main: #f4f4f5;
  --text-muted: #a1a1aa;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --online: #22c55e;
  --offline: #ef4444;
  --warning: #eab308;
}

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

body {
  background-color: var(--bg-app);
  color: var(--text-main);
  font-family: 'Inter', sans-serif;
  overflow: hidden;
}

h1, h2, h3, h4, .brand__name { font-family: 'Space Grotesk', sans-serif; }

.shell { display: flex; height: 100vh; width: 100vw; }

/* SIDEBAR */
.sidebar {
  width: 300px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
}

.brand {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}
.brand__mark {
  background: var(--text-main);
  border-radius: 8px;
  width: 32px; height: 32px;
  display: flex; justify-content: center; align-items: center;
}
.brand__mark svg { width: 20px; height: 20px; }
.brand__text { display: flex; flex-direction: column; }
.brand__name { font-weight: 700; font-size: 1.1rem; }
.brand__tag { font-size: 0.65rem; color: var(--text-muted); letter-spacing: 1px; }

.nav { padding: 15px; display: flex; flex-direction: column; gap: 5px; border-bottom: 1px solid var(--border); }
.nav__btn {
  background: transparent; border: none; color: var(--text-muted);
  padding: 10px 12px; border-radius: 6px; font-size: 0.9rem;
  display: flex; align-items: center; gap: 10px; cursor: pointer; transition: 0.2s;
  text-align: left;
}
.nav__btn svg { width: 18px; height: 18px; }
.nav__btn:hover { background: var(--bg-hover); color: var(--text-main); }
.nav__btn.is-active { background: var(--bg-panel); color: var(--text-main); font-weight: 500; }

.channels { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.channels__head { padding: 15px 20px 10px; display: flex; justify-content: space-between; font-size: 0.8rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; }
.channel-search { padding: 0 15px 10px; }
.channel-search input {
  width: 100%; background: var(--bg-panel); border: 1px solid var(--border);
  color: var(--text-main); padding: 8px 12px; border-radius: 6px; font-size: 0.85rem;
}
.channel-list { flex: 1; overflow-y: auto; padding: 0 10px 10px; }
.channel-item {
  display: flex; flex-direction: column; padding: 10px; border-radius: 6px; cursor: pointer; transition: 0.2s; margin-bottom: 4px;
}
.channel-item:hover { background: var(--bg-hover); }
.channel-item.active { background: var(--bg-panel); border: 1px solid var(--border); }

/* ==== TAMBAHAN KELAS DISABLED ==== */
.channel-item.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.channel-item.disabled:hover {
  background: transparent;
}
/* ================================= */

.channel-item__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.channel-item__name { font-size: 0.9rem; font-weight: 500; }
.channel-item__multiplier { font-size: 0.7rem; background: var(--bg-app); padding: 2px 6px; border-radius: 4px; color: var(--accent); border: 1px solid var(--border); }
.channel-item__status { font-size: 0.75rem; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.channel__dot { width: 8px; height: 8px; border-radius: 50%; }
.status-online { background: var(--online); box-shadow: 0 0 8px var(--online); }
.status-offline { background: var(--offline); }
.status-warning { background: var(--warning); }

.sidebar__foot {
  padding: 15px 20px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; background: var(--bg-panel);
}
.status-pill { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; }
.status-pill__dot { width: 10px; height: 10px; border-radius: 50%; background: var(--offline); }
.status-pill.connected .status-pill__dot { background: var(--online); }

.icon-btn { background: transparent; border: none; color: var(--text-muted); cursor: pointer; padding: 8px; border-radius: 6px; transition: 0.2s; display: flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: var(--bg-hover); color: var(--text-main); }
.icon-btn svg { width: 20px; height: 20px; }

/* MAIN */
.main { flex: 1; display: flex; flex-direction: column; position: relative; }
.topbar { height: 65px; border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 20px; justify-content: space-between; background: rgba(9,9,11,0.8); backdrop-filter: blur(10px); z-index: 10; }
.topbar__title { display: flex; flex-direction: column; }
.topbar__eyebrow { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }
.topbar__model { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 1rem; }
.topbar__actions { display: flex; gap: 10px; }

.view { display: none; flex: 1; flex-direction: column; overflow: hidden; }
.view.is-active { display: flex; }

/* CHAT */
.chat-scroll { flex: 1; overflow-y: auto; padding: 40px 20px 120px; display: flex; flex-direction: column; align-items: center; }
.chat-empty { max-width: 700px; width: 100%; margin-top: 5vh; text-align: center; }
.chat-empty h2 { font-size: 2rem; margin-bottom: 15px; }
.chat-empty p { color: var(--text-muted); line-height: 1.6; margin-bottom: 40px; }
.chat-empty__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; text-align: left; }
.chat-empty__card { background: var(--bg-panel); border: 1px solid var(--border); padding: 20px; border-radius: 12px; cursor: pointer; transition: 0.2s; }
.chat-empty__card:hover { border-color: var(--accent); background: var(--bg-hover); }
.chat-empty__card b { display: block; margin-bottom: 5px; color: var(--text-main); }
.chat-empty__card { font-size: 0.85rem; color: var(--text-muted); }

#chatMessages { width: 100%; max-width: 800px; display: flex; flex-direction: column; gap: 24px; }
.msg { display: flex; flex-direction: column; gap: 8px; font-size: 0.95rem; line-height: 1.6; }
.msg.user { align-items: flex-end; }
.msg.ai { align-items: flex-start; }
.msg-bubble { padding: 12px 18px; border-radius: 12px; max-width: 85%; white-space: pre-wrap; word-wrap: break-word; }
.msg.user .msg-bubble { background: var(--accent); color: white; border-bottom-right-radius: 4px; }
.msg.ai .msg-bubble { background: var(--bg-panel); border: 1px solid var(--border); border-bottom-left-radius: 4px; font-family: inherit; }

/* ==== EFEK KETIK & ANIMASI LOADING ==== */
.typing-cursor::after {
  content: '▌';
  display: inline-block;
  vertical-align: bottom;
  animation: blink 1s step-start infinite;
  color: var(--text-muted);
  margin-left: 2px;
}
@keyframes blink {
  50% { opacity: 0; }
}

.typing-indicator span {
  display: inline-block;
  width: 6px; height: 6px;
  background-color: var(--text-muted);
  border-radius: 50%;
  margin: 0 2px;
  animation: bounce 1.4s infinite ease-in-out both;
}
.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }
@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}
/* ======================================= */

.composer-wrap { position: absolute; bottom: 0; left: 0; right: 0; padding: 20px; background: linear-gradient(to top, var(--bg-app) 70%, transparent); display: flex; justify-content: center; }
.composer { width: 100%; max-width: 800px; background: var(--bg-panel); border: 1px solid var(--border); border-radius: 16px; padding: 10px; box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
.composer__box { display: flex; align-items: flex-end; gap: 10px; }
#chatInput { flex: 1; background: transparent; border: none; color: var(--text-main); resize: none; max-height: 200px; padding: 10px; font-family: inherit; font-size: 0.95rem; outline: none; }
.composer__send { background: var(--text-main); color: var(--bg-app); border: none; width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: 0.2s; }
.composer__send:hover { background: var(--accent); color: white; }
.composer__send svg { width: 20px; height: 20px; }
.composer__hint { font-size: 0.7rem; color: var(--text-muted); text-align: center; margin-top: 8px; }
.pending-files { display: flex; gap: 10px; padding: 0 10px; flex-wrap: wrap; margin-bottom: 5px; }
.file-chip { background: var(--bg-hover); padding: 4px 10px; border-radius: 6px; font-size: 0.75rem; display: flex; align-items: center; gap: 5px; border: 1px solid var(--border); }

/* STUDIO & ABOUT */
.studio, .about { padding: 40px; flex: 1; overflow-y: auto; display: flex; justify-content: center; }
.studio__grid { width: 100%; max-width: 1000px; display: grid; grid-template-columns: 350px 1fr; gap: 30px; }
.studio-panel { background: var(--bg-panel); border: 1px solid var(--border); padding: 24px; border-radius: 16px; height: fit-content; }
.studio-panel h3 { margin-bottom: 10px; }
.studio-panel .hint { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 20px; line-height: 1.5; }
.field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 15px; }
.field label { font-size: 0.85rem; font-weight: 500; color: var(--text-muted); }
.field input, .field select, .field textarea { background: var(--bg-app); border: 1px solid var(--border); color: var(--text-main); padding: 10px; border-radius: 8px; font-family: inherit; font-size: 0.9rem; outline: none; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); }
.field textarea { resize: vertical; min-height: 100px; }
.field-row { display: flex; gap: 15px; }
.field-row .field { flex: 1; }
.btn { padding: 12px; border-radius: 8px; font-weight: 600; cursor: pointer; transition: 0.2s; border: none; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 0.9rem; width: 100%; }
.btn-primary { background: var(--text-main); color: var(--bg-app); }
.btn-primary:hover { background: var(--accent); color: white; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text-main); }
.btn-ghost:hover { background: var(--bg-hover); }
.btn-signal { background: var(--accent); color: white; }
.btn-signal:hover { background: var(--accent-hover); }

.studio-output { border: 1px dashed var(--border); border-radius: 16px; display: flex; align-items: center; justify-content: center; min-height: 400px; background: rgba(24,24,27,0.3); }
.studio-output__empty { text-align: center; color: var(--text-muted); font-size: 0.9rem; line-height: 1.5; }
.gallery { width: 100%; padding: 20px; display: flex; flex-wrap: wrap; gap: 20px; justify-content: center; }
.gallery img { max-width: 100%; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.5); }

.about__wrap { max-width: 600px; width: 100%; }
.about-hero { display: flex; align-items: center; gap: 20px; margin-bottom: 40px; }
.about-hero__avatar { width: 80px; height: 80px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), #8b5cf6); display: flex; align-items: center; justify-content: center; font-size: 1.5rem; font-weight: bold; }
.about-hero h1 { font-size: 2rem; margin-bottom: 5px; }
.about-hero p { color: var(--text-muted); }
.about-section { margin-bottom: 30px; }
.about-section h4 { font-size: 1.1rem; margin-bottom: 15px; color: var(--text-main); }
.about-section p { color: var(--text-muted); line-height: 1.7; font-size: 0.95rem; }
.about-links { display: flex; gap: 15px; }
.about-links a { display: flex; align-items: center; gap: 8px; padding: 10px 15px; background: var(--bg-panel); border: 1px solid var(--border); border-radius: 8px; color: var(--text-main); text-decoration: none; font-size: 0.9rem; transition: 0.2s; }
.about-links a:hover { background: var(--bg-hover); border-color: var(--text-muted); }
.about-links svg { width: 18px; height: 18px; }

/* ==== ADMIN: TOGGLE MODEL AKTIF/NONAKTIF ==== */
.admin-quick-toggle {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  margin-top: 6px;
  flex-shrink: 0;
}
.admin-quick-toggle input { opacity: 0; width: 0; height: 0; }
.admin-quick-toggle__slider {
  position: absolute; cursor: pointer; inset: 0;
  background-color: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: 0.2s;
}
.admin-quick-toggle__slider::before {
  content: "";
  position: absolute;
  height: 14px; width: 14px;
  left: 2px; top: 2px;
  background-color: var(--text-muted);
  border-radius: 50%;
  transition: 0.2s;
}
.admin-quick-toggle input:checked + .admin-quick-toggle__slider {
  background-color: var(--online);
  border-color: var(--online);
}
.admin-quick-toggle input:checked + .admin-quick-toggle__slider::before {
  transform: translateX(16px);
  background-color: white;
}

/* ==== ADMIN: PANEL KELOLA MODEL ==== */
.admin-model-list { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
#saveAllModelsBtn {
  position: sticky;
  top: 0;
  z-index: 5;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
#saveAllModelsBtn:disabled { opacity: 0.6; cursor: not-allowed; }
.admin-model-row {
  display: grid;
  grid-template-columns: 1.6fr 0.9fr 1.2fr auto auto auto;
  gap: 10px;
  align-items: center;
  background: var(--bg-app);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}
.admin-model-row__main { display: flex; flex-direction: column; gap: 2px; }
.admin-model-row__id { font-size: 0.7rem; color: var(--text-muted); font-family: 'JetBrains Mono', monospace; }
.admin-inline-input, .admin-inline-select {
  background: var(--bg-panel); border: 1px solid var(--border); color: var(--text-main);
  padding: 8px 10px; border-radius: 6px; font-size: 0.85rem; font-family: inherit; width: 100%;
}
.admin-save-btn:hover { color: var(--online); }
.admin-delete-btn:hover { color: var(--offline); }

@media (max-width: 900px) {
  .admin-model-row { grid-template-columns: 1fr 1fr; grid-auto-rows: auto; }
}

/* MODAL */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.8); backdrop-filter: blur(5px); z-index: 100; display: none; align-items: center; justify-content: center; }
.modal-backdrop.is-active { display: flex; }
.modal { background: var(--bg-app); border: 1px solid var(--border); width: 100%; max-width: 500px; border-radius: 16px; padding: 24px; box-shadow: 0 20px 50px rgba(0,0,0,0.5); }
.modal__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.modal__note { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 20px; line-height: 1.5; }
.modal__foot { display: flex; gap: 15px; margin-top: 25px; }
.test-result { margin-bottom: 15px; font-size: 0.85rem; padding: 10px; border-radius: 8px; display: none; }
.test-result.success { background: rgba(34, 197, 94, 0.1); color: var(--online); border: 1px solid var(--online); display: block; }
.test-result.error { background: rgba(239, 68, 68, 0.1); color: var(--offline); border: 1px solid var(--offline); display: block; }

/* TOAST */
.toast-stack { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast { background: var(--bg-panel); border: 1px solid var(--border); color: var(--text-main); padding: 12px 20px; border-radius: 8px; font-size: 0.9rem; box-shadow: 0 10px 30px rgba(0,0,0,0.5); animation: slideIn 0.3s ease; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

@media (max-width: 768px) {
  .sidebar { position: absolute; z-index: 50; height: 100%; transform: translateX(-100%); }
  .sidebar.is-open { transform: translateX(0); }
  #menuToggleBtn { display: block !important; }
  .studio__grid { grid-template-columns: 1fr; }
}