
/* ChatBox */

/* ====== chat.css (tam sıfırdan) ====== */

/* Box sizing for predictable sizing */
* { box-sizing: border-box; }

/* Toggle button (aşağı sağ künc) */
.chat-toggle {
  position: fixed;
  bottom: 22px;
  right: 10px;
  background-color: #5B8C51;
  color: #fff;
  border-radius: 50%;
  width: 60px;
  height: 60px;
  font-size: 28px;
  border: none;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0,0,0,0.25);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Chat container */
.chat-container {
  width: 360px;
  max-width: calc(100% - 40px);
  height: 520px;
  position: fixed;
  bottom: 90px;
  right: 20px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.12);
  display: none; /* JS açacaq */
  flex-direction: column;
  z-index: 9998;
  overflow: hidden;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
}

/* Header */
.chat-header {
  flex-shrink: 0;
  background: linear-gradient(180deg, #38a169, #2f855a);
  color: #fff;
  padding: 12px 14px;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Close X */
.chat-close {
  cursor: pointer;
  font-size: 18px;
  opacity: 0.95;
}

/* Messages area */
.chat-messages {
  flex: 1 1 auto;
  padding: 12px;
  overflow-y: auto;
  background: #f4f6f7;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}

/* Reply preview (səbət) - absolute inside chat-container, sits above input */
#replyPreview {
  position: absolute;
  left: 12px;
  right: 12px;
  /* place above the chat-input (chat-input height ~56px + margin) */
  bottom: 78px;
  display: none; /* JS toggles this */
  background: #f7fbff;
  border-left: 4px solid #35aaff;
  padding: 8px 10px;
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.06);
  z-index: 60;
  align-items: center;
  gap: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* content inside reply preview */
#replyToText {
  font-size: 13px;
  color: #05445E;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: calc(100% - 36px); /* room for close button */
}

/* close button inside reply preview */
#replyPreview > button {
  background: transparent;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: #557A8A;
}

/* Chat input area (fixed at bottom of container) */
.chat-input {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  background: #fff;
  border-top: 1px solid #e6e9eb;
}

/* textarea styling */
.chat-input textarea {
  flex: 1 1 auto;
  min-height: 44px;
  max-height: 120px;
  padding: 10px 12px;
  border-radius: 22px;
  border: 1px solid #d1d5db;
  resize: none;
  font-size: 14px;
  line-height: 1.25;
  background: #fff;
}

/* file button and send button */
.chat-input button {
  background: #28a745;
  color: #fff;
  border: none;
  padding: 8px 12px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 14px;
}

/* Message bubble base */
.message {
  max-width: 78%;
  padding: 12px 14px 64px 14px; 
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
  word-wrap: break-word;
  position: relative; /* for reply icon absolute inside */
  display: flex;
  flex-direction: column;
  gap: 6px;
  /* reserve space at bottom for the reply icon */
  padding-bottom: 56px;
}

/* My message (right) */
.message.user {
  align-self: flex-end;
  background: #dcf8c6;
}

/* Other's message (left) */
.message.other {
  align-self: flex-start;
  background: #fff;
}

/* message text */
.message .message-text {
  font-size: 14px;
  padding-right: 72px;
  color: #0f172a;
  padding-right: 8px; /* slight room so icon won't overlap text */
}

.message-reply {
  font-size: 13px;
  color: #555;
  background: #f1f0f0;
  border-left: 3px solid #4caf50;
  padding: 4px 6px;
  margin-bottom: 4px;
  border-radius: 4px;
}


/* message image */
.message img {
  max-width: 100%;
  border-radius: 8px;
  margin-top: 6px;
  display: block;
}

/* Reply (quote) preview inside each message */
.reply-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 8px;
  background: #f2fbff;
  border-left: 4px solid #35aaff;
  font-size: 13px;
  color: #034c62;
  cursor: pointer;
}

/* small text for user and text inside message reply */
.reply-preview .reply-user {
  font-weight: 600;
  font-size: 12px;
  color: #0366a6;
}
.reply-preview .reply-text {
  font-size: 13px;
  color: #034c62;
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reply-preview img.reply-thumb {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.04);
}

/* Reply icon - IMPORTANT: JS should add class 'reply-icon' to icon element */
.reply-icon {
  position: absolute;
  right: 12px;
  bottom: 12px;          /* lower position so it's visually lower in bubble */
  font-size: 14px;
  color: #0073aa;
  background: rgba(0,115,170,0.08);
  padding: 8px;
  margin-bottom: -20px;
  border-radius: 8px;
  cursor: pointer;
  transition: transform .12s ease, background .12s ease;
  z-index: 20;
}

/* hover effect */
.reply-icon:hover {
  transform: scale(1.05);
  background: rgba(0,115,170,0.16);
}

/* small helpers */
.message .meta { font-size: 12px; color: #667085; }

/* ====== Responsive tweaks ====== */
@media (max-width: 520px) {
  .chat-header {
    position: sticky;
    top: 0;
    background: #38a169;
    color: #fff;
    padding: 14px 16px;
    font-size: 16px;
    font-weight: 700;
    z-index: 101; /* toggle və mesajdan yuxarı */
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .chat-close {
    position: absolute; /* sticky header içində absolute */
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 20px;
    cursor: pointer;
    color: #fff;
    z-index: 102;
  }
  
  /* Chat konteyneri tam ekran */
  .chat-container {
    top: 0;
    left: 0;
    right: 0;       /* sağ boşluğu sıfırla */
    bottom: 0;      /* aşağı boşluğu sıfırla */
    width: 100%;
    height: 100vh !important; 
    max-height: none;
    max-width: 100% !important;
    border-radius: 0;
    flex-direction: column;
    z-index: 9999;
  }

  /* Toggle buton */
  .chat-toggle {
    position: fixed;
    bottom: 18px;
    right: 12px;
    width: 52px;
    height: 52px;
    font-size: 24px;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }

  .chat-messages {
    height: calc(100% - 120px); /* üst + input hissəsi qədər çıxılır */
    padding: 10px;
  }

  .chat-input {
    padding: 10px;
    border-top: 1px solid #ddd;
  }

  #replyPreview { 
    bottom: 96px; 
    left: 8px; 
    right: 8px; 
  }

  .message { 
    padding-bottom: 68px; 
  }

  .reply-icon { 
    right: 8px; 
    bottom: 8px; 
    padding: 6px; 
  }

  .chat-input textarea { 
    min-height: 56px; 
  }
}




/* tiny touch targets for accessibility */
.chat-input button, .reply-icon {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
