/* ================================================
   AI MESSAGE - Modern Interactive Messaging Page
   ================================================ */

/* ================================================
   1. CONTENT AREA - Left & Right Layout
   ================================================ */

.content-area {
  flex: 1;
  display: flex;
  overflow: hidden;
  gap: 0;
}

/* ================================================
   2. CONVERSATION LIST - Left Sidebar Scrollable
   ================================================ */

.conversation-list {
  width: 380px;
  flex-shrink: 0;
  background: linear-gradient(135deg, #0f1419 0%, #1a1f2e 100%);
  border-right: 1px solid rgba(20, 184, 166, 0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.conversation-header {
  padding: 20px;
  border-bottom: 1px solid rgba(20, 184, 166, 0.1);
  background: rgba(0, 0, 0, 0.3);
}

.search-box {
  position: relative;
  margin-bottom: 16px;
  animation: slideInDown 0.6s ease-out;
}

.search-box input {
  width: 100%;
  padding: 12px 16px 12px 40px;
  background: rgba(20, 184, 166, 0.05);
  border: 1.5px solid rgba(20, 184, 166, 0.2);
  border-radius: 12px;
  color: #d1d5db;
  font-size: 14px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-box input:focus {
  outline: none;
  border-color: #14b8a6;
  background: rgba(20, 184, 166, 0.1);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.1);
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: #6b7280;
  stroke-width: 2;
  pointer-events: none;
}

.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #9ca3af;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.filter-btn:hover {
  background: rgba(20, 184, 166, 0.2);
  border-color: rgba(20, 184, 166, 0.4);
  color: #14b8a6;
}

.filter-btn .icon {
  width: 16px;
  height: 16px;
  stroke-width: 2;
}

/* ================================================
   3. CONVERSATIONS - Conversation Items List
   ================================================ */

.conversations {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.conversation-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: transparent;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: left;
  position: relative;
  margin-bottom: 6px;
  animation: slideInLeft 0.4s ease-out forwards;
  opacity: 0;
}

.conversation-item:nth-child(1) {
  animation-delay: 0.1s;
}
.conversation-item:nth-child(2) {
  animation-delay: 0.15s;
}
.conversation-item:nth-child(3) {
  animation-delay: 0.2s;
}
.conversation-item:nth-child(4) {
  animation-delay: 0.25s;
}
.conversation-item:nth-child(5) {
  animation-delay: 0.3s;
}
.conversation-item:nth-child(6) {
  animation-delay: 0.35s;
}
.conversation-item:nth-child(7) {
  animation-delay: 0.4s;
}

.conversation-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  /* background: linear-gradient(180deg, #14b8a6 0%, transparent 100%); */
  border-radius: 2px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.conversation-item:hover,
.conversation-item.active {
  background: rgba(20, 184, 166, 0.15);
  border-left: 3px solid #14b8a6;
  padding-left: 11px;
}

.conversation-item.active::before {
  opacity: 1;
}

.conversation-avatar {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 600;
  position: relative;
  flex-shrink: 0;
}

.conversation-avatar.whatsapp {
  background: linear-gradient(135deg, #10b981 0%, #06b6d4 100%);
}

.conversation-avatar.telegram {
  background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
}

.conversation-avatar.messenger {
  background: linear-gradient(135deg, #3b82f6 0%, #a855f7 100%);
}

.conversation-avatar.teams {
  background: linear-gradient(135deg, #a855f7 0%, #ec4899 100%);
}

.status-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 3px solid #0f1419;
}

.status-dot.online {
  background: #10b981;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

.status-dot.failed {
  background: #ef4444;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
}

.conversation-info {
  flex: 1;
  min-width: 0;
}

.conversation-info h3 {
  font-size: 15px;
  font-weight: 600;
  color: white;
  margin: 0 0 4px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-info .date {
  font-size: 12px;
  color: #6b7280;
  margin: 0;
}

.conversation-info .meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.failed-badge {
  font-size: 11px;
  color: #f87171;
  font-weight: 600;
  background: rgba(239, 68, 68, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
}

/* ================================================
   4. MESSAGE THREAD - Chat Display Area (Right Side)
   ================================================ */

.message-thread {
  flex: 1;
  background: linear-gradient(135deg, #0f1419 0%, #1a1f2e 100%);
  display: flex;
  flex-direction: column;
  border-left: none;
  border-radius: 0;
  overflow: hidden;
  box-shadow: none;
}

.thread-header {
  padding: 20px 24px;
  border-bottom: 1px solid rgba(20, 184, 166, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
  flex-shrink: 0;
}

.thread-info {
  display: flex;
  align-items: center;
  gap: 14px;
}

.thread-avatar {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, #14b8a6 0%, #06b6d4 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: white;
  box-shadow: 0 4px 12px rgba(20, 184, 166, 0.3);
}

.thread-info h2 {
  font-size: 18px;
  font-weight: 700;
  color: #ffffff;
  margin: 0 0 4px 0;
}

.thread-info p {
  font-size: 13px;
  color: #9ca3af;
  margin: 0;
}

.menu-btn {
  padding: 8px;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  color: #9ca3af;
  flex-shrink: 0;
}

.menu-btn:hover {
  background: rgba(20, 184, 166, 0.2);
  color: #14b8a6;
}

.menu-btn .icon {
  width: 20px;
  height: 20px;
  stroke-width: 2;
}

/* ================================================
   5. MESSAGES - Message Display & Scrollable Area
   ================================================ */

.messages {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message {
  display: flex;
  flex-direction: column;
  max-width: 70%;
  animation: fadeInAndSlide 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  opacity: 0;
}

.message:nth-child(1) {
  animation-delay: 0.1s;
}
.message:nth-child(2) {
  animation-delay: 0.2s;
}
.message:nth-child(3) {
  animation-delay: 0.3s;
}
.message:nth-child(n + 4) {
  animation-delay: 0.4s;
}

.message.ai {
  align-self: flex-start;
}

.message.user {
  align-self: flex-end;
}

.message-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding: 0 4px;
}

.message.user .message-header {
  justify-content: flex-end;
}

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.message.ai .message-avatar {
  background: linear-gradient(135deg, #14b8a6 0%, #06b6d4 100%);
  color: white;
}

.message.user .message-avatar {
  background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
  color: white;
}

.message-sender {
  font-size: 13px;
  font-weight: 600;
  color: #d1d5db;
}

.message-time {
  font-size: 12px;
  color: #6b7280;
}

.message.user .message-sender {
  order: 2;
}

.message.user .message-time {
  order: 3;
}

.message-content {
  padding: 14px 16px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.6;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.message.ai .message-content {
  background: linear-gradient(135deg, rgba(20, 184, 166, 0.15) 0%, rgba(6, 182, 212, 0.1) 100%);
  border: 1px solid rgba(20, 184, 166, 0.3);
  color: #ccfbf1;
  box-shadow: 0 4px 12px rgba(20, 184, 166, 0.15);
}

.message.ai .message-content::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 3px;
  background: linear-gradient(180deg, #14b8a6 0%, #06b6d4 100%);
  border-radius: 2px;
}

.message.user .message-content {
  background: #1f2937;
  color: #e5e7eb;
  border: 1px solid #374151;
}

.message:hover .message-content {
  box-shadow: 0 8px 16px rgba(20, 184, 166, 0.2);
}

/* ================================================
   6. MESSAGE INPUT - Modern Input Area
   ================================================ */

.message-input {
  padding: 20px 24px;
  border-top: 1px solid rgba(20, 184, 166, 0.1);
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
  flex-shrink: 0;
}

.stop-ai-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  border: none;
  border-radius: 10px;
  color: white;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  flex-shrink: 0;
}

.stop-ai-btn:hover {
  box-shadow: 0 8px 16px rgba(239, 68, 68, 0.3);
  transform: translateY(-2px);
}

.stop-ai-btn .icon {
  width: 16px;
  height: 16px;
  stroke-width: 2;
}

.message-input input {
  flex: 1;
  padding: 12px 16px;
  background: rgba(20, 184, 166, 0.05);
  border: 1.5px solid rgba(20, 184, 166, 0.2);
  border-radius: 10px;
  color: #d1d5db;
  font-size: 14px;
  transition: all 0.3s ease;
}

.message-input input::placeholder {
  color: #6b7280;
}

.message-input input:focus {
  outline: none;
  border-color: #14b8a6;
  background: rgba(20, 184, 166, 0.1);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.1);
}

.send-btn {
  padding: 12px;
  background: linear-gradient(135deg, #14b8a6 0%, #06b6d4 100%);
  border: none;
  border-radius: 10px;
  color: white;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(20, 184, 166, 0.3);
}

.send-btn:hover {
  box-shadow: 0 8px 20px rgba(20, 184, 166, 0.4);
  transform: translateY(-2px);
}

.send-btn:active {
  transform: translateY(0);
}

.send-btn .icon {
  width: 20px;
  height: 20px;
  stroke-width: 2;
}

/* ================================================
   7. ANIMATIONS
   ================================================ */

@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translateY(-16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-16px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeInAndSlide {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.8;
  }
}

/* ================================================
   8. SCROLLBAR - Custom Scrollbar
   ================================================ */

.conversations::-webkit-scrollbar,
.messages::-webkit-scrollbar {
  width: 8px;
}

.conversations::-webkit-scrollbar-track,
.messages::-webkit-scrollbar-track {
  background: transparent;
}

.conversations::-webkit-scrollbar-thumb,
.messages::-webkit-scrollbar-thumb {
  background: rgba(20, 184, 166, 0.3);
  border-radius: 4px;
}

.conversations::-webkit-scrollbar-thumb:hover,
.messages::-webkit-scrollbar-thumb:hover {
  background: rgba(20, 184, 166, 0.5);
}

/* ================================================
   9. RESPONSIVE DESIGN - AI Message
   ================================================ */

@media (max-width: 1200px) {
  .conversation-list {
    width: 320px;
  }

  .message-thread {
    border-radius: 0;
  }

  .messages {
    padding: 16px;
  }

  .message {
    max-width: 80%;
  }
}

@media (max-width: 1024px) {
  .content-area {
    flex-direction: column;
  }

  .conversation-list {
    width: 100%;
    max-height: 35vh;
    border-right: none;
    border-bottom: 1px solid rgba(20, 184, 166, 0.1);
    flex-shrink: 0;
  }

  .message-thread {
    width: 100%;
    border-left: none;
    flex-shrink: 0;
  }

  .message {
    max-width: 85%;
  }
}

@media (max-width: 768px) {
  .content-area {
    flex-direction: column;
  }

  .search-box {
    margin-left: 3rem;
    margin-top: -20px;
  }

  .conversation-list {
    width: 100%;
    max-height: 35vh;
    border-right: none;
    border-bottom: 1px solid rgba(20, 184, 166, 0.1);
  }

  .conversation-item {
    padding: 12px;
  }

  .message-thread {
    width: 100%;
    border-radius: 0;
  }

  .thread-header {
    padding: 12px;
  }

  .thread-avatar {
    width: 36px;
    height: 36px;
    font-size: 12px;
  }

  .thread-info h2 {
    font-size: 14px;
  }

  .thread-info p {
    font-size: 12px;
  }

  .messages {
    padding: 12px;
    gap: 12px;
  }

  .message {
    max-width: 90%;
  }

  .message-header {
    font-size: 12px;
  }

  .message-avatar {
    width: 28px;
    height: 28px;
    font-size: 10px;
  }

  .message-content {
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.5;
  }

  .message-input {
    padding: 12px;
    gap: 8px;
    flex-wrap: wrap;
  }

  .stop-ai-btn {
    padding: 8px 12px;
    font-size: 12px;
    min-width: auto;
  }

  .message-input input {
    padding: 8px 12px;
    font-size: 12px;
    flex: 1;
    min-width: 120px;
  }

  .send-btn {
    padding: 8px;
  }
}

@media (max-width: 480px) {
  .conversation-header {
    padding: 12px;
  }
  .search-box {
    margin-left: 3rem;
    margin-top: -10px;
  }
  .search-box input {
    padding: 10px 14px 10px 36px;
    font-size: 13px;
  }

  .search-icon {
    left: 10px;
    width: 14px;
    height: 14px;
  }

  .filter-btn {
    padding: 6px 10px;
    font-size: 12px;
  }

  .conversation-list {
    max-height: 35vh;
  }

  .conversation-item {
    padding: 10px;
    margin-bottom: 4px;
    border-radius: 10px;
  }

  .conversation-avatar {
    width: 40px;
    height: 40px;
    font-size: 18px;
  }

  .conversation-info h3 {
    font-size: 14px;
  }

  .messages-container {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 8px;
  }

  .message-thread {
    border-radius: 8px;
  }

  .thread-header {
    padding: 12px;
    gap: 8px;
  }

  .thread-avatar {
    width: 32px;
    height: 32px;
    font-size: 10px;
  }

  .thread-info h2 {
    font-size: 13px;
  }

  .thread-info p {
    font-size: 11px;
  }

  .menu-btn {
    padding: 6px;
    flex-shrink: 0;
  }

  .messages {
    padding: 10px;
    gap: 8px;
  }

  .message {
    max-width: 100%;
  }

  .message-header {
    font-size: 11px;
    margin-bottom: 6px;
  }

  .message-avatar {
    width: 24px;
    height: 24px;
    font-size: 9px;
  }

  .message-content {
    padding: 8px 10px;
    font-size: 12px;
    line-height: 1.4;
  }

  .message-input {
    padding: 10px;
    gap: 6px;
    flex-wrap: wrap;
  }

  .stop-ai-btn {
    padding: 6px 10px;
    font-size: 11px;
    min-width: auto;
    flex-shrink: 0;
  }

  .message-input input {
    padding: 8px 10px;
    font-size: 12px;
    flex: 1;
    min-width: 100px;
  }

  .send-btn {
    padding: 8px;
    flex-shrink: 0;
  }
}

/* ================================================
   10. DARK MODE ENHANCEMENTS
   ================================================ */

@media (prefers-color-scheme: dark) {
  .conversation-list {
    background: linear-gradient(135deg, #0a0e14 0%, #141a25 100%);
  }

  .message-thread {
    background: linear-gradient(135deg, #0a0e14 0%, #141a25 100%);
  }
}

/* ================================================
   11. ACCESSIBILITY FEATURES
   ================================================ */

@media (prefers-reduced-motion: reduce) {
  .conversation-item,
  .message,
  .search-box,
  .message-input input,
  .send-btn,
  .stop-ai-btn {
    animation: none;
    transition: none;
  }
}

@media (prefers-contrast: more) {
  .message.ai .message-content {
    border-color: #14b8a6;
  }

  .conversation-item.active {
    border-left-width: 4px;
  }

  .send-btn,
  .stop-ai-btn {
    font-weight: 700;
  }
}
