/* messages.css — full file */

/* Root layout (renders inside #maincontentclientlistpage) */
.messaging-app {
  display: grid;
  grid-template-columns: 320px 1fr 320px;
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "sidebar header info"
    "sidebar content info"
    "sidebar composer info";
  height: calc(100vh - 120px);
  gap: 10px;
  padding: 10px;
  box-sizing: border-box;
  background: #f5f7fb;
}

/* SIDEBAR (threads & directory) */
.ms-sidebar {
  grid-area: sidebar;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  overflow: hidden;
  min-width: 280px;
}

.ms-sidebar .tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid #eee;
}

.ms-tab {
  padding: 12px;
  text-align: center;
  cursor: pointer;
  font-weight: 600;
  background: #fafafa;
  border-right: 1px solid #eee;
  user-select: none;
}

.ms-tab:last-child {
  border-right: none;
}
.ms-tab.active {
  background: #fff;
  color: #2e7d32;
  border-bottom: 2px solid #2e7d32;
}

.ms-search {
  padding: 10px;
  border-bottom: 1px solid #f0f0f0;
}
.ms-search input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 10px;
  outline: none;
}

.ms-list {
  flex: 1;
  overflow-y: auto;
}
.ms-item {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  cursor: pointer;
  border-bottom: 1px solid #f6f6f6;
}
.ms-item:hover { background: #f9fbff; }
.ms-item.active { background: #eef7ff; }

.ms-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #e0e0e0;
  position: relative;
  flex: 0 0 36px;
}
.ms-presence {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: #9e9e9e;
}
.ms-presence.online { background: #43a047; }
.ms-presence.away { background: #ffb300; }

.ms-item .meta {
  flex: 1;
  min-width: 0;
}
.ms-item .meta .top {
  display: flex;
  justify-content: space-between;
  font-weight: 600;
}
.ms-item .meta .title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ms-item .meta .time {
  color: #888;
  font-size: 0.8rem;
  margin-left: 10px;
}
.ms-item .meta .line2 {
  display: flex;
  justify-content: space-between;
  color: #666;
  font-size: 0.85rem;
}
.ms-badge {
  min-width: 22px;
  height: 22px;
  border-radius: 11px;
  background: #e53935;
  color: #fff;
  font-size: 0.75rem;
  line-height: 22px;
  text-align: center;
  padding: 0 6px;
}

/* HEADER (thread title / participants) */
.ms-header {
  grid-area: header;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
}
.ms-header .left {
  display: flex;
  gap: 12px;
  align-items: center;
}
.ms-header .title {
  font-size: 1.1rem;
  font-weight: 700;
}
.ms-header .subtitle {
  color: #555;
  font-size: 0.9rem;
}

/* CONTENT (messages) */
.ms-content {
  grid-area: content;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.ms-message-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  background: #f8f9fa;
  border-radius: 10px;
}

.ms-msg {
  display: inline-block;
  max-width: 70%;
  padding: 8px 12px;
  border-radius: 14px;
  margin: 6px 0;
  position: relative;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.ms-msg.self { background: #d1ffd6; align-self: flex-end; border-bottom-right-radius: 4px; }
.ms-msg.other { background: #ffffff; border-bottom-left-radius: 4px; box-shadow: 0 1px 2px rgba(0,0,0,0.06); }
.ms-msg .time {
  display: block;
  font-size: 0.72rem;
  color: #777;
  margin-top: 4px;
}
.ms-attachments {
  margin-top: 6px;
  display: flex; 
  gap: 8px; 
  flex-wrap: wrap;
}
.ms-attachment {
  padding: 6px 8px;
  background: #eef3ff;
  border-radius: 8px;
  font-size: 0.85rem;
}

/* TYPING */
.ms-typing {
  height: 20px;
  margin-top: 4px;
  color: #666;
  font-size: 0.85rem;
}

/* COMPOSER */
.ms-composer {
  grid-area: composer;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  padding: 10px;
  display: flex;
  gap: 10px;
  align-items: center;
}
.ms-composer input[type="text"] {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #ddd;
  outline: none;
}
.ms-btn {
  padding: 10px 12px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  background: #2e7d32;
  color: #fff;
  font-weight: 700;
}
.ms-btn.secondary { background: #1976d2; }
.ms-btn.ghost { background: #f1f1f1; color: #222; }
.ms-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* INFO PANEL (thread details) */
.ms-info {
  grid-area: info;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  padding: 12px;
  overflow-y: auto;
}
.ms-info h3 { margin: 8px 0 6px; }
.ms-pill {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  border: 1px solid #e0e0e0;
  padding: 6px 10px;
  border-radius: 999px;
  margin: 4px 6px 4px 0;
  font-size: 0.85rem;
}

/* Directory list (start DM) */
.ms-directory-list .ms-item { cursor: pointer; }
.ms-empty {
  padding: 20px;
  text-align: center;
  color: #777;
  font-style: italic;
}

/* Responsive collapse of info panel */
@media (max-width: 1200px) {
  .messaging-app {
    grid-template-columns: 300px 1fr;
    grid-template-areas:
      "sidebar header"
      "sidebar content"
      "sidebar composer";
  }
  .ms-info { display: none; }
}
