/* WhatsApp Chat Component */

.whatsapp-chat-shell {
  display: flex;
  height: calc(100vh - 180px);
  border: 1px solid #dee2e6;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.whatsapp-chat-shell .card {
  cursor: default;
}

/* Left panel - Chat list */
.wa-chat-list {
  width: 340px;
  min-width: 340px;
  border-right: 1px solid #dee2e6;
  display: flex;
  flex-direction: column;
  background: #fff;
}

.wa-chat-list-header {
  padding: 0.75rem;
  border-bottom: 1px solid #dee2e6;
}

.wa-chat-list-header input {
  border-radius: 20px;
  background: #f0f2f5;
  border: none;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
}

.wa-chat-list-header input:focus {
  background: #fff;
  box-shadow: 0 0 0 2px rgba(0, 128, 105, 0.25);
}

.wa-chat-items {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  margin: 0;
  list-style: none;
}

.wa-chat-items::-webkit-scrollbar {
  width: 6px;
}

.wa-chat-items::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.wa-chat-items::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
}

.wa-chat-items::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

.wa-chat-item {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f0f2f5;
  cursor: pointer;
  transition: background 0.15s;
  gap: 0.75rem;
}

.wa-chat-item:hover {
  background: #f0f2f5;
}

.wa-chat-item.active {
  background: #e9ecef;
}

.wa-chat-avatar {
  width: 48px;
  height: 48px;
  min-width: 48px;
  border-radius: 50%;
  background: #dfe5e7;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: #8696a0;
  overflow: hidden;
}

.wa-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.wa-chat-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.wa-chat-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: #111b21;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wa-chat-phone {
  font-size: 0.75rem;
  color: #8696a0;
}


.wa-chat-last-msg {
  font-size: 0.85rem;
  color: #8696a0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.wa-chat-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.wa-chat-time {
  font-size: 0.75rem;
  color: #8696a0;
}

.wa-unread-badge {
  background: #25d366;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Right panel - Messages */
.wa-messages-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #ece5dd;
  min-width: 0;
  position: relative;
}

.wa-messages-header {
  padding: 0.75rem 1rem;
  background: #f0f2f5;
  border-bottom: 1px solid #dee2e6;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.wa-messages-header-name {
  font-weight: 600;
  font-size: 1rem;
  color: #111b21;
}

.wa-messages-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.wa-messages-body::-webkit-scrollbar {
  width: 6px;
}

.wa-messages-body::-webkit-scrollbar-track {
  background: transparent;
}

.wa-messages-body::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
}

.wa-message {
  display: flex;
  margin-bottom: 2px;
}

.wa-message.sent {
  justify-content: flex-end;
}

.wa-message.received {
  justify-content: flex-start;
}

.wa-bubble {
  max-width: 65%;
  padding: 6px 12px 8px;
  border-radius: 8px;
  position: relative;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
  word-wrap: break-word;
  font-size: 0.9rem;
  line-height: 1.4;
}

.wa-message.sent .wa-bubble {
  background: #d9fdd3;
  border-top-right-radius: 0;
}

.wa-message.received .wa-bubble {
  background: #fff;
  border-top-left-radius: 0;
}

.wa-bubble-text {
  white-space: pre-wrap;
}

.wa-bubble-time {
  font-size: 0.68rem;
  color: #667781;
  text-align: right;
  margin-top: 2px;
  margin-left: 12px;
  float: right;
  position: relative;
  top: 5px;
}

/* Message status icons */
.wa-msg-status {
  margin-left: 3px;
  display: inline-block;
  vertical-align: middle;
  position: relative;
  top: -1px;
}
.wa-msg-status svg {
  vertical-align: middle;
}
.wa-msg-status-pending { color: #667781; }
.wa-msg-status-sent { color: #667781; }
.wa-msg-status-delivered { color: #667781; }
.wa-msg-status-read { color: #53bdeb; }
.wa-msg-status-failed { color: #e74c3c; }

/* Compose bar */
.wa-compose {
  padding: 0.75rem 1rem;
  background: #f0f2f5;
  border-top: 1px solid #dee2e6;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.wa-compose input {
  flex: 1;
  border-radius: 20px;
  border: none;
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  background: #fff;
}

.wa-compose input:focus {
  outline: none;
  box-shadow: none;
}

.wa-compose button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: #00a884;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}

.wa-compose button:hover {
  background: #008c6f;
}

.wa-compose button:disabled {
  background: #b0b0b0;
  cursor: not-allowed;
}

/* Empty state */
.wa-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #8696a0;
  background: #f0f2f5;
}

.wa-empty-state i {
  font-size: 5rem;
  margin-bottom: 1rem;
  opacity: 0.4;
}

.wa-empty-state p {
  font-size: 1rem;
}

/* History loading */
.wa-history-loading {
  text-align: center;
  color: #8696a0;
  font-size: 0.85rem;
  padding: 2rem;
}

/* Media messages */
.wa-media-img {
  max-width: 100%;
  border-radius: 6px;
  cursor: pointer;
  display: block;
  margin-bottom: 4px;
}

.wa-media-video {
  max-width: 100%;
  border-radius: 6px;
  display: block;
  margin-bottom: 4px;
}

.wa-media-audio {
  width: 100%;
  margin-bottom: 4px;
}

.wa-voice-note {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 240px;
  margin-bottom: 4px;
}

.wa-voice-note audio {
  display: none;
}

.wa-voice-play {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  border: none;
  background: #00a884;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0;
}

.wa-voice-play:hover {
  background: #008c6f;
}

.wa-voice-track {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  height: 24px;
  justify-content: center;
}

.wa-voice-track::before {
  content: "";
  display: block;
  height: 4px;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.15);
  width: 100%;
}

.wa-voice-bar {
  position: absolute;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
  height: 4px;
  border-radius: 2px;
  background: #00a884;
  width: 0%;
  transition: width 0.1s linear;
}

.wa-voice-duration {
  font-size: 0.7rem;
  color: #667781;
  position: absolute;
  bottom: -2px;
  left: 0;
}

.wa-media-sticker {
  max-width: 180px;
  display: block;
  margin-bottom: 4px;
}

.wa-media-doc {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 6px;
  color: #027eb5;
  text-decoration: none;
  font-size: 0.85rem;
  margin-bottom: 4px;
}

.wa-media-doc:hover {
  background: rgba(0, 0, 0, 0.08);
}

.wa-media-doc i {
  font-size: 1.25rem;
}

.wa-bubble-unsupported {
  color: #8696a0;
  font-style: italic;
  font-size: 0.85rem;
}

/* Attach button */
.wa-attach-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: #54656f;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.25rem;
  flex-shrink: 0;
  transition: color 0.15s;
}

.wa-attach-btn:hover {
  color: #111b21;
}

/* File preview bar */
.wa-file-preview {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  background: #e8e8e8;
  border-top: 1px solid #dee2e6;
}

.wa-file-preview-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
}

.wa-file-preview i {
  font-size: 2rem;
  color: #54656f;
}

.wa-file-preview-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.wa-file-preview-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: #111b21;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wa-file-preview-size {
  font-size: 0.75rem;
  color: #667781;
}

.wa-file-preview-remove {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: #667781;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}

.wa-file-preview-remove:hover {
  color: #111b21;
}

/* Drop zone overlay */
.wa-drop-zone {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(0, 168, 132, 0.15);
  border: 3px dashed #00a884;
  border-radius: 8px;
  z-index: 10;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 600;
  color: #00a884;
  pointer-events: none;
}

.wa-drop-zone.active {
  display: flex;
}

/* Upload state */
.wa-uploading .wa-compose {
  opacity: 0.6;
  pointer-events: none;
}

/* Session selector */
.wa-session-select {
  border-radius: 6px;
  font-size: 0.85rem;
  padding: 0.25rem 0.5rem;
  border: 1px solid #dee2e6;
}

/* Date dividers */
.wa-date-divider {
  display: flex;
  justify-content: center;
  margin: 12px 0;
}

.wa-date-divider span {
  background: rgba(255, 255, 255, 0.9);
  color: rgba(0, 0, 0, 0.6);
  font-size: 0.8rem;
  padding: 4px 12px;
  border-radius: 6px;
  box-shadow: 0 0 1px 1px rgba(0, 0, 0, 0.06), 0 1px 0 0 rgba(0, 0, 0, 0.05);
}

/* Group chat sender name */
.wa-bubble-sender {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: #1f7aec; /* default, overridden by inline style per contact */
  margin-bottom: 2px;
}

/* Raw JSON dialog (easter egg) */
.wa-json-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wa-json-dialog {
  background: #1e1e1e;
  color: #d4d4d4;
  border-radius: 8px;
  width: 600px;
  max-width: 90vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.wa-json-dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid #333;
  font-weight: 600;
  font-size: 0.9rem;
}

.wa-json-dialog-close {
  background: none;
  border: none;
  color: #d4d4d4;
  font-size: 1.2rem;
  cursor: pointer;
}

.wa-json-dialog pre {
  margin: 0;
  padding: 16px;
  overflow: auto;
  flex: 1;
  font-family: monospace;
  font-size: 0.75rem;
  white-space: pre-wrap;
  word-break: break-all;
  user-select: text;
}

/* Chat dialog (modal) */
.wa-chat-dialog-body {
  height: 70vh;
  display: flex;
  flex-direction: column;
}

.wa-chat-dialog-body .wa-messages-panel {
  flex: 1;
  border-radius: 0;
}

.wa-chat-dialog-body .wa-messages-body {
  padding: 1rem 2rem;
}
