/**
 * NigerBizz Customer-Vendor Live Chat CSS
 * Ultra-Responsive for Mobile (Android & iOS) and Desktop
 */

:root {
  --chat-sidebar-width: 320px;
  --chat-bg-mine: #e8f5e9;
  --chat-bg-other: #ffffff;
  --chat-border: #e2e8f0;
}

.nb-chat-container {
  max-width: 1200px;
  margin: 30px auto 60px;
  padding: 0 15px;
  box-sizing: border-box;
}

.nb-chat-wrapper {
  display: flex;
  height: 680px;
  background: #ffffff;
  border: 1px solid var(--chat-border);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
  overflow: hidden;
  position: relative;
}

/* Sidebar */
.nb-chat-sidebar {
  width: var(--chat-sidebar-width);
  border-right: 1px solid var(--chat-border);
  display: flex;
  flex-direction: column;
  background: #f8fafc;
  flex-shrink: 0;
  z-index: 2;
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.nb-chat-sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--chat-border);
  background: #ffffff;
}

.nb-chat-sidebar-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--ink-900, #0f172a);
  margin: 0 0 10px 0;
}

.nb-chat-search-box {
  position: relative;
}

.nb-chat-search-input {
  width: 100%;
  padding: 9px 12px 9px 34px;
  border: 1px solid var(--grey-200, #cbd5e1);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  background: #f1f5f9;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.nb-chat-search-input:focus {
  background: #ffffff;
  border-color: var(--primary-green, #3db83a);
  box-shadow: 0 0 0 3px rgba(61, 184, 58, 0.15);
}

.nb-chat-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  pointer-events: none;
}

.nb-conversations-list {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 0;
  -webkit-overflow-scrolling: touch;
}

.nb-conversation-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  transition: background 0.15s ease;
  position: relative;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.nb-conversation-item:hover,
.nb-conversation-item:active {
  background: #f1f5f9;
}

.nb-conversation-item.active {
  background: #eefdf0;
  border-inline-start: 4px solid var(--primary-green, #3db83a);
}

.nb-conv-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

.nb-conv-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid #e2e8f0;
}

.nb-conv-details {
  flex: 1;
  min-width: 0;
}

.nb-conv-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.nb-conv-name {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nb-conv-time {
  font-size: 11.5px;
  color: #94a3b8;
  white-space: nowrap;
}

.nb-conv-bottom-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nb-conv-last-msg {
  font-size: 13px;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.nb-conv-unread-badge {
  background: var(--primary-green, #3db83a);
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 12px;
  line-height: 1.4;
}

/* Empty State */
.nb-chat-empty-sidebar {
  padding: 40px 20px;
  text-align: center;
  color: #94a3b8;
  font-size: 13.5px;
}

/* Main Chat Area */
.nb-chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #f8fafc;
  position: relative;
  z-index: 1;
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.nb-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #ffffff;
  border-bottom: 1px solid var(--chat-border);
  min-height: 60px;
  box-sizing: border-border;
}

.nb-chat-header-user {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.nb-mobile-back-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #f1f5f9;
  border: none;
  cursor: pointer;
  color: #334155;
  flex-shrink: 0;
  padding: 0;
  transition: background 0.15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.nb-mobile-back-btn:active {
  background: #e2e8f0;
}

.nb-chat-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.nb-chat-header-title {
  font-size: 15px;
  font-weight: 800;
  color: #0f172a;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nb-chat-header-status {
  font-size: 12px;
  color: #10b981;
  display: flex;
  align-items: center;
  gap: 4px;
}

.nb-chat-header-product {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f1f5f9;
  padding: 6px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: #334155;
  font-size: 12.5px;
  font-weight: 600;
  max-width: 240px;
  transition: background 0.15s;
  flex-shrink: 0;
}

.nb-chat-header-product:hover {
  background: #e2e8f0;
}

.nb-chat-product-thumb {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  object-fit: cover;
}

/* Messages Body */
.nb-chat-messages-body {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background-image: radial-gradient(#cbd5e1 1px, transparent 1px);
  background-size: 20px 20px;
  -webkit-overflow-scrolling: touch;
}

.nb-chat-placeholder-main {
  margin: auto;
  text-align: center;
  color: #94a3b8;
  padding: 20px;
}

.nb-chat-placeholder-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.nb-message-row {
  display: flex;
  flex-direction: column;
  max-width: 72%;
}

.nb-message-row.mine {
  align-self: flex-end;
}

.nb-message-row.other {
  align-self: flex-start;
}

.nb-message-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.nb-message-row.mine .nb-message-bubble {
  background: var(--primary-green, #3db83a);
  color: #ffffff;
  border-bottom-right-radius: 2px;
}

.nb-message-row.other .nb-message-bubble {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid var(--chat-border);
  border-bottom-left-radius: 2px;
}

.nb-message-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #94a3b8;
  margin-top: 4px;
}

.nb-message-row.mine .nb-message-meta {
  justify-content: flex-end;
}

/* Chat Composer Footer */
.nb-chat-composer {
  padding: 12px 14px;
  background: #ffffff;
  border-top: 1px solid var(--chat-border);
  display: flex;
  align-items: center;
  gap: 8px;
  box-sizing: border-box;
}

.nb-chat-tools {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nb-chat-tool-btn {
  background: #f1f5f9;
  border: none;
  border-radius: 20px;
  padding: 6px 12px;
  cursor: pointer;
  color: #475569;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s;
  min-height: 38px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.nb-chat-tool-btn:hover,
.nb-chat-tool-btn:active {
  background: #e2e8f0;
}

.nb-chat-input {
  flex: 1;
  border: 1px solid var(--grey-200, #cbd5e1);
  border-radius: 24px;
  padding: 10px 16px;
  font-size: 15px;
  outline: none;
  resize: none;
  height: 42px;
  max-height: 100px;
  transition: border-color 0.2s;
  font-family: inherit;
  box-sizing: border-border;
  background: #ffffff;
}

.nb-chat-input:focus {
  border-color: var(--primary-green, #3db83a);
}

.nb-chat-send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--primary-green, #3db83a);
  color: #ffffff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
  flex-shrink: 0;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.nb-chat-send-btn:hover,
.nb-chat-send-btn:active {
  background: var(--primary-green-hover, #32962f);
}

.nb-chat-send-btn:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
}

/* Modal Styling */
.nb-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  z-index: 999999;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

/* =========================================================
   Mobile Responsiveness (Android & iOS iPhone)
   ========================================================= */
@media (max-width: 768px) {
  .nb-chat-container {
    margin: 0;
    padding: 0;
    max-width: 100%;
    width: 100%;
  }

  .nb-chat-wrapper {
    height: calc(100dvh - 56px);
    height: calc(100vh - 56px);
    border-radius: 0;
    border: none;
    box-shadow: none;
    position: relative;
    overflow: hidden;
  }

  .nb-chat-sidebar {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-right: none;
    transform: translateX(0);
  }

  .nb-chat-main {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    transform: translateX(100%);
  }

  .nb-chat-wrapper.mobile-open-chat .nb-chat-sidebar {
    transform: translateX(-100%);
  }

  .nb-chat-wrapper.mobile-open-chat .nb-chat-main {
    transform: translateX(0);
  }

  .nb-mobile-back-btn {
    display: inline-flex;
  }

  .nb-message-row {
    max-width: 86%;
  }

  .nb-chat-input {
    font-size: 16px; /* Prevents auto-zoom in iOS Safari */
    height: 40px;
    padding: 8px 14px;
  }

  .nb-chat-composer {
    padding: 8px 10px;
    gap: 6px;
  }

  .nb-chat-header {
    padding: 10px 12px;
  }

  .nb-chat-header-product {
    max-width: 160px;
    font-size: 11.5px;
    padding: 4px 8px;
  }

  .nb-chat-header-product span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .nb-chat-offer-trigger span {
    font-size: 12px;
  }
}
