/* Chat module — floating widget (bottom-right, expandable to full page) and
   inline (admin management page) presentation of the same ChatWidget JS class. */

.chat-widget--floating {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 10000;
    font-family: inherit;
}

.chat-widget-bubble {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #0eb582;
    color: #fff;
    border: none;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .2);
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    transition: transform .15s ease;
}

.chat-widget-bubble:hover {
    transform: scale(1.06);
}

.chat-widget--open .chat-widget-bubble {
    display: none;
}

.chat-widget-bubble-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ff4d4f;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    border: 2px solid #fff;
}

.chat-widget-panel {
    display: none;
    flex-direction: column;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, .25);
    overflow: hidden;
}

.chat-widget--floating .chat-widget-panel {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 48px);
}

.chat-widget--floating.chat-widget--open .chat-widget-panel {
    display: flex;
}

.chat-widget--floating.chat-widget--maximized .chat-widget-panel {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
}

.chat-widget--inline .chat-widget-panel {
    display: flex;
    width: 100%;
    height: 78vh;
    min-height: 480px;
    border-radius: 12px;
}

@keyframes chat-widget-flash-pulse {
    0%, 100% { box-shadow: 0 6px 20px rgba(0, 0, 0, .2); }
    50% { box-shadow: 0 0 0 8px rgba(14, 181, 130, .35); }
}

.chat-widget-flash .chat-widget-bubble {
    animation: chat-widget-flash-pulse 1.1s ease;
}

.chat-widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #0eb582;
    color: #fff;
    flex-shrink: 0;
}

.chat-widget-header-title {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.chat-widget-header-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-widget-header-name {
    font-weight: 600;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-widget-header-status {
    font-size: 11px;
    opacity: .85;
}

.chat-widget-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.chat-widget-header-actions button,
.chat-widget-back {
    background: rgba(255, 255, 255, .18);
    border: none;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-widget-header-actions button:hover,
.chat-widget-back:hover {
    background: rgba(255, 255, 255, .3);
}

.chat-widget-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    position: relative;
}

.chat-widget-list {
    flex: 1;
    overflow-y: auto;
}

.chat-widget-empty {
    padding: 30px 16px;
    text-align: center;
    color: #888;
    font-size: 13px;
}

.chat-widget-contact-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid #f1f1f1;
}

.chat-widget-contact-row:hover {
    background: #f8f9fa;
}

.chat-widget-contact-row.is-unread .chat-widget-contact-name {
    font-weight: 700;
}

.chat-widget-contact-row.is-unread {
    background: #eefaf5;
}

.chat-widget-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}

.chat-widget-avatar-wrap img,
.chat-widget-directory-row img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.chat-widget-online-dot {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ccc;
    border: 2px solid #fff;
}

.chat-widget-online-dot.is-online {
    background: #21c55d;
}

.chat-widget-contact-info {
    min-width: 0;
    flex: 1;
}

.chat-widget-contact-name {
    font-size: 13.5px;
    color: #222;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-widget-contact-preview {
    font-size: 12px;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-widget-unread-count {
    background: #0eb582;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}

/* Directory (admin "start new chat" contact picker) */
.chat-widget-directory {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 10px 14px;
}

.chat-widget-directory-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}

.chat-widget-directory-tab {
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 16px;
    padding: 4px 12px;
    font-size: 12.5px;
    cursor: pointer;
}

.chat-widget-directory-tab.active {
    background: #0eb582;
    border-color: #0eb582;
    color: #fff;
}

.chat-widget-directory-search {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 13px;
    margin-bottom: 8px;
}

.chat-widget-directory-results {
    flex: 1;
    overflow-y: auto;
}

.chat-widget-directory-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 4px;
    cursor: pointer;
    border-bottom: 1px solid #f1f1f1;
}

.chat-widget-directory-row:hover {
    background: #f8f9fa;
}

.chat-widget-directory-row-name {
    font-size: 13.5px;
    color: #222;
}

.chat-widget-directory-row-meta {
    font-size: 11.5px;
    color: #888;
}

/* Thread */
.chat-widget-thread {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chat-widget-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: #f7f8fa;
}

.chat-widget-message {
    max-width: 78%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 13.5px;
    line-height: 1.4;
    cursor: pointer;
    word-break: break-word;
}

.chat-widget-message.is-other {
    align-self: flex-start;
    background: #fff;
    border: 1px solid #eee;
    border-bottom-left-radius: 4px;
}

.chat-widget-message.is-own {
    align-self: flex-end;
    background: #0eb582;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-widget-quote {
    border-left: 3px solid rgba(0, 0, 0, .2);
    padding: 4px 8px;
    margin-bottom: 6px;
    font-size: 12px;
    border-radius: 4px;
    background: rgba(0, 0, 0, .05);
}

.chat-widget-message.is-own .chat-widget-quote {
    border-left-color: rgba(255, 255, 255, .6);
    background: rgba(255, 255, 255, .15);
}

.chat-widget-quote-sender {
    font-weight: 700;
    opacity: .85;
}

.chat-widget-quote-body {
    opacity: .85;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-widget-attachment-image-link {
    display: block;
    margin-bottom: 4px;
}

.chat-widget-attachment-image {
    max-width: 100%;
    max-height: 220px;
    border-radius: 8px;
    display: block;
}

.chat-widget-attachment-file {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    background: rgba(0, 0, 0, .05);
    text-decoration: none;
    color: inherit;
    margin-bottom: 4px;
}

.chat-widget-message.is-own .chat-widget-attachment-file {
    background: rgba(255, 255, 255, .18);
}

.chat-widget-attachment-file i {
    font-size: 18px;
    flex-shrink: 0;
}

.chat-widget-attachment-file-info {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.chat-widget-attachment-file-name {
    font-size: 12.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.chat-widget-attachment-file-size {
    font-size: 10.5px;
    opacity: .75;
}

.chat-widget-message-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    margin-top: 4px;
    font-size: 10.5px;
    opacity: .75;
}

.chat-widget-seen-tick i {
    font-size: 11px;
}

.chat-widget-reply-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    background: #eef1f4;
    border-top: 1px solid #e2e5e9;
    font-size: 12px;
}

.chat-widget-reply-preview-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #555;
}

.chat-widget-reply-cancel {
    border: none;
    background: none;
    color: #888;
    cursor: pointer;
    flex-shrink: 0;
    margin-left: 8px;
}

.chat-widget-attachment-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: #eef1f4;
    border-top: 1px solid #e2e5e9;
    font-size: 12px;
    color: #555;
}

.chat-widget-attachment-preview-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-widget-attachment-cancel {
    border: none;
    background: none;
    color: #888;
    cursor: pointer;
    flex-shrink: 0;
}

.chat-widget-attach-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #888;
    flex-shrink: 0;
    cursor: pointer;
    font-size: 15px;
}

.chat-widget-attach-btn:hover {
    background: #f1f1f1;
    color: #555;
}

.chat-widget-composer {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #eee;
    flex-shrink: 0;
    background: #fff;
}

.chat-widget-composer input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 9px 14px;
    font-size: 13.5px;
}

.chat-widget-composer button {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: #0eb582;
    color: #fff;
    flex-shrink: 0;
    cursor: pointer;
}

@media (max-width: 480px) {
    .chat-widget--floating .chat-widget-panel {
        width: calc(100vw - 24px);
        right: -12px;
    }
}
