/* ============================================================
   Chat & Notification Styles
   ============================================================ */

/* --- Chat Page Layout --- */

.chat-page {
  padding-top: var(--space-md);
  padding-bottom: 0;
  max-width: 1100px;
}

.chat-container {
  display: flex;
  height: calc(100vh - 80px);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--color-surface);
}

/* --- Conversation List --- */

.chat-list {
  width: 340px;
  min-width: 280px;
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
}

.chat-list-header {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
}

.chat-list-header h2 {
  font-size: var(--text-lg);
  font-weight: 600;
  margin: 0;
}

.chat-list-items {
  flex: 1;
  overflow-y: auto;
}

.chat-list-empty {
  padding: var(--space-xl);
  text-align: center;
}

.chat-list-item {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  transition: background-color 0.15s;
}

.chat-list-item:hover {
  background: var(--color-surface);
}

.chat-list-item.active {
  background: var(--color-surface);
  border-left: 3px solid var(--color-primary);
  padding-left: calc(var(--space-lg) - 3px);
}

.chat-list-item.unread {
  background: rgba(45, 106, 79, 0.04);
}

.chat-list-item-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.chat-list-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-list-item-name {
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.chat-list-item.unread .chat-list-item-name {
  color: var(--color-primary-dark);
}

.chat-list-item-time {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.chat-list-item-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-sm);
}

.chat-list-item-preview {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.chat-list-item.unread .chat-list-item-preview {
  font-weight: 500;
  color: var(--color-text);
}

.chat-list-item-badge {
  background: var(--color-primary);
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.1rem 0.45rem;
  border-radius: 10px;
  flex-shrink: 0;
  min-width: 18px;
  text-align: center;
}

/* --- Message Thread --- */

.chat-thread {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-thread-header {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  background: var(--color-surface);
}

.chat-thread-header-info {
  flex: 1;
  min-width: 0;
}

.chat-thread-header-name {
  font-weight: 600;
  font-size: var(--text-base);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-thread-header-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Messages --- */

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.chat-load-more {
  text-align: center;
  margin-bottom: var(--space-md);
}

.chat-date-separator {
  text-align: center;
  margin: var(--space-md) 0 var(--space-sm);
}

.chat-date-separator span {
  background: var(--color-bg);
  padding: 2px var(--space-md);
  font-size: 0.75rem;
  color: var(--color-text-muted);
  border-radius: var(--radius-sm);
}

.chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 75%;
}

.chat-msg-own {
  align-self: flex-end;
  align-items: flex-end;
}

.chat-msg-other {
  align-self: flex-start;
  align-items: flex-start;
}

.chat-msg-system {
  align-self: center;
  max-width: 90%;
}

.chat-msg-system span {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  font-style: italic;
  background: var(--color-bg);
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-md);
  display: inline-block;
}

.chat-msg-sender {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text-muted);
  margin-bottom: 2px;
  padding-left: var(--space-xs);
}

.chat-msg-bubble {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  line-height: 1.45;
  word-break: break-word;
  white-space: pre-wrap;
}

.chat-msg-own .chat-msg-bubble {
  background: var(--color-primary);
  color: white;
  border-bottom-right-radius: var(--radius-sm);
}

.chat-msg-other .chat-msg-bubble {
  background: var(--color-bg);
  color: var(--color-text);
  border-bottom-left-radius: var(--radius-sm);
}

.chat-msg-time {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  padding: 2px var(--space-xs) 0;
}

.chat-typing {
  align-self: flex-start;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  font-style: italic;
  padding: var(--space-xs) var(--space-sm);
}

/* --- Input Area --- */

.chat-input {
  display: flex;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
  align-items: flex-end;
}

.chat-input-field {
  flex: 1;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: var(--text-sm);
  resize: none;
  max-height: 120px;
  line-height: 1.45;
  outline: none;
  transition: border-color 0.15s;
}

.chat-input-field:focus {
  border-color: var(--color-primary);
}

.chat-send-btn {
  flex-shrink: 0;
  padding: var(--space-sm) var(--space-lg);
}

/* --- Notification Bell --- */

.notif-bell-container {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.notif-bell {
  position: relative;
  cursor: pointer;
  padding: var(--space-xs);
  color: var(--color-text);
  display: flex;
  align-items: center;
  transition: color 0.15s;
}

.notif-bell:hover {
  color: var(--color-primary);
}

.notif-badge {
  position: absolute;
  top: -4px;
  right: -6px;
  background: var(--color-error);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 10px;
  min-width: 16px;
  text-align: center;
  line-height: 1.3;
}

/* --- Notification Dropdown --- */

.notif-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  width: 340px;
  max-height: 420px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.notif-dropdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--color-border);
}

.notif-list {
  overflow-y: auto;
  flex: 1;
}

.notif-empty {
  padding: var(--space-xl);
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.notif-item {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  transition: background-color 0.15s;
}

.notif-item:hover {
  background: var(--color-bg);
}

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

.notif-unread {
  background: rgba(45, 106, 79, 0.04);
  border-left: 3px solid var(--color-primary);
  padding-left: calc(var(--space-md) - 3px);
}

.notif-item-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
}

.notif-item-body {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notif-item-time {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* --- Mobile Responsive --- */

@media (max-width: 767px) {
  .chat-page {
    padding: 0;
  }

  .chat-container {
    height: calc(100vh - 56px);
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .chat-list {
    width: 100%;
    min-width: unset;
    border-right: none;
  }

  .chat-thread {
    width: 100%;
  }

  .chat-msg {
    max-width: 85%;
  }

  .notif-dropdown {
    width: calc(100vw - 2rem);
    right: -1rem;
  }

  .chat-list-item-name {
    max-width: 160px;
  }
}
