/* ============================================================
   SLF Chat Widget - styles
   Brand color: #0d2b5e
   ============================================================ */
#slf-chat-root *,
#slf-chat-root *::before,
#slf-chat-root *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

#slf-chat-fab {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    z-index: 999995;
    background: linear-gradient(135deg, #0d2b5e 0%, #1a73e8 100%);
    box-shadow: 0 6px 22px rgba(13, 43, 94, 0.45);
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}
#slf-chat-fab:hover {
    transform: scale(1.06);
    box-shadow: 0 8px 28px rgba(13, 43, 94, 0.55);
}
#slf-chat-fab:active {
    transform: scale(0.96);
}
#slf-chat-fab.slf-visible {
    display: flex;
}
#slf-chat-root.slf-has-newbtn #slf-chat-fab {
    bottom: 92px;
}

#slf-chat-fab .slf-fab-icon {
    width: 28px;
    height: 28px;
    display: block;
}
#slf-chat-fab .slf-fab-icon svg {
    width: 100%;
    height: 100%;
    fill: #fff;
}

#slf-chat-fab-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    background: #e02424;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
    padding: 0 5px;
    display: none;
    box-shadow: 0 2px 6px rgba(224, 36, 36, 0.5);
    border: 2px solid #fff;
}
#slf-chat-fab-badge.slf-visible {
    display: block;
}

#slf-chat-window {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 372px;
    height: 580px;
    max-height: calc(100vh - 40px);
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 18px 60px rgba(7, 25, 56, 0.35);
    z-index: 999996;
    overflow: hidden;
    flex-direction: column;
    font-size: 14px;
    color: #1f2937;
}
#slf-chat-window.slf-open {
    display: flex;
}
#slf-chat-root.slf-has-newbtn #slf-chat-window {
    bottom: 92px;
}

/* Header */
#slf-chat-header {
    flex: 0 0 auto;
    background: linear-gradient(135deg, #0d2b5e 0%, #1a73e8 100%);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 58px;
}
#slf-chat-header .slf-chat-back {
    display: none;
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    padding: 2px 6px 2px 0;
    -webkit-tap-highlight-color: transparent;
}
#slf-chat-window.slf-in-thread #slf-chat-header .slf-chat-back {
    display: block;
}
#slf-chat-window.slf-in-search #slf-chat-header .slf-chat-back {
    display: block;
}
#slf-chat-header-title {
    flex: 1 1 auto;
    min-width: 0;
}
#slf-chat-header-title .slf-chat-title {
    font-size: 16px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#slf-chat-header-title .slf-chat-subtitle {
    font-size: 12px;
    opacity: 0.85;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#slf-chat-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
    padding: 2px 4px;
    -webkit-tap-highlight-color: transparent;
}

/* Body */
#slf-chat-body {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #f5f7fb;
    position: relative;
}

/* Search / new chat */
#slf-chat-searchbar {
    flex: 0 0 auto;
    padding: 10px 12px;
    display: none;
    border-bottom: 1px solid #e8ecf3;
    background: #fff;
}
#slf-chat-searchbar.slf-visible {
    display: block;
}
#slf-chat-search-input {
    width: 100%;
    border: 1.5px solid #e2e8f0;
    border-radius: 24px;
    padding: 9px 14px 9px 36px;
    font-size: 14px;
    outline: none;
    background: #f8fafc url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") 14px center no-repeat;
    color: #1f2937;
}
#slf-chat-search-input:focus {
    border-color: #1a73e8;
    background-color: #fff;
}

#slf-chat-newbtn {
    flex: 0 0 auto;
    display: none;
    margin: 10px 12px 4px;
    background: linear-gradient(135deg, #0d2b5e, #1a73e8);
    color: #fff;
    border: none;
    border-radius: 22px;
    padding: 9px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    -webkit-tap-highlight-color: transparent;
}
#slf-chat-newbtn.slf-visible {
    display: block;
}

/* Conversation / people list */
#slf-chat-list {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 6px 0 12px;
}
.slf-chat-listitem {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 14px;
    cursor: pointer;
    border-bottom: 1px solid #eef1f6;
    background: #fff;
    transition: background 0.15s ease;
}
.slf-chat-listitem:hover {
    background: #f2f6fc;
}
.slf-chat-avatar {
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 17px;
    font-weight: 700;
    text-transform: uppercase;
    background: #0d2b5e;
}
.slf-chat-listitem-main {
    flex: 1 1 auto;
    min-width: 0;
}
.slf-chat-listitem-title {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.slf-chat-listitem-sub {
    font-size: 12px;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}
.slf-chat-listitem-right {
    flex: 0 0 auto;
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}
.slf-chat-time {
    font-size: 11px;
    color: #94a3b8;
}
.slf-chat-unread {
    min-width: 19px;
    height: 19px;
    border-radius: 10px;
    background: #e02424;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 19px;
    text-align: center;
    padding: 0 5px;
    display: none;
}
.slf-chat-unread.slf-visible {
    display: block;
}

#slf-chat-list .slf-chat-empty {
    padding: 40px 20px;
    text-align: center;
    color: #94a3b8;
    font-size: 13px;
    background: #f5f7fb;
}
#slf-chat-list .slf-chat-empty .slf-chat-empty-icon {
    font-size: 40px;
    margin-bottom: 10px;
}

/* Thread */
#slf-chat-thread {
    display: none;
    flex: 1 1 auto;
    flex-direction: column;
    overflow: hidden;
    background: #eef1f6;
}
#slf-chat-window.slf-in-thread #slf-chat-thread {
    display: flex;
}
#slf-chat-window.slf-in-thread #slf-chat-list {
    display: none;
}

#slf-chat-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 14px 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.slf-msg-row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    max-width: 82%;
}
.slf-msg-row.slf-mine {
    align-self: flex-end;
    align-items: flex-end;
}
.slf-msg-bubble {
    padding: 9px 12px;
    border-radius: 16px;
    background: #fff;
    border: 1px solid #e2e8f0;
    color: #111827;
    font-size: 14px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.slf-msg-row.slf-mine .slf-msg-bubble {
    background: linear-gradient(135deg, #0d2b5e, #1a73e8);
    color: #fff;
    border: none;
    border-bottom-right-radius: 4px;
}
.slf-msg-row:not(.slf-mine) .slf-msg-bubble {
    border-bottom-left-radius: 4px;
}
.slf-msg-meta {
    font-size: 10.5px;
    color: #94a3b8;
    margin-top: 3px;
    padding: 0 4px;
    display: flex;
    align-items: center;
    gap: 5px;
}
.slf-msg-meta .slf-msg-read {
    font-weight: 700;
    color: #34a853;
}
.slf-thread-date {
    align-self: center;
    font-size: 11px;
    color: #94a3b8;
    background: rgba(255,255,255,0.7);
    border-radius: 10px;
    padding: 3px 10px;
    margin: 4px 0;
}

#slf-chat-typing {
    display: none;
    font-size: 12px;
    color: #94a3b8;
    padding: 0 12px;
}
#slf-chat-typing.slf-visible {
    display: block;
}

/* Composer */
#slf-chat-composer {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    background: #fff;
    border-top: 1px solid #e8ecf3;
}
#slf-chat-composer textarea {
    flex: 1 1 auto;
    border: 1.5px solid #e2e8f0;
    border-radius: 20px;
    padding: 9px 14px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 100px;
    color: #111827;
    background: #f8fafc;
    line-height: 1.4;
}
#slf-chat-composer textarea:focus {
    border-color: #1a73e8;
    background: #fff;
}
#slf-chat-composer textarea::placeholder {
    color: #94a3b8;
}
#slf-chat-sendbtn {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background: linear-gradient(135deg, #0d2b5e, #1a73e8);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 10px rgba(13, 43, 94, 0.35);
    -webkit-tap-highlight-color: transparent;
}
#slf-chat-sendbtn:disabled {
    opacity: 0.5;
    cursor: default;
}
#slf-chat-sendbtn svg {
    width: 18px;
    height: 18px;
    fill: #fff;
    transform: translateX(-1px);
}

/* Toast (e.g. "message sent", errors) */
#slf-chat-toast {
    display: none;
    position: absolute;
    left: 50%;
    bottom: 76px;
    transform: translateX(-50%);
    background: rgba(13, 43, 94, 0.94);
    color: #fff;
    font-size: 12.5px;
    padding: 9px 16px;
    border-radius: 20px;
    box-shadow: 0 6px 20px rgba(7, 25, 56, 0.4);
    z-index: 999997;
    white-space: nowrap;
    max-width: 90%;
    overflow: hidden;
    text-overflow: ellipsis;
}
#slf-chat-toast.slf-visible {
    display: block;
}

/* Mobile full-screen */
@media (max-width: 600px) {
    #slf-chat-window {
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }
    #slf-chat-root.slf-has-newbtn #slf-chat-window {
        bottom: 0;
    }
}
