.hcgpt-chat-layout {
  position: relative;
  min-height: 100vh;
  /* Chat gutter variables – scoped to chat page only */
  --hcgpt-sidebar-width: var(--hcgpt-sidebar-mini-width, 52px);
  --hcgpt-chat-gutter-left: calc(var(--hcgpt-sidebar-width) + 20px);
  --hcgpt-chat-gutter-right: 20px;
}

.hcgpt-app-shell.hcgpt-scope[data-hcgpt-app="unified"] .hcgpt-chat-layout {
  --hcgpt-chat-gutter-left: 0px;
  --hcgpt-chat-gutter-right: 0px;
}

.hcgpt-chat-layout.hcgpt-scope,
.hcgpt-chat-layout.hcgpt-scope .hcgpt-chat-layout-main,
.hcgpt-chat-layout-main.hcgpt-scope {
  background: var(--hcgpt-color-bg);
  color: var(--hcgpt-color-text);
}

.hcgpt-chat-sidebar {
  --hcgpt-sidebar-top-height: 180px;
  --hcgpt-sidebar-bottom-height: 170px;
  position: fixed;
  top: 0;
  left: 0;
  width: var(--hcgpt-sidebar-mini-width, 52px);
  height: 100vh;
  max-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--hcgpt-sidebar-bg);
  color: var(--hcgpt-sidebar-item-text);
  padding: 0;
  box-sizing: border-box;
  transition: width 0.25s ease, background-color 0.25s ease;
  border-radius: 0;
  border: 0;
  border-left: none;
  --hcgpt-sidebar-divider: transparent;
  box-shadow: none;
  z-index: 10010;
  will-change: width;
  backface-visibility: hidden;
}

.hcgpt-chat-sidebar[data-state="mini"] {
  width: var(--hcgpt-sidebar-mini-width, 52px);
  background-color: var(--hcgpt-sidebar-bg);
  cursor: pointer;
}

.hcgpt-chat-sidebar[data-state="full"] {
  --hcgpt-sidebar-top-height: 180px;
  --hcgpt-sidebar-bottom-height: 170px;
  width: var(--hcgpt-sidebar-full-width, 260px);
  padding: 0 0px 0px 5px;
}

.hcgpt-chat-layout-main {
  min-height: 0;
  height: 100%;
  padding: 0;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  overflow: clip;
  margin-left: 0;
  /* Offset spostato su padding-left della shell */
  backface-visibility: hidden;
}

#hcgpt-unified-chat-wrapper,
.hcgpt-unified-chat-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  overflow: clip;
  position: relative;
}

/* Rimossa ridefinizione di .hcgpt-shell per evitare conflitti con frontend.css */

#hcgpt-unified-chat-wrapper #hcgpt-chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  padding-bottom: 0;
}

#hcgpt-unified-chat-wrapper #hcgpt-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  padding-top: 16px;
  padding-bottom: calc(var(--hcgpt-bottom-gap, calc(var(--hcgpt-inputbar-h, 72px) + var(--hcgpt-suggestions-h, 0px) + env(safe-area-inset-bottom, 0px))) + var(--hcgpt-feedback-h, 0px) + 16px);
  scroll-padding-bottom: calc(var(--hcgpt-bottom-gap, calc(var(--hcgpt-inputbar-h, 72px) + var(--hcgpt-suggestions-h, 0px) + env(safe-area-inset-bottom, 0px))) + var(--hcgpt-feedback-h, 0px) + 16px);
}

.hcgpt-chat-sidebar__toggle {
  background: none !important;
  border: none !important;
  width: 100%;
  padding: 4px 0;
  cursor: pointer;
  color: var(--hcgpt-sidebar-item-text);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: left;
  position: relative;
  min-height: 44px;
  box-shadow: none !important;
  outline: none !important;
}

.hcgpt-chat-sidebar[data-state="full"] .hcgpt-chat-sidebar__toggle,
.hcgpt-chat-sidebar[data-state="mobile-open"] .hcgpt-chat-sidebar__toggle {
  justify-content: flex-start;
  padding-left: 8px;
  gap: 12px;
}

.hcgpt-chat-sidebar__toggle:hover {
  background: transparent !important;
  color: var(--hcgpt-sidebar-item-text);
  text-decoration: none;
  box-shadow: none !important;
  outline: none !important;
  border: none !important;
}

/* Toggle icon wrapper per hover effect */
.hcgpt-toggle-icon-wrapper {
  position: relative;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  border-radius: 8px;
  overflow: visible;
  box-sizing: border-box;
}

.hcgpt-chat-sidebar__toggle-img {
  width: 30px;
  height: 30px;
  object-fit: contain;
  transition: opacity 0.2s ease;
}

.hcgpt-chat-sidebar__toggle-hover-icon {
  position: absolute;
  top: 0;
  left: 4px;
  width: 20px;
  height: 20px;
  opacity: 0;
  transition: opacity 0.2s ease;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hcgpt-chat-sidebar[data-state="mini"]:hover .hcgpt-chat-sidebar__toggle-img {
  opacity: 0;
}

.hcgpt-chat-sidebar[data-state="mini"]:hover .hcgpt-chat-sidebar__toggle-hover-icon {
  opacity: 1;
}

.hcgpt-chat-sidebar[data-state="mini"]:hover .hcgpt-toggle-icon-wrapper {
  background: transparent;
}

/* Tooltip */
.hcgpt-toggle-tooltip {
  position: absolute;
  left: calc(100% + 12px);
  background: var(--hcgpt-sidebar-item-hover-bg);
  color: var(--hcgpt-sidebar-item-text);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 1001;
}

.hcgpt-toggle-tooltip::before {
  content: '';
  position: absolute;
  right: 100%;
  top: 50%;
  transform: translateY(-50%);
  border: 6px solid transparent;
  border-right-color: var(--hcgpt-sidebar-item-hover-bg);
}

.hcgpt-chat-sidebar[data-state="mini"] .hcgpt-chat-sidebar__toggle:hover .hcgpt-toggle-tooltip {
  opacity: 1;
}

.hcgpt-chat-sidebar[data-state="full"] .hcgpt-toggle-tooltip {
  display: none;
}

.hcgpt-chat-sidebar__toggle-icon {
  display: inline-block;
  width: 16px;
  height: 2px;
  background: currentColor;
  position: relative;
}

.hcgpt-chat-sidebar__toggle-icon::before,
.hcgpt-chat-sidebar__toggle-icon::after {
  content: '';
  position: absolute;
  left: 0;
  width: 16px;
  height: 2px;
  background: currentColor;
}

.hcgpt-chat-sidebar__toggle-icon::before {
  top: -5px;
}

.hcgpt-chat-sidebar__toggle-icon::after {
  bottom: -5px;
}


.hcgpt-chat-sidebar__toggle-label {
  display: none !important;
  font-size: 17px;
  font-weight: 900;
  color: var(--hcgpt-sidebar-item-text);
  text-decoration: none;
}

.hcgpt-chat-sidebar__nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  margin-top: 26px;
  width: 100%;
}

.hcgpt-chat-sidebar[data-state="full"] .hcgpt-chat-sidebar__nav,
.hcgpt-chat-sidebar[data-state="mobile-open"] .hcgpt-chat-sidebar__nav {
  align-items: flex-start;
}

.hcgpt-chat-sidebar__top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 8px 0 6px;
  border-bottom: 1px solid var(--hcgpt-sidebar-divider);
  position: relative;
}

.hcgpt-chat-sidebar[data-state="full"] .hcgpt-chat-sidebar__top,
.hcgpt-chat-sidebar[data-state="mobile-open"] .hcgpt-chat-sidebar__top {
  align-items: flex-start;
}

.hcgpt-sidebar-close-btn {
  display: none;
  position: absolute;
  top: 12px;
  right: 12px;
  background: transparent;
  border: 0;
  padding: 6px;
  cursor: pointer;
  color: var(--hcgpt-sidebar-item-text-muted);
  transition: color 0.2s ease;
  border-radius: 6px;
  z-index: 10;
}

.hcgpt-sidebar-close-btn:hover {
  color: var(--hcgpt-sidebar-item-text);
  background: transparent;
}

.hcgpt-chat-sidebar[data-state="full"] .hcgpt-sidebar-close-btn,
.hcgpt-chat-sidebar[data-state="mobile-open"] .hcgpt-sidebar-close-btn {
  display: block;
}

.hcgpt-chat-sidebar__nav-item {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  gap: 12px;
  padding: 4px 0;
  border-radius: var(--hcgpt-menu-item-radius, 8px);
  text-decoration: none;
  color: var(--hcgpt-sidebar-item-text);
  background: transparent;
  transition: color 0.2s ease, background-color 0.2s ease, border-radius 0.2s ease;
  border: 0;
  border-bottom: 1px solid var(--hcgpt-sidebar-divider);
  min-height: 36px;
  margin-left: 0px;
  font-weight: 500;
  font-size: 14px;
  box-sizing: border-box;
  overflow: visible;
}

.hcgpt-chat-sidebar__nav-item:last-child {
  border-bottom: none;
}

.hcgpt-chat-sidebar[data-state="full"] .hcgpt-chat-sidebar__nav-item,
.hcgpt-chat-sidebar[data-state="mobile-open"] .hcgpt-chat-sidebar__nav-item {
  justify-content: flex-start;
  padding: 4px 8px;
}

.hcgpt-chat-sidebar__nav-item:hover {
  color: var(--hcgpt-sidebar-item-text);
  text-decoration: none;
  background: var(--hcgpt-menu-item-hover-bg, var(--hcgpt-overlay-item-hover-bg));
}

.hcgpt-chat-sidebar__nav-item:focus-visible {
  outline: none;
  background: var(--hcgpt-menu-item-hover-bg, var(--hcgpt-overlay-item-hover-bg));
}

.hcgpt-chat-sidebar__nav-item.is-active {
  border-radius: var(--hcgpt-menu-item-radius, 8px);
}

.hcgpt-chat-sidebar__nav-icon {
  font-size: 20px;
  line-height: 1;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  box-sizing: border-box;
  color: inherit;
  transition: color 0.2s ease;
}

/* Ensure themify icons inside nav-icon are consistent size */
.hcgpt-chat-sidebar__nav-icon .tf-icon,
.hcgpt-chat-sidebar__nav-icon i {
  font-size: 20px !important;
  width: 20px !important;
  height: 20px !important;
  line-height: 1 !important;
}

/* Ensure SVG icons inside nav-icon are consistent size */
.hcgpt-chat-sidebar__nav-icon svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: block;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Ensure all icon font icons in nav are visible (Themify, LineAwesome, FontAwesome) */
.hcgpt-chat-sidebar__nav-icon i,
.hcgpt-chat-sidebar__nav-icon .tf-icon,
.hcgpt-chat-sidebar__nav-icon [class^="ti-"],
.hcgpt-chat-sidebar__nav-icon [class*=" ti-"],
.hcgpt-chat-sidebar__nav-icon [class^="la-"],
.hcgpt-chat-sidebar__nav-icon [class*=" la-"],
.hcgpt-chat-sidebar__nav-icon [class^="fa-"],
.hcgpt-chat-sidebar__nav-icon [class*=" fa-"],
.hcgpt-chat-sidebar__nav-icon [class^="fontello-"],
.hcgpt-chat-sidebar__nav-icon [class*=" fontello-"] {
  display: inline-block !important;
  font-size: 20px !important;
  line-height: 1 !important;
  width: 20px !important;
  height: 20px !important;
  text-align: center !important;
}

.hcgpt-chat-sidebar__nav-label {
  display: none;
  margin-left: 8px;
  font-weight: 300;
  color: var(--hcgpt-sidebar-item-text);
}


.hcgpt-chat-sidebar[data-state="full"] .hcgpt-chat-sidebar__nav-label,
.hcgpt-chat-sidebar[data-state="mobile-open"] .hcgpt-chat-sidebar__nav-label {
  display: inline-block;
}

.hcgpt-chat-sidebar__middle {
  flex: 1;
  min-height: 0;
  /* Critical: allows flexbox to shrink below content size */
  margin: 12px 0;
  padding: 0;
  border: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.hcgpt-sidebar-logs-scroll {
  flex: 1;
  min-height: 0;
  /* Critical: allows flexbox to shrink below content size */
  overflow: hidden;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding-right: 0;
  padding-bottom: 8px;
}

/* Scrollbar sottile per i log buttons */
.hcgpt-sidebar-logs-scroll::-webkit-scrollbar {
  width: 4px;
}

.hcgpt-sidebar-logs-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.hcgpt-sidebar-logs-scroll::-webkit-scrollbar-thumb {
  background: var(--hcgpt-color-text-muted);
  border-radius: 4px;
}

.hcgpt-sidebar-logs-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--hcgpt-color-text);
}

.hcgpt-sidebar-logs-scroll {
  scrollbar-width: thin;
  /* Firefox */
  scrollbar-color: var(--hcgpt-color-text-muted) transparent;
  /* Firefox */
}

.hcgpt-chat-sidebar[data-state="mini"] .hcgpt-sidebar-logs-scroll {
  display: none;
}

.hcgpt-sidebar-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin: 0;
  padding: 6px 8px;
  font-size: 12px;
  line-height: 1.3;
  font-weight: 600;
  color: var(--hcgpt-sidebar-item-text-muted);
  letter-spacing: 0.01em;
  text-transform: none;
}

.hcgpt-sidebar-section-title--static {
  padding-top: 10px;
  padding-bottom: 8px;
}

.hcgpt-sidebar-recent-toggle {
  background: transparent;
  border: 0;
  border-radius: var(--hcgpt-menu-item-radius, 8px);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  box-shadow: none;
  transition: color var(--hcgpt-transition-fast);
}

.hcgpt-sidebar-recent-toggle:hover {
  background: transparent;
  color: var(--hcgpt-sidebar-item-text);
  box-shadow: none;
}

.hcgpt-sidebar-recent-toggle:focus-visible {
  background: transparent;
  box-shadow: none;
}

.hcgpt-sidebar-recent-toggle.is-static,
.hcgpt-sidebar-recent-toggle:disabled {
  cursor: default;
}

.hcgpt-sidebar-recent-toggle.is-static:hover,
.hcgpt-sidebar-recent-toggle:disabled:hover {
  background: transparent;
}

.hcgpt-sidebar-section-caret {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--hcgpt-sidebar-item-text-muted);
  opacity: 0;
  transition: transform 0.2s ease, color 0.2s ease, opacity 0.2s ease;
}

.hcgpt-sidebar-recent-clients.is-expandable .hcgpt-sidebar-recent-toggle:hover .hcgpt-sidebar-section-caret,
.hcgpt-sidebar-recent-clients.is-expandable .hcgpt-sidebar-recent-toggle:focus-visible .hcgpt-sidebar-section-caret,
.hcgpt-sidebar-recent-clients.is-expandable[data-state="expanded"] .hcgpt-sidebar-section-caret,
.hcgpt-sidebar-recent-clients.is-expandable.is-expanded .hcgpt-sidebar-section-caret {
  opacity: 1;
  color: var(--hcgpt-sidebar-item-text);
}

.hcgpt-sidebar-recent-clients.is-expanded .hcgpt-sidebar-section-caret,
.hcgpt-sidebar-recent-clients[data-state="expanded"] .hcgpt-sidebar-section-caret {
  transform: rotate(180deg);
}

.hcgpt-sidebar-recent-clients {
  margin-bottom: 8px;
}

.hcgpt-sidebar-recent-clients__list-wrap {
  overflow: hidden;
}

.hcgpt-sidebar-recent-clients[data-state="expanded"] .hcgpt-sidebar-recent-clients__list-wrap,
.hcgpt-sidebar-recent-clients.is-expanded .hcgpt-sidebar-recent-clients__list-wrap {
  max-height: 300px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
}

.hcgpt-sidebar-recent-clients__list-wrap::-webkit-scrollbar {
  width: 4px;
}

.hcgpt-sidebar-recent-clients__list-wrap::-webkit-scrollbar-track {
  background: transparent;
}

.hcgpt-sidebar-recent-clients__list-wrap::-webkit-scrollbar-thumb {
  background: var(--hcgpt-color-text-muted);
  border-radius: 4px;
}

.hcgpt-sidebar-recent-clients__list-wrap {
  scrollbar-width: thin;
  scrollbar-color: var(--hcgpt-color-text-muted) transparent;
}

.hcgpt-sidebar-recent-clients__list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.hcgpt-sidebar-recent-clients__item {
  margin: 0;
  padding: 0;
}

.hcgpt-sidebar-recent-clients[data-state="compact"] .hcgpt-sidebar-recent-clients__item:nth-child(n+4) {
  display: none;
}

.hcgpt-recent-client-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 0;
  border-bottom: 0;
  border-radius: var(--hcgpt-menu-item-radius, 8px);
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  color: var(--hcgpt-sidebar-item-text);
  text-align: left;
  text-decoration: none;
  box-shadow: none;
  cursor: pointer;
  transition: background-color var(--hcgpt-transition-fast), color var(--hcgpt-transition-fast);
}

.hcgpt-recent-client-item:hover,
.hcgpt-recent-client-item:focus-visible,
.hcgpt-recent-client-item:active {
  background: transparent;
  color: var(--hcgpt-sidebar-item-text);
  border-bottom: 0;
  text-decoration: none;
  box-shadow: none;
}

.hcgpt-recent-client-item__avatar {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-top-left-radius: 12px;
  border-bottom-left-radius: 12px;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--hcgpt-color-surface-2);
}

.hcgpt-recent-client-item__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.hcgpt-recent-client-item__avatar-fallback {
  font-size: 12px;
  line-height: 1;
  font-weight: 700;
  color: var(--hcgpt-color-text);
}

.hcgpt-recent-client-item__meta {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  align-items: flex-start;
  padding: 2px 6px;
  border-radius: var(--hcgpt-menu-item-radius, 8px);
  transition: background-color var(--hcgpt-transition-fast), color var(--hcgpt-transition-fast);
}

.hcgpt-recent-client-item:hover .hcgpt-recent-client-item__meta,
.hcgpt-recent-client-item:focus-visible .hcgpt-recent-client-item__meta {
  background: var(--hcgpt-menu-item-hover-bg, var(--hcgpt-overlay-item-hover-bg));
}

.hcgpt-recent-client-item__name,
.hcgpt-recent-client-item__days,
.hcgpt-recent-client-item__detail {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 170px;
}

.hcgpt-recent-client-item__name {
  font-size: 13px;
  line-height: 1.3;
  font-weight: 500;
  color: var(--hcgpt-sidebar-item-text);
}

.hcgpt-recent-client-item__days {
  font-size: 11px;
  line-height: 1.25;
  color: var(--hcgpt-sidebar-item-text-muted);
  text-transform: none !important;
}

.hcgpt-recent-client-item__detail {
  font-size: 10px;
  line-height: 1.3;
  color: var(--hcgpt-sidebar-item-text-muted);
}

.hcgpt-sidebar-empty-state {
  margin: 0;
  padding: 6px 8px 10px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--hcgpt-sidebar-item-text-muted);
}

.hcgpt-sidebar-chat-history {
  border-top: 1px solid var(--hcgpt-sidebar-divider);
  padding-top: 2px;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.hcgpt-sidebar-log-buttons {
  flex: 1 1 auto;
  min-height: 0;
  background: transparent;
  border-radius: 0;
  padding: 0px 4px 0 0;
  /* Ridotto padding-right per permettere ai titoli di estendersi */
  box-shadow: none;
  max-height: none;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

.hcgpt-sidebar-log-buttons::-webkit-scrollbar {
  width: 4px;
}

.hcgpt-sidebar-log-buttons::-webkit-scrollbar-track {
  background: transparent;
}

.hcgpt-sidebar-log-buttons::-webkit-scrollbar-thumb {
  background: var(--hcgpt-color-text-muted);
  border-radius: 4px;
}

.hcgpt-sidebar-log-buttons::-webkit-scrollbar-thumb:hover {
  background: var(--hcgpt-color-text);
}

.hcgpt-sidebar-log-buttons {
  scrollbar-width: thin;
  scrollbar-color: var(--hcgpt-color-text-muted) transparent;
}

.hcgpt-sidebar-log-buttons .hcgpt-log-buttons {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.hcgpt-sidebar-log-buttons .hcgpt-log-btn {
  width: 100% !important;
  border: 0 !important;
  border-radius: var(--hcgpt-sidebar-item-radius, 24px) !important;
  background: transparent !important;
  color: var(--hcgpt-sidebar-item-text) !important;
  padding: 8px !important;
  font-size: 13px !important;
  font-weight: 400 !important;
  justify-content: flex-start !important;
  box-shadow: none !important;
  transition: background 0.3s ease, color 0.3s ease !important;
  gap: 8px !important;
  display: block !important;
  position: relative !important;
  transform: none !important;
}

/* Rimuove icona 📂 aggiunta da chat-status.css */
.hcgpt-sidebar-log-buttons .hcgpt-log-btn::before {
  content: none !important;
  display: none !important;
}

.hcgpt-sidebar-log-buttons .hcgpt-log-btn:hover {
  background: var(--hcgpt-sidebar-item-hover-bg) !important;
  color: var(--hcgpt-sidebar-item-text) !important;
  transform: none !important;
  box-shadow: none !important;
}

/* === STRATEGIA 2: Titolo occupa tutto lo spazio, menu in overlay su hover === */
.hcgpt-sidebar-log-buttons .hcgpt-log-item {
  position: relative;
}

/* Titolo occupa tutto lo spazio disponibile - Stile Gemini */
.hcgpt-sidebar-log-buttons .log-title {
  display: block !important;
  width: 100% !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  font-weight: 400 !important;
  font-size: 13px !important;
  line-height: 1.4 !important;
  margin: 0 !important;
  margin-bottom: 0 !important;
  padding-right: 0 !important;
  transition: padding-right 0.3s ease !important;
}

/* Stato hover: titolo si accorcia per fare spazio ai 3 puntini (stile Gemini) */
.hcgpt-sidebar-log-buttons .hcgpt-log-item:hover .log-title {
  padding-right: 32px !important;
}

/* Stato menu aperto: titolo resta accorciato */
.hcgpt-sidebar-log-buttons .hcgpt-log-item.menu-open .log-title {
  padding-right: 32px !important;
}

/* Nascondi date, status e count nella sidebar */
.hcgpt-sidebar-log-buttons .log-date,
.hcgpt-sidebar-log-buttons .log-status,
.hcgpt-sidebar-log-buttons .log-messages-count {
  display: none;
}

/* Bottone menu 3 puntini - appare su hover (stile Gemini) */
.hcgpt-sidebar-log-buttons .hcgpt-log-menu-btn {
  position: absolute;
  right: 8px;
  /* Allineato con padding-right del log-btn */
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  padding: 4px 6px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease, background 0.2s ease;
  /* Transizione sincronizzata con titolo */
  border-radius: 4px;
  z-index: 2;
}

.hcgpt-sidebar-log-buttons .hcgpt-log-menu-dots {
  font-size: 16px;
  font-weight: bold;
  color: var(--hcgpt-sidebar-item-text-muted);
  line-height: 1;
}

/* Su hover del log-item: mostra bottone menu */
.hcgpt-sidebar-log-buttons .hcgpt-log-item:hover .hcgpt-log-menu-btn {
  opacity: 1;
}

/* Hover sul bottone menu stesso */
.hcgpt-sidebar-log-buttons .hcgpt-log-menu-btn:hover {
  background: var(--hcgpt-sidebar-item-hover-bg);
}

.hcgpt-sidebar-log-buttons .hcgpt-log-menu-btn:hover .hcgpt-log-menu-dots {
  color: var(--hcgpt-sidebar-item-text);
}

/* Dropdown menu */
.hcgpt-sidebar-log-buttons .hcgpt-log-menu-dropdown {
  position: absolute;
  right: 0;
  top: 100%;
  background: var(--hcgpt-overlay-bg);
  border: 1px solid var(--hcgpt-overlay-border);
  border-radius: var(--hcgpt-menu-shell-radius, var(--hcgpt-overlay-radius));
  box-shadow: var(--hcgpt-overlay-shadow);
  min-width: 120px;
  padding: var(--hcgpt-menu-shell-padding, 8px);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
  z-index: 100;
}

.hcgpt-sidebar-log-buttons .hcgpt-log-item.menu-open .hcgpt-log-menu-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.hcgpt-sidebar-log-buttons .hcgpt-log-item.menu-open .hcgpt-log-menu-btn {
  opacity: 1;
}

/* Menu items */
.hcgpt-sidebar-log-buttons .hcgpt-log-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: var(--hcgpt-menu-item-pad-y, 9px) var(--hcgpt-menu-item-pad-x, 12px);
  background: transparent;
  border: none;
  border-radius: var(--hcgpt-menu-item-radius, 8px);
  font-size: var(--hcgpt-menu-item-font-size, var(--hcgpt-font-size-13));
  font-weight: var(--hcgpt-menu-item-font-weight, var(--hcgpt-font-weight-medium));
  line-height: var(--hcgpt-menu-item-line-height, var(--hcgpt-line-height-120));
  font-family: var(--hcgpt-font-sans);
  font-style: normal;
  text-transform: var(--hcgpt-text-transform-none);
  color: var(--hcgpt-color-text);
  cursor: pointer;
  text-align: left;
  transition: background var(--hcgpt-transition-fast), color var(--hcgpt-transition-fast);
}

.hcgpt-sidebar-log-buttons .hcgpt-log-menu-item:hover {
  background: var(--hcgpt-menu-item-hover-bg, var(--hcgpt-overlay-item-hover-bg));
}

.hcgpt-sidebar-log-buttons .hcgpt-log-menu-item[data-action="delete"] {
  color: var(--hcgpt-danger);
}

.hcgpt-sidebar-log-buttons .hcgpt-log-menu-item[data-action="delete"]:hover {
  background: var(--hcgpt-menu-item-hover-bg, var(--hcgpt-overlay-item-hover-bg));
}

.hcgpt-sidebar-log-buttons .hcgpt-log-menu-item svg {
  flex-shrink: 0;
}

/* Load more button - nascosto ma presente nel DOM per infinite scroll */
#hcgpt-logs-more {
  height: 0;
  overflow: hidden;
  visibility: hidden;
  position: absolute;
}

/* === Skeleton Loading per Infinite Scroll === */
@keyframes hcgpt-skeleton-pulse {

  0%,
  100% {
    opacity: 0.4;
  }

  50% {
    opacity: 0.8;
  }
}

.hcgpt-chat-item-skeleton {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  gap: 10px;
  border-radius: var(--hcgpt-sidebar-item-radius, 24px);
}

.hcgpt-skeleton-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hcgpt-skeleton-title {
  height: 14px;
  background: linear-gradient(90deg, var(--hcgpt-color-surface-2) 25%, var(--hcgpt-color-surface) 50%, var(--hcgpt-color-surface-2) 75%);
  background-size: 200% 100%;
  border-radius: 4px;
  animation: hcgpt-skeleton-pulse 2s ease-in-out infinite;
}

.hcgpt-skeleton-title-1 {
  width: 85%;
}

.hcgpt-skeleton-title-2 {
  width: 70%;
}

.hcgpt-skeleton-title-3 {
  width: 90%;
}

.hcgpt-skeleton-action {
  width: 24px;
  height: 24px;
  background: var(--hcgpt-color-surface-2);
  border-radius: 50%;
  animation: hcgpt-skeleton-pulse 2s ease-in-out infinite;
  animation-delay: 0.3s;
}

/* Fade-in per elementi caricati */
.hcgpt-chat-item.hcgpt-fade-in {
  animation: hcgpt-fade-slide-in 0.6s ease-out forwards;
  opacity: 0;
}

@keyframes hcgpt-fade-slide-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Stagger delay per effetto cascade */
.hcgpt-chat-item.hcgpt-fade-in:nth-child(1) {
  animation-delay: 0ms;
}

.hcgpt-chat-item.hcgpt-fade-in:nth-child(2) {
  animation-delay: 30ms;
}

.hcgpt-chat-item.hcgpt-fade-in:nth-child(3) {
  animation-delay: 60ms;
}

.hcgpt-chat-item.hcgpt-fade-in:nth-child(4) {
  animation-delay: 90ms;
}

.hcgpt-chat-item.hcgpt-fade-in:nth-child(5) {
  animation-delay: 120ms;
}

.hcgpt-chat-item.hcgpt-fade-in:nth-child(6) {
  animation-delay: 150ms;
}

.hcgpt-chat-item.hcgpt-fade-in:nth-child(7) {
  animation-delay: 180ms;
}

.hcgpt-chat-item.hcgpt-fade-in:nth-child(8) {
  animation-delay: 210ms;
}

.hcgpt-chat-item.hcgpt-fade-in:nth-child(9) {
  animation-delay: 240ms;
}

.hcgpt-chat-item.hcgpt-fade-in:nth-child(10) {
  animation-delay: 270ms;
}

/* === Stili per il nuovo sistema con hcgpt-action-toggle-btn === */
/* Contenitore azioni delle chat */
.hcgpt-chat-actions {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
}

/* Bottone toggle menu 3 puntini - stile Gemini/ChatGPT */
.hcgpt-action-toggle-btn {
  background: transparent;
  border: none;
  padding: 6px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease, background 0.2s ease;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
}

/* Su hover del chat-item: mostra il bottone */
.hcgpt-chat-sidebar .hcgpt-chat-item:hover .hcgpt-action-toggle-btn {
  opacity: 1;
}

/* Hover sul bottone stesso: background grigio come sidebar */
.hcgpt-action-toggle-btn:hover {
  background: var(--hcgpt-sidebar-item-hover-bg);
}

/* Icona del menu (3 pallini) */
.hcgpt-menu-icon {
  color: var(--hcgpt-sidebar-item-text-muted);
  flex-shrink: 0;
}

.hcgpt-action-toggle-btn:hover .hcgpt-menu-icon {
  color: var(--hcgpt-sidebar-item-text);
}

/* Menu dropdown azioni */
.hcgpt-action-menu {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 4px;
  background: var(--hcgpt-overlay-bg);
  border: 1px solid var(--hcgpt-overlay-border);
  border-radius: var(--hcgpt-menu-shell-radius, var(--hcgpt-overlay-radius));
  box-shadow: var(--hcgpt-overlay-shadow);
  min-width: 160px;
  padding: var(--hcgpt-menu-shell-padding, 8px);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
  z-index: 100;
  display: flex;
  flex-direction: column;
}

/* Menu aperto - NASCOSTO perché usiamo il portal menu nel body */
.hcgpt-chat-sidebar .hcgpt-chat-item.menu-open .hcgpt-action-menu {
  /* Menu originale sempre nascosto - il portal menu è nel body */
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
}

.hcgpt-chat-sidebar .hcgpt-chat-item.menu-open .hcgpt-action-toggle-btn {
  opacity: 1;
}

/* === PORTAL MENU (rendered in body) === */
.hcgpt-portal-menu {
  position: fixed !important;
  background: var(--hcgpt-overlay-bg);
  border: 1px solid var(--hcgpt-overlay-border);
  border-radius: var(--hcgpt-menu-shell-radius, var(--hcgpt-overlay-radius));
  box-shadow: var(--hcgpt-overlay-shadow);
  min-width: 160px;
  padding: var(--hcgpt-menu-shell-padding, 8px);
  display: flex;
  flex-direction: column;
  z-index: 99999 !important;
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
  transform: none !important;
  overflow: hidden;
  /* Clip hover backgrounds */
}

.hcgpt-portal-menu .hcgpt-action-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: var(--hcgpt-menu-item-pad-y, 9px) var(--hcgpt-menu-item-pad-x, 12px);
  background: transparent;
  border: none;
  border-radius: var(--hcgpt-menu-item-radius, 8px);
  font-size: var(--hcgpt-menu-item-font-size, var(--hcgpt-font-size-13));
  font-weight: var(--hcgpt-menu-item-font-weight, var(--hcgpt-font-weight-medium));
  line-height: var(--hcgpt-menu-item-line-height, var(--hcgpt-line-height-120));
  font-family: var(--hcgpt-font-sans);
  font-style: normal;
  color: var(--hcgpt-color-text);
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  text-transform: var(--hcgpt-text-transform-none);
  transition: background var(--hcgpt-transition-fast), color var(--hcgpt-transition-fast);
}

.hcgpt-portal-menu .hcgpt-action-item:hover {
  background: var(--hcgpt-menu-item-hover-bg, var(--hcgpt-overlay-item-hover-bg));
  text-decoration: none;
}

.hcgpt-portal-menu .hcgpt-action-item.hcgpt-action-delete {
  color: var(--hcgpt-danger);
}

.hcgpt-portal-menu .hcgpt-action-item.hcgpt-action-delete:hover {
  background: var(--hcgpt-menu-item-hover-bg, var(--hcgpt-overlay-item-hover-bg));
}

.hcgpt-portal-menu .hcgpt-action-divider {
  height: 1px;
  background: var(--hcgpt-overlay-border);
  margin: 4px 0;
}

.hcgpt-portal-menu .hcgpt-action-icon {
  flex-shrink: 0;
}

/* Voci del menu */
.hcgpt-action-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: var(--hcgpt-menu-item-pad-y, 9px) var(--hcgpt-menu-item-pad-x, 12px);
  background: transparent;
  border: none;
  border-radius: var(--hcgpt-menu-item-radius, 8px);
  font-size: var(--hcgpt-menu-item-font-size, var(--hcgpt-font-size-13));
  font-weight: var(--hcgpt-menu-item-font-weight, var(--hcgpt-font-weight-medium));
  line-height: var(--hcgpt-menu-item-line-height, var(--hcgpt-line-height-120));
  font-family: var(--hcgpt-font-sans);
  font-style: normal;
  color: var(--hcgpt-color-text);
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  text-transform: var(--hcgpt-text-transform-none);
  transition: background var(--hcgpt-transition-fast), color var(--hcgpt-transition-fast);
}

.hcgpt-action-item:hover {
  background: var(--hcgpt-menu-item-hover-bg, var(--hcgpt-overlay-item-hover-bg));
  text-decoration: none;
}

.hcgpt-action-item.hcgpt-action-delete {
  color: var(--hcgpt-danger);
}

.hcgpt-action-item.hcgpt-action-delete:hover {
  background: var(--hcgpt-menu-item-hover-bg, var(--hcgpt-overlay-item-hover-bg));
}

.hcgpt-action-icon {
  flex-shrink: 0;
}

/* Separatore tra voci */
.hcgpt-action-divider {
  height: 1px;
  background: var(--hcgpt-overlay-border);
  margin: 4px 0;
}

/* === LOG ACTION MENU (non-chat pages) === */
body:not(.hcgpt-chat-page) .hcgpt-saved-chats-container .hcgpt-action-toggle-btn {
  background: transparent;
  border: none;
  color: #5f6368;
  padding: 5px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px !important;
  height: 32px !important;
  opacity: 1 !important;
  visibility: visible !important;
}

body:not(.hcgpt-chat-page) .hcgpt-saved-chats-container .hcgpt-action-toggle-btn:hover {
  background-color: rgba(0, 0, 0, 0.08);
}

body:not(.hcgpt-chat-page) .hcgpt-saved-chats-container .hcgpt-action-toggle-btn .hcgpt-menu-icon {
  width: 20px !important;
  height: 20px !important;
  stroke: #5f6368;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 1 !important;
  visibility: visible !important;
  display: block !important;
  flex-shrink: 0;
}

body:not(.hcgpt-chat-page) .hcgpt-saved-chats-container .hcgpt-action-toggle-btn .dashicons {
  display: none !important;
}

body:not(.hcgpt-chat-page) .hcgpt-saved-chats-container .hcgpt-action-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: #202124;
  font-size: var(--hcgpt-font-size-14);
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.2s ease;
}

body:not(.hcgpt-chat-page) .hcgpt-saved-chats-container .hcgpt-action-item:hover {
  background-color: #f1f3f4;
  color: #202124;
}

body:not(.hcgpt-chat-page) .hcgpt-saved-chats-container .hcgpt-action-item .hcgpt-action-icon {
  width: 16px !important;
  height: 16px !important;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
  opacity: 1 !important;
  visibility: visible !important;
  display: block !important;
}

body:not(.hcgpt-chat-page) .hcgpt-saved-chats-container .hcgpt-action-divider {
  height: 1px;
  background-color: #e8eaed;
  margin: 4px 0;
}

body:not(.hcgpt-chat-page) .hcgpt-saved-chats-container .hcgpt-action-delete,
body:not(.hcgpt-chat-page) .hcgpt-saved-chats-container .hcgpt-action-item.hcgpt-action-delete:hover {
  color: #d93025 !important;
}

body:not(.hcgpt-chat-page) .hcgpt-saved-chats-container .hcgpt-action-menu {
  display: none;
  position: absolute;
  top: 40px;
  right: -8px;
  left: auto;
  background-color: var(--hcgpt-surface);
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  z-index: 10002;
  min-width: 160px;
  width: auto;
  padding: 8px 0;
  overflow: visible;
  margin: 0;
  white-space: nowrap;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-family: var(--hcgpt-font-sans);
  font-weight: var(--hcgpt-font-weight-medium);
  font-style: normal;
  text-transform: var(--hcgpt-text-transform-none);
}

body:not(.hcgpt-chat-page) .hcgpt-saved-chats-container .hcgpt-action-menu:not(.hcgpt-portal-menu),
body:not(.hcgpt-chat-page) .hcgpt-saved-chats-container .hcgpt-action-menu.active:not(.hcgpt-portal-menu),
body:not(.hcgpt-chat-page) .hcgpt-saved-chats-container .hcgpt-chat-item .hcgpt-action-menu:not(.hcgpt-portal-menu),
body:not(.hcgpt-chat-page) .hcgpt-saved-chats-container .hcgpt-chat-item .hcgpt-action-menu.active:not(.hcgpt-portal-menu),
body:not(.hcgpt-chat-page) .hcgpt-saved-chats-container .hcgpt-chat-item.menu-open .hcgpt-action-menu:not(.hcgpt-portal-menu),
body:not(.hcgpt-chat-page) .hcgpt-saved-chats-container .hcgpt-chat-item.menu-open .hcgpt-action-menu.active:not(.hcgpt-portal-menu) {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

body:not(.hcgpt-chat-page) .hcgpt-portal-menu,
body:not(.hcgpt-chat-page) .hcgpt-portal-menu.hcgpt-action-menu,
body:not(.hcgpt-chat-page) > .hcgpt-portal-menu {
  display: flex !important;
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
}

body:not(.hcgpt-chat-page) .hcgpt-action-menu svg {
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  shape-rendering: geometricPrecision;
  text-rendering: optimizeLegibility;
}

@media screen and (-webkit-min-device-pixel-ratio: 0) {
  body:not(.hcgpt-chat-page) .hcgpt-action-toggle-btn .hcgpt-menu-icon,
  body:not(.hcgpt-chat-page) .hcgpt-action-item .hcgpt-action-icon {
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-perspective: 1000;
    perspective: 1000;
  }
}

body:not(.hcgpt-chat-page) .hcgpt-action-toggle-btn .hcgpt-menu-icon,
body:not(.hcgpt-chat-page) .hcgpt-action-item .hcgpt-action-icon {
  -moz-appearance: none;
  appearance: none;
}

body:not(.hcgpt-chat-page) .hcgpt-action-add-to-book {
  display: inline-block;
  margin-top: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  background: #f3f4f6;
  color: #111;
  text-decoration: none;
  border: 1px solid #e5e7eb;
  font-size: var(--hcgpt-font-size-12);
  line-height: var(--hcgpt-line-height-100);
  font-family: var(--hcgpt-font-sans);
  font-weight: var(--hcgpt-font-weight-regular);
  font-style: normal;
  text-transform: var(--hcgpt-text-transform-uppercase);
}

body:not(.hcgpt-chat-page) .hcgpt-action-add-to-book:hover {
  background: #e5e7eb;
}

body:not(.hcgpt-chat-page) .hcgpt-action-toggle-btn,
body:not(.hcgpt-chat-page) .hcgpt-action-toggle-btn * {
  box-sizing: border-box !important;
}

body:not(.hcgpt-chat-page) .hcgpt-action-toggle-btn .hcgpt-menu-icon {
  min-width: 20px !important;
  min-height: 20px !important;
  max-width: 20px !important;
  max-height: 20px !important;
  line-height: var(--hcgpt-line-height-100) !important;
  vertical-align: middle !important;
}

body:not(.hcgpt-chat-page) .hcgpt-action-item .hcgpt-action-icon {
  min-width: 16px !important;
  min-height: 16px !important;
  max-width: 16px !important;
  max-height: 16px !important;
  line-height: var(--hcgpt-line-height-100) !important;
  vertical-align: middle !important;
  margin-right: 0 !important;
}

@media screen and (-webkit-min-device-pixel-ratio: 0) and (min-resolution: .001dpcm) {
  body:not(.hcgpt-chat-page) .hcgpt-action-toggle-btn .hcgpt-menu-icon,
  body:not(.hcgpt-chat-page) .hcgpt-action-item .hcgpt-action-icon {
    will-change: transform;
    transform: translateZ(0);
  }
}

body:not(.hcgpt-chat-page) .hcgpt-saved-chats-container .hcgpt-chat-item {
  position: relative !important;
}

body:not(.hcgpt-chat-page) .hcgpt-saved-chats-container .hcgpt-chat-item::after,
body:not(.hcgpt-chat-page) .hcgpt-saved-chats-container .hcgpt-chat-item::before {
  display: none !important;
  content: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
}

body:not(.hcgpt-chat-page) :where(.hcgpt-scope[data-hcgpt-theme="dark"]) .hcgpt-action-menu,
body:not(.hcgpt-chat-page) :where(.hcgpt-scope[data-hcgpt-theme="dark"]) .hcgpt-portal-menu {
  background-color: var(--hcgpt-color-surface);
  border-color: var(--hcgpt-color-border-strong);
}

body:not(.hcgpt-chat-page) :where(.hcgpt-scope[data-hcgpt-theme="dark"]) .hcgpt-action-item {
  color: var(--hcgpt-color-text);
}

body:not(.hcgpt-chat-page) :where(.hcgpt-scope[data-hcgpt-theme="dark"]) .hcgpt-action-item:hover {
  background-color: var(--hcgpt-color-surface-3);
}

body:not(.hcgpt-chat-page) :where(.hcgpt-scope[data-hcgpt-theme="dark"]) .hcgpt-action-item.hcgpt-action-delete {
  color: var(--hcgpt-danger);
}

body:not(.hcgpt-chat-page) :where(.hcgpt-scope[data-hcgpt-theme="dark"]) .hcgpt-action-divider {
  background-color: var(--hcgpt-color-border);
}

body:not(.hcgpt-chat-page) :where(.hcgpt-scope[data-hcgpt-theme="dark"]) .hcgpt-action-toggle-btn {
  color: var(--hcgpt-color-text-muted);
}

body:not(.hcgpt-chat-page) :where(.hcgpt-scope[data-hcgpt-theme="dark"]) .hcgpt-action-toggle-btn:hover {
  background-color: var(--hcgpt-color-surface-2);
  color: var(--hcgpt-color-text);
}

body:not(.hcgpt-chat-page) :where(.hcgpt-scope[data-hcgpt-theme="dark"]) .hcgpt-action-toggle-btn .hcgpt-menu-icon {
  stroke: currentColor;
}

body:not(.hcgpt-chat-page) :where(.hcgpt-scope[data-hcgpt-theme="dark"]) .hcgpt-action-item .hcgpt-action-icon {
  stroke: currentColor;
}

body:not(.hcgpt-chat-page) :where(.hcgpt-scope[data-hcgpt-theme="dark"]) .hcgpt-action-add-to-book {
  background: var(--hcgpt-color-surface-2);
  color: var(--hcgpt-color-text);
  border-color: var(--hcgpt-color-border);
}

body:not(.hcgpt-chat-page) :where(.hcgpt-scope[data-hcgpt-theme="dark"]) .hcgpt-action-add-to-book:hover {
  background: var(--hcgpt-color-surface-3);
}

@media (prefers-color-scheme: dark) {
  body:not(.hcgpt-chat-page) :where(.hcgpt-scope[data-hcgpt-theme="system"]) .hcgpt-action-menu,
  body:not(.hcgpt-chat-page) :where(.hcgpt-scope[data-hcgpt-theme="system"]) .hcgpt-portal-menu {
    background-color: var(--hcgpt-color-surface);
    border-color: var(--hcgpt-color-border-strong);
  }

  body:not(.hcgpt-chat-page) :where(.hcgpt-scope[data-hcgpt-theme="system"]) .hcgpt-action-item {
    color: var(--hcgpt-color-text);
  }

  body:not(.hcgpt-chat-page) :where(.hcgpt-scope[data-hcgpt-theme="system"]) .hcgpt-action-item:hover {
    background-color: var(--hcgpt-color-surface-3);
  }

  body:not(.hcgpt-chat-page) :where(.hcgpt-scope[data-hcgpt-theme="system"]) .hcgpt-action-item.hcgpt-action-delete {
    color: var(--hcgpt-danger);
  }

  body:not(.hcgpt-chat-page) :where(.hcgpt-scope[data-hcgpt-theme="system"]) .hcgpt-action-divider {
    background-color: var(--hcgpt-color-border);
  }

  body:not(.hcgpt-chat-page) :where(.hcgpt-scope[data-hcgpt-theme="system"]) .hcgpt-action-toggle-btn {
    color: var(--hcgpt-color-text-muted);
  }

  body:not(.hcgpt-chat-page) :where(.hcgpt-scope[data-hcgpt-theme="system"]) .hcgpt-action-toggle-btn:hover {
    background-color: var(--hcgpt-color-surface-2);
    color: var(--hcgpt-color-text);
  }

  body:not(.hcgpt-chat-page) :where(.hcgpt-scope[data-hcgpt-theme="system"]) .hcgpt-action-toggle-btn .hcgpt-menu-icon {
    stroke: currentColor;
  }

  body:not(.hcgpt-chat-page) :where(.hcgpt-scope[data-hcgpt-theme="system"]) .hcgpt-action-item .hcgpt-action-icon {
    stroke: currentColor;
  }

  body:not(.hcgpt-chat-page) :where(.hcgpt-scope[data-hcgpt-theme="system"]) .hcgpt-action-add-to-book {
    background: var(--hcgpt-color-surface-2);
    color: var(--hcgpt-color-text);
    border-color: var(--hcgpt-color-border);
  }

  body:not(.hcgpt-chat-page) :where(.hcgpt-scope[data-hcgpt-theme="system"]) .hcgpt-action-add-to-book:hover {
    background: var(--hcgpt-color-surface-3);
  }
}

/* Adattamento per chat-item */
.hcgpt-chat-sidebar .hcgpt-chat-item {
  position: relative;
  display: flex;
  align-items: center;
  padding: 8px;
  border-radius: var(--hcgpt-sidebar-item-radius, 24px);
  cursor: pointer;
  color: var(--hcgpt-sidebar-item-text);
  transition: background 0.3s ease, color 0.2s ease, border-radius 0.2s ease;
}

.hcgpt-chat-sidebar .hcgpt-chat-item:hover {
  background: var(--hcgpt-menu-item-hover-bg, var(--hcgpt-overlay-item-hover-bg));
  border-radius: var(--hcgpt-menu-item-radius, 8px);
}

.hcgpt-chat-sidebar .hcgpt-chat-item.menu-open {
  border-radius: var(--hcgpt-menu-item-radius, 8px);
}

.hcgpt-chat-sidebar .hcgpt-chat-item--current {
  background: var(--hcgpt-menu-item-hover-bg, var(--hcgpt-overlay-item-hover-bg));
  border-radius: var(--hcgpt-menu-item-radius, 8px);
  box-shadow: none;
}

.hcgpt-chat-sidebar .hcgpt-chat-item--current:hover,
.hcgpt-chat-sidebar .hcgpt-chat-item--current:focus-visible {
  background: var(--hcgpt-menu-item-hover-bg, var(--hcgpt-overlay-item-hover-bg));
  border-radius: var(--hcgpt-menu-item-radius, 8px);
  box-shadow: none;
}

.hcgpt-chat-sidebar .hcgpt-chat-item--current .hcgpt-chat-title-text {
  font-weight: 400;
  color: var(--hcgpt-sidebar-item-text);
}

.hcgpt-chat-sidebar .hcgpt-chat-item:last-child {
  border-bottom: none;
}

.hcgpt-chat-sidebar .hcgpt-chat-title-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--hcgpt-font-sans);
  font-weight: 300;
  font-size: 13px;
  line-height: 1.4;
  margin: 0;
  padding-left: 4px;
  padding-right: 0;
  transition: padding-right 0.3s ease;
}

/* Su hover: titolo si accorcia per fare spazio al bottone */
.hcgpt-chat-sidebar .hcgpt-chat-item:hover .hcgpt-chat-title-text {
  padding-right: 32px;
}

/* Quando menu è aperto: titolo resta accorciato */
.hcgpt-chat-sidebar .hcgpt-chat-item.menu-open .hcgpt-chat-title-text {
  padding-right: 32px;
}

/* Lista chat */
.hcgpt-chats-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.hcgpt-chat-sidebar__bottom {
  margin-top: auto;
  padding-top: 4px;
  border-top: none;
  position: relative;
  z-index: 20;
  margin-bottom: 5px;
  margin-right: 0px;
  flex-shrink: 0;
  min-height: 60px;
}

.hcgpt-chat-sidebar[data-state="full"] .hcgpt-sidebar-log-buttons,
.hcgpt-chat-sidebar[data-state="mobile-open"] .hcgpt-sidebar-log-buttons {
  -webkit-mask-image: linear-gradient(to bottom,
      rgba(0, 0, 0, 1) 0%,
      rgba(0, 0, 0, 1) calc(100% - 14px),
      rgba(0, 0, 0, 0.76) calc(100% - 8px),
      rgba(0, 0, 0, 0) 100%);
  mask-image: linear-gradient(to bottom,
      rgba(0, 0, 0, 1) 0%,
      rgba(0, 0, 0, 1) calc(100% - 14px),
      rgba(0, 0, 0, 0.76) calc(100% - 8px),
      rgba(0, 0, 0, 0) 100%);
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
}

.hcgpt-chat-sidebar__user {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: transparent;
  border: none;
  border-top-left-radius: var(--hcgpt-menu-item-radius, 8px);
  border-bottom-left-radius: var(--hcgpt-menu-item-radius, 8px);
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  color: var(--hcgpt-sidebar-item-text);
  padding: 6px 4px;
  cursor: pointer;
  transition: background-color var(--hcgpt-transition-fast), color var(--hcgpt-transition-fast), border-radius var(--hcgpt-transition-fast);
  position: relative;
  text-align: left;
}

.hcgpt-chat-sidebar__user img {
  display: block;
  border-top-left-radius: 12px !important;
  border-bottom-left-radius: 12px !important;
  border-top-right-radius: 0 !important;
  border-bottom-right-radius: 0 !important;
  width: 36px !important;
  height: 36px !important;
  object-fit: cover;
}

.hcgpt-chat-sidebar[data-state="full"] .hcgpt-chat-sidebar__user,
.hcgpt-chat-sidebar[data-state="mobile-open"] .hcgpt-chat-sidebar__user {
  justify-content: flex-start;
  padding: var(--hcgpt-menu-item-pad-y, 9px) var(--hcgpt-menu-item-pad-x, 12px);
}

.hcgpt-chat-sidebar[data-state="full"] .hcgpt-chat-sidebar__user img,
.hcgpt-chat-sidebar[data-state="mobile-open"] .hcgpt-chat-sidebar__user img {
  width: 36px !important;
  height: 36px !important;
}

.hcgpt-chat-sidebar__user:hover,
.hcgpt-chat-sidebar__bottom.is-open .hcgpt-chat-sidebar__user {
  background: var(--hcgpt-menu-item-hover-bg, var(--hcgpt-overlay-item-hover-bg));
  color: var(--hcgpt-sidebar-item-text);
  text-decoration: none;
}

.hcgpt-chat-sidebar__user-info {
  display: none;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  line-height: 1.2;
  min-width: 0;
}

.hcgpt-chat-sidebar__user-name {
  display: none;
  color: var(--hcgpt-sidebar-item-text);
  font-weight: 400;
  text-decoration: none;
  font-size: 13px;
}

.hcgpt-user-plan {
  display: block;
  font-size: 11px;
  color: var(--hcgpt-sidebar-item-text-muted);
  font-weight: 300;
}

.hcgpt-chat-sidebar[data-state="full"] .hcgpt-chat-sidebar__user-info,
.hcgpt-chat-sidebar[data-state="mobile-open"] .hcgpt-chat-sidebar__user-info {
  display: flex;
}

.hcgpt-chat-sidebar[data-state="full"] .hcgpt-chat-sidebar__user-name,
.hcgpt-chat-sidebar[data-state="mobile-open"] .hcgpt-chat-sidebar__user-name {
  display: block;
}

.hcgpt-chat-sidebar__user-caret {
  margin-left: auto;
  margin-right: 18px;
  display: none;
  font-size: 18px;
  color: var(--hcgpt-sidebar-item-text-muted);
  flex-shrink: 0;
}

.hcgpt-chat-sidebar__user-caret svg {
  display: block;
  stroke: currentColor;
}

.hcgpt-chat-sidebar[data-state="full"] .hcgpt-chat-sidebar__user-caret,
.hcgpt-chat-sidebar[data-state="mobile-open"] .hcgpt-chat-sidebar__user-caret {
  display: inline;
}

/* User dropdown menu */
.hcgpt-user-dropdown {
  position: absolute;
  left: 50%;
  bottom: calc(100% - 4px);
  background-color: var(--hcgpt-overlay-bg, var(--hcgpt-sidebar-bg));
  color: var(--hcgpt-sidebar-item-text);
  border-radius: var(--hcgpt-menu-shell-radius, var(--hcgpt-overlay-radius));
  padding: var(--hcgpt-menu-shell-padding, 8px);
  min-width: 280px;
  max-width: 340px;
  box-shadow: none;
  display: block;
  z-index: 10020;
  border: 1px solid var(--hcgpt-overlay-border, var(--hcgpt-sidebar-divider));
  overflow: visible;
  box-sizing: border-box;
  opacity: 0;
  visibility: hidden;
  transform: translateX(-50%) translateY(6px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
}

.hcgpt-chat-sidebar__bottom.is-open .hcgpt-user-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.hcgpt-user-dropdown-item {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: var(--hcgpt-menu-item-pad-y, 9px) var(--hcgpt-menu-item-pad-x, 12px);
  border-radius: var(--hcgpt-menu-item-radius, 8px);
  font-size: var(--hcgpt-menu-item-font-size, var(--hcgpt-font-size-13));
  line-height: var(--hcgpt-menu-item-line-height, var(--hcgpt-line-height-120));
  cursor: pointer;
  border: 0;
  width: 100%;
  background: transparent;
  color: var(--hcgpt-sidebar-item-text);
  text-align: left;
  font-family: var(--hcgpt-font-sans);
  font-weight: var(--hcgpt-menu-item-font-weight, var(--hcgpt-font-weight-medium));
  font-style: normal;
  text-transform: var(--hcgpt-text-transform-none);
  transition: background-color var(--hcgpt-transition-fast), color var(--hcgpt-transition-fast);
}

/* Apply hover background only to items WITHOUT children */
.hcgpt-user-dropdown-item:not(.hcgpt-user-dropdown-item--has-children):hover {
  background-color: var(--hcgpt-menu-item-hover-bg, var(--hcgpt-sidebar-item-hover-bg));
  color: var(--hcgpt-sidebar-item-text);
}

.hcgpt-user-dropdown-label {
  flex: 1 1 auto;
  min-width: 0;
}

.hcgpt-user-dropdown-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: var(--hcgpt-sidebar-item-text);
  overflow: visible;
}

.hcgpt-user-dropdown-icon svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
  display: block;
  flex-shrink: 0;
}

/* Ensure all icon font icons in dropdown are visible (Themify, LineAwesome, FontAwesome) */
.hcgpt-user-dropdown-icon i,
.hcgpt-user-dropdown-icon .tf-icon,
.hcgpt-user-dropdown-icon [class^="ti-"],
.hcgpt-user-dropdown-icon [class*=" ti-"],
.hcgpt-user-dropdown-icon [class^="la-"],
.hcgpt-user-dropdown-icon [class*=" la-"],
.hcgpt-user-dropdown-icon [class^="fa-"],
.hcgpt-user-dropdown-icon [class*=" fa-"],
.hcgpt-user-dropdown-icon [class^="fontello-"],
.hcgpt-user-dropdown-icon [class*=" fontello-"] {
  font-size: 18px !important;
  line-height: 1 !important;
  display: inline-block !important;
  width: 18px !important;
  height: 18px !important;
  text-align: center !important;
}

.hcgpt-user-dropdown-divider {
  height: 1px;
  margin: 6px 0;
  background: var(--hcgpt-overlay-border, var(--hcgpt-sidebar-divider));
}

/* User dropdown header */
.hcgpt-user-dropdown-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--hcgpt-sidebar-divider);
  margin-bottom: 8px;
}

.hcgpt-user-dropdown-header img {
  width: 40px !important;
  height: 40px !important;
  border-top-left-radius: 12px !important;
  border-bottom-left-radius: 12px !important;
  border-top-right-radius: 0 !important;
  border-bottom-right-radius: 0 !important;
  object-fit: cover;
  flex-shrink: 0;
}

.hcgpt-user-dropdown-header-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.hcgpt-user-dropdown-header-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--hcgpt-sidebar-item-text);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hcgpt-user-dropdown-header-plan {
  font-size: 12px;
  color: var(--hcgpt-sidebar-item-text-muted);
  line-height: 1.3;
}

/* Menu separator */
.hcgpt-menu-separator {
  position: relative;
  border-top: 0;
  margin-top: 8px;
  /* Keep separator line + preserve normal item height */
  padding-top: var(--hcgpt-menu-item-pad-y, 9px);
}

.hcgpt-menu-separator::before {
  content: '';
  position: absolute;
  left: 12px;
  right: 12px;
  top: 0;
  height: 1px;
  background: var(--hcgpt-overlay-border, var(--hcgpt-sidebar-divider));
}

/* Widget item (for language selector, etc.) */
.hcgpt-user-dropdown-widget {
  flex: 1 1 auto;
  min-width: 0;
}

.hcgpt-widget-item {
  cursor: default;
}

.hcgpt-widget-item:hover {
  background-color: transparent !important;
}

/* TranslatePress language selector styling */
.hcgpt-user-dropdown-widget .trp-language-switcher,
.hcgpt-user-dropdown-widget .trp-ls-shortcode-language {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Ensure all TranslatePress images are visible */
.hcgpt-user-dropdown-widget img,
.hcgpt-user-dropdown-widget img.trp-flag-image,
.hcgpt-user-dropdown-widget img.trp-flag-rounded {
  display: inline-block !important;
  width: 18px !important;
  height: 14px !important;
  border-radius: 2px;
  object-fit: cover;
  vertical-align: middle;
  margin-right: 6px;
}

.hcgpt-user-dropdown-widget .trp-ls-shortcode-current-language {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--hcgpt-sidebar-item-text);
}

/* TranslatePress menu label with flag */
.hcgpt-user-dropdown-widget .trp-menu-ls-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.hcgpt-user-dropdown-widget a {
  color: var(--hcgpt-sidebar-item-text);
  text-decoration: none;
  transition: color 0.15s ease;
}

.hcgpt-user-dropdown-widget a:hover {
  color: var(--hcgpt-accent);
}

/* Custom language switcher styling */
.hcgpt-language-switcher {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}

.hcgpt-lang-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  color: var(--hcgpt-sidebar-item-text);
  text-decoration: none;
  transition: background-color 0.15s ease;
  cursor: pointer;
}

.hcgpt-lang-item:hover {
  background-color: var(--hcgpt-sidebar-item-hover-bg);
  color: var(--hcgpt-sidebar-item-text);
}

.hcgpt-lang-item.hcgpt-lang-current {
  background-color: var(--hcgpt-sidebar-item-selected-bg);
  font-weight: 500;
}

.hcgpt-lang-flag {
  width: 18px !important;
  height: 14px !important;
  border-radius: 2px;
  object-fit: cover;
  flex-shrink: 0;
}

.hcgpt-lang-name {
  font-size: 14px;
  line-height: 1.4;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hcgpt-user-dropdown-item--has-children {
  position: relative;
  padding: 0;
  /* Remove padding from parent to avoid double padding */
  width: 100%;
}

.hcgpt-user-dropdown-item-main {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1 1 auto;
  padding: var(--hcgpt-menu-item-pad-y, 9px) var(--hcgpt-menu-item-pad-x, 12px);
  border-radius: var(--hcgpt-menu-item-radius, 8px);
  width: 100%;
  transition: background-color var(--hcgpt-transition-fast), color var(--hcgpt-transition-fast);
}

.hcgpt-user-dropdown-caret {
  color: var(--hcgpt-color-text-muted);
  font-size: 14px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  /* Fixed width to prevent overflow */
  height: 14px;
  margin-left: auto;
}

.hcgpt-user-dropdown-caret svg {
  display: block;
  stroke: currentColor;
}

.hcgpt-user-dropdown-item--has-children {
  overflow: visible;
}

.hcgpt-user-dropdown-item--has-children.is-submenu-open .hcgpt-user-dropdown-item-main,
.hcgpt-user-dropdown-item--has-children:hover .hcgpt-user-dropdown-item-main {
  background: var(--hcgpt-menu-item-hover-bg, var(--hcgpt-sidebar-item-hover-bg));
  border-radius: var(--hcgpt-menu-item-radius, 8px);
}

.hcgpt-user-dropdown-submenu {
  position: absolute;
  left: calc(100% + 8px);
  bottom: 0;
  background: var(--hcgpt-overlay-bg, var(--hcgpt-sidebar-bg));
  border-radius: var(--hcgpt-menu-shell-radius, var(--hcgpt-overlay-radius));
  padding: var(--hcgpt-menu-shell-padding, 8px);
  min-width: 190px;
  max-width: 240px;
  box-shadow: var(--hcgpt-shadow-lg);
  border: 1px solid var(--hcgpt-overlay-border, var(--hcgpt-sidebar-divider));
  opacity: 0;
  visibility: hidden;
  transform: translateX(-8px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  z-index: 60;
  overflow: hidden;
}

.hcgpt-user-dropdown-item--has-children.is-submenu-open .hcgpt-user-dropdown-submenu {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
}

.hcgpt-user-dropdown-submenu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: var(--hcgpt-menu-item-pad-y, 9px) var(--hcgpt-menu-item-pad-x, 12px);
  border-radius: var(--hcgpt-menu-item-radius, 8px);
  font-size: var(--hcgpt-menu-item-font-size, var(--hcgpt-font-size-13));
  font-weight: var(--hcgpt-menu-item-font-weight, var(--hcgpt-font-weight-medium));
  line-height: var(--hcgpt-menu-item-line-height, var(--hcgpt-line-height-120));
  font-family: var(--hcgpt-font-sans);
  font-style: normal;
  color: var(--hcgpt-sidebar-item-text);
  text-decoration: none;
  text-transform: var(--hcgpt-text-transform-none);
  transition: background-color var(--hcgpt-transition-fast), color var(--hcgpt-transition-fast);
  margin: 0;
  box-sizing: border-box;
}

.hcgpt-user-dropdown-submenu-item:hover {
  background: var(--hcgpt-menu-item-hover-bg, var(--hcgpt-sidebar-item-hover-bg));
  color: var(--hcgpt-sidebar-item-text);
}

@media (max-width: 767.98px) {
  .hcgpt-user-dropdown {
    left: auto;
    right: 16px;
    transform: translateY(6px);
  }

  .hcgpt-chat-sidebar__bottom.is-open .hcgpt-user-dropdown {
    transform: translateY(0);
  }
}

/* Desktop (>768px): gutter condivisa per messaggi e input */
@media (min-width: 768px) {

  /* Shell messaggi: padding sinistro = sidebar + gutter */
  .hcgpt-chat-layout .hcgpt-shell {
    padding-left: var(--hcgpt-chat-gutter-left);
    padding-right: var(--hcgpt-chat-gutter-right);
  }

  /* Input: allineato orizzontalmente alla shell */
  #hcgpt-unified-chat-wrapper .hcgpt-chatbox-input-container {
    left: var(--hcgpt-app-main-left, 0px);
    right: var(--hcgpt-app-main-right, 0px);
    padding-left: calc(var(--hcgpt-col-gutter-x, 12px) + var(--hcgpt-chat-shell-pad, 0px) + env(safe-area-inset-left, 0px));
    padding-right: calc(var(--hcgpt-col-gutter-x, 12px) + var(--hcgpt-chat-shell-pad, 0px) + env(safe-area-inset-right, 0px));
    box-sizing: border-box;
  }
}

@media (max-width: 767.98px) {

  /* Hamburger menu mobile - top-left */
  .hcgpt-mobile-sidebar-toggle {
    position: fixed;
    top: calc(var(--hcgpt-admin-offset, 0px) + (var(--hcgpt-topbar-row-min-h, 56px) - var(--hcgpt-topbar-control-h, 36px)) / 2);
    left: calc(var(--hcgpt-topbar-pad-x, var(--hcgpt-space-4, 16px)));
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: var(--hcgpt-sidebar-bg);
    border: 1px solid var(--hcgpt-sidebar-divider);
    border-radius: 12px;
    box-shadow: none;
    cursor: pointer;
    transition: transform 0.18s ease, background 0.2s ease;
    padding: 0;
    color: var(--hcgpt-sidebar-item-text);
    appearance: none;
    -webkit-appearance: none;
  }

  .hcgpt-mobile-sidebar-toggle:hover {
    background: var(--hcgpt-sidebar-bg);
    box-shadow: none !important;
    color: var(--hcgpt-sidebar-item-text);
    transform: translateY(-1px);
  }

  .hcgpt-mobile-hamburger-icon {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    flex-shrink: 0;
  }

  /* Sidebar mobile: Slide-in animation */
  .hcgpt-chat-sidebar,
  .hcgpt-chat-sidebar[data-state="mini"],
  .hcgpt-chat-sidebar[data-state="full"] {
    display: flex !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    height: 100% !important;
    width: var(--hcgpt-sidebar-full-width, 260px) !important;
    max-width: min(85vw, var(--hcgpt-sidebar-full-width, 260px)) !important;
    padding: 0 15px !important;
    margin: 0 !important;
    z-index: 999;
    border-radius: 0;
    border-right: 0;
    background: var(--hcgpt-sidebar-bg);
    /* Nascosta fuori schermo a sinistra */
    transform: translateX(-100%);
    visibility: hidden;
    /* Transizione smooth per slide-in */
    transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1),
      visibility 0.32s ease;
  }

  .hcgpt-chat-sidebar[data-state="mobile-open"] {
    transform: translateX(0);
    visibility: visible;
  }

  /* Nascondi hamburger quando sidebar è aperta */
  .hcgpt-mobile-sidebar-toggle.is-sidebar-open,
  body:has(.hcgpt-chat-sidebar[data-state="mobile-open"]) .hcgpt-mobile-sidebar-toggle {
    display: none !important;
  }

  /* Overlay per chiudere sidebar su mobile - sempre presente ma invisibile */
  .hcgpt-sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.32s cubic-bezier(0.32, 0.72, 0, 1),
      visibility 0.32s ease;
  }

  .hcgpt-sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  /* Reset variabile gutter per mobile – niente offset sidebar */
  .hcgpt-chat-layout {
    --hcgpt-chat-gutter-left: 0px;
    --hcgpt-sidebar-width: 0px;
    --hcgpt-chat-gutter-right: 0px;
    --hcgpt-app-main-left: 0px;
    --hcgpt-app-main-right: 0px;
    --hcgpt-messages-max-width: 100%;
    --hcgpt-messages-margin-inline: 0;
    --hcgpt-input-box-max-width: 100%;
    --hcgpt-input-box-margin-inline: 0;
    --hcgpt-chatbox-input-pad-left: calc(var(--hcgpt-col-gutter-x, 12px) + var(--hcgpt-chat-shell-pad, 0px) + env(safe-area-inset-left, 0px));
    --hcgpt-chatbox-input-pad-right: calc(var(--hcgpt-col-gutter-x, 12px) + var(--hcgpt-chat-shell-pad, 0px) + env(safe-area-inset-right, 0px));
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: none !important;
    min-width: 100% !important;
  }

  .hcgpt-chat-layout-main,
  #hcgpt-unified-chat-wrapper {
    --hcgpt-app-main-left: 0px;
    --hcgpt-app-main-right: 0px;
    --hcgpt-messages-max-width: 100%;
    --hcgpt-messages-margin-inline: 0;
    --hcgpt-input-box-max-width: 100%;
    --hcgpt-input-box-margin-inline: 0;
    --hcgpt-chatbox-input-pad-left: calc(var(--hcgpt-col-gutter-x, 12px) + var(--hcgpt-chat-shell-pad, 0px) + env(safe-area-inset-left, 0px));
    --hcgpt-chatbox-input-pad-right: calc(var(--hcgpt-col-gutter-x, 12px) + var(--hcgpt-chat-shell-pad, 0px) + env(safe-area-inset-right, 0px));
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: none !important;
    /* Sovrascrive limiti del builder */
    min-width: 100% !important;
  }

  /* Forza i wrapper del builder a non limitare la larghezza */
  .tb_text_wrap:has(.hcgpt-chat-layout),
  .module-plain-text:has(.hcgpt-chat-layout),
  .module_column:has(.hcgpt-chat-layout),
  .row_inner:has(.hcgpt-chat-layout),
  .themify_builder_row:has(.hcgpt-chat-layout) {
    max-width: none !important;
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  /* Shell: full-width, nessun padding orizzontale */
  #hcgpt-unified-chat-wrapper .hcgpt-shell,
  .hcgpt-chat-layout .hcgpt-shell {
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    margin-left: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    box-sizing: border-box !important;
  }

  /* Chat container e messaggi: nessun offset */
  .hcgpt-personalized-chat,
  #hcgpt-chat-container,
  .hcgpt-chat-container {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
.hcgpt-chat-container {
    font-family: var(--hcgpt-font-sans);
    font-weight: var(--hcgpt-font-weight-thin);
    font-style: normal;
}


  /* Suggerimenti: posizionamento corretto - NO width, usa left/right */
  #hcgpt-suggestions-box.suggestion-float,
  #hcgpt-unified-chat-wrapper #hcgpt-suggestions-box.suggestion-float,
  .hcgpt-chatbox-input-container #hcgpt-suggestions-box.suggestion-float {
    position: absolute !important;
    margin: 0 !important;
    padding: 10px 0 10px 0 !important;
    /* NO padding orizzontale - il contenitore già ce l'ha */
    left: 0 !important;
    right: 0 !important;
    /* width RIMOSSO - left/right calcolano la larghezza */
    max-width: none !important;
    box-sizing: border-box !important;
    transform: none !important;
    scroll-padding-left: 0 !important;
    --hcgpt-chat-gutter-left: 0px !important;
    --hcgpt-chat-gutter-right: 0px !important;
  }

  /* Prima suggestion card: margine ZERO */
  #hcgpt-suggestions-box.suggestion-float .suggestion-card:first-child,
  #hcgpt-unified-chat-wrapper .suggestion-card:first-child,
  .suggestion-card:first-child {
    margin-left: 0 !important;
    scroll-margin-left: 0 !important;
    transform: none !important;
  }

  /* Tutte le suggestion cards: reset completo */
  #hcgpt-suggestions-box.suggestion-float .suggestion-card,
  .suggestion-card {
    margin-left: 0 !important;
    margin-right: 10px !important;
    transform: none !important;
    flex-shrink: 0 !important;
  }
.suggestion-card {
    font-family: var(--hcgpt-font-sans);
    font-weight: var(--hcgpt-font-weight-thin);
    font-style: normal;
}


  /* Ultima card: nessun margin destro */
  #hcgpt-suggestions-box.suggestion-float .suggestion-card:last-child {
    margin-right: 0 !important;
  }

  #hcgpt-suggestions-container {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
  }
}

/* Desktop: nascondi hamburger */
@media (min-width: 768px) {
  .hcgpt-mobile-sidebar-toggle {
    display: none !important;
  }

  .hcgpt-sidebar-overlay {
    display: none !important;
  }
}


/* Sidebar offset when WP Admin Bar is visible */
body.admin-bar .hcgpt-chat-sidebar {
  top: 32px;
  height: calc(100vh - 32px);
  max-height: calc(100vh - 32px);
}

/* mobile admin bar */
@media screen and (max-width: 782px) {
  body.admin-bar .hcgpt-chat-sidebar {
    top: 0;
    height: 100vh;
    max-height: 100vh;
    padding-top: 46px;
  }
}

/* Adjust the main wrapper to avoid overflow */
body.admin-bar .hcgpt-chat-layout-main {
  min-height: 0;
  padding-top: 0;
}

@media screen and (max-width: 782px) {
  body.admin-bar .hcgpt-chat-layout-main {
    min-height: 0;
    padding-top: 0;
  }
}

/* === SIDEBAR OVERFLOW CONTROL === */
.hcgpt-chat-sidebar {
  overflow: visible;
}

/* Hide scrollbars on sidebar (all browsers) */
.hcgpt-chat-sidebar::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.hcgpt-chat-sidebar {
  scrollbar-width: none;
  /* Firefox */
  -ms-overflow-style: none;
  /* IE and Edge */
}

/* === FIX WORDPRESS ADMIN BAR SCROLL === */
/* Forza l'Admin Bar di WordPress a rimanere fissa */
#wpadminbar {
  position: fixed !important;
}

/* ══════════════════════════════════════════════════════════
   ACADEMY VIEW — Sidebar content swap
   When data-view="academy", hide chat-specific sections
   and show Academy navigation instead.
   ══════════════════════════════════════════════════════════ */

/* Default: Academy nav hidden */
.hcgpt-sidebar-academy-nav {
  display: none;
}

/* When Academy view is active: swap content */
.hcgpt-app-shell[data-view="academy"] .hcgpt-sidebar-recent-clients,
.hcgpt-app-shell[data-view="academy"] .hcgpt-sidebar-chat-history {
  display: none;
}

.hcgpt-app-shell[data-view="academy"] .hcgpt-sidebar-academy-nav {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

/* Sidebar nav items disabled during onboarding/welcome (no course started yet) */
/* Academy sidebar menu items */
.hcgpt-sidebar-academy-menu {
  display: flex;
  flex-direction: column;
  padding: 10px 8px 8px;
  gap: 4px;
}

.hcgpt-sidebar-academy-item {
  font: inherit;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--hcgpt-color-text-secondary, #9ca3af);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: normal;
  cursor: pointer;
  text-transform: none;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
  text-align: left;
  width: 100%;
}

.hcgpt-sidebar-academy-item:hover {
  background: color-mix(in srgb, var(--hcgpt-color-surface-2, #1f2937) 84%, transparent);
  color: var(--hcgpt-color-text, #f9fafb);
  border-color: var(--hcgpt-color-border, #374151);
  transform: translateY(-1px);
}

.hcgpt-sidebar-academy-item.is-active {
  background: color-mix(in srgb, var(--hcgpt-color-surface-2, #1f2937) 92%, transparent);
  color: var(--hcgpt-color-text, #f9fafb);
  border-color: var(--hcgpt-color-border, #374151);
}

.hcgpt-sidebar-academy-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

/* Sidebar collapsed: hide labels */
.hcgpt-chat-sidebar[data-state="mini"] .hcgpt-sidebar-academy-item span:not(.hcgpt-sidebar-academy-icon) {
  display: none;
}

.hcgpt-chat-sidebar[data-state="mini"] .hcgpt-sidebar-academy-item {
  justify-content: center;
  padding: 10px 8px;
}

.hcgpt-chat-sidebar[data-state="mini"] .hcgpt-sidebar-academy-outline {
  display: none;
}

/* Academy course outline */
.hcgpt-sidebar-academy-outline {
  padding: 12px;
  border-top: 1px solid var(--hcgpt-color-border, #374151);
}

.hcgpt-sidebar-academy-outline-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--hcgpt-color-text-secondary, #9ca3af);
  margin: 0 0 10px 0;
  padding: 0;
}

/* Lesson items in course outline */
.hcgpt-sidebar-academy-lesson {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--hcgpt-color-text-secondary, #9ca3af);
  transition: background 0.15s ease, border-color 0.15s ease;
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
  width: 100%;
  font-family: inherit;
}

.hcgpt-sidebar-academy-lesson:hover {
  background: color-mix(in srgb, var(--hcgpt-color-surface-2, #1f2937) 84%, transparent);
  border-color: var(--hcgpt-color-border, #374151);
}

.hcgpt-sidebar-academy-lesson.is-active {
  background: color-mix(in srgb, var(--hcgpt-color-surface-2, #1f2937) 92%, transparent);
  color: var(--hcgpt-color-text, #f9fafb);
  font-weight: 600;
  border-color: var(--hcgpt-color-border, #374151);
}

.hcgpt-sidebar-academy-lesson.is-locked {
  opacity: 0.5;
  cursor: default;
}

.hcgpt-sidebar-academy-lesson-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 2px;
}

/* Academy sidebar historical styling restore.
   Keeps the new Course Outline behavior but returns to the denser pre-redesign look. */
.hcgpt-sidebar-academy-menu {
  display: flex;
  flex-direction: column;
  padding: 8px;
  gap: 2px;
}

.hcgpt-sidebar-academy-item {
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  border: none;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--hcgpt-color-text-secondary, #9ca3af);
  background: transparent;
  box-shadow: none;
  transform: none;
}

.hcgpt-sidebar-academy-item:hover {
  background: var(--hcgpt-color-surface-2, #1f2937);
  color: var(--hcgpt-color-text, #f9fafb);
  border-color: transparent;
  transform: none;
}

.hcgpt-sidebar-academy-item.is-active {
  background: var(--hcgpt-color-surface-2, #1f2937);
  color: var(--hcgpt-color-text, #f9fafb);
  border-color: transparent;
  font-weight: 600;
}

.hcgpt-chat-sidebar[data-state="mini"] .hcgpt-sidebar-academy-item {
  padding: 8px;
}

.hcgpt-sidebar-academy-outline {
  padding: 8px 12px;
  border-top: 1px solid var(--hcgpt-color-border, #374151);
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}

.hcgpt-sidebar-academy-outline:hover {
  scrollbar-color: color-mix(in srgb, var(--hcgpt-color-text-secondary, #9ca3af) 30%, transparent) transparent;
}

.hcgpt-sidebar-academy-outline::-webkit-scrollbar {
  width: 4px;
}

.hcgpt-sidebar-academy-outline::-webkit-scrollbar-track {
  background: transparent;
}

.hcgpt-sidebar-academy-outline::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 4px;
}

.hcgpt-sidebar-academy-outline:hover::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--hcgpt-color-text-secondary, #9ca3af) 30%, transparent);
}

.hcgpt-sidebar-academy-outline-title {
  margin: 0 0 8px;
  padding: 0;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.hcgpt-sidebar-academy-lesson {
  gap: 6px;
  padding: 6px 8px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-size: 0.8125rem;
  line-height: 1.4;
}

.hcgpt-sidebar-academy-lesson:hover {
  background: var(--hcgpt-color-surface-2, #1f2937);
  border-color: transparent;
}

.hcgpt-sidebar-academy-lesson.is-active {
  background: var(--hcgpt-color-surface-2, #1f2937);
  border-color: transparent;
  color: var(--hcgpt-color-text, #f9fafb);
  font-weight: 600;
}
