/* Drawer styles for the chat sidebar */

/* Drawer overlay */
.drawer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-30);
  background-color: var(--color-black);
  opacity: 0;
  transition: opacity var(--transition-slow) var(--transition-ease);
}

/* Base drawer styles */
.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 18rem; /* w-72 from original */
  background-color: var(--color-white);
  z-index: var(--z-40);
  transition: transform var(--transition-slow) var(--transition-ease);
  display: flex;
  flex-direction: column;
  height: 100vh; /* Use viewport height for consistency */
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  overflow: hidden; /* Critical to contain content */
}

/* Drawer header */
.drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4);
  border-bottom: var(--border-width-1) solid var(--color-gray-200);
  flex-shrink: 0; /* Prevents the header from shrinking */
}

.drawer__title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-medium);
}

.drawer__title a:hover {
  text-decoration: underline;
}

.drawer__close-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 2.5rem; /* h-10 from original */
  width: 2.5rem; /* w-10 from original */
  border-radius: var(--border-radius-full);
  transition-property: color, background-color;
  transition-duration: var(--transition-normal);
  transition-timing-function: var(--transition-ease);
}

.drawer__close-button:hover {
  background-color: var(--color-gray-100);
}

.drawer__close-icon {
  height: 1.25rem; /* h-5 w-5 from original */
  width: 1.25rem;
}

/* New chat button section */
.drawer__new-chat {
  padding: var(--space-3);
  flex-shrink: 0; /* Prevents this section from shrinking */
}

.drawer__new-chat-button {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-2);
  width: 100%;
  height: 2.5rem; /* h-10 from original */
  padding: var(--space-2) var(--space-4);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  background-color: var(--color-gray-100);
  color: var(--color-gray-900);
  border-radius: var(--border-radius-md);
  transition-property: background-color;
  transition-duration: var(--transition-normal);
  transition-timing-function: var(--transition-ease);
}

.drawer__new-chat-button:hover {
  background-color: var(--color-gray-200);
}

.drawer__new-chat-icon {
  height: 1rem; /* h-4 w-4 from original */
  width: 1rem;
}
/* Chat list container */

/* Chat Turbo Frame Container */
#drawer_chats {
  display: flex;
  overflow-y: scroll;
}

.drawer__chats {
  flex: 1 1 auto; /* Grow and shrink as needed */
  overflow-y: auto; /* Enable vertical scrolling */
  min-height: 0; /* CRITICAL for nested flex items to scroll properly */
}

/* Chat list item */
.drawer__chat-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: var(--space-3);
  cursor: pointer;
  transition-property: background-color;
  transition-duration: var(--transition-normal);
  transition-timing-function: var(--transition-ease);
}

.drawer__chat-item:hover {
  background-color: var(--color-gray-100);
}

.drawer__chat-item--active {
  background-color: var(--color-gray-100);
}

.drawer__chat-item > a {
  display: flex;
  align-items: flex-start;
  flex: 1;
  min-width: 0;
}

.drawer__chat-icon {
  height: 1.25rem;
  width: 1.25rem;
  margin-right: var(--space-3);
  flex-shrink: 0;
  color: var(--color-gray-500);
  margin-top: 0.125rem; /* Slight adjustment to align with title */
}

.drawer__chat-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.drawer__chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: var(--space-2);
}

.drawer__chat-title {
  font-weight: var(--font-weight-medium);
  font-size: var(--font-size-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drawer__chat-time {
  font-size: var(--font-size-xs);
  color: var(--color-gray-500);
  flex-shrink: 0;
}

.drawer__chat-preview {
  font-size: var(--font-size-xs);
  color: var(--color-gray-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drawer__chat-actions {
  display: flex;
  align-items: flex-start;
  margin-left: var(--space-2);
  flex-shrink: 0;
}

.drawer__chat-menu-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 1.75rem; /* h-7 from original */
  width: 1.75rem; /* w-7 from original */
  border-radius: var(--border-radius-full);
  transition-property: background-color;
  transition-duration: var(--transition-normal);
  transition-timing-function: var(--transition-ease);
}

.drawer__chat-menu-button:hover {
  background-color: var(--color-gray-100);
}

/* Helper class for visually showing/hiding the drawer */
.-translate-x-full {
  transform: translateX(-100%);
}

/* Hide elements visually but keep them in the DOM */
.hidden {
  display: none;
}

/* Helper for opacity transitions */
.opacity-50 {
  opacity: 0.5;
}

/* User info and logout in drawer footer */
.drawer__footer {
  padding: var(--space-4);
  border-top: var(--border-width-1) solid var(--color-gray-200);
  margin-top: auto; /* Pushes footer to the bottom */
  flex-shrink: 0; /* Prevents footer from shrinking */
  background-color: var(--color-white); /* Ensures opaque background */
}

.drawer_footer-section {
  font-size: var(--font-size-sm);
  border-bottom: var(--border-width-1) solid var(--color-gray-200);
  padding-bottom: 14px;
  margin-bottom: 14px;
}
.drawer__user-info {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.drawer__user-email {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-gray-700);
  overflow: hidden;
  text-overflow: ellipsis;
}

.drawer__logout-button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-gray-700);
  background-color: transparent;
  border: none;
  border-radius: var(--border-radius-md);
  cursor: pointer;
  transition: background-color var(--transition-normal);
}

.drawer__logout-button:hover {
  background-color: var(--color-gray-100);
  color: var(--color-gray-900);
}

.drawer__logout-icon {
  flex-shrink: 0;
}
