/* ========================================
   Sidebar Header (widgetLayout-based)
   Independent from existing header CSS.
   ======================================== */

/* Base header layout */
.sidebar-header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 56px;
  background-color: #fff;
  box-shadow: 0px 3px 11px -5px rgba(0, 0, 0, 0.51);
  z-index: 9999;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  box-sizing: border-box;
}

/* Header visibility - controlled by html class set in inline <head> script.
   !important ensures this wins over the base layout display:flex above. */
.sidebar-header {
  display: none !important;
}

html.header-mode-new .sidebar-header {
  display: flex !important;
}

html.header-mode-new .s1-header#chat-gpt-header {
  visibility: hidden !important;
  pointer-events: none !important;
  height: 56px !important;
}

/* Logo */
.sidebar-header__logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.sidebar-header__logo img {
  height: 40px;
  width: auto;
  max-width: 100%;
}

/* User info (shown when logged in) */
.sidebar-header__user {
  display: none;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  margin-right: 8px;
  min-width: 0;
  overflow: hidden;
}

.sidebar-header__user.visible {
  display: flex;
}

.sidebar-header__user img {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sidebar-header__user-text {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
  min-width: 0;
  line-height: 1.4;
}

.sidebar-header__user-name {
  font-size: 12px;
  font-weight: 400;
  color: #606060;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  text-decoration: underline;
  text-underline-position: from-font;
  text-decoration-skip-ink: none;
}

.sidebar-header__user-suffix {
  font-size: 10px;
  font-weight: 400;
  color: #606060;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Right side buttons */
.sidebar-header__actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Button base */
.sidebar-header__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  -webkit-tap-highlight-color: transparent;
}

.sidebar-header__btn:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.sidebar-header__btn img {
  display: block;
  width: 24px;
  height: 24px;
}

.sidebar-header__btn--expand img,
.sidebar-header__btn--collapse img {
  width: 14px;
  height: 14px;
}

.sidebar-header__btn--close img {
  width: 20px;
  height: 20px;
}

/* Expand/Collapse button visibility:
   - widgetLayout=floating or sidebar: never show expand/collapse
   - widgetLayout=expandable: show expand (initial floating state) or collapse (sidebar state) */
.sidebar-header__btn--expand,
.sidebar-header__btn--collapse {
  display: none !important;
}

html.sidebar-widget-expandable.sidebar-state-floating .sidebar-header__btn--expand {
  display: flex !important;
}

html.sidebar-widget-expandable.sidebar-state-sidebar .sidebar-header__btn--collapse {
  display: flex !important;
}

/* ========================================
   Dropdown Menu
   ======================================== */

.sidebar-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 8px;
  min-width: 200px;
  max-width: 300px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  z-index: 10001;
  overflow: hidden;
  flex-direction: column;
  padding: 4px 0;
}

.sidebar-dropdown.open {
  display: flex;
}

/* Dropdown item */
.sidebar-dropdown__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  font-size: 14px;
  color: #333;
  text-decoration: none;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

.sidebar-dropdown__item:hover {
  background-color: #f5f5f5;
}

.sidebar-dropdown__item img {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.sidebar-dropdown__item-text {
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

.sidebar-dropdown__item-arrow {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.5;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-dropdown__item-arrow svg {
  width: 16px;
  height: 16px;
}

/* Divider (before logout item) */
.sidebar-dropdown__divider {
  height: 1px;
  background-color: #e0e0e0;
  margin: 4px 0;
}

/* Dropdown sub-panel (Language list) */
.sidebar-dropdown__back {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  cursor: pointer;
  font-size: 14px;
  color: #333;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

.sidebar-dropdown__back:hover {
  background-color: #f5f5f5;
}

.sidebar-dropdown__back svg {
  width: 16px;
  height: 16px;
  transform: rotate(180deg);
}

.sidebar-dropdown__back-text {
  font-weight: 500;
}

.sidebar-dropdown__lang-item {
  display: flex;
  align-items: center;
  padding: 10px 16px 10px 40px;
  cursor: pointer;
  font-size: 14px;
  color: #333;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

.sidebar-dropdown__lang-item:hover {
  background-color: #f5f5f5;
}

/* ========================================
   Active Language Highlight
   ======================================== */

.sidebar-dropdown__lang-item.active {
  color: #FF008C;
  background-color: rgba(255, 0, 140, 0.06);
  font-weight: 500;
}

.sidebar-dropdown__lang-item.active:hover {
  background-color: rgba(255, 0, 140, 0.1);
}

.sidebar-dropdown__lang-check {
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-dropdown__lang-check svg {
  width: 16px;
  height: 16px;
}

/* ========================================
   Dropdown Footer
   ======================================== */

.sidebar-dropdown__footer {
  position: static;
  width: auto;
  margin: 0 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 6px 8px;
  box-sizing: border-box;
}

.sidebar-dropdown__footer-divider {
  width: 100%;
  height: 1px;
  background-color: #e6e6e6;
}

.sidebar-dropdown__footer-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4.82px;
  width: 111.66px;
  height: 21.6px;
}

.sidebar-dropdown__footer-logo-text {
  font-family: 'Noto Sans JP', sans-serif !important;
  font-size: 7px;
  font-weight: 400;
  line-height: 1;
  color: #000;
  white-space: nowrap;
}

.sidebar-dropdown__footer-logo-image {
  display: block;
  width: 68.4px;
  height: 20.16px;
}

.sidebar-dropdown__footer-copyright {
  width: 158px;
  margin: 0;
  font-family: 'Noto Sans JP', sans-serif !important;
  font-size: 7px !important;
  font-weight: 400;
  line-height: 1.5;
  color: #a3a3a3;
  text-align: center;
}
