/* =========================================================
   ISERVPORT – Messenger (Flex puro, sem Bootstrap)
   File: iservport-message.css
   ========================================================= */

/* THREAD BODY */
.thread-body {
    padding: 16px;
    background: #efeae2;
    overflow-y: auto;
}

/* ROW */
.msg-row {
    display: flex;
    margin-bottom: 8px;
}

/* ALIGNMENT */
.msg-row.is-in {
    justify-content: flex-start;
}

.msg-row.is-out {
    justify-content: flex-end;
}

.msg-row.is-system {
    justify-content: center;
}

/* WRAPPER */
.msg-bubble-wrapper {
    max-width: 75%;
}

/* BUBBLE BASE */
.msg-bubble {
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    position: relative;
    display: inline-block;
    word-break: break-word;
}

/* INCOMING */
.msg-row.is-in .msg-bubble {
    background: #ffffff;
    color: #111;
    border-top-left-radius: 0;
}

/* OUTGOING */
.msg-row.is-out .msg-bubble {
    background: #d9fdd3;
    color: #111;
    border-top-right-radius: 0;
}

/* SYSTEM */
.msg-row.is-system .msg-bubble {
    background: #f0f0f0;
    font-style: italic;
    border-radius: 20px;
}

/* TIME */
.msg-meta {
    text-align: right;
    margin-top: 4px;
}

.msg-time {
    font-size: 11px;
    color: #666;
}

/* =========================================================
   AngularJS custom elements
   ---------------------------------------------------------
   Custom tags default to inline → must be block/flex
   ========================================================= */

messenger-chat-list,
messenger-conversation-list,
custom-filter-container {
    display: block;
}


/* =========================================================
   Root
   ========================================================= */

#messenger-conversation-form {
    margin: 0;
    width: 100%;
    box-sizing: border-box;
}


/* =========================================================
   Tabs (top)
   ========================================================= */

.messenger-tabs {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    border-bottom: 1px solid #e5e5e5;
}

.messenger-tab {
    background: transparent;
    border: none;
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    font-size: 14px;
}

.messenger-tab.is-active {
    border-bottom-color: #1e6cff;
    color: #1e6cff;
    font-weight: 600;
}


/* =========================================================
   Fixed-height shell (2 columns)
   ========================================================= */

.messenger-shell {
    display: flex !important;
    width: 100% !important;

    height: 400px;
    min-height: 400px;
    max-height: 400px;

    overflow: hidden;
    box-sizing: border-box;
}


/* =========================================================
   Left column (fixed width)
   ========================================================= */

.messenger-left {
    flex: 0 0 320px !important;
    width: 320px !important;
    min-width: 280px;
    max-width: 380px;

    border-right: 1px solid #e5e5e5;
    padding: 8px;

    overflow: auto;

    /* neutralize old layouts */
    float: none !important;
    box-sizing: border-box;
}


/* =========================================================
   Right column (takes ALL remaining space)
   ========================================================= */

.messenger-right {
    flex: 1 1 0% !important;   /* 🔑 the real fix */
    width: auto !important;
    max-width: none !important;
    min-width: 0 !important;

    display: flex !important;
    overflow: hidden !important;

    /* neutralize old layouts */
    float: none !important;
    box-sizing: border-box;
}

/* custom element must stretch */
.messenger-right > messenger-chat-list {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    display: flex;
}


/* =========================================================
   Thread (right side)
   ========================================================= */

.thread {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;

    display: flex;
    overflow: hidden;
    box-sizing: border-box;
}

.thread-empty {
    margin: auto;
    padding: 24px;
    text-align: center;
    color: #888;
    width: 100%;
}


/* =========================================================
   Thread inner (column layout)
   ========================================================= */

.thread-inner {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;

    display: flex;
    flex-direction: column;
    overflow: hidden;

    box-sizing: border-box;
}


/* =========================================================
   Header
   ========================================================= */

.thread-header {
    flex: 0 0 auto;

    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 10px 12px;

    background: #f7f7f7;
    border-bottom: 1px solid #e5e5e5;
}

.thread-name {
    font-weight: 600;
    font-size: 14px;
}

.thread-sub {
    margin-top: 2px;
    font-size: 12px;
    color: #777;
}

.thread-refresh {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 6px 10px;
    font-size: 14px;
}


/* =========================================================
   Body (ONLY this scrolls)
   ========================================================= */

.thread-body {
    flex: 1 1 auto;
    min-height: 0;               /* 🔑 critical for flex scroll */
    overflow: auto;

    padding: 12px;
    background: var(--i-color-light);

    box-sizing: border-box;
}

.thread-empty-messages {
    padding: 16px;
    text-align: center;
    color: #888;
}


/* =========================================================
   Messages
   ========================================================= */

.msg-row {
    display: flex;
    margin: 6px 0;
}

.msg-row.is-in {
    justify-content: flex-start;
}

.msg-row.is-out {
    justify-content: flex-end;
}

.msg-row.is-system {
    justify-content: center;
}

.msg-bubble {
    max-width: 75%;
    padding: 8px 10px;
    border-radius: 8px;

    background: #ffffff;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
}

.msg-row.is-out .msg-bubble {
    background: #d9fdd3;
}

.msg-row.is-system .msg-bubble {
    max-width: 90%;
    background: rgba(255, 255, 255, 0.65);
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.msg-text {
    word-break: break-word;
}

.msg-meta {
    margin-top: 4px;
    font-size: 11px;
    color: #777;
    text-align: right;
}


/* =========================================================
   Composer (pinned bottom)
   ========================================================= */

.thread-composer {
    flex: 0 0 auto;

    padding: 8px;
    background: #f7f7f7;
    border-top: 1px solid #e5e5e5;

    box-sizing: border-box;
}

.composer-form {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.composer-input {
    flex: 1 1 auto;
    min-width: 0;

    padding: 10px 12px;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    outline: none;
}

.composer-send {
    padding: 10px 14px;
    border-radius: 6px;

    border: 1px solid #1e6cff;
    background: #1e6cff;
    color: #ffffff;

    cursor: pointer;
}

.composer-send[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}
