/* Wise-Inspired Full-Page Chat Styles */

:root {
  --wise-green: #9fe870;
  --wise-dark-green: #163300;
  --wise-near-black: #0e0f0c;
  --wise-light-mint: #e2f6d5;
  --wise-gray: #868685;
  --wise-border: rgba(14, 15, 12, 0.06);
  --wise-radius-card: 30px;
  --wise-radius-pill: 9999px;
  --font-display: 'Wise Sans', 'Inter', sans-serif;
  --font-body: 'Inter', sans-serif;
}

#chat-panel {
  height: auto !important; /* Managed by viewport wrapper */
  margin-top: 0 !important; /* Main container handles margin now */
  background: #ffffff;
  display: none; /* Managed by app.js 'active' class */
  padding: 0 !important; /* Override global 16px padding */
  overflow: hidden;
  position: relative;
}

#chat-panel.active {
  display: block;
}

.chat-viewport-wrapper {
  height: calc(100vh - 96px); /* Fix to viewport below header */
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-full-container {
  display: flex;
  height: 100%;
  width: 100%;
  background: #ffffff;
}

/* Legacy Sidebar Removed */

/* Main Chat Area */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #ffffff;
}

.chat-main-header {
  padding: 20px 30px;
  border-bottom: 1px solid var(--wise-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-header-name {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 32px;
  line-height: 0.85;
  text-transform: uppercase;
  color: var(--wise-near-black);
}

.chat-header-status {
  font-size: 12px;
  font-weight: 700;
  color: var(--wise-gray);
  text-transform: uppercase;
  margin-top: 4px;
  display: block;
}

.chat-messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 30px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background-image: radial-gradient(var(--wise-border) 1px, transparent 1px);
  background-size: 20px 20px;
}

.chat-message-bubble-row {
  display: flex;
  flex-direction: column;
  max-width: 75%;
}

.chat-message-bubble-row.sent {
  align-self: flex-end;
  align-items: flex-end;
}

.chat-message-bubble-row.received {
  align-self: flex-start;
  align-items: flex-start;
}

.chat-message-sender-name {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--wise-gray);
  margin-left: 12px;
}

.chat-message-bubble {
  padding: 14px 20px;
  font-size: 15px;
  line-height: 1.5;
  position: relative;
  word-wrap: break-word;
}

.sent .chat-message-bubble {
  background: var(--wise-near-black);
  color: #ffffff;
  border-radius: 24px 24px 4px 24px;
}

.received .chat-message-bubble {
  background: var(--wise-light-mint);
  color: var(--wise-near-black);
  border-radius: 24px 24px 24px 4px;
}

.chat-message-timestamp {
  font-size: 10px;
  color: var(--wise-gray);
  margin-top: 4px;
  text-transform: uppercase;
  font-weight: 600;
}

.chat-message-delete-btn {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 20px;
  height: 20px;
  background: var(--wise-near-black);
  color: white;
  border: 1px solid white;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12px;
}

.chat-message-bubble:hover .chat-message-delete-btn {
  display: flex;
}

/* Input Area */
.chat-input-area {
  padding: 24px 30px;
  border-top: 1px solid var(--wise-border);
  display: flex;
  gap: 12px;
  align-items: center;
  position: relative;
}

.chat-text-input {
  flex: 1;
  background: #f4f6f3;
  border: 1px solid var(--wise-border);
  border-radius: var(--wise-radius-pill);
  padding: 14px 24px;
  font-family: var(--font-body);
  font-size: 16px;
  color: var(--wise-near-black);
  transition: all 0.2s;
}

.chat-text-input:focus {
  outline: none;
  background: #ffffff;
  border-color: var(--wise-green);
  box-shadow: 0 0 0 4px rgba(159, 232, 112, 0.2);
}

.chat-send-btn {
  width: 48px;
  height: 48px;
  background: var(--wise-near-black);
  color: #ffffff;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.chat-send-btn:hover {
  transform: scale(1.1);
}

.chat-send-btn:active {
  transform: scale(0.95);
}

/* Mention Dropdown */
.chat-mention-dropdown {
  position: absolute;
  bottom: 100%;
  left: 30px;
  width: 280px;
  max-height: 200px;
  background: #ffffff;
  border: 1px solid var(--wise-border);
  border-radius: 16px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 100;
  margin-bottom: 8px;
}

.chat-mention-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.2s;
}

.chat-mention-item:hover {
  background: var(--wise-light-mint);
}

.chat-mention-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--wise-near-black);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
}

.chat-mention-details {
  display: flex;
  flex-direction: column;
}

.chat-mention-name {
  font-size: 14px;
  font-weight: 600;
}

.chat-mention-role {
  font-size: 11px;
  color: var(--wise-gray);
}

.mention-tag {
  color: var(--wise-green);
  font-weight: 700;
  background: rgba(159, 232, 112, 0.1);
  padding: 0 4px;
  border-radius: 4px;
}

/* Toggle Button styling */
.chat-sidebar-toggle-btn {
  display: flex; /* Visible on all screens */
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: #f4f6f3;
  border: 1px solid var(--wise-border);
  border-radius: var(--wise-radius-pill);
  color: var(--wise-near-black);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  height: 36px;
}

.chat-sidebar-toggle-btn:hover {
  background: #e8ebe6;
}

/* Sidebar sliding drawer overlay */
.chat-sidebar-overlay {
  display: none;
  position: fixed;
  top: 62px;
  bottom: 54px;
  left: 0;
  right: 0;
  background: rgba(14, 15, 12, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1005;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.chat-sidebar-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* Tablet & Mobile Tweaks */
@media (max-width: 992px) {
  #chat-panel {
    position: fixed !important;
    top: 102px !important;
    bottom: 78px !important;
    height: auto !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    z-index: 800 !important;
  }

  .chat-viewport-wrapper {
    height: 100% !important;
  }

  .chat-sidebar-toggle-btn {
    display: flex !important;
  }

  .chat-main-header {
    padding: 16px 20px !important;
  }

  .chat-messages-container {
    padding: 20px !important;
    gap: 12px !important;
  }

  .chat-input-area {
    padding: 16px 20px !important;
  }

  .chat-message-bubble-row {
    max-width: 85% !important;
  }
}

@media (max-width: 576px) {
  .chat-main-header {
    padding: 12px 16px;
  }

  .chat-header-name {
    font-size: 20px !important;
  }

  .chat-messages-container {
    padding: 16px;
  }

  .chat-input-area {
    padding: 12px 16px;
  }
}

/* --- MOBILE FLOATING CHAT FAB --- */
#mobile-chat-fab-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  pointer-events: none;
}

.mobile-chat-fab {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  background-color: #f4f6f3;
  color: var(--wise-near-black);
  border: 1px solid var(--wise-border);
  border-radius: var(--wise-radius-pill);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.mobile-chat-fab:hover {
  transform: scale(1.05);
  box-shadow: 0 15px 50px rgba(0, 0, 0, 0.2);
}

.mobile-chat-fab:active {
  transform: scale(0.95);
}

.mobile-chat-fab.active {
  background: var(--wise-near-black);
  color: #ffffff;
}

/* --- MOBILE CHAT POPUP --- */
.mobile-chat-popup {
  position: fixed;
  bottom: 90px;
  right: 24px;
  width: 360px;
  max-height: 520px;
  background: #ffffff;
  border-radius: 30px;
  box-shadow: 0 30px 90px rgba(14, 15, 12, 0.2), 0 0 0 1px var(--wise-border);
  z-index: 2001;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  transform-origin: bottom right;
}

.mobile-chat-popup.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.mobile-chat-popup-header {
  padding: 24px;
  background: var(--wise-near-black);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mobile-chat-popup-header h3 {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 22px;
  text-transform: uppercase;
  margin: 0;
  letter-spacing: -0.02em;
  line-height: 0.85;
}

.mobile-chat-close-btn {
  background: none;
  border: none;
  font-size: 28px;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color 0.2s;
}

.mobile-chat-close-btn:hover {
  color: #ffffff;
}

.mobile-chat-colleagues-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.colleague-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.colleague-item:hover {
  background: #f4f6f3;
  transform: scale(1.02);
}

.colleague-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #e8ebe6;
  color: var(--wise-near-black);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  position: relative;
  flex-shrink: 0;
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 1px var(--wise-border);
}

.colleague-status {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  background: #10b981;
}

.colleague-info {
  display: flex;
  flex-direction: column;
}

.colleague-name {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 16px;
  color: var(--wise-near-black);
}

.colleague-role {
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--wise-gray);
}

.mobile-chat-popup-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--wise-border);
  background: #fcfdfb;
}

.btn-pill-subtle {
  width: 100%;
  background: rgba(14, 15, 12, 0.08);
  color: var(--wise-near-black);
  border: none;
  border-radius: var(--wise-radius-pill);
  padding: 10px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-pill-subtle:hover {
  background: rgba(14, 15, 12, 0.12);
  transform: scale(1.02);
}

/* Hide on large desktop if desired, but user asked for "any screen" */
@media (min-width: 1441px) {
  /* Optional: Could hide or move it */
}

/* Adjust for mobile view to create a premium bottom-sheet feel */
@media (max-width: 1024px) {
  #mobile-chat-fab-container {
    bottom: 24px;
    right: 20px;
  }

  .mobile-chat-popup {
    bottom: 0;
    right: 0;
    width: 100%;
    max-height: 85vh;
    border-radius: 40px 40px 0 0;
    transform: translateY(100%) scale(1);
    transform-origin: bottom center;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.1);
  }

  .mobile-chat-popup.active {
    transform: translateY(0) scale(1);
  }

  .mobile-chat-popup-header {
    padding: 24px;
    border-radius: 40px 40px 0 0;
  }
}

/* ============================================================
   PREMIUM PLAIN WHITE & GRAY POPUP REDESIGN (WISE STYLE)
   ============================================================ */

/* 1. Containers: Set background plain white (#ffffff), text black, border gray */
.mobile-chat-popup {
  background-color: #ffffff !important;
  background: #ffffff !important;
  color: #000000 !important;
  border: 1.5px solid rgba(14, 15, 12, 0.12) !important;
  border-radius: 24px !important;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15) !important;
}

/* 2. Text Elements & Headers: Force color to be plain black */
.mobile-chat-popup *, 
.mobile-chat-popup h3, 
.mobile-chat-popup p, 
.mobile-chat-popup span,
.mobile-chat-popup-header h3,
.colleague-name,
.colleague-role,
.mobile-chat-popup-footer {
  color: #000000 !important;
}

/* 3. Header & Footer styling for chat popup */
.mobile-chat-popup-header,
.mobile-chat-popup-footer {
  background-color: transparent !important;
  background: transparent !important;
  border-bottom: 1px solid rgba(14, 15, 12, 0.08) !important;
  border-top: 1px solid rgba(14, 15, 12, 0.08) !important;
}

.mobile-chat-close-btn {
  color: #000000 !important;
}

/* colleague-item hover */
.colleague-item:hover {
  background: #f4f4f5 !important;
}

/* 4. Buttons */
.mobile-chat-popup-footer button,
.mobile-chat-popup button {
  border-radius: 9999px !important;
  font-weight: 700 !important;
  padding: 10px 20px !important;
  cursor: pointer !important;
  background-color: #27272a !important;
  background: #27272a !important;
  color: #ffffff !important;
  border: 1.5px solid #27272a !important;
  transition: all 0.2s !important;
}

.mobile-chat-popup-footer button:hover,
.mobile-chat-popup button:hover {
  background-color: #09090b !important;
  background: #09090b !important;
  color: #ffffff !important;
  border-color: #09090b !important;
}
