/* ── Page background ── */
.chat-page-bg {
  background: #f5f5f5;
  min-height: 100vh;
}

/* ── Mobile sub-header ── */
.chat-mobile-subheader {
  display: flex;
  align-items: center;
  background: #fff;
  padding: 13px 20px;
  border-bottom: 1px solid #eee;
  position: sticky;
  top: 56px;
  z-index: 99;
}

/* ── Main wrapper ── */
.chat-main-wrapper {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  background: #fff;
  min-height: calc(100vh - 120px);
  padding-bottom: 80px;
}

@media (min-width: 768px) {
  .chat-main-wrapper {
    max-width: 1100px;
    margin: 2rem auto;
    height: calc(100vh - 160px);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
    display: grid;
    grid-template-columns: 340px 1fr;
    overflow: hidden;
    border: 1px solid #eee;
    padding-bottom: 0;
    min-height: unset;
  }
}

/* ── Sidebar ── */
.chat-sidebar {
  border-right: 1px solid #eee;
  display: flex;
  flex-direction: column;
  background: #fff;
}

.chat-sidebar-header {
  padding: 18px;
  border-bottom: 1px solid #eee;
}

.chat-list-scroll {
  flex: 1;
  overflow-y: auto;
}

/* ── Chat item ── */
.chat-item {
  display: flex;
  padding: 15px 20px;
  border-bottom: 1px solid #f5f5f5;
  cursor: pointer;
  transition: background 0.2s;
}

.chat-item:hover {
  background: #fcfcfc;
}

@media (min-width: 768px) {
  .chat-item.active {
    background: #fff0e6;
    border-left: 4px solid #ff5200;
  }
}

.avatar-wrapper {
  margin-right: 15px;
  flex-shrink: 0;
}

.chat-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid #eee;
}

.chat-info {
  flex: 1;
  overflow: hidden;
}

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

.chat-user-name {
  font-weight: 700;
  font-size: 14.5px;
  color: #333;
}

.chat-time-label {
  font-size: 11px;
  color: #aaa;
}

.chat-time-label.text-orange {
  color: #ff5200;
}

.chat-last-msg {
  font-size: 13px;
  color: #888;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.chat-unread-badge {
  background: #ff5200;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  flex-shrink: 0;
}

/* ── Desktop placeholder ── */
.chat-placeholder {
  background: #fdfdfd;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #bbb;
  text-align: center;
}

.chat-placeholder-icon {
  font-size: 5rem;
  opacity: 0.15;
  color: #ff5200;
}

/* ============================================
   CHAT DETAIL PAGE
   ============================================ */

/* ── Outer wrapper (ChatDetailPage) ── */
.chatd-outer {
  background: #f5f5f5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Layout: sidebar + panel (desktop grid, mobile full) ── */
.chatd-layout {
  display: flex;
  flex: 1;
}

@media (min-width: 768px) {
  .chatd-layout {
    max-width: 1100px;
    margin: 2rem auto;
    height: calc(100vh - 160px);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    border: 1px solid #eee;
    width: 100%;
  }
}

/* ── Sidebar dalam ChatDetail (desktop only) ── */
.chatd-sidebar {
  width: 340px;
  flex-shrink: 0;
  border-right: 1px solid #eee;
  flex-direction: column;
  background: #fff;
  overflow: hidden;
}

/* ── Chat panel ── */
.chatd-page {
  display: flex;
  flex-direction: column;
  flex: 1;
  background: #fff;
  height: calc(100vh - 56px); /* kurangi tinggi Header */
  overflow: hidden;
}

@media (min-width: 768px) {
  .chatd-page {
    height: 100%;
    border-radius: 0;
    box-shadow: none;
    border: none;
    margin: 0;
  }
}

/* Header */
.chatd-header {
  background: #fff;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #e6e6e6;
  flex-shrink: 0;
}

.chatd-avatar-wrap {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  margin-right: 12px;
  border: 1px solid #eee;
}

.chatd-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chatd-partner-name {
  font-weight: 700;
  font-size: 16px;
  line-height: 1.2;
  color: #222;
}

.chatd-online {
  font-size: 11px;
  color: #28a745;
  font-weight: 600;
}

/* Messages area */
.chatd-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background-color: #e5ddd5;
  background-image: url('https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png');
  min-height: 400px;
}

.chatd-encrypted-tag {
  align-self: center;
  background: rgba(255, 255, 255, 0.85);
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 12px;
  color: #666;
  margin-bottom: 4px;
}

/* Bubbles */
.chatd-bubble {
  max-width: 75%;
  padding: 10px 14px;
  font-size: 14.5px;
  line-height: 1.5;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  word-break: break-word;
}

.chatd-bubble.them {
  align-self: flex-start;
  background: #fff;
  color: #333;
  border-radius: 0 12px 12px 12px;
}

.chatd-bubble.me {
  align-self: flex-end;
  background: #ff5200;
  color: #fff;
  border-radius: 12px 0 12px 12px;
}

.chatd-time {
  font-size: 10px;
  margin-top: 4px;
  display: block;
  opacity: 0.65;
  text-align: right;
}

/* Typing indicator */
.chatd-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
}

.chatd-typing span {
  width: 8px;
  height: 8px;
  background: #aaa;
  border-radius: 50%;
  animation: typing-bounce 1.2s infinite ease-in-out;
}

.chatd-typing span:nth-child(2) { animation-delay: 0.2s; }
.chatd-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
  40% { transform: scale(1.1); opacity: 1; }
}

/* Input bar */
.chatd-input-bar {
  background: #f0f0f0;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-top: 1px solid #e6e6e6;
  flex-shrink: 0;
}

@media (min-width: 992px) {
  .chatd-input-bar { 
    border-bottom-right-radius: 16px;
  }
}

.chatd-input {
  flex: 1;
  border: none;
  background: #fff;
  padding: 11px 18px;
  border-radius: 25px;
  outline: none;
  font-size: 15px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  font-family: inherit;
}

.chatd-input:disabled {
  background: #f5f5f5;
}

.chatd-send-btn {
  width: 44px;
  height: 44px;
  background: #ff5200;
  color: #fff;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: 0.2s;
  flex-shrink: 0;
  font-size: 1rem;
  padding-left: 3px;
}

.chatd-send-btn:hover:not(:disabled) {
  background: #e64a00;
  transform: scale(1.05);
}

.chatd-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
