/* =============================================================================
   Mesaje — panoul cu doua coloane si modalul public.
   Bulele sunt aceleasi in ambele locuri (.ms-bubbles), ca discutia sa arate
   identic din pagina publica si din panou.
   ========================================================================== */

/* -----------------------------------------------------------------------------
   Panoul: lista de fire + conversatia
   ----------------------------------------------------------------------------- */
.ms-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 16px;
    align-items: start;
}

.ms-threads {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    overflow: hidden;
    max-height: 70vh;
    overflow-y: auto;
}

.ms-thread {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 12px 14px;
    border-bottom: 1px solid #f1f5f9;
    text-decoration: none;
    color: #0f172a;
    transition: background .15s ease;
}
.ms-thread:last-child { border-bottom: 0; }
.ms-thread:hover      { background: #f8fafc; }
.ms-thread.is-active  { background: #eff6ff; }

.ms-avatar {
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: #e2e8f0;
    color: #475569;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 15px;
    overflow: hidden;
}
.ms-avatar img { width: 100%; height: 100%; object-fit: cover; }

.ms-thread-body { flex: 1; min-width: 0; }
.ms-thread-top {
    display: flex;
    align-items: baseline;
    gap: 8px;
}
.ms-thread-top b {
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ms-thread-top time { margin-left: auto; font-size: 11px; color: #94a3b8; flex: 0 0 auto; }

.ms-thread-last {
    display: block;
    margin-top: 2px;
    font-size: 12.5px;
    color: #64748b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* Firul cu mesaje necitite: nume ingrosat, ca in orice client de mesagerie */
.ms-thread.is-unread .ms-thread-top b,
.ms-thread.is-unread .ms-thread-last { color: #0f172a; font-weight: 600; }

.ms-badge {
    flex: 0 0 auto;
    min-width: 20px;
    padding: 2px 7px;
    border-radius: 999px;
    background: #2563eb;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    text-align: center;
}

.ms-conv {
    display: flex;
    flex-direction: column;
    min-height: 420px;
    max-height: 70vh;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    overflow: hidden;
}
.ms-conv-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
    flex: 0 0 auto;
}
.ms-conv-head b { font-size: 15px; }
.ms-conv-link {
    margin-left: auto;
    font-size: 12.5px;
    color: #2563eb;
    text-decoration: none;
}
.ms-conv-link:hover { text-decoration: underline; }

/* Butonul de „inapoi la lista" apare doar pe ecran ingust */
.ms-back { display: none; color: #475569; text-decoration: none; font-size: 16px; }

/* -----------------------------------------------------------------------------
   Bulele
   ----------------------------------------------------------------------------- */
.ms-bubbles {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ms-daysep {
    display: flex;
    justify-content: center;
    margin: 6px 0;
}
.ms-daysep span {
    padding: 3px 12px;
    border-radius: 999px;
    background: #e2e8f0;
    color: #64748b;
    font-size: 11.5px;
    font-weight: 600;
}

.ms-bubble {
    max-width: min(72%, 520px);
    align-self: flex-start;
    padding: 9px 13px;
    border-radius: 14px 14px 14px 4px;
    background: #fff;
    border: 1px solid #e2e8f0;
}
.ms-bubble.is-mine {
    align-self: flex-end;
    border-radius: 14px 14px 4px 14px;
    background: #dbeafe;
    border-color: #bfdbfe;
}
.ms-bubble p {
    margin: 0;
    font-size: 14px;
    line-height: 1.55;
    color: #0f172a;
    overflow-wrap: anywhere;
}

/* Activitatea de la care a pornit mesajul */
.ms-context {
    display: block;
    margin-bottom: 5px;
    padding-bottom: 5px;
    border-bottom: 1px dashed #cbd5e1;
    font-size: 11.5px;
    color: #64748b;
}
.ms-context i { font-size: 10px; margin-right: 3px; }

.ms-meta {
    display: block;
    margin-top: 3px;
    text-align: right;
    font-size: 10.5px;
    color: #94a3b8;
}
.ms-meta i { margin-left: 4px; }
/* Bifa dubla albastra = citit de partea cealalta */
.ms-meta .is-seen { color: #2563eb; }

/* -----------------------------------------------------------------------------
   Caseta de scris
   ----------------------------------------------------------------------------- */
.ms-composer {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid #f1f5f9;
    background: #fff;
    flex: 0 0 auto;
}
.ms-composer textarea {
    flex: 1;
    resize: none;
    max-height: 140px;
    padding: 10px 13px;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
}
.ms-composer textarea:focus { outline: 2px solid #bfdbfe; outline-offset: 0; border-color: #93c5fd; }

.ms-send {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: #2563eb;
    color: #fff;
    font-size: 15px;
    cursor: pointer;
    transition: background .15s ease, box-shadow .15s ease;
}
.ms-send:hover    { background: #1d4ed8; box-shadow: 0 6px 18px rgba(37, 99, 235, .25); }
.ms-send:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }

/* -----------------------------------------------------------------------------
   Butonul public + modalul
   ----------------------------------------------------------------------------- */
.bt-msg-btn { cursor: pointer; }

.bt-msg-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.bt-msg-modal[hidden] { display: none; }

.bt-msg-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, .55);
}

.bt-msg-panel {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    width: min(560px, 100%);
    max-height: min(680px, 90vh);
    background: #fff;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 24px 60px rgba(15, 23, 42, .3);
}

.bt-msg-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid #f1f5f9;
    flex: 0 0 auto;
}
.bt-msg-head h2 { margin: 0; font-size: 17px; color: #0f172a; }
.bt-msg-x {
    margin-left: auto;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #64748b;
    font-size: 16px;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}
.bt-msg-x:hover { background: #f1f5f9; color: #0f172a; }

.bt-msg-body { display: flex; flex-direction: column; flex: 1; min-height: 220px; }
.bt-msg-body[hidden] { display: none; }
.bt-msg-body .ms-bubbles { max-height: 46vh; }

.bt-msg-hint {
    margin: 0;
    padding: 18px 20px;
    text-align: center;
    font-size: 13.5px;
    color: #64748b;
}

/* --- starea „trebuie sa te loghezi" --- */
.bt-msg-auth { padding: 34px 24px; text-align: center; }
.bt-msg-auth[hidden] { display: none; }
.bt-msg-auth-icon {
    width: 52px;
    height: 52px;
    margin: 0 auto 14px;
    border-radius: 50%;
    background: #eff6ff;
    color: #2563eb;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}
.bt-msg-auth p { margin: 0 0 18px; color: #475569; font-size: 14.5px; line-height: 1.6; }
.bt-msg-auth-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.bt-msg-cta {
    padding: 11px 22px;
    border-radius: 30px;
    background: #2563eb;
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    transition: background .15s ease, box-shadow .15s ease;
}
.bt-msg-cta:hover { background: #1d4ed8; box-shadow: 0 6px 18px rgba(37, 99, 235, .25); }
.bt-msg-cta--ghost {
    background: #fff;
    color: #334155;
    border: 1px solid #e2e8f0;
}
.bt-msg-cta--ghost:hover { background: #f1f5f9; color: #0f172a; box-shadow: none; }

.bt-msg-status {
    margin: 0;
    padding: 0 20px 12px;
    min-height: 18px;
    font-size: 13px;
    color: #b91c1c;
}

/* -----------------------------------------------------------------------------
   Mobil — o singura coloana; lista si conversatia se schimba intre ele
   ----------------------------------------------------------------------------- */
@media (max-width: 860px) {
    .ms-layout { grid-template-columns: 1fr; }
    .ms-back   { display: inline-flex; }

    /* Cu un fir deschis se vede doar conversatia; „inapoi" duce la lista */
    .ms-layout .ms-threads:not(.is-only) { display: none; }

    .ms-conv { max-height: none; min-height: 60vh; }
    .ms-bubble { max-width: 86%; }
}
