/* =========================================
   GLOBAL
========================================= */

html,
body {
    overflow-x: hidden;
}


/* =========================================
   FLOATING CHAT BUTTON
========================================= */

#floating-chat-btn {
    position: fixed;

    bottom: 25px;
    right: 25px;

    z-index: 999999;

    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;

    padding: 16px 24px;

    border-radius: 60px;

    font-size: 18px;
    font-weight: 600;

    text-decoration: none;

    box-shadow:
        0 6px 16px rgba(0, 0, 0, 0.25),
        0 2px 6px rgba(0, 0, 0, 0.1);

    transition: all 0.3s ease;

    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

#floating-chat-btn i {
    font-size: 22px;
}

.floating-chat-unread-count{
    position:absolute;
    top:-6px;
    right:-6px;

    min-width:24px;
    height:24px;

    padding:0 7px;

    border-radius:999px;

    background:#dc3545;
    color:#fff;

    display:inline-flex;
    align-items:center;
    justify-content:center;

    font-size:12px;
    font-weight:700;
}

#floating-chat-btn:hover {
    transform: scale(1.06);
}


/* =========================================
   CHAT POPUP CONTAINER
========================================= */

#chat-popup {
    position: fixed;

    bottom: 105px;
    right: 25px;

    width: 1000px;
    max-width: calc(100vw - 30px);

    height: 78vh;
    max-height: 820px;
    min-height: 500px;

    background: #ffffff;

    border-radius: 24px;

    box-shadow:
        0 12px 40px rgba(0,0,0,0.22),
        0 2px 8px rgba(0,0,0,0.08);

    z-index: 99999;

    overflow: hidden;

    display: flex;
    flex-direction: column;

    opacity: 0;
    visibility: hidden;

    transform: translateY(30px) scale(0.92);

    transform-origin: bottom right;

    transition:
        opacity 0.25s ease,
        transform 0.25s ease,
        visibility 0.25s;
}


/* =========================================
   SHOW POPUP
========================================= */

#chat-popup.show {
    opacity: 1;
    visibility: visible;

    transform: translateY(0) scale(1);
}


/* =========================================
   CHAT HEADER
========================================= */

#chat-popup-header {
    background: #ffc107;

    color: #000;

    padding: 18px 22px;

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

    border-bottom: 1px solid rgba(0,0,0,0.08);
}

#chat-popup-header strong {
    font-size: 18px;
}

#chat-popup-header .small {
    font-size: 13px;
    opacity: 0.8;
}


/* =========================================
   CLOSE BUTTON
========================================= */

#close-chat-popup {
    border: none;
    background: transparent;

    width: 40px;
    height: 40px;

    border-radius: 50%;

    font-size: 22px;

    cursor: pointer;

    transition: all 0.2s ease;
}

#close-chat-popup:hover {
    background: rgba(0,0,0,0.08);
}


/* =========================================
   CHAT BODY
========================================= */

#chat-popup-body {
    flex: 1;

    overflow-y: auto;

    background: #f8f9fa;
}


/* =========================================
   SCROLLBAR
========================================= */

#chat-popup-body::-webkit-scrollbar {
    width: 8px;
}

#chat-popup-body::-webkit-scrollbar-track {
    background: #f1f1f1;
}

#chat-popup-body::-webkit-scrollbar-thumb {
    background: #c7c7c7;
    border-radius: 10px;
}

#chat-popup-body::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}


/* =========================================
   TABLET RESPONSIVE
========================================= */

@media (max-width: 992px) {

    #chat-popup {
        width: 460px;
        height: 82vh;
    }

    #floating-chat-btn {
        padding: 15px 22px;
        font-size: 17px;
    }

    #floating-chat-btn i {
        font-size: 21px;
    }
}


/* =========================================
   MOBILE RESPONSIVE
========================================= */

@media (max-width: 768px) {

    /* FLOATING BUTTON */
    #floating-chat-btn {
        position: fixed !important;

        bottom: max(18px, env(safe-area-inset-bottom));
        right: 18px;

        z-index: 999999 !important;

        padding: 14px 20px;

        font-size: 16px;

        display: flex !important;
        align-items: center;
        justify-content: center;

        visibility: visible !important;
        opacity: 1 !important;

        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }

    #floating-chat-btn i {
        font-size: 20px;
    }


    /* CHAT POPUP */
    #chat-popup {
        width: calc(100% - 20px);

        height: 84vh;
        max-height: 84vh;

        right: 10px;

        bottom: calc(10px + env(safe-area-inset-bottom));

        border-radius: 20px;

        transform-origin: bottom center;
    }

    #chat-popup.show {
        transform: translateY(0) scale(1);
    }

    #chat-popup-header {
        padding: 14px 16px;
    }

    #chat-popup-header strong {
        font-size: 16px;
    }

    #chat-popup-body {
        padding: 12px;
    }
}


/* =========================================
   EXTRA SMALL MOBILE
========================================= */

@media (max-width: 480px) {

    /* FLOATING BUTTON */
    #floating-chat-btn {
        position: fixed !important;

        width: 62px;
        height: 62px;

        padding: 0;

        border-radius: 50%;

        justify-content: center;

        bottom: max(16px, env(safe-area-inset-bottom));
        right: 16px;

        z-index: 999999 !important;

        display: flex !important;

        visibility: visible !important;
        opacity: 1 !important;

        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }

    #floating-chat-btn span {
        display: none;
    }

    #floating-chat-btn i {
        font-size: 24px;
    }


    /* CHAT POPUP */
    #chat-popup {
        width: calc(100% - 16px);

        height: 80vh;
        max-height: 80vh;

        right: 8px;

        bottom: calc(8px + env(safe-area-inset-bottom));

        border-radius: 18px;
    }

    #chat-popup-body {
        padding: 10px;
    }
}

.group-item {
    cursor: pointer;
    padding: 10px;
}

.group-item:hover {
    background: #f1f1f1;
}

.group-item.active {
    background: #ffe08a;
}

/* =========================================
   FORCE CHAT BUBBLE STYLE
========================================= */

.message-row{
    width:100%;
    display:flex;
    margin-bottom:12px;
}

.message-row.mine{
    justify-content:flex-end;
}

.message-row.other{
    justify-content:flex-start;
}

.message-bubble{

    display:inline-block;

    width:fit-content;

    max-width:75%;

    padding:10px 14px;

    border-radius:18px;

    box-sizing:border-box;

    word-break:break-word;

    overflow-wrap:anywhere;
}

/* MY MESSAGE */
.message-row.mine .message-bubble{
    background:#ffc107 !important;
    color:#000 !important;

    border-bottom-right-radius:6px;
}

/* OTHER MESSAGE */
.message-row.other .message-bubble{
    background:#fff !important;

    border-bottom-left-radius:6px;
}

/* NAME */
.message-name{

    font-size:13px;
    font-weight:700;

    margin-bottom:6px;

    white-space:normal;

    word-break:break-word;

    max-width:250px;
}

/* MESSAGE */
.message-text{

    display:block !important;

    width:auto !important;

    text-align:left !important;

    line-height:1.4;

    margin:0;
    padding:0;
}

/* TIME */
.message-time{
    font-size:11px;
    opacity:0.7;

    margin-top:6px;

    text-align:right !important;
}

.pending-message .message-bubble{
    opacity:0.78;
}

.sending-indicator{
    font-style:italic;
}

.failed-message .message-bubble{
    background:#f8d7da !important;
    color:#721c24 !important;
}

.failed-message .message-time{
    opacity:1;
    font-weight:600;
}

/* =========================================
   RECIPIENTS
========================================= */

#chat-recipients{
    display:flex;
    flex-wrap:wrap;
    gap:6px;

    margin-top:8px;
}

.recipient-badge{

    background:#f1f1f1;

    padding:4px 10px;

    border-radius:20px;

    font-size:12px;

    color:#555;

    border:1px solid #ddd;
}

.chat-groups > .border-bottom,
.chat-window > .border-bottom{
    background:#fff;
    position:sticky;
    top:0;
    z-index:10;

    min-height:76px;

    padding:12px 14px !important;
}

.chat-groups > .border-bottom{
    padding-right:152px !important;
}

.chat-groups > .border-bottom > .d-flex{
    min-height:52px;
    justify-content:space-between !important;
}

.chat-groups > .border-bottom strong{
    margin:0;

    display:flex;
    align-items:center;

    min-height:52px;

    text-align:left;
}

.chat-window > .border-bottom{
    padding-right:160px !important;
}

.group-last-sender{
    color:#333;
    font-weight:600;
}

.group-last-text{
    color:inherit;
}

/* =========================================
   CREATE GROUP FLOAT PANEL
========================================= */

#create-group-panel{

    position:absolute;

    top:calc(100% + 4px);

    right:10px;

    width:280px;

    background:#fff;

    border-radius:16px;

    padding:14px;

    box-shadow:
        0 10px 30px rgba(0,0,0,0.18);

    border:1px solid #eee;

    z-index:20;

    opacity:0;

    visibility:hidden;

    transform:
        translateY(-10px)
        scale(0.95);

    transform-origin:top right;

    transition:all 0.2s ease;
}

/* SHOW */
#create-group-panel.show{

    opacity:1;

    visibility:visible;

    transform:
        translateY(0)
        scale(1);
}

/* =========================================
   SELECT2 CHAT STYLE
========================================= */

.select2-container{

    width:100% !important;
}

.select2-container--default
.select2-selection--multiple{

    border-radius:12px !important;

    border:1px solid #ddd !important;

    min-height:42px !important;

    padding:4px;
}

.select2-container--default
.select2-selection--multiple
.select2-selection__choice{

    background:#ffc107 !important;

    border:none !important;

    color:#000 !important;

    border-radius:20px !important;

    padding:4px 10px !important;

    font-size:12px;
}

.select2-dropdown{

    border-radius:12px !important;

    border:1px solid #ddd !important;

    overflow:hidden;
}

.select2-search__field{
    margin-top:6px !important;
}

/* =========================================
   ADD RECIPIENT PANEL
========================================= */

#add-recipient-panel {

    display: none;

    position: absolute;

    top: calc(100% + 4px);

    right: 10px;

    width: 300px;

    background: #fff;

    border: 1px solid #ddd;

    border-radius: 16px;

    padding: 14px;

    box-shadow: 0 10px 30px rgba(0,0,0,0.18);

    z-index: 99999;
}

#add-recipient-panel.show {
    display: block !important;
}

/* HIDE BUTTON UNTIL GROUP SELECTED */
#btn-add-recipient {
    display: none;
}

.chat-header-action-btn{
    position:absolute;
    right:10px;
    top:50%;
    transform:translateY(-50%);

    display:inline-flex;
    align-items:center;
    justify-content:center;
    gap:8px;

    min-height:38px;

    padding:8px 13px;

    border-radius:8px;

    font-size:13px;
    font-weight:600;

    white-space:nowrap;

    z-index:11;
}

.chat-header-action-btn i{
    font-size:15px;
}

.chat-header-action-btn span{
    line-height:1;
}

#btn-add-recipient.chat-header-action-btn{
    display:none;
}

@media (max-width: 768px) {
    .chat-groups > .border-bottom,
    .chat-window > .border-bottom{
        padding-right:58px !important;
    }

    .chat-header-action-btn{
        width:40px;
        min-width:40px;
        height:40px;

        justify-content:center;

        padding:0;
    }

    .chat-header-action-btn span{
        display:none;
    }
}


/* =========================================
   EXISTING CHAT CSS
========================================= */

.skeleton-2hun9fcd7ah:empty {
    height: 170px;
    margin-bottom: 10px;

    background-color: #E1E1E1;

    border-radius: 0;

    background-image:
        linear-gradient(
            100deg,
            rgba(255,255,255, 0),
            rgba(255,255,255, 0.5) 50%,
            rgba(255,255,255, 0) 80%
        ),
        linear-gradient(#cccccc 20px, transparent 0),
        radial-gradient(circle 14px at 14px 14px, #cccccc 13px, transparent 14px),
        linear-gradient(#cccccc 20px, transparent 0),
        radial-gradient(circle 14px at 14px 14px, #cccccc 13px, transparent 14px),
        linear-gradient(#cccccc 20px, transparent 0),
        radial-gradient(circle 14px at 14px 14px, #cccccc 13px, transparent 14px);

    background-repeat: repeat-y;

    background-size:
        50px 170px,
        300px 170px,
        28px 170px,
        300px 170px,
        28px 170px,
        300px 170px,
        28px 170px;

    background-position:
        -20% 0,
        left 70px top 125px,
        left 20px top 120px,
        left 70px top 75px,
        left 20px top 70px,
        left 70px top 25px,
        left 20px top 20px;

    animation: shineForSkeleton-2hun9fcd7ah 2s infinite;
}

@keyframes shineForSkeleton-2hun9fcd7ah {
    to {
        background-position:
            120% 0,
            left 70px top 125px,
            left 20px top 120px,
            left 70px top 75px,
            left 20px top 70px,
            left 70px top 25px,
            left 20px top 20px;
    }
}

[contentEditable=true]:empty:not(:focus):before {
    content: attr(data-placeholder);
    color: gray;
}

/* =========================================
   GLOBAL PO CHAT INBOX
========================================= */

.global-po-chat-inbox{
    position:fixed;
    right:25px;
    bottom:25px;
    z-index:999998;
}

.global-po-chat-btn{
    position:relative;

    display:inline-flex;
    align-items:center;
    justify-content:center;
    gap:10px;

    min-height:58px;

    padding:14px 22px;

    border-radius:60px;

    font-size:16px;
    font-weight:600;

    box-shadow:
        0 6px 16px rgba(0, 0, 0, 0.25),
        0 2px 6px rgba(0, 0, 0, 0.1);
}

.global-po-chat-btn i{
    font-size:20px;
}

.global-po-chat-count{
    position:absolute;
    top:-6px;
    right:-6px;

    min-width:24px;
    height:24px;

    padding:0 7px;

    border-radius:999px;

    background:#dc3545;
    color:#fff;

    display:inline-flex;
    align-items:center;
    justify-content:center;

    font-size:12px;
    font-weight:700;
}

.global-po-chat-panel{
    position:absolute;
    right:0;
    bottom:74px;

    width:340px;
    max-width:calc(100vw - 30px);

    background:#fff;

    border:1px solid #ddd;
    border-radius:10px;

    box-shadow:0 12px 34px rgba(0,0,0,0.2);

    overflow:hidden;

    opacity:0;
    visibility:hidden;
    transform:translateY(12px);

    transition:all 0.2s ease;
}

.global-po-chat-panel.show{
    opacity:1;
    visibility:visible;
    transform:translateY(0);
}

.global-po-chat-header{
    min-height:52px;

    padding:12px 14px;

    background:#fff;

    border-bottom:1px solid #eee;

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

#global-po-chat-close{
    border:none;
    background:transparent;

    width:34px;
    height:34px;

    cursor:pointer;
}

.global-po-chat-list{
    max-height:360px;
    overflow-y:auto;
}

.global-po-chat-item{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;

    padding:12px 14px;

    color:#333;
    text-decoration:none;

    border-bottom:1px solid #f0f0f0;
}

.global-po-chat-item:hover{
    background:#fff8df;
    color:#000;
    text-decoration:none;
}

.global-po-chat-item-main{
    min-width:0;

    display:block;
}

.global-po-chat-item-main strong{
    display:block;

    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
}

.global-po-chat-unread{
    min-width:24px;
    height:24px;

    padding:0 7px;

    border-radius:999px;

    background:#dc3545;
    color:#fff;

    display:inline-flex;
    align-items:center;
    justify-content:center;

    font-size:12px;
    font-weight:700;

    flex:0 0 auto;
}

.global-po-chat-empty{
    padding:18px;

    color:#777;
    text-align:center;
}

@media (max-width: 480px) {
    .global-po-chat-inbox{
        right:16px;
        bottom:max(16px, env(safe-area-inset-bottom));
    }

    .global-po-chat-btn{
        width:62px;
        height:62px;
        min-height:62px;

        padding:0;

        border-radius:50%;
    }

    .global-po-chat-btn span:not(.global-po-chat-count){
        display:none;
    }

    .global-po-chat-panel{
        right:0;
        bottom:76px;

        width:calc(100vw - 32px);
    }
}
