/* Modern Chat Design */

.chat-container {
  display: flex;
  height: calc(100vh - 64px);
  background: var(--lighter);
}

.chat-sidebar {
  width: 320px;
  background: #fff;
  border-right: 1px solid var(--gray-lighter);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-header-search {
  padding: 16px;
  border-bottom: 1px solid var(--gray-lighter);
}

.chat-search-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--gray-lighter);
  border-radius: var(--border-radius);
  font-size: 13px;
  background: var(--lighter);
}

.chat-search-input:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
}

.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.chat-item {
  padding: 12px;
  margin-bottom: 8px;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  background: transparent;
}

.chat-item:hover {
  background: var(--lighter);
}

.chat-item.active {
  background: rgba(123, 31, 162, 0.08);
  border-color: var(--primary);
}

.chat-item-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.chat-item-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

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

.chat-item-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item-meta {
  font-size: 11px;
  color: var(--gray);
  margin-top: 2px;
}

.chat-item-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gray-light);
  flex-shrink: 0;
}

.chat-item-status.online {
  background: var(--success);
}

.chat-item-status.away {
  background: var(--warning);
}

/* Main Chat Area */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #fff;
}

.chat-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-lighter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.chat-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}

.chat-header-details {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.chat-header-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--dark);
}

.chat-header-meta {
  font-size: 12px;
  color: var(--gray);
}

.chat-header-actions {
  display: flex;
  gap: 8px;
}

.chat-header-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--border-radius);
  border: none;
  background: var(--lighter);
  color: var(--gray);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.chat-header-btn:hover {
  background: var(--gray-light);
  color: var(--primary);
}

/* Messages Area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--gray);
  text-align: center;
}

.chat-empty i {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.3;
}

.msg {
  display: flex;
  margin-bottom: 8px;
  animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.msg.in {
  justify-content: flex-start;
}

.msg.out {
  justify-content: flex-end;
}

.msg > div {
  max-width: 60%;
  padding: 10px 14px;
  border-radius: var(--border-radius);
  font-size: 13px;
  line-height: 1.4;
  word-wrap: break-word;
}

.msg.in > div {
  background: var(--light);
  color: var(--dark);
}

.msg.out > div {
  background: var(--primary);
  color: #fff;
}

.msg.internal > div {
  background: #fff8e1;
  border: 1px dashed #FFA000;
  color: var(--dark);
}

.msg.system > div {
  background: transparent;
  color: var(--gray);
  text-align: center;
  font-size: 12px;
  font-style: italic;
}

.msg img,
.msg video,
.msg audio {
  max-width: 100%;
  border-radius: var(--border-radius);
  margin-bottom: 6px;
}

.msg .time {
  font-size: 11px;
  color: var(--gray);
  margin-top: 4px;
}

.msg.out .time {
  color: rgba(255, 255, 255, 0.7);
}

/* Compose Area */
.chat-compose {
  padding: 16px 20px;
  border-top: 1px solid var(--gray-lighter);
  background: #fff;
}

.compose-form {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.compose-input-wrapper {
  flex: 1;
  display: flex;
  gap: 8px;
  align-items: center;
}

.compose-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--gray-lighter);
  border-radius: var(--border-radius);
  font-size: 13px;
  font-family: inherit;
  resize: none;
  max-height: 100px;
  transition: var(--transition);
}

.compose-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(123, 31, 162, 0.1);
}

.compose-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--border-radius);
  border: none;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.compose-btn:hover {
  background: var(--primary-dark);
  transform: scale(1.05);
}

.compose-btn:disabled {
  background: var(--gray-light);
  cursor: not-allowed;
  transform: scale(1);
}

/* Responsive */
@media (max-width: 768px) {
  .chat-sidebar {
    width: 100%;
    max-height: 200px;
    border-right: none;
    border-bottom: 1px solid var(--gray-lighter);
  }

  .chat-main {
    min-height: calc(100vh - 264px);
  }

  .msg > div {
    max-width: 85%;
  }

  .compose-form {
    flex-wrap: wrap;
  }
}

@media (max-width: 480px) {
  .chat-messages {
    padding: 12px;
  }

  .msg > div {
    max-width: 100%;
  }

  .chat-compose {
    padding: 12px;
  }
}
