html {
  scroll-behavior: smooth;
}

:root {
  --chat-visible-message-count: 8;
  --chat-row-height: 58px;
}

body {
  font-family: 'Poppins', sans-serif;
  background: linear-gradient(180deg, #f6fbff 0%, #f9fafc 55%, #ffffff 100%);
}

a, button, .card, .btn, input, .form-control, textarea {
  transition: all 0.25s ease;
}

.logo {
  display: flex;
  align-items: center;
  text-decoration: none;
  font-size: large;
  gap: 0.4rem;
  font-weight: 600;
  color: #39ade5;
}

.navbar .nav-link:hover,
.navbar .dropdown-item:hover,
.navbar .logo:hover {
  transform: none !important;
}

button.btn-primary {
  background-color: #39ade5;
  border: none;
  border-radius: 6px;
}

/* Account Dropdown */
.btn-account {
  background-color: #39ade5;
  border: none;
  border-radius: 6px;
  transition: background 0.2s ease;
}

.btn-account:hover,
.btn-account:focus,
.btn-account:active,
.btn-account.show {
  background-color: #2d9ad0 !important;
  border: none !important;
  box-shadow: none !important;
}

.account-dropdown-menu {
  min-width: 180px;
  border: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  border-radius: 10px;
  padding: 6px 0;
}

.account-dropdown-menu .dropdown-item {
  padding: 8px 18px;
  font-size: 0.9rem;
  color: #333;
  border-radius: 6px;
  margin: 1px 6px;
  width: auto;
}

.account-dropdown-menu .dropdown-item:hover {
  background-color: #f0f8ff;
  color: #39ade5;
}

.account-dropdown-menu .dropdown-divider {
  margin: 4px 12px;
}

.btn:hover {
  transform: translateY(-1px);
}

.list-group-item.active {
  background-color: #39ade5;
  border-color: #39ade5;
  color: #fff;
  font-weight: 600;
}

.list-group-item {
  border: none;
  padding: 17px 18px;
}

.list-group-item:hover {
  background-color: #f5f8ff;
}

.messages-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 620px;
  background: #ffffff;
}

.thread-list {
  max-height: 550px;
  overflow-y: auto;
}

.thread-item {
  width: 100%;
  border: none;
  border-bottom: 1px solid #f0f3f9;
  text-align: left;
  background: #fff;
  padding: 14px 16px;
}

.thread-item:hover {
  background: #f7fbff;
}

.thread-item.active {
  background: #edf7ff;
}

.thread-title {
  font-weight: 600;
  font-size: 0.95rem;
  margin: 0;
  color: #173047;
}

.thread-meta {
  font-size: 0.8rem;
  color: #7b8794;
  margin-top: 2px;
}

.thread-preview {
  font-size: 0.85rem;
  color: #5f6f80;
  margin-top: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.unread-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #39ade5;
}

.chat-panel {
  display: flex;
  flex-direction: column;
  min-height: 620px;
}

.chat-active {
  display: flex;
  flex-direction: column;
  min-height: 620px;
}

.chat-header {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
}

.chat-empty-state {
  margin: auto;
  text-align: center;
  color: #6f7f90;
}

.chat-empty-state i {
  font-size: 2.8rem;
  color: #39ade5;
  opacity: 0.5;
}

.chat-messages {
  flex: 0 0 auto;
  padding: 14px 14px;
  overflow-y: auto;
  height: calc(var(--chat-visible-message-count) * var(--chat-row-height));
  min-height: calc(var(--chat-visible-message-count) * var(--chat-row-height));
  max-height: calc(var(--chat-visible-message-count) * var(--chat-row-height));
  scrollbar-gutter: stable;
  overscroll-behavior: contain;
  background:
    radial-gradient(circle at 15% 10%, rgba(57, 173, 229, 0.12) 0, transparent 25%),
    radial-gradient(circle at 85% 90%, rgba(57, 173, 229, 0.08) 0, transparent 30%),
    #f8fbff;
}

.message-row {
  display: flex;
  margin-bottom: 7px;
}

.message-row.self {
  justify-content: flex-end;
}

.message-bubble {
  position: relative;
  max-width: 76%;
  border-radius: 16px;
  padding: 7px 10px;
  font-size: 0.84rem;
  line-height: 1.32;
  box-shadow: 0 3px 10px rgba(20, 54, 88, 0.09);
}

.message-body {
  white-space: pre-wrap;
  word-break: break-word;
}

.message-context-menu {
  position: absolute;
  z-index: 20;
  min-width: 152px;
  padding: 6px;
  border: 1px solid #d9e7f3;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 16px 30px rgba(22, 52, 84, 0.16);
  backdrop-filter: blur(10px);
}

.message-context-item {
  width: 100%;
  border: none;
  background: transparent;
  color: #244159;
  border-radius: 10px;
  padding: 9px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
}

.message-context-item:hover {
  transform: none;
  background: #eef6ff;
}

.message-context-item.danger {
  color: #bf314c;
}

.message-context-item.danger:hover {
  background: #fff0f3;
}

.message-editing-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  margin-bottom: 10px;
  border: 1px solid #d9e7f5;
  border-radius: 16px;
  background: #f4f9ff;
}

.message-row.self .message-bubble {
  background: linear-gradient(135deg, #3ab2eb 0%, #2f9dd2 100%);
  color: #ffffff;
  border-top-right-radius: 8px;
}

.message-row.self .message-bubble::after {
  content: '';
  position: absolute;
  right: -5px;
  bottom: 8px;
  width: 10px;
  height: 10px;
  background: #2f9dd2;
  transform: rotate(45deg);
  border-radius: 2px;
}

.message-row.other .message-bubble {
  background: #ffffff;
  color: #2f4051;
  border: 1px solid #e6edf5;
  border-top-left-radius: 8px;
}

.message-row.other .message-bubble::after {
  content: '';
  position: absolute;
  left: -6px;
  bottom: 8px;
  width: 10px;
  height: 10px;
  background: #ffffff;
  border-left: 1px solid #e6edf5;
  border-bottom: 1px solid #e6edf5;
  transform: rotate(45deg);
  border-radius: 1px;
}

.message-meta {
  display: block;
  margin-top: 4px;
  font-size: 0.66rem;
  opacity: 0.8;
}

.chat-composer textarea {
  resize: none;
}

.chat-composer {
  background: #ffffff;
  position: sticky;
  bottom: 0;
}

.composer-shell {
  background: #f5f8fc;
  border: 1px solid #e3ebf4;
  border-radius: 22px;
  padding: 6px;
}

.message-input {
  border: none;
  border-radius: 16px;
  background: transparent;
  min-height: 38px;
  max-height: 110px;
  padding: 8px 10px;
}

.message-input:focus {
  box-shadow: none;
  transform: none;
}

.send-btn {
  min-width: 38px;
  height: 38px;
  border-radius: 50%;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.empty-list {
  padding: 20px;
  color: #7f8b96;
  text-align: center;
  font-size: 0.9rem;
}

@media (max-width: 1200px) {
  .messages-layout {
    grid-template-columns: 280px minmax(0, 1fr);
  }
}

@media (max-width: 992px) {
  :root {
    --chat-row-height: 54px;
  }

  .messages-layout {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .thread-list-panel {
    border-right: none;
    border-bottom: 1px solid #e8eef5;
  }

  .thread-list {
    max-height: 250px;
  }

  .chat-panel {
    min-height: 460px;
  }

  .chat-active {
    min-height: 460px;
  }

  .message-bubble {
    max-width: 90%;
  }

  .list-group-item {
    text-align: center;
  }
}
