/* === Sidebar === */

.sidebar {
  position: fixed;
  top: var(--sidebar-top);
  left: var(--sidebar-left);
  width: var(--sidebar-width);
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: var(--z-sidebar);
  background-color: #FAFAFA; /* Light gray background matching screenshot */
  overflow: hidden; /* Changed from visible to prevent content squishing during transition */
  transition: width 0.5s cubic-bezier(0.16, 1, 0.3, 1), transform 0.5s ease;
}

.sidebar.is-collapsed {
  width: 100px;
}

.sidebar__inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 48px 24px 32px; /* Top, horizontal, bottom padding */
  width: 100%;
  min-width: var(--sidebar-width); /* Maintain width to prevent text squishing */
  overflow: hidden; /* Prevent double scrollbars, rely on Deep Chat internal scroll */
  transition: padding 0.5s ease;
}

.sidebar__inner::-webkit-scrollbar {
  display: none;
}

.sidebar.is-collapsed .sidebar__inner {
  padding: 48px 24px 32px;
}

/* --- Header --- */
.sidebar__header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px; /* Reduced margin to give more space to chat */
  position: relative;
  flex-shrink: 0; /* Prevent header from shrinking */
}

.sidebar.is-collapsed .sidebar__header {
  flex-direction: column;
  align-items: flex-start;
  gap: 24px;
}

.sidebar__avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background-color: var(--color-surface);
  overflow: hidden;
  flex-shrink: 0;
  transition: width 0.3s ease, height 0.3s ease;
  position: relative;
}

.sidebar__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Sidebar Toggle Button (Inside Avatar) */
.sidebar__toggle {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  background-color: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-white);
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 2;
  cursor: pointer;
  border-radius: 50%;
  padding: 0;
}

.sidebar:hover .sidebar__toggle {
  opacity: 1;
}

.sidebar.is-collapsed .sidebar__toggle {
  transform: rotate(180deg);
}

.sidebar__toggle svg {
  width: 20px;
  height: 20px;
}

.sidebar__header-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar.is-collapsed .sidebar__header-info {
  pointer-events: none;
}

.sidebar__name {
  font-size: 1.5rem;
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tight);
  color: var(--color-text-primary);
  line-height: var(--leading-tight);
  margin: 0;
}

.sidebar__role-socials {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.sidebar__role {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  font-weight: var(--weight-regular);
}

.sidebar__socials {
  display: flex;
  gap: 8px;
}

.sidebar__social-link {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background-color: #EFEFEF;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--duration-fast) ease, color var(--duration-fast) ease;
  color: var(--color-text-secondary);
}

.sidebar__social-link:hover {
  background-color: #E5E5E5;
  color: var(--color-text-primary);
}

.sidebar__social-link svg {
  width: 16px;
  height: 16px;
}

@media (max-width: 809px) {
  .sidebar__toggle {
    display: none;
  }
}

/* --- Chat Area (Deep Chat) --- */
.sidebar__chat-container {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  width: 100%;
  margin-bottom: 16px;
  min-width: 0; /* Prevent flex overflow */
  min-height: 0; /* Allow container to shrink for internal scroll */
}

.sidebar.is-collapsed .sidebar__chat-container {
  pointer-events: none;
}

/* --- Footer --- */
.sidebar__footer {
  text-align: center;
  padding-bottom: 16px;
}

.sidebar.is-collapsed .sidebar__footer {
  pointer-events: none;
}

.sidebar__copyright {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
}

/* --- Mobile header --- */
.mobile-header {
  display: none;
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  height: 72px;
  padding: 0 var(--padding-mobile);
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: var(--z-mobile-header);
  border-bottom: 1px solid var(--color-border);
}

.mobile-header__left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mobile-header__left .sidebar__avatar {
  width: 40px;
  height: 40px;
}

.mobile-header__info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mobile-header__name {
  font-size: var(--text-base);
  font-weight: var(--weight-bold);
  color: var(--color-text-primary);
  letter-spacing: var(--tracking-tight);
}

.mobile-header__role {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
}

.mobile-header__actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mobile-header__socials {
  display: flex;
  gap: 8px;
}

.mobile-header__socials .sidebar__social-link {
  width: 36px;
  height: 36px;
  background-color: var(--color-surface);
}

@media (max-width: 380px) {
  .mobile-header__role {
    display: none;
  }
  .mobile-header__socials {
    display: none; /* Hide socials on very small screens to avoid overlap */
  }
}

/* Hamburger button */
.hamburger {
  width: 36px;
  height: 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.hamburger__line {
  width: 20px;
  height: 2px;
  background-color: var(--color-text-primary);
  border-radius: 2px;
  transition: transform var(--duration-fast) ease, opacity var(--duration-fast) ease;
}

.hamburger.is-active .hamburger__line:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.hamburger.is-active .hamburger__line:nth-child(2) {
  opacity: 0;
}

.hamburger.is-active .hamburger__line:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* Mobile overlay backdrop */
body.menu-open::before {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: calc(var(--z-mobile-overlay) - 1);
  opacity: 1;
  transition: opacity 0.3s ease;
}
