/* Organic Picks Admin Custom Styles */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  letter-spacing: -0.01em;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Compact Chat bubble styling (WhatsApp/Telegram style) */
.msg-bubble {
  max-width: 80% !important;
  min-width: 0 !important;
  width: fit-content !important;
  box-sizing: border-box !important;
  word-break: break-word !important;
  overflow-wrap: anywhere !important;
  word-wrap: break-word !important;
  position: relative !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05) !important;
  /* Ultra-compact padding: 6px top/bottom, 11px left/right */
  padding: 6px 11px !important;
  border-radius: 12px !important;
  line-height: 1.35 !important;
}

/* Keep text tight inside the bubble */
.msg-bubble .msg-text-body {
  font-size: 13.5px !important;
  line-height: 1.35 !important;
}

.msg-text-body {
  display: inline !important;
  font-size: 13.5px !important;
  line-height: 1.35 !important;
  word-break: break-word !important;
  overflow-wrap: anywhere !important;
  word-wrap: break-word !important;
  white-space: pre-wrap !important;
  max-width: 100% !important;
}

.msg-bubble.admin {
  background-color: #059669 !important; /* Lush Organic Emerald */
  color: #ffffff !important;
  border-top-right-radius: 3px !important;
  border: none !important;
}

.msg-bubble.customer {
  background-color: #ffffff !important;
  color: #0f172a !important;
  border-top-left-radius: 3px !important;
  border: 1px solid #e2e8f0 !important;
}

/* Message Meta & Read Receipt Checkmarks */
.msg-meta {
  display: flex !important;
  align-items: center !important;
  gap: 3px !important;
  margin-top: 1px !important;
  margin-bottom: 0 !important;
  padding: 0 2px !important;
  line-height: 1 !important;
}

.msg-meta span {
  font-size: 10px !important;
  line-height: 1 !important;
  color: #94a3b8 !important;
}

.read-tick {
  font-size: 11px !important;
  font-weight: 800 !important;
  letter-spacing: -0.5px !important;
  line-height: 1 !important;
}

.read-tick.sent {
  color: #94a3b8 !important;
}

.read-tick.read {
  color: #059669 !important; /* Green double checkmark */
}

/* Audio Player inside Admin */
.admin-audio-player {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 210px;
  padding: 4px 0;
}

.admin-audio-play-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.msg-bubble.admin .admin-audio-play-btn {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}
.msg-bubble.admin .admin-audio-play-btn:hover {
  background: rgba(255, 255, 255, 0.35);
}

.msg-bubble.customer .admin-audio-play-btn {
  background: #059669;
  color: #ffffff;
}
.msg-bubble.customer .admin-audio-play-btn:hover {
  background: #047857;
}

.admin-audio-progress-bar {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  position: relative;
  cursor: pointer;
}

.msg-bubble.admin .admin-audio-progress-bar {
  background: rgba(255, 255, 255, 0.3);
}

.msg-bubble.customer .admin-audio-progress-bar {
  background: #e2e8f0;
}

.admin-audio-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  border-radius: 3px;
  width: 0%;
}

.msg-bubble.admin .admin-audio-fill {
  background: #ffffff;
}

.msg-bubble.customer .admin-audio-fill {
  background: #059669;
}

/* Active session item */
.session-item.active {
  background-color: #ecfdf5 !important;
  border-left: 4px solid #059669 !important;
}

/* Quick response chips */
.canned-chip {
  padding: 4px 11px;
  border-radius: 20px;
  background-color: #f1f5f9;
  color: #334155;
  font-weight: 600;
  font-size: 11px;
  white-space: nowrap;
  transition: all 0.15s ease;
  cursor: pointer;
  border: 1px solid #e2e8f0;
}
.canned-chip:hover {
  background-color: #ecfdf5;
  color: #065f46;
  border-color: #a7f3d0;
}

/* WhatsApp action button */
.btn-whatsapp-action {
  background: #25d366;
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.2s ease;
  text-decoration: none;
}
.btn-whatsapp-action:hover {
  background: #128c7e;
  transform: translateY(-1px);
}

/* Animations */
@keyframes pulse-subtle {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.85; transform: scale(1.06); }
}

.unread-pulse {
  animation: pulse-subtle 2s infinite ease-in-out;
}

/* Message hover action menu (Edit / Delete) */
.msg-row {
  position: relative !important;
  display: flex !important;
  flex-direction: column !important;
  margin-bottom: 4px !important;
  margin-top: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
}

/* Consecutive messages from the same sender sit closer together */
.msg-row.admin + .msg-row.admin,
.msg-row.customer + .msg-row.customer {
  margin-top: -2px !important;
  margin-bottom: 3px !important;
}

/* Disallow floating awkward pill permanently */
.msg-actions {
  display: none !important;
}

/* Native long-press & interaction feedback */
.msg-bubble {
  -webkit-touch-callout: none !important;
  user-select: text;
  transition: transform 0.12s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.15s ease, opacity 0.12s ease;
  cursor: pointer;
}

.msg-bubble.pressing {
  transform: scale(0.97) !important;
  opacity: 0.9 !important;
}

.msg-bubble.selected-action {
  box-shadow: 0 0 0 2.5px #059669, 0 4px 12px rgba(5, 150, 105, 0.25) !important;
}

.msg-edited-tag {
  font-size: 10px;
  font-style: italic;
  opacity: 0.82;
  margin-left: 4px;
  user-select: none;
}

.msg-bubble.is-deleted {
  background-color: #f1f5f9 !important;
  color: #64748b !important;
  border: 1px dashed #cbd5e1 !important;
  font-style: italic !important;
  box-shadow: none !important;
}

.msg-inline-edit-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 220px;
}

.msg-inline-edit-textarea {
  width: 100%;
  padding: 6px 10px;
  font-size: 13px;
  border-radius: 8px;
  border: 1.5px solid #059669;
  background: #ffffff;
  color: #0f172a;
  outline: none;
  resize: vertical;
}

.msg-inline-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.msg-edit-save-btn {
  background: #059669;
  color: white;
  border: none;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.msg-edit-cancel-btn {
  background: #e2e8f0;
  color: #475569;
  border: none;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

/* ===================================================
   Mobile Responsiveness & Touch Optimizations
   =================================================== */
/* ===================================================
   Mobile Responsiveness & Native App Experience
   =================================================== */
@media (max-width: 767px) {
  html, body {
    width: 100%;
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    -webkit-overflow-scrolling: touch;
  }

  /* When viewing an active conversation on mobile, HIDE the main global header!
     The screen has ONLY the conversation header at the top, just like WhatsApp/Telegram! */
  body.mobile-chat-open #main-header {
    display: none !important;
  }

  /* Chat bubbles take full readable width on phone without clipping */
  .msg-bubble {
    max-width: 86% !important;
    font-size: 13.5px !important;
    line-height: 1.35 !important;
    padding: 6px 10px !important;
  }

  .msg-bubble .msg-text-body {
    font-size: 13.5px !important;
    line-height: 1.35 !important;
  }

  /* Compact audio player on mobile */
  .admin-audio-player {
    min-width: 160px !important;
    max-width: 100% !important;
    gap: 8px !important;
  }


  /* Prevent iOS automatic screen zoom on focus */
  #admin-message-input,
  #search-input,
  input[type="text"],
  input[type="tel"],
  input[type="password"],
  select {
    font-size: 16px !important;
  }

  /* Safe area padding for notched mobile screens */
  header, #conversation-header {
    padding-top: max(env(safe-area-inset-top, 0px), 4px);
  }

  #canned-replies-bar {
    -webkit-overflow-scrolling: touch;
  }
}
