/* ============================================================
   Layout — sidebar + main content
   ============================================================ */
:root {
  --sidebar-width: 240px;
  --sidebar-bg: #1f2733;
  --sidebar-fg: #d8dde6;
  --sidebar-fg-muted: #7e8898;
  --sidebar-active-bg: #2c3645;
  --sidebar-active-fg: #69d3a7;
  --tg-bg: #0e1621;
  --tg-msg-bg: #1c2a39;
  --tg-btn-bg: #2b5278;
  --tg-btn-hover: #3a6ea0;
}

body { background: #f5f6f8; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif; }
code { background: rgba(0,0,0,.05); padding: 1px 4px; border-radius: 3px; font-size: 0.92em; }
textarea { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 0.92em; }

.app-shell {
  display: flex;
  min-height: 100vh;
}
.app-sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-fg);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.app-brand {
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid #2a3441;
}
.brand-emoji { font-size: 28px; }
.brand-name { color: #fff; font-weight: 600; font-size: 14px; }
.brand-bot { font-size: 11px; }
.app-nav { padding: 10px 0; flex: 1; }
.nav-section {
  color: var(--sidebar-fg-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 14px 20px 6px;
}
.app-nav .nav-link {
  color: var(--sidebar-fg);
  padding: 8px 20px;
  border-radius: 0;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.1s;
}
.app-nav .nav-link i { width: 18px; text-align: center; }
.app-nav .nav-link:hover { background: var(--sidebar-active-bg); color: #fff; }
.app-nav .nav-link.active { background: var(--sidebar-active-bg); color: var(--sidebar-active-fg); border-left: 3px solid var(--sidebar-active-fg); padding-left: 17px; }
.app-footer {
  padding: 14px 20px;
  border-top: 1px solid #2a3441;
}

.app-main { flex: 1; min-width: 0; }
.app-content { padding: 24px 28px; max-width: 1280px; }

@media (max-width: 768px) {
  .app-shell { flex-direction: column; }
  .app-sidebar { width: 100%; height: auto; position: static; }
  .app-content { padding: 16px; }
}

/* ============================================================
   TG-style chat preview (used in /menus/<key>)
   ============================================================ */
.tg-preview {
  background: var(--tg-bg);
  border-radius: 12px;
  padding: 20px;
  min-height: 500px;
  position: relative;
  background-image: linear-gradient(135deg, #0e1621 0%, #182433 100%);
}
.tg-preview-header {
  color: #94a3b8;
  font-size: 12px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.tg-preview-header b { color: #69d3a7; }
.tg-msg {
  background: var(--tg-msg-bg);
  color: #e6e9ef;
  border-radius: 8px 8px 8px 2px;
  padding: 10px 14px;
  margin-bottom: 10px;
  max-width: 540px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: 14px;
}
.tg-msg b { color: #fff; font-weight: 600; }
.tg-msg code {
  background: rgba(255,255,255,0.08);
  color: #e6e9ef;
  padding: 1px 4px;
  border-radius: 3px;
}
.tg-keyboard { max-width: 540px; display: flex; flex-direction: column; gap: 4px; }
.tg-row { display: flex; gap: 4px; }
.tg-btn {
  flex: 1;
  background: var(--tg-btn-bg);
  color: #fff;
  border: none;
  padding: 10px 8px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.1s;
  text-align: center;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  text-decoration: none;
}
.tg-btn:hover { background: var(--tg-btn-hover); color: #fff; }
.tg-btn .tg-btn-actions {
  position: absolute;
  top: -10px;
  right: -10px;
  display: none;
  gap: 2px;
}
.tg-btn:hover .tg-btn-actions { display: flex; }
.tg-btn-action {
  background: #fff;
  color: #1f2733;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 11px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #ccc;
  cursor: pointer;
  text-decoration: none;
}
.tg-btn-action:hover { background: #69d3a7; color: #fff; border-color: #69d3a7; }
.tg-btn-disabled { opacity: 0.4; }
.tg-btn-divider {
  background: transparent;
  color: #94a3b8;
  font-size: 11px;
  letter-spacing: 1px;
  pointer-events: none;
}
.tg-btn-back { background: rgba(255,255,255,0.08); }
.tg-btn-back:hover { background: rgba(255,255,255,0.15); }
.tg-btn-add {
  background: rgba(105,211,167,0.15);
  color: #69d3a7;
  border: 1px dashed #69d3a7;
}
.tg-btn-add:hover { background: rgba(105,211,167,0.25); color: #fff; }
.tg-btn[data-type="url"]::after { content: "↗"; opacity: 0.6; margin-left: 4px; }
.tg-btn[data-type="submenu"]::after { content: "›"; opacity: 0.7; margin-left: 4px; }

/* Edit panel (right side of preview) */
.tg-editor-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

/* ============================================================
   Misc
   ============================================================ */
.kpi-card {
  background: #fff;
  border-radius: 10px;
  padding: 18px 20px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.kpi-card .kpi-value { font-size: 24px; font-weight: 600; color: #1f2733; }
.kpi-card .kpi-label { font-size: 12px; color: #7e8898; text-transform: uppercase; letter-spacing: 0.5px; }

table.compact td, table.compact th { padding: 6px 10px !important; font-size: 13px; }

.breadcrumb { font-size: 0.95em; }
.page-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.page-title h2 { margin: 0; font-size: 20px; font-weight: 600; }

.bot-preview .btn { pointer-events: none; cursor: default; }

/* ============================================================
   Floating random-emoji button (visible on all authenticated pages)
   ============================================================ */
#emojiBtn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid #d8dde6;
  font-size: 28px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,0.15);
  z-index: 1050;
  transition: transform 0.15s, background 0.15s, border-color 0.15s;
  line-height: 1;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
#emojiBtn:hover {
  transform: scale(1.08) rotate(-12deg);
  background: #f0fdf4;
  border-color: #69d3a7;
}
#emojiBtn:active { transform: scale(0.96); }
#emojiBtn.emoji-active { border-color: #69d3a7; box-shadow: 0 4px 14px rgba(105,211,167,0.3); }

.emoji-hint {
  position: fixed;
  bottom: 84px;
  right: 24px;
  background: #1f2733;
  color: #fff;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  z-index: 1051;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  white-space: nowrap;
}
.emoji-hint-show { opacity: 1; transform: translateY(0); }

/* Persistent contextual tip — shows when an input is focused */
.emoji-tip {
  position: fixed;
  bottom: 88px;
  right: 24px;
  background: #1f2733;
  color: #fff;
  padding: 8px 12px 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 1051;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  display: flex;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.emoji-tip::after {
  content: '';
  position: absolute;
  bottom: -6px;
  right: 22px;
  width: 12px;
  height: 12px;
  background: #1f2733;
  transform: rotate(45deg);
}
.emoji-tip-show { opacity: 1; transform: translateY(0); pointer-events: auto; }
.emoji-tip kbd {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 11px;
  font-family: ui-monospace, monospace;
}
.emoji-tip-x {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.6);
  font-size: 14px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
}
.emoji-tip-x:hover { color: #fff; }
