.ui-icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  vertical-align: -0.125em;
  color: inherit;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.ui-icon use {
  pointer-events: none;
}

.icon-shape .ui-icon {
  width: 0.9rem;
  height: 0.9rem;
}

.input-group-text .ui-icon {
  width: 0.9em;
  height: 0.9em;
}

.navbar-vertical .navbar-nav .nav-link .nav-link-text {
  font-size: 14px;
}

/* Active nav badge — dark, white icon */
.navbar-vertical .navbar-nav > .nav-item .nav-link.active .icon {
  background-image: linear-gradient(310deg, #18181b 0%, #27272a 100%);
  color: #fff;
  box-shadow: 0 4px 6px -1px rgba(39, 39, 42, 0.4), 0 2px 4px -2px rgba(39, 39, 42, 0.3);
}

/* Ensure stroke-based SVG icons inherit white on active badge */
/* !important needed to override text-dark !important on the SVG element */
.navbar-vertical .navbar-nav > .nav-item .nav-link.active .icon .ui-icon {
  color: #fff !important;
}

/* Inactive badge: white background, black icon */
#sidenav-main .navbar-nav > .nav-item > .nav-link:not(.active) .icon .ui-icon {
  color: #000 !important;
}

#sidenav-main .navbar-nav > .nav-item > .nav-link,
#sidenav-main hr.horizontal,
#sidenav-main .sidebar-chat-launcher {
  width: 80%;
  margin-left: auto;
  margin-right: auto;
}

@media (max-width: 1199.98px) {
  #sidenav-main {
    overflow-y: auto;
  }

  /* Let the mobile sidenav show all items in normal flow; the aside can scroll if needed. */
  #sidenav-main .navbar-collapse {
    height: auto;
    overflow-y: visible;
  }
}

@media (min-width: 1200px) {
  .sidenav.fixed-start ~ .main-content {
    margin-left: 16.25rem;
  }

  .g-sidenav-hidden .navbar-vertical:hover.fixed-start ~ .main-content {
    margin-left: 16.25rem;
  }

  #sidenav-main {
    overflow: visible;
  }

  /* Reduce the old template's oversized reserved footer area so Profile fits. */
  #sidenav-main .navbar-collapse {
    height: calc(100vh - 240px);
    overflow-y: hidden;
  }
}

#sidenav-main .ps__rail-x,
#sidenav-main .ps__rail-y,
#sidenav-main .ps__thumb-x,
#sidenav-main .ps__thumb-y,
#sidenav-main .scrollbar-track,
#sidenav-main .scrollbar-thumb {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
}

.sidebar-chat-shell {
  position: relative;
  margin-top: 1rem;
  margin-bottom: 1rem;
}

@media (min-width: 1200px) {
  .sidebar-chat-shell {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 1rem;
    margin-top: 0;
    z-index: 20;
  }
}

.sidebar-chat-wrap {
  position: relative;
}

.sidebar-chat-launcher {
  width: 100%;
  border: 0;
  border-radius: 0.75rem;
  background: #fff;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
  padding: 0.5rem;
  display: flex;
  gap: 0.75rem;
  align-items: center;
  text-align: left;
  color: #27272a;
  transition: box-shadow 160ms ease;
}

.sidebar-chat-launcher:hover {
  box-shadow: 0 4px 8px -2px rgba(15, 23, 42, 0.12), 0 2px 4px -2px rgba(15, 23, 42, 0.12);
}

.sidebar-chat-launcher:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 0.2rem rgba(196, 178, 188, 0.35), 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

.sidebar-chat-launcher__icon {
  width: 32px;
  height: 32px;
  border-radius: 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-image: linear-gradient(310deg, #18181b 0%, #27272a 100%);
  color: #fff;
  box-shadow: 0 4px 6px -1px rgba(39, 39, 42, 0.4), 0 2px 4px -2px rgba(39, 39, 42, 0.3);
  position: relative;
}

.sidebar-chat-launcher__icon .ui-icon {
  width: 0.9rem;
  height: 0.9rem;
}

.sidebar-chat-launcher__text {
  min-width: 0;
  display: block;
  line-height: 1.2;
}

.sidebar-chat-launcher__title {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: #27272a;
}

.sidebar-chat-launcher__subtitle {
  display: none;
}

.sidebar-chat-launcher__dot {
  display: none;
  position: absolute;
  top: -3px;
  right: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
  border: 1.5px solid #fff;
  animation: chat-dot-pulse 2s infinite;
}

.sidebar-chat-launcher__dot--visible {
  display: block;
}

@keyframes chat-dot-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}

.sidebar-chat-panel {
  position: fixed;
  width: 280px;
  border-radius: 1rem;
  background: #fff;
  border: 1px solid rgba(212, 212, 216, 0.85);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.14),
              -12px 0 20px rgba(15, 23, 42, 0.06),
              12px 0 20px rgba(15, 23, 42, 0.06);
  padding: 0.75rem;
  z-index: 1050;
  display: flex;
  flex-direction: column;
  max-height: min(480px, calc(100vh - 100px));
}

@media (max-width: 575.98px) {
  .sidebar-chat-panel {
    width: calc(100vw - 2rem);
    left: 1rem !important;
    bottom: 3.5rem !important;
  }
}

.sidebar-chat-panel[hidden] {
  display: none !important;
}

.sidebar-chat-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(52, 71, 103, 0.08);
}

.sidebar-chat-panel__badge {
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 0.5rem;
  background: rgba(52, 71, 103, 0.08);
  color: #344767;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-chat-panel__badge .ui-icon {
  width: 0.8rem;
  height: 0.8rem;
}

.sidebar-chat-panel__close {
  color: rgba(52, 71, 103, 0.4);
  line-height: 1;
  padding: 2px;
  transition: color 0.12s;
}

.sidebar-chat-panel__close:hover {
  color: #344767;
}

.sidebar-chat-panel__close .ui-icon {
  width: 1.1rem;
  height: 1.1rem;
}

/* ── Messages area ─────────────────────────────────────────────────────── */
.sidebar-chat-panel__messages {
  flex: 1;
  min-height: 250px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding-right: 0.1rem;
}

/* ── Individual message ────────────────────────────────────────────────── */
.chat-msg {
  display: flex;
  gap: 7px;
  align-items: flex-start;
  position: relative;
}

.chat-msg__avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1.5px solid rgba(52, 71, 103, 0.1);
  margin-top: 1px;
}

.chat-msg__body {
  flex: 1;
  min-width: 0;
}

.chat-msg__meta {
  display: flex;
  align-items: baseline;
  gap: 5px;
  margin-bottom: 2px;
}

.chat-msg__name {
  font-size: 14px;
  font-weight: 700;
  color: #344767;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}

.chat-msg__time {
  font-size: 13px;
  color: rgba(52, 71, 103, 0.45);
  white-space: nowrap;
  flex-shrink: 0;
}

.chat-msg__text {
  font-size: 15px;
  color: #000;
  line-height: 1.45;
  word-break: break-word;
}

.chat-msg__text a {
  color: #17ad37;
  text-decoration: underline;
  word-break: break-all;
}

.chat-msg__edited {
  font-size: 10px;
  color: rgba(52, 71, 103, 0.35);
  font-style: italic;
}

/* Actions (edit / delete) — always visible on own messages; delete visible for admin on others' */
.chat-msg__actions {
  display: none;
  gap: 6px;
  margin-top: 3px;
}

.chat-msg.is-mine .chat-msg__actions,
.chat-msg.can-delete .chat-msg__actions {
  display: flex;
}

.chat-msg__btn {
  border: none;
  background: none;
  padding: 0;
  font-size: 10px;
  cursor: pointer;
  color: rgba(52, 71, 103, 0.35);
  line-height: 1;
  font-family: inherit;
}

.chat-msg__btn:hover { color: #344767; }
.chat-msg__del-btn:hover { color: #f5365c; }

/* Inline edit */
.chat-msg__edit-wrap { margin-top: 3px; }

.chat-msg__edit-input {
  width: 100%;
  font-size: 12px;
  border: 1px solid rgba(52, 71, 103, 0.2);
  border-radius: 6px;
  padding: 3px 7px;
  color: #344767;
  outline: none;
  font-family: inherit;
  box-sizing: border-box;
}

.chat-msg__edit-input:focus {
  border-color: rgba(52, 71, 103, 0.4);
}

.chat-msg__edit-btns {
  display: flex;
  gap: 6px;
  margin-top: 3px;
}

.chat-msg__save-btn,
.chat-msg__cancel-btn {
  border: none;
  background: none;
  font-size: 10px;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}

.chat-msg__save-btn   { color: #17ad37; font-weight: 600; }
.chat-msg__cancel-btn { color: rgba(52, 71, 103, 0.4); }
.chat-msg__cancel-btn:hover { color: #344767; }

/* ── Composer ──────────────────────────────────────────────────────────── */
.sidebar-chat-panel__composer {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  margin-top: 0.55rem;
  position: relative;
}

/* ── Emoji button ──────────────────────────────────────────────────────── */
.chat-emoji-btn {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 17px;
  padding: 0 1px;
  line-height: 1;
  flex-shrink: 0;
  opacity: 0.55;
  transition: opacity 0.12s;
}

.chat-emoji-btn:hover { opacity: 1; }

/* ── Emoji picker ──────────────────────────────────────────────────────── */
.chat-emoji-picker {
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  background: #fff;
  border: 1px solid rgba(52, 71, 103, 0.12);
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(52, 71, 103, 0.14);
  padding: 7px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  z-index: 60;
}

.chat-emoji-picker[hidden] { display: none !important; }

.chat-emoji-item {
  font-size: 20px;
  cursor: pointer;
  text-align: center;
  padding: 5px 4px;
  border-radius: 6px;
  border: none;
  background: none;
  line-height: 1;
  transition: background 0.1s;
}

.chat-emoji-item:hover { background: rgba(52, 71, 103, 0.07); }

.sidebar-chat-input {
  flex: 1;
  min-width: 0;
  border: 1px solid rgba(52, 71, 103, 0.15);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 15px;
  color: #000;
  outline: none;
  font-family: inherit;
  background: rgba(52, 71, 103, 0.03);
}

.sidebar-chat-input::placeholder { color: rgba(52, 71, 103, 0.35); }
.sidebar-chat-input:focus { border-color: rgba(52, 71, 103, 0.3); }

.sidebar-chat-send {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border: none;
  border-radius: 7px;
  background: linear-gradient(310deg, #344767 0%, #4a6080 100%);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.15s;
}

.sidebar-chat-send:hover { opacity: 0.82; }

.sidebar-chat-send .ui-icon {
  width: 0.75rem;
  height: 0.75rem;
}

@media (prefers-reduced-motion: reduce) {
  .sidebar-chat-launcher {
    transition: none;
  }
}

/* ── Vocabulary panel ───────────────────────────────────────────────────── */
.vocab-nav-item {
  position: relative;
  margin-right: 10px;
}

.vocab-toggle-btn {
  border: none;
  background: none;
  padding: 2px 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  opacity: 0.65;
  transition: opacity 0.15s;
  line-height: 1;
}

.vocab-toggle-btn:hover { opacity: 1; }

.vocab-toggle-btn img {
  width: 22px;
  height: auto;
  display: block;
}

.vocab-panel {
  position: fixed;
  width: 400px;
  max-height: 500px;
  background: #fff;
  border: 1px solid rgba(212, 212, 216, 0.85);
  border-radius: 1rem;
  box-shadow: 0 12px 36px rgba(15, 23, 42, 0.18);
  z-index: 1100;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: 'Aptos', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

.vocab-panel[hidden] { display: none !important; }

.vocab-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 1rem 0.6rem;
  border-bottom: 1px solid rgba(52, 71, 103, 0.08);
  flex-shrink: 0;
}

.vocab-panel__title {
  font-size: 15px;
  font-weight: 700;
  color: #1a1f2e;
}

.vocab-panel__close {
  border: none;
  background: none;
  cursor: pointer;
  color: rgba(52, 71, 103, 0.4);
  font-size: 18px;
  line-height: 1;
  padding: 0 2px;
  transition: color 0.12s;
}

.vocab-panel__close:hover { color: #344767; }

.vocab-search-wrap {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid rgba(52, 71, 103, 0.08);
  flex-shrink: 0;
}

.vocab-search-input {
  width: 100%;
  border: 1px solid rgba(52, 71, 103, 0.18);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 14px;
  color: #1a1f2e;
  outline: none;
  font-family: inherit;
  box-sizing: border-box;
  background: rgba(52, 71, 103, 0.03);
}

.vocab-search-input:focus { border-color: rgba(52, 71, 103, 0.35); }
.vocab-search-input::placeholder { color: rgba(52, 71, 103, 0.35); }

.vocab-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.4rem 0;
}

.vocab-item {
  padding: 0.55rem 1rem;
  border-bottom: 1px solid rgba(52, 71, 103, 0.05);
}

.vocab-item:last-child { border-bottom: none; }

.vocab-item__word {
  font-size: 14px;
  font-weight: 700;
  color: #111827;
  margin-bottom: 3px;
}

.vocab-item__meaning {
  font-size: 13px;
  color: rgba(17, 24, 39, 0.72);
  line-height: 1.55;
}

.vocab-empty {
  padding: 1.5rem 1rem;
  text-align: center;
  font-size: 13px;
  color: rgba(52, 71, 103, 0.4);
}

.vocab-highlight {
  background: #ffe066;
  border-radius: 2px;
  padding: 0 1px;
  font-style: inherit;
}

@media (max-width: 480px) {
  .vocab-panel {
    width: calc(100vw - 2rem);
  }
}
