/* Messenger / WhatsApp styl pro seznam konverzací a chat */

/* ── Seznam konverzací ───────────────────────────────── */
.ms-wrap { max-width: 720px; margin: 0 auto; }
.ms-list { background: #fff; border: 1px solid #e4e6eb; border-radius: 14px; overflow: hidden; }

.ms-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; cursor: pointer;
  border-bottom: 1px solid #f0f2f5;
  color: inherit; text-decoration: none;
  transition: background .15s;
}
.ms-item:last-child { border-bottom: none; }
.ms-item:hover { background: #f5f6f7; color: inherit; }

.ms-avatar {
  flex: 0 0 52px; width: 52px; height: 52px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: 1.25rem; text-transform: uppercase;
}
.ms-body { flex: 1; min-width: 0; }
.ms-row { display: flex; align-items: baseline; gap: 8px; }
.ms-name {
  flex: 1; min-width: 0; margin: 0; font-size: 1rem; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ms-time { flex: 0 0 auto; font-size: .78rem; color: #65676b; }
.ms-preview {
  flex: 1; min-width: 0; margin: 2px 0 0; font-size: .9rem; color: #65676b;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ms-dot { flex: 0 0 12px; width: 12px; height: 12px; border-radius: 50%; background: #0d6efd; }
.ms-item.unread .ms-name,
.ms-item.unread .ms-preview { font-weight: 700; color: #050505; }
.ms-item.unread .ms-time { color: #0d6efd; font-weight: 600; }

/* ── Chat ────────────────────────────────────────────── */
body.ms-chat-page { background: #eef1f5; }

#chat-container {
  height: calc(100vh - 150px); min-height: 420px;
  max-width: 820px; margin: 0 auto;
  display: flex; flex-direction: column;
  background: #fff; border: 1px solid #e4e6eb; border-radius: 14px;
  padding: 0; overflow: hidden;
}
#messages {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  margin: 0; padding: 16px 14px;
  background: #f0f2f5; border-radius: 0;
  display: flex; flex-direction: column; gap: 2px;
}

.message { margin: 1px 0; max-width: 78%; min-width: 0; display: flex; }
.my-message    { align-self: flex-end;   margin-left: auto; }
.their-message { align-self: flex-start; margin-right: auto; }

.message-content {
  position: relative; min-width: 0; max-width: 100%;
  padding: 8px 12px 6px; border-radius: 18px;
  overflow-wrap: anywhere; word-break: break-word;
  line-height: 1.35; box-shadow: 0 1px 1px rgba(0,0,0,.06);
}
.my-message .message-content    { background: #0d6efd; color: #fff; border-bottom-right-radius: 5px; }
.their-message .message-content { background: #fff;    color: #050505; border-bottom-left-radius: 5px; }
.my-message .message-content a  { color: #fff; text-decoration: underline; }

.message-role { display: none; }
.message-time { font-size: .68rem; margin-top: 2px; opacity: .7; color: inherit; }
.my-message .message-time    { text-align: right; color: #fff; }
.their-message .message-time { text-align: right; color: #65676b; }

.my-message .attachment-file { background: rgba(255,255,255,.2); }

/* Vstupní řádek */
#input-area { margin: 0; padding: 10px 12px; background: #fff; border-top: 1px solid #e4e6eb; }
#new-message {
  background: #f0f2f5; border: none; border-radius: 22px;
  padding: 10px 16px; min-height: 42px; box-shadow: none;
}
#new-message:focus { background: #e9ecf0; box-shadow: none; }
#attach-btn, #emoji-btn { border: none; background: transparent; color: #0d6efd; }
#attach-btn:hover, #emoji-btn:hover { background: #f0f2f5; color: #0d6efd; }
#send-message-btn {
  flex: 0 0 42px; width: 42px; height: 42px; padding: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 1.1rem;
}

@media (max-width: 576px) {
  #chat-container { height: calc(100vh - 120px); border-radius: 0; border-left: none; border-right: none; }
  .message { max-width: 88%; }
  .ms-list { border-radius: 0; border-left: none; border-right: none; }
}

/* ── Dvousloupcové rozložení (seznam vlevo, chat vpravo) ── */
.ms-split {
  display: grid; grid-template-columns: 360px 1fr;
  height: calc(100vh - 80px); min-height: 480px;
  max-width: 1400px; margin: 12px auto; padding: 0 12px; gap: 12px;
}
.ms-side, .ms-main {
  background: #fff; border: 1px solid #e4e6eb; border-radius: 14px;
  overflow: hidden; min-height: 0; display: flex; flex-direction: column;
}
.ms-side-head { padding: 16px 16px 8px; font-size: 1.4rem; font-weight: 700; }
.ms-side .ms-list { flex: 1; overflow-y: auto; }
.ms-split .ms-list { border: none; border-radius: 0; }
.ms-item.active { background: #e7f0ff; }
.ms-item.active:hover { background: #e7f0ff; }

.ms-main { position: relative; }
#chat-frame { display: none; flex: 1; width: 100%; border: 0; }
.ms-main.has-chat #chat-frame { display: block; }
.ms-main.has-chat .ms-empty { display: none; }
.ms-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: #65676b; gap: 10px; font-weight: 600;
}
.ms-empty i { font-size: 3.5rem; color: #b0b3b8; }

@media (max-width: 767.98px) {
  .ms-split { grid-template-columns: 1fr; padding: 0; margin: 0; height: auto; min-height: 0; }
  .ms-side { border-radius: 0; border-left: none; border-right: none; }
  .ms-main { display: none; }
}

/* ── Chat vložený v iframe (?embed=1) ── */
body.ms-embed { background: #fff; }
body.ms-embed .container { max-width: none; margin: 0 !important; padding: 0; }
body.ms-embed .ms-chat-top { margin: 0 !important; padding: 12px 16px; border-bottom: 1px solid #e4e6eb; }
body.ms-embed .ms-chat-top .btn,
body.ms-embed .ms-prefix { display: none; }
body.ms-embed .ms-chat-top h4 { font-size: 1.1rem; font-weight: 600; }
body.ms-embed #chat-container { height: calc(100vh - 53px); max-width: none; border: none; border-radius: 0; }
