/* 채팅 매니저 panel. Everything is scoped under .bot; tokens come from site.css
   with fallbacks so the panel also renders on a page without it. */

.bot {
  --b-bg: var(--bg, #0e0e12);
  --b-surface: var(--surface, #17171d);
  --b-line: var(--line, #26262f);
  --b-text: var(--text, #f1f1f5);
  --b-muted: var(--muted, #9a9aa8);
  --b-accent: var(--accent, #ffb020);
  --b-accent-soft: var(--accent-soft, rgba(255, 176, 32, 0.14));
  --b-danger: #ff6b6b;
  --b-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  color: var(--b-text);
  font-size: 15px;
  line-height: 1.5;
}

.bot button,
.bot input,
.bot select { font: inherit; color: inherit; }
.bot button { cursor: pointer; }
.bot [hidden] { display: none !important; }

.bot-icon { display: inline-grid; place-items: center; flex: none; }
.bot-icon svg { width: 16px; height: 16px; }

/* master switch */
.bot-master {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--b-radius);
  background: var(--b-surface);
  border: 1px solid var(--b-line);
}
.bot-master-label { font-weight: 700; }

.bot-switch {
  position: relative;
  flex: none;
  width: 42px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: #3a3a46;
  transition: background 0.15s;
}
.bot-switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
}
.bot-switch[aria-checked='true'] { background: var(--b-accent); }
.bot-switch[aria-checked='true']::after { transform: translateX(18px); }
.bot-switch:focus-visible,
.bot button:focus-visible,
.bot input:focus-visible,
.bot select:focus-visible { outline: 2px solid var(--b-accent); outline-offset: 2px; }

/* quick controls */
.bot-quick {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}
.bot-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid var(--b-line);
  border-radius: 10px;
  background: var(--b-surface);
  font-size: 14px;
  font-weight: 600;
}
.bot-btn:hover { border-color: #3a3a46; }
.bot-freeze[aria-pressed='true'] { background: var(--b-accent-soft); border-color: var(--b-accent); color: var(--b-accent); }

.bot-slow { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bot-slow .bot-label { white-space: nowrap; }

.bot-seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 2px;
  border-radius: 10px;
  background: var(--b-bg);
  border: 1px solid var(--b-line);
}
.bot-seg button {
  min-height: 30px;
  padding: 3px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--b-muted);
  font-size: 14px;
  white-space: nowrap;
}
.bot-seg button[aria-pressed='true'] { background: var(--b-surface); color: var(--b-text); font-weight: 600; box-shadow: inset 0 0 0 1px #3a3a46; }

/* sections */
.bot-rules { display: flex; flex-direction: column; gap: 10px; }
.bot[data-enabled='false'] .bot-rules { opacity: 0.55; }

.bot-sec {
  padding: 0; /* site.css pads every <section> */
  border-radius: var(--b-radius);
  background: var(--b-surface);
  border: 1px solid var(--b-line);
}
.bot-sec-head { display: flex; align-items: center; gap: 8px; padding: 0 14px 0 6px; }
.bot-sec-title {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 48px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  text-align: left;
}
.bot-sec-title .bot-icon { color: var(--b-muted); transition: transform 0.15s; }
.bot-sec[data-open='true'] .bot-sec-title .bot-icon { transform: rotate(90deg); }
.bot-sec-name { font-weight: 700; white-space: nowrap; }
.bot-sec-sum { color: var(--b-muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bot-sec[data-open='false'] .bot-sec-body { display: none; }
.bot-sec-body { display: flex; flex-direction: column; gap: 10px; padding: 2px 14px 14px; }
.bot-sec[data-on='false'] .bot-sec-body,
.bot-sec[data-on='false'] .bot-sec-sum { opacity: 0.5; }

.bot-row { display: grid; grid-template-columns: 88px minmax(0, 1fr); align-items: center; gap: 10px; }
.bot-label { color: var(--b-muted); font-size: 14px; }
.bot-inline { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--b-muted); font-size: 14px; }

.bot-input,
.bot-select {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid var(--b-line);
  border-radius: 8px;
  background: var(--b-bg);
  font-size: 14px;
}
.bot-input::placeholder { color: #6c6c7a; }
.bot-input:focus,
.bot-select:focus { border-color: #4a4a58; outline: none; }
.bot-num { width: 64px; text-align: right; }
.bot-select { width: auto; padding-right: 6px; }

/* word chips */
.bot-chips { display: flex; flex-wrap: wrap; gap: 6px; max-height: 168px; overflow-y: auto; }
.bot-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  max-width: 100%;
  padding: 2px 2px 2px 10px;
  border-radius: 999px;
  background: var(--b-bg);
  border: 1px solid var(--b-line);
  font-size: 14px;
}
.bot-chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bot-chip-x {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--b-muted);
}
.bot-chip-x:hover { color: var(--b-text); background: var(--b-line); }
.bot-chip-x .bot-icon svg { width: 14px; height: 14px; }

.bot-add { display: flex; gap: 6px; }
.bot-icon-btn {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--b-line);
  border-radius: 8px;
  background: var(--b-bg);
  color: var(--b-muted);
}
.bot-icon-btn:hover { color: var(--b-text); }
.bot-import { align-self: flex-start; }

/* commands */
.bot-cmd { display: grid; grid-template-columns: 96px minmax(0, 1fr) 36px; gap: 6px; }
.bot-cmd-new { padding-top: 4px; }

/* log */
.bot-log { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow-y: auto; }
.bot-log:empty { display: none; }
.bot-log-item {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: baseline;
  gap: 8px;
  padding: 6px 0;
  border-top: 1px solid var(--b-line);
  font-size: 13px;
}
.bot-log-item:first-child { border-top: 0; }
.bot-log-time { color: var(--b-muted); font-variant-numeric: tabular-nums; }
.bot-log-type {
  padding: 0 6px;
  border-radius: 6px;
  background: var(--b-bg);
  color: var(--b-muted);
  font-weight: 600;
  white-space: nowrap;
}
.bot-log-item[data-type='ban'] .bot-log-type,
.bot-log-item[data-type='fail'] .bot-log-type { color: var(--b-danger); }
.bot-log-item[data-type='warn'] .bot-log-type,
.bot-log-item[data-type='slow'] .bot-log-type { color: var(--b-accent); }
.bot-log-text { overflow-wrap: anywhere; }
.bot-log-text b { margin-right: 6px; font-weight: 600; }

@media (max-width: 480px) {
  .bot-row { grid-template-columns: 1fr; gap: 4px; }
  .bot-cmd { grid-template-columns: 84px minmax(0, 1fr) 36px; }
  .bot-slow { flex-wrap: wrap; }
  .bot-log-item { grid-template-columns: auto minmax(0, 1fr); }
  .bot-log-time { grid-column: 1 / -1; }
}
