/* ==========================================================================
   DateMeet - Chat CSS
   Chat list, chat room, message bubbles, input bar
   ========================================================================== */

/* --------------------------------------------------------------------------
   Chat List Page
   -------------------------------------------------------------------------- */
.chat-page {
  background: var(--bg);
  min-height: 100vh;
}

.chat-list {
  background: var(--bg);
  padding-top: 4px;
}

/* Search bar at top of chat list */
.chat-search-bar {
  padding: 8px 12px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.chat-search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.chat-search-icon {
  position: absolute;
  left: 12px;
  font-size: 15px;
  color: var(--text-light);
  pointer-events: none;
}

.chat-search-input {
  width: 100%;
  height: 36px;
  background: var(--bg);
  border: none;
  border-radius: 18px;
  padding: 0 14px 0 36px;
  font-size: 14px;
  color: var(--text);
  outline: none;
}

.chat-search-input::placeholder {
  color: var(--text-light);
}

/* --------------------------------------------------------------------------
   Chat Item (in list)
   -------------------------------------------------------------------------- */
.chat-item {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s ease;
  text-decoration: none;
  color: inherit;
  position: relative;
  gap: 12px;
}

.chat-item:active {
  background: #f8f8f8;
}

.chat-item:last-child {
  border-bottom: none;
}

/* Avatar area */
.chat-item-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

.chat-item-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg);
}

.chat-item-online-dot {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  background: #2ed573;
  border-radius: 50%;
  border: 2px solid #fff;
}

/* Chat item content */
.chat-item-content {
  flex: 1;
  min-width: 0;
}

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

.chat-item-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.chat-item-time {
  font-size: 12px;
  color: var(--text-light);
  flex-shrink: 0;
  margin-left: 8px;
}

.chat-item-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.chat-item-preview {
  font-size: 13px;
  color: var(--text-light);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.chat-item-preview.unread {
  color: var(--text-medium);
  font-weight: 500;
}

/* Unread badge */
.chat-unread-badge {
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  flex-shrink: 0;
  line-height: 1;
}

.chat-unread-badge.badge-muted {
  background: var(--text-light);
}

/* Muted icon */
.chat-muted-icon {
  color: var(--text-light);
  font-size: 13px;
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   Chat Room / Conversation Page
   -------------------------------------------------------------------------- */
.chat-room {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: #f8f8f8;
  position: fixed;
  inset: 0;
  max-width: 480px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
}

/* Chat room top bar */
.chat-room-header {
  display: flex;
  align-items: center;
  height: 56px;
  padding: 0 12px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  padding-top: env(safe-area-inset-top);
  gap: 10px;
  box-shadow: var(--shadow-sm);
}

.chat-room-back {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  color: var(--text);
  flex-shrink: 0;
}

.chat-room-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg);
  flex-shrink: 0;
  cursor: pointer;
}

.chat-room-info {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.chat-room-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-room-status {
  font-size: 12px;
  color: #2ed573;
  font-weight: 500;
}

.chat-room-status.offline {
  color: var(--text-light);
}

.chat-room-more {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 20px;
  color: var(--text-light);
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   Messages Area
   -------------------------------------------------------------------------- */
.messages-area {
  flex: 1;
  overflow-y: scroll;
  padding: 12px 12px 0;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Hide scrollbar */
.messages-area::-webkit-scrollbar {
  display: none;
}

.messages-area {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Date separator */
.message-date-sep {
  text-align: center;
  font-size: 12px;
  color: var(--text-light);
  padding: 8px 0;
  flex-shrink: 0;
}

.message-date-sep span {
  background: #e8e8e8;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
}

/* --------------------------------------------------------------------------
   Bubble Wrap / Bubble
   -------------------------------------------------------------------------- */
.bubble-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 85%;
  flex-shrink: 0;
}

/* Other user messages: left-aligned */
.bubble-wrap.other {
  align-self: flex-start;
}

/* Own messages: right-aligned, reversed */
.bubble-wrap.mine {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.bubble-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg);
  flex-shrink: 0;
  align-self: flex-end;
}

.bubble-wrap.mine .bubble-avatar {
  display: none;
}

.bubble-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bubble-wrap.mine .bubble-content {
  align-items: flex-end;
}

/* The bubble itself */
.bubble {
  padding: 9px 13px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.5;
  word-break: break-word;
  max-width: 100%;
  position: relative;
}

/* Other's bubble: left (light gray) */
.bubble-wrap.other .bubble {
  background: #f0f0f0;
  color: var(--text);
  border-bottom-left-radius: 4px;
}

/* Own bubble: right (primary color) */
.bubble-wrap.mine .bubble {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Bubble time */
.bubble-time {
  font-size: 11px;
  color: var(--text-light);
  padding: 0 4px;
  align-self: flex-end;
  white-space: nowrap;
}

.bubble-wrap.mine .bubble-time {
  text-align: right;
}

/* Read receipt for own messages */
.bubble-read {
  font-size: 11px;
  color: var(--text-light);
  padding-right: 4px;
}

.bubble-read.is-read {
  color: #1e90ff;
}

/* Image message bubble */
.bubble.bubble-image {
  padding: 3px;
  background: transparent !important;
}

.bubble-image img {
  max-width: 200px;
  border-radius: 14px;
  display: block;
  cursor: pointer;
}

.bubble-wrap.other .bubble-image img {
  border-bottom-left-radius: 4px;
}

.bubble-wrap.mine .bubble-image img {
  border-bottom-right-radius: 4px;
}

/* System message */
.system-message {
  text-align: center;
  font-size: 12px;
  color: var(--text-light);
  padding: 6px 0;
  align-self: center;
}

.system-message span {
  background: rgba(0,0,0,0.06);
  padding: 3px 12px;
  border-radius: 12px;
}

/* --------------------------------------------------------------------------
   Chat Input Bar
   -------------------------------------------------------------------------- */
.chat-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 12px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
  background: #fff;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-extra-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 20px;
  color: var(--text-light);
  flex-shrink: 0;
  transition: background 0.15s;
  border: none;
}

.chat-extra-btn:active {
  background: var(--border);
}

.chat-text-input-wrap {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border-radius: 20px;
  padding: 8px 14px;
  min-height: 36px;
  max-height: 120px;
  display: flex;
  align-items: center;
  border: 1.5px solid transparent;
  transition: border-color 0.2s;
}

.chat-text-input-wrap:focus-within {
  border-color: var(--primary);
  background: #fff;
}

.chat-text-input {
  width: 100%;
  border: none;
  background: transparent;
  font-size: 15px;
  color: var(--text);
  outline: none;
  resize: none;
  line-height: 1.5;
  max-height: 104px;
  overflow-y: auto;
}

.chat-text-input::placeholder {
  color: var(--text-light);
}

.chat-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  color: #fff;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.15s;
}

.chat-send-btn:active {
  background: var(--primary-dark);
  transform: scale(0.9);
}

.chat-send-btn:disabled {
  background: var(--text-light);
  cursor: not-allowed;
}

/* --------------------------------------------------------------------------
   Chat Extra Panel (emoji / media)
   -------------------------------------------------------------------------- */
.chat-extra-panel {
  background: #fff;
  border-top: 1px solid var(--border);
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  flex-shrink: 0;
}

.chat-extra-panel.hidden {
  display: none;
}

.chat-extra-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.chat-extra-item-icon {
  width: 52px;
  height: 52px;
  background: var(--bg);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  transition: background 0.15s;
}

.chat-extra-item:active .chat-extra-item-icon {
  background: var(--border);
}

.chat-extra-item-label {
  font-size: 11px;
  color: var(--text-light);
}

/* --------------------------------------------------------------------------
   Locked Chat Overlay
   -------------------------------------------------------------------------- */
.chat-locked-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(255,255,255,1) 60%, rgba(255,255,255,0.9) 80%, transparent 100%);
  padding: 32px 16px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  z-index: 10;
}

.chat-locked-icon {
  font-size: 32px;
}

.chat-locked-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.chat-locked-desc {
  font-size: 13px;
  color: var(--text-medium);
  line-height: 1.5;
}
