/* ========================
   FinDeals - Additions for API-wired screens
   Small, targeted rules for markup added while wiring
   My Loans, Boost Post, and Chats to the backend APIs.
   Kept separate from style.css so the base stylesheet stays untouched.
======================== */

/* My Loans: promoted status label */
.myloan-status-label.is-promoted {
  color: var(--primary);
}

/* Boost Post: selectable tier cards */
.boost-highlight-card {
  cursor: pointer;
  width: 100%;
  text-align: left;
}

.boost-highlight-card.is-selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(106, 56, 255, .15);
}

/* ============================================================================
   FinDeals - Complete Synchronized Chat System Styling
   ============================================================================ */

/* Chat layout sizing & viewport lock */
.chats-app-main {
  height: calc(100vh - 74px);
  height: calc(100dvh - 74px);
  max-height: calc(100vh - 74px);
  max-height: calc(100dvh - 74px);
  padding: 0;
  margin: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #f8f7fc;
}

body:has(.chats-app-main) .site-footer,
body:has(.chats-app-main) footer {
  display: none !important;
}

.chats-app-shell {
  flex: 1;
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-columns: minmax(320px, 390px) minmax(0, 1fr);
  background: #ffffff;
  border-top: 1px solid #e9e5f5;
  overflow: hidden;
}

/* Sidebar styling */
.chats-sidebar {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  background: #faf9fd;
  border-right: 1px solid #ece8f7;
  overflow: hidden;
}

.chats-sidebar .chats-toolbar {
  padding: 1.1rem 1.25rem 0.5rem;
  margin-bottom: 0.25rem;
  flex-shrink: 0;
}

.chats-sidebar .chats-toolbar h1 {
  font-size: 1.4rem;
  font-weight: 800;
  color: #1f1845;
  margin: 0;
  letter-spacing: -0.02em;
}

.chats-sidebar .chats-tabs {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0 1rem 0.65rem;
  margin: 0;
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.chats-sidebar .chats-tabs::-webkit-scrollbar {
  display: none;
}

.chats-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.4rem 0.65rem;
  border-radius: 999px;
  border: 1px solid #e4def5;
  background: #ffffff;
  color: #554a7c;
  font-weight: 600;
  font-size: 0.78rem;
  white-space: nowrap;
  transition: all 0.2s ease;
  cursor: pointer;
}

.chats-tab:hover {
  background: #f1edfc;
  color: #6a38ff;
  border-color: #d6cbfa;
}

.chats-tab.is-active {
  background: #6a38ff !important;
  border-color: #6a38ff !important;
  color: #ffffff !important;
  box-shadow: 0 4px 12px rgba(106, 56, 255, 0.24);
}

.chats-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  padding: 0 4px;
  background: rgba(0, 0, 0, 0.07);
  font-size: 0.68rem;
  font-weight: 700;
}

.chats-tab.is-active .chats-tab-count {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

.chats-search {
  position: relative;
  padding: 0 1rem 0.75rem;
  margin: 0;
  flex-shrink: 0;
}

.chats-search > i {
  position: absolute;
  left: 1.85rem;
  top: 40%;
  transform: translateY(-50%);
  color: #9a93b8;
  font-size: 0.95rem;
  pointer-events: none;
}

.chats-search .form-control {
  border-radius: 12px;
  border: 1px solid #e4def5;
  background: #ffffff;
  padding: 0.55rem 0.85rem 0.55rem 2.35rem;
  font-size: 0.85rem;
  height: 42px;
  box-shadow: none;
  transition: all 0.2s ease;
}

.chats-search .form-control:focus {
  border-color: #6a38ff;
  box-shadow: 0 0 0 3px rgba(106, 56, 255, 0.12);
}

.chats-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

/* Chat Card in sidebar */
.chats-card {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 0.65rem;
  align-items: center;
  padding: 0.7rem 0.85rem;
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid #ebe6f8;
  text-align: left;
  cursor: pointer;
  transition: all 0.18s ease;
  width: 100%;
}

.chats-card:hover {
  background: #f5f2ff;
  border-color: #d8cefb;
  transform: translateY(-1px);
}

.chats-card.is-active {
  background: #ede8ff !important;
  border-color: #b7a3fc !important;
  box-shadow: 0 4px 14px rgba(106, 56, 255, 0.12);
}

.chats-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0;
}

.chats-card-body {
  min-width: 0;
  overflow: hidden;
}

.chats-card-top {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.15rem;
}

.chats-masked-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: #1f1845;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chats-tag {
  font-size: 0.64rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.chats-tag.is-borrowing {
  background: #efeaff;
  color: #6a38ff;
}

.chats-tag.is-lending {
  background: #fce7f3;
  color: #be185d;
}

.chats-last-msg {
  margin: 0;
  font-size: 0.78rem;
  color: #6e678a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chats-card-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
  min-width: 50px;
}

.chats-card-meta time {
  font-size: 0.68rem;
  color: #928ca9;
  white-space: nowrap;
}

.chats-unread {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  padding: 0 4px;
  background: #6a38ff;
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 700;
}

/* Conversation Area */
.chats-conversation {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  min-width: 0;
  background: #ffffff;
  position: relative;
  overflow: hidden;
}

.chat-detail-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  width: 100%;
  overflow: hidden;
  background: #ffffff;
  border: none;
  box-shadow: none;
  border-radius: 0;
}

/* Conversation Topbar */
.chat-detail-topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  background: #ffffff;
  border-bottom: 1px solid #ece7f8;
  flex-shrink: 0;
  color: #1f1845;
}

.chat-peer-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6a38ff 0%, #a855f7 100%);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(106, 56, 255, 0.2);
}

.chat-peer-meta {
  flex: 1;
  min-width: 0;
}

.chat-peer-meta strong {
  display: flex;
  align-items: center;
  font-size: 0.95rem;
  font-weight: 700;
  color: #1f1845;
}

.chat-peer-online {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: #16a34a;
}

.online-pulse {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #16a34a;
  box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.25);
}

.chat-top-loan {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  background: #f1edfc;
  color: #6a38ff;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid #ded6fa;
  transition: all 0.18s ease;
  max-width: 240px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-top-loan:hover {
  background: #6a38ff;
  color: #ffffff;
  border-color: #6a38ff;
}

.chat-more-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid #e4def5;
  background: #ffffff;
  color: #554a7c;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.18s ease;
}

.chat-more-btn:hover {
  background: #f3f0fc;
  color: #6a38ff;
}

.chat-more-menu .dropdown-menu {
  min-width: 180px;
  border-radius: 12px;
  border: none;
  box-shadow: 0 12px 32px rgba(60, 40, 120, .16);
  padding: .4rem;
}

.chat-more-menu .dropdown-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  border-radius: 8px;
  font-size: .85rem;
  padding: .5rem .6rem;
}

.chat-blocked-banner {
  margin: .7rem 1rem 0;
  display: flex;
  align-items: center;
  gap: .45rem;
  background: #fdeaea;
  color: #a12626;
  border-radius: 10px;
  padding: .55rem .75rem;
  font-size: .76rem;
  font-weight: 600;
}

.chat-blocked-banner i {
  color: #d92d2d;
}

.chat-secure-banner {
  margin: 0.5rem 1rem 0;
  padding: 0.45rem 0.85rem;
  border-radius: 10px;
  background: #f5f2ff;
  color: #5824e8;
  font-size: 0.74rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid #e7dffd;
  flex-shrink: 0;
}

/* Chat Message Thread */
.chat-thread {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem 1.25rem;
  background: #fbfaff;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.chat-msg {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  width: 100%;
}

.chat-msg.is-out {
  justify-content: flex-end;
}

.chat-msg.is-in {
  justify-content: flex-start;
}

.chat-bubble-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #ece7fb;
  color: #6a38ff;
  font-size: 0.68rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-bubble-avatar.is-me {
  background: #6a38ff;
  color: #ffffff;
}

.chat-bubble {
  max-width: min(76%, 500px);
  padding: 0.65rem 0.95rem;
  font-size: 0.86rem;
  line-height: 1.45;
  position: relative;
  word-break: break-word;
}

.chat-msg.is-in .chat-bubble {
  background: #ffffff;
  color: #1f1845;
  border-radius: 16px 16px 16px 4px;
  box-shadow: 0 2px 8px rgba(40, 28, 90, 0.05);
  border: 1px solid #ece7f8;
}

.chat-msg.is-out .chat-bubble {
  background: linear-gradient(135deg, #6a38ff 0%, #5824e8 100%);
  color: #ffffff;
  border-radius: 16px 16px 4px 16px;
  box-shadow: 0 4px 14px rgba(106, 56, 255, 0.22);
}

.chat-bubble p {
  margin: 0 0 0.25rem;
}

.chat-bubble time {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.25rem;
  font-size: 0.68rem;
  opacity: 0.75;
}

.chat-msg.is-out .chat-bubble time {
  color: rgba(255, 255, 255, 0.85);
}

.chat-msg.is-out .chat-bubble time i {
  font-size: 0.85rem;
  color: #c7b3ff;
}

/* Quick replies horizontal scroll */
.chat-composer-dock {
  background: #ffffff;
  border-top: 1px solid #ece7f8;
  padding: 0.6rem 1rem 0.75rem;
  flex-shrink: 0;
}

.chat-quick-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 0.5rem;
  white-space: nowrap;
}

.chat-quick-row::-webkit-scrollbar {
  display: none;
}

.chat-quick-btn {
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  border: 1px solid #ded6fa;
  background: #f7f5fd;
  color: #6a38ff;
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.chat-quick-btn:hover {
  background: #6a38ff;
  color: #ffffff;
  border-color: #6a38ff;
}

/* 2-column flex Composer fix */
.chat-composer {
  display: flex !important;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
}

.chat-composer .form-control {
  flex: 1;
  border-radius: 999px;
  border: 1px solid #ded6fa;
  padding: 0.6rem 1.15rem;
  font-size: 0.88rem;
  height: 44px;
  background: #fbfaff;
  box-shadow: none;
  transition: all 0.2s ease;
}

.chat-composer .form-control:focus {
  background: #ffffff;
  border-color: #6a38ff;
  box-shadow: 0 0 0 3px rgba(106, 56, 255, 0.12);
}

.chat-send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #6a38ff 0%, #5824e8 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(106, 56, 255, 0.28);
  flex-shrink: 0;
}

.chat-send-btn:hover {
  transform: scale(1.04);
  box-shadow: 0 6px 16px rgba(106, 56, 255, 0.38);
}

/* Empty State */
.chat-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2.5rem;
  background: #fbfaff;
}

.chat-empty-icon {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: #efeaff;
  color: #6a38ff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin-bottom: 1rem;
  box-shadow: 0 8px 24px rgba(106, 56, 255, 0.15);
}

/* Responsive Mobile View Transition */
@media (max-width: 1199.98px) {
  .chats-app-main {
    height: calc(100vh - 64px);
    height: calc(100dvh - 64px);
    max-height: calc(100vh - 64px);
    max-height: calc(100dvh - 64px);
  }

  .chats-app-shell {
    grid-template-columns: 1fr;
  }

  .chats-sidebar {
    display: flex;
    width: 100%;
  }

  .chats-conversation {
    display: none;
    width: 100%;
  }

  .chats-app-shell.is-chat-open .chats-sidebar {
    display: none;
  }

  .chats-app-shell.is-chat-open .chats-conversation {
    display: flex;
  }

  .chat-back {
    display: inline-flex !important;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid #ded6fa;
    background: #f5f2ff;
    color: #6a38ff;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    flex-shrink: 0;
  }
}

/* ========================
   Edit Profile Enhancements
   ======================== */
.edit-profile-avatar-card {
  background: #fff;
  border: 1px solid #ebeaf2;
  border-radius: 20px;
  padding: 1.5rem;
  box-shadow: 0 8px 24px rgba(40, 28, 90, .04);
}

.edit-avatar-preview-wrap {
  position: relative;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  box-shadow: 0 8px 20px rgba(106, 56, 255, .15);
  border: 3px solid #fff;
  overflow: hidden;
  background: linear-gradient(135deg, #6a38ff 0%, #a855f7 100%);
  flex-shrink: 0;
}

.edit-avatar-preview-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.edit-avatar-initials {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  font-weight: 700;
  color: #fff;
  text-transform: uppercase;
}

.edit-avatar-overlay {
  position: absolute;
  inset: 0;
  background: rgba(20, 15, 45, .55);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: .75rem;
  opacity: 0;
  transition: opacity .2s ease;
  cursor: pointer;
  border-radius: 50%;
}

.edit-avatar-preview-wrap:hover .edit-avatar-overlay {
  opacity: 1;
}

.edit-avatar-overlay i {
  font-size: 1.35rem;
  margin-bottom: 2px;
}

.edit-avatar-upload-btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font-weight: 600;
  font-size: .88rem;
  padding: .5rem 1.1rem;
  border-radius: 12px;
  background: #f4f0ff;
  color: #6a38ff;
  border: 1px solid #e3d7fc;
  cursor: pointer;
  transition: all .2s ease;
}

.edit-avatar-upload-btn:hover {
  background: #6a38ff;
  color: #fff;
  border-color: #6a38ff;
}

.edit-avatar-remove-btn {
  font-size: .82rem;
  font-weight: 600;
  color: #ef4444;
  border: none;
  background: transparent;
  padding: .4rem .6rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  border-radius: 8px;
}

.edit-avatar-remove-btn:hover {
  background: #fee2e2;
}

.location-detect-btn {
  font-size: .8rem;
  font-weight: 600;
  padding: .35rem .75rem;
  border-radius: 8px;
  border: 1px solid #dcd7f5;
  background: #f8f6ff;
  color: #6a38ff;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  transition: all .2s;
}

.location-detect-btn:hover:not(:disabled) {
  background: #6a38ff;
  color: #fff;
  border-color: #6a38ff;
}

.profile-section-heading {
  font-size: 1.05rem;
  font-weight: 700;
  color: #1a163a;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}

.profile-section-heading i {
  color: #6a38ff;
  font-size: 1.2rem;
}

.quick-action-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .9rem 1.1rem;
  background: #fcfbfe;
  border: 1px solid #ebeaf2;
  border-radius: 14px;
  text-decoration: none;
  color: #1a163a;
  font-weight: 600;
  font-size: .9rem;
  transition: all .2s ease;
}

.quick-action-link:hover {
  background: #f4f0ff;
  border-color: #dcd7f5;
  color: #6a38ff;
  transform: translateY(-1px);
}

.quick-action-link.is-danger {
  color: #dc2626;
  background: #fffafa;
  border-color: #fee2e2;
}

.quick-action-link.is-danger:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #b91c1c;
}

.toast-feedback {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  min-width: 300px;
  max-width: 420px;
}

/* ============================================================================
   City / Location Search Modal Styling
   ============================================================================ */
.city-modal-content {
  background: #ffffff;
  border-radius: 20px !important;
  border: 1px solid #edf0f5;
  box-shadow: 0 20px 40px -10px rgba(10, 25, 60, 0.15) !important;
}

.city-modal-icon-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: #f0ecff;
  border-radius: 50%;
  font-size: 0.95rem;
}

.city-modal-search-wrap {
  position: relative;
}

.city-modal-search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.1rem;
  color: #94a3b8;
  pointer-events: none;
  z-index: 2;
}

.city-modal-search-input {
  padding-left: 46px !important;
  padding-right: 42px !important;
  border-radius: 14px !important;
  border: 1.5px solid #e2e8f0 !important;
  font-size: 0.98rem !important;
  font-weight: 500;
  background: #f8fafc;
  transition: all 0.2s ease;
}

.city-modal-search-input:focus {
  background: #ffffff;
  border-color: #6a38ff !important;
  box-shadow: 0 0 0 3px rgba(106, 56, 255, 0.15) !important;
}

.city-modal-clear-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  padding: 4px 8px;
  font-size: 1.1rem;
  z-index: 2;
}

.city-modal-spinner {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
}

.city-chip-btn {
  font-size: 0.82rem !important;
  font-weight: 500 !important;
  background: #f8fafc !important;
  border: 1px solid #e2e8f0 !important;
  color: #334155 !important;
  transition: all 0.15s ease !important;
}

.city-chip-btn:hover {
  background: #f1edff !important;
  border-color: #dcd3ff !important;
  color: #5824e8 !important;
  transform: translateY(-1px);
}

.city-modal-results-list {
  max-height: 280px;
  overflow-y: auto;
  margin-top: 8px;
}

.city-result-item {
  background: #ffffff;
  border: 1px solid transparent !important;
  transition: all 0.15s ease;
  cursor: pointer;
}

.city-result-item:hover {
  background: #f8faff !important;
  border-color: #e5e9f8 !important;
  transform: translateX(2px);
}

.city-result-item.active-city-item {
  background: #f2edff !important;
  border-color: #dcd3ff !important;
}

.city-result-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: #f1edff;
  color: #6a38ff;
  border-radius: 10px;
  font-size: 0.95rem;
  flex-shrink: 0;
}


