/* Halaman pesan (messages.html) */
body.msg-body {
    background: radial-gradient(ellipse at center, #3a3a3a 0%, #1e1e1e 100%) !important;
    color: #e8e8e8;
    margin: 0;
    /* main.css menjadikan body grid: jangan regangkan baris header */
    align-content: start;
}
.msg-body .hidden { display: none !important; }
/* Hanya area konten: link di header tetap memakai gaya header */
.msg-page a { color: #38bdf8; text-decoration: none; }

/* width 100%: body adalah grid ber-justify-items:center (main.css), tanpa ini halaman menyusut */
.msg-page { width: 100%; max-width: 1100px; margin: 20px auto; padding: 0 16px; box-sizing: border-box; }
.msg-card { background: #2b2b2b; border: 1px solid #444; border-radius: 6px; padding: 14px; box-sizing: border-box; min-width: 0; }
.msg-empty { color: #888; text-align: center; padding: 30px 12px; font-size: 14px; line-height: 1.5; }

.msg-layout {
    display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 14px;
    /* Muat dalam satu layar (header + margin), supaya halaman tidak ikut tergulir */
    height: calc(100vh - 120px); min-height: 420px;
}
.msg-list-col { display: flex; flex-direction: column; gap: 10px; overflow: hidden; }
.msg-list-col h1 { margin: 0; font-size: 20px; }
.msg-thread-col { display: flex; flex-direction: column; overflow: hidden; padding: 0; }

.msg-input {
    background: #1f1d1b; color: #e8e8e8; border: 1px solid #555; border-radius: 4px;
    padding: 8px 10px; font-size: 14px; font-family: inherit; box-sizing: border-box; width: 100%;
}
.msg-input:focus { outline: none; border-color: #38bdf8; }
.msg-btn {
    background: #444; color: #e8e8e8; border: 1px solid #555; border-radius: 4px;
    padding: 8px 12px; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.msg-btn:hover:not(:disabled) { background: #555; }
.msg-btn:disabled { opacity: 0.5; cursor: default; }
.msg-btn.primary { background: #2e7d32; border-color: #2e7d32; color: #fff; }
.msg-new { display: flex; gap: 6px; }
.msg-admin-btn { text-align: left; }

/* Daftar percakapan */
.msg-convs { overflow-y: auto; display: flex; flex-direction: column; gap: 2px; margin: 0 -6px; }
.msg-conv {
    display: flex; align-items: center; gap: 10px; width: 100%;
    background: transparent; border: 0; border-radius: 6px; padding: 8px 6px;
    color: #e8e8e8; text-align: left; cursor: pointer; font-family: inherit;
}
.msg-conv:hover { background: #333; }
.msg-conv.active { background: #1f2a3a; }
.msg-avatar {
    position: relative; width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
    background: #3a3a3a; display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.msg-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.msg-online { position: absolute; right: 0; bottom: 0; width: 10px; height: 10px; border-radius: 50%; background: #22c55e; border: 2px solid #2b2b2b; }
.msg-conv-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.msg-conv-top { display: flex; align-items: center; gap: 6px; }
.msg-conv-top strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-time { margin-left: auto; font-size: 11px; color: #888; flex-shrink: 0; }
.msg-conv-last { font-size: 13px; color: #9a9a9a; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-conv.unread .msg-conv-last { color: #e8e8e8; font-weight: 600; }
.msg-unread { background: #ef4444; color: #fff; border-radius: 10px; padding: 1px 7px; font-size: 11px; font-weight: 700; }
.msg-badge { font-size: 10px; padding: 1px 6px; border-radius: 8px; background: #3a6ea5; color: #fff; }

/* Isi percakapan */
.msg-thread-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid #444; min-height: 24px; }
.msg-thread-title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; min-width: 0; }
.msg-status { font-size: 12px; font-weight: 400; color: #22c55e; }
.msg-back { display: none; padding: 4px 10px; font-size: 18px; }
.msg-thread { flex: 1; overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.msg-more { align-self: center; margin-bottom: 6px; }
.msg-day { align-self: center; font-size: 11px; color: #888; margin: 8px 0 2px; }
.msg-bubble {
    max-width: 75%; padding: 7px 10px; border-radius: 10px; font-size: 14px; line-height: 1.45;
    display: flex; flex-direction: column; gap: 2px;
}
.msg-bubble.me { align-self: flex-end; background: #2e5a8a; border-bottom-right-radius: 3px; }
.msg-bubble.them { align-self: flex-start; background: #3a3a3a; border-bottom-left-radius: 3px; }
.msg-bubble.broadcast { background: #3a2f1f; border: 1px solid #f59e0b; }
.msg-broadcast-tag { font-size: 11px; font-weight: 700; color: #fbbf24; }
.msg-content { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-meta { font-size: 10px; color: rgba(255, 255, 255, 0.55); align-self: flex-end; }
.msg-compose { display: flex; gap: 8px; padding: 10px 14px; border-top: 1px solid #444; align-items: flex-end; }
.msg-compose textarea { resize: none; max-height: 140px; }

/* HP: satu kolom, daftar atau isi percakapan */
@media (max-width: 760px) {
    .msg-page { margin: 8px auto; padding: 0 8px; }
    .msg-layout { grid-template-columns: 1fr; height: calc(100vh - 90px); }
    .msg-layout .msg-thread-col { display: none; }
    .msg-layout.thread-open .msg-list-col { display: none; }
    .msg-layout.thread-open .msg-thread-col { display: flex; }
    .msg-back { display: inline-block; }
    .msg-bubble { max-width: 88%; }
}
