/*
  CRMChat mobile kefu patch - WeChat-like skin
  Scope: only active on <=768px and only when body has .crmchat-mobile-kefu
*/
@media (max-width: 768px) {
  :root {
    --crmchat-wx-bg: #ededed;
    --crmchat-wx-panel: #f7f7f7;
    --crmchat-wx-line: rgba(0, 0, 0, 0.08);
    --crmchat-wx-text: #111;
    --crmchat-wx-subtext: #888;
    --crmchat-wx-green: #95ec69;
    --crmchat-wx-green-deep: #07c160;
    --crmchat-vv-bottom: 0px;
  }

  html, body, #app {
    height: 100%;
    overflow: hidden;
  }

  body.crmchat-mobile-kefu {
    overflow: hidden;
    background: var(--crmchat-wx-bg);
    color: var(--crmchat-wx-text);
    -webkit-font-smoothing: antialiased;
  }

  body.crmchat-mobile-kefu .kefu-layouts {
    position: relative;
    height: 100dvh !important;
    overflow: hidden !important;
    padding: 0 !important;
    background: var(--crmchat-wx-bg) !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .content-wrapper {
    width: 100vw !important;
    height: 100dvh !important;
    min-width: 0 !important;
    margin: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: var(--crmchat-wx-bg) !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .base-header {
    height: 48px !important;
    min-height: 48px !important;
    padding: 0 10px !important;
    background: #f6f6f6 !important;
    color: var(--crmchat-wx-text) !important;
    border-bottom: 1px solid var(--crmchat-wx-line);
  }

  body.crmchat-mobile-kefu .kefu-layouts .base-header .left-wrapper {
    padding-right: 8px !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .base-header .left-wrapper .search_box {
    display: none !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .base-header .user_info img {
    width: 28px !important;
    height: 28px !important;
    margin-right: 8px !important;
    border-radius: 9px !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .base-header .user_info span {
    max-width: 40vw;
    font-size: 15px !important;
    font-weight: 600;
    color: var(--crmchat-wx-text) !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  body.crmchat-mobile-kefu .kefu-layouts .base-header .user_info .status {
    margin-left: 6px !important;
    padding: 0 8px !important;
    height: 20px !important;
    border-radius: 999px !important;
    background: rgba(7, 193, 96, 0.12) !important;
    color: #16874a !important;
    font-size: 11px !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .base-header .user_info .status.off {
    background: rgba(0, 0, 0, 0.06) !important;
    color: #888 !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .base-header .user_info .status .dot {
    width: 6px !important;
    height: 6px !important;
    margin-right: 4px !important;
    background: var(--crmchat-wx-green-deep) !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .base-header .user_info .status.off .dot {
    background: #999 !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .base-header .right-menu {
    display: none !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .base-header .out-btn {
    right: 10px !important;
    width: auto !important;
    min-width: 58px;
    height: 28px !important;
    line-height: 28px !important;
    padding: 0 10px;
    transform: translateY(-50%) !important;
    font-size: 12px !important;
    color: #666 !important;
    background: #fff !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  }

  body.crmchat-mobile-kefu .kefu-layouts .container {
    position: relative !important;
    display: block !important;
    width: 100% !important;
    height: calc(100dvh - 48px) !important;
    overflow: hidden !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chatList,
  body.crmchat-mobile-kefu .kefu-layouts .chat-content {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chatList {
    z-index: 30;
    display: flex !important;
    flex-direction: column !important;
    background: #f6f6f6 !important;
    border-right: 0 !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chat-content {
    z-index: 20;
    display: flex !important;
    flex-direction: column !important;
    background: var(--crmchat-wx-bg) !important;
    border-left: 0 !important;
    border-right: 0 !important;
  }

  body.crmchat-mobile-kefu:not(.crmchat-mobile-chat-open) .kefu-layouts .chat-content {
    display: none !important;
  }

  body.crmchat-mobile-kefu.crmchat-mobile-chat-open .kefu-layouts .chatList {
    display: none !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chatList .search_box {
    position: sticky;
    top: 0;
    z-index: 6;
    margin: 0 !important;
    padding: 8px 12px 6px;
    background: #f6f6f6;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chatList .search_box .ivu-input,
  body.crmchat-mobile-kefu .kefu-layouts .chatList .search_box input {
    height: 34px !important;
    border: 0 !important;
    border-radius: 10px !important;
    background: #e9e9eb !important;
    box-shadow: none !important;
    padding-left: 12px !important;
    color: #333 !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chatList .tab-head {
    position: sticky;
    top: 48px;
    z-index: 5;
    height: 42px !important;
    padding: 0 18px !important;
    justify-content: flex-start !important;
    gap: 22px;
    background: #f6f6f6 !important;
    border-bottom: 1px solid var(--crmchat-wx-line);
    color: #666 !important;
    font-size: 14px !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chatList .tab-head .item {
    height: 42px;
    line-height: 42px;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chatList .tab-head .item.active {
    color: var(--crmchat-wx-text) !important;
    font-weight: 600;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chatList .tab-head .item.active::after {
    display: block !important;
    bottom: 5px !important;
    height: 3px !important;
    width: 18px !important;
    border-radius: 999px;
    background: var(--crmchat-wx-green-deep) !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chatList .scroll-box {
    height: calc(100dvh - 48px - 48px - 42px) !important;
    overflow: auto !important;
    -webkit-overflow-scrolling: touch;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    background: #fff;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chatList .chat-item {
    position: relative;
    height: 76px !important;
    padding: 10px 12px !important;
    border-left: 0 !important;
    background: #fff !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chatList .chat-item::after {
    content: "";
    position: absolute;
    left: 64px;
    right: 0;
    bottom: 0;
    height: 1px;
    background: rgba(0, 0, 0, 0.06);
  }

  body.crmchat-mobile-kefu .kefu-layouts .chatList .chat-item.active {
    background: #f2f2f2 !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chatList .chat-item .avatar {
    width: 48px !important;
    height: 48px !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chatList .chat-item .avatar img {
    border-radius: 12px !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chatList .chat-item .avatar .status {
    width: 10px !important;
    height: 10px !important;
    right: 1px !important;
    bottom: 1px !important;
    border-width: 2px !important;
    background: var(--crmchat-wx-green-deep) !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chatList .chat-item .avatar .status.off {
    background: #b5b5b5 !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chatList .chat-item .user-info {
    width: auto !important;
    min-width: 0 !important;
    flex: 1;
    margin: 0 10px 0 12px !important;
    font-size: 15px !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chatList .chat-item .user-info .hd {
    color: #111 !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chatList .chat-item .user-info .hd .name {
    max-width: 56vw !important;
    font-size: 15px !important;
    font-weight: 500;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chatList .chat-item .user-info .hd .label {
    margin-left: 6px !important;
    padding: 0 6px !important;
    border-radius: 999px !important;
    font-size: 10px !important;
    line-height: 18px !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chatList .chat-item .user-info .hd .label.wechat {
    color: #16874a !important;
    background: rgba(7, 193, 96, 0.14) !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chatList .chat-item .user-info .bd {
    max-width: 58vw;
    margin-top: 5px !important;
    color: #888 !important;
    font-size: 12px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chatList .chat-item .right-box {
    min-width: 42px;
    color: #999 !important;
    font-size: 11px !important;
    gap: 5px;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chatList .chat-item .right-box .num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    margin-right: 0 !important;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--crmchat-wx-green-deep);
    color: #fff;
    font-size: 11px;
    line-height: 20px;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chat-content .mobile-chat-topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 48px;
    padding: 0 8px 0 6px;
    background: #f6f6f6;
    border-bottom: 1px solid var(--crmchat-wx-line);
    flex: 0 0 48px;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chat-content .mobile-chat-back,
  body.crmchat-mobile-kefu .kefu-layouts .chat-content .mobile-chat-more {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #222;
    font-size: 20px;
    padding: 0;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chat-content .mobile-chat-avatar {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    object-fit: cover;
    background: #ddd;
    flex: 0 0 32px;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chat-content .mobile-chat-meta {
    flex: 1;
    min-width: 0;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chat-content .mobile-chat-title {
    min-width: 0;
    font-size: 15px;
    font-weight: 600;
    color: #111;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chat-content .mobile-chat-subtitle {
    margin-top: 1px;
    font-size: 11px;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chat-content .chat-body {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    max-height: none !important;
    width: 100% !important;
    overflow: hidden !important;
    background: var(--crmchat-wx-bg) !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chat-content #chat_scroll,
  body.crmchat-mobile-kefu .kefu-layouts .chat-content .happy-scroll-content {
    width: auto !important;
    min-width: 0 !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chat-content #chat_scroll {
    padding: 10px 10px 14px !important;
    background: var(--crmchat-wx-bg) !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chat-content .chat-item {
    margin-bottom: 12px !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chat-content .chat-item .time {
    display: inline-block;
    margin: 2px auto 10px !important;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.08);
    color: #7f7f7f !important;
    font-size: 11px !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chat-content .chat-item .flex-box {
    align-items: flex-start;
    gap: 8px;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chat-content .chat-item .avatar {
    width: 36px !important;
    height: 36px !important;
    margin-right: 0 !important;
    margin-left: 0 !important;
    flex: 0 0 36px;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chat-content .chat-item .avatar img {
    border-radius: 10px !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chat-content .chat-item .msg-wrapper {
    position: relative;
    overflow: visible !important;
    max-width: 74vw !important;
    border-radius: 8px !important;
    background: #fff !important;
    color: #111 !important;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
  }

  body.crmchat-mobile-kefu .kefu-layouts .chat-content .chat-item .msg-wrapper::before {
    content: "";
    position: absolute;
    top: 10px;
    left: -6px;
    width: 12px;
    height: 12px;
    background: #fff;
    transform: rotate(45deg);
    border-radius: 2px;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chat-content .chat-item .msg-wrapper .pad16 {
    padding: 10px 12px !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chat-content .chat-item .msg-wrapper .txt-wrapper {
    word-break: break-word !important;
    white-space: pre-wrap;
    line-height: 1.45;
    font-size: 15px;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chat-content .chat-item .msg-wrapper .img-wraper,
  body.crmchat-mobile-kefu .kefu-layouts .chat-content .chat-item .msg-wrapper .order-wrapper {
    max-width: 74vw !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chat-content .chat-item .msg-wrapper .img-wraper img {
    display: block;
    max-width: 66vw !important;
    max-height: 52vw !important;
    border-radius: 8px;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chat-content .chat-item .msg-wrapper .order-wrapper {
    width: auto !important;
    min-width: 0;
    padding: 10px 12px;
    align-items: flex-start;
    gap: 10px;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chat-content .chat-item .msg-wrapper .order-wrapper .img-box {
    width: 56px !important;
    height: 56px !important;
    flex: 0 0 56px;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chat-content .chat-item .msg-wrapper .order-wrapper .order-info {
    width: auto !important;
    min-width: 0;
    margin-left: 0 !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chat-content .chat-item.right-box .flex-box {
    flex-direction: row-reverse !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chat-content .chat-item.right-box .msg-wrapper {
    background: var(--crmchat-wx-green) !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chat-content .chat-item.right-box .msg-wrapper::before {
    left: auto;
    right: -6px;
    background: var(--crmchat-wx-green);
  }

  body.crmchat-mobile-kefu .kefu-layouts .chat-content .chat-item.right-box.gary .msg-wrapper,
  body.crmchat-mobile-kefu .kefu-layouts .chat-content .chat-item.right-box.gary .msg-wrapper::before {
    background: #fff !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chat-content .chat-textarea {
    display: flex !important;
    flex-direction: column !important;
    gap: 0;
    height: auto !important;
    min-height: 0 !important;
    padding-bottom: max(env(safe-area-inset-bottom), var(--crmchat-vv-bottom));
    border-top: 1px solid var(--crmchat-wx-line) !important;
    background: #f7f7f7 !important;
    flex: 0 0 auto;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chat-content .textarea-box {
    order: 1;
    position: relative;
    display: block !important;
    flex: 0 0 auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 8px 12px 0 !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chat-content .editable {
    min-height: 42px !important;
    max-height: 30dvh !important;
    padding: 10px 52px 10px 12px !important;
    overflow-y: auto !important;
    border: 1px solid #d6d6d6;
    border-radius: 10px !important;
    background: #fff !important;
    color: #111 !important;
    font-size: 16px !important;
    line-height: 1.4 !important;
    -webkit-overflow-scrolling: touch;
    box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.02);
  }

  body.crmchat-mobile-kefu .kefu-layouts .chat-content .send-btn {
    position: absolute !important;
    right: 18px !important;
    bottom: 8px !important;
    display: flex !important;
    margin: 0 !important;
    z-index: 2;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chat-content .send-btn .btns,
  body.crmchat-mobile-kefu .kefu-layouts .chat-content .send-btn .ivu-btn {
    min-width: 44px !important;
    height: 30px !important;
    padding: 0 10px !important;
    border: 0 !important;
    border-radius: 8px !important;
    background: var(--crmchat-wx-green-deep) !important;
    color: #fff !important;
    font-size: 13px !important;
    line-height: 30px !important;
    box-shadow: none !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chat-content .send-btn .btns[disabled],
  body.crmchat-mobile-kefu .kefu-layouts .chat-content .send-btn .ivu-btn[disabled] {
    background: #cfcfcf !important;
    color: #fff !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chat-content .chat-btn-wrapper {
    order: 2;
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px 8px !important;
    background: #f7f7f7 !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chat-content .left-wrapper,
  body.crmchat-mobile-kefu .kefu-layouts .chat-content .right-wrapper {
    display: flex !important;
    align-items: center;
    gap: 8px;
    padding: 0 !important;
    margin: 0 !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chat-content .left-wrapper .icon-item,
  body.crmchat-mobile-kefu .kefu-layouts .chat-content .right-wrapper .icon-item {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    margin: 0 !important;
    border-radius: 8px;
    color: #555 !important;
    background: transparent;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chat-content .left-wrapper .icon-item .iconfont,
  body.crmchat-mobile-kefu .kefu-layouts .chat-content .right-wrapper .icon-item .iconfont {
    font-size: 20px !important;
    color: #5c5c5c !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chat-content .right-wrapper .icon-item span {
    display: none !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chat-content .emoji-box,
  body.crmchat-mobile-kefu .kefu-layouts .chat-content .transfer-box {
    position: fixed !important;
    left: 10px !important;
    right: 10px !important;
    bottom: calc(88px + env(safe-area-inset-bottom) + var(--crmchat-vv-bottom)) !important;
    top: auto !important;
    width: auto !important;
    max-height: 42dvh !important;
    overflow: auto !important;
    border-radius: 16px !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18) !important;
    background: #fff !important;
    z-index: 1002 !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chat-content .emoji-box {
    padding: 14px 10px !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .chat-content .transfer-bg {
    position: fixed !important;
    inset: 0 !important;
    background: rgba(0, 0, 0, 0.22) !important;
    z-index: 1001 !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .right_menu {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    top: auto !important;
    width: auto !important;
    height: auto !important;
    max-height: 74dvh !important;
    padding: 14px 14px calc(14px + env(safe-area-inset-bottom)) !important;
    overflow: auto !important;
    background: #fff !important;
    border-radius: 18px 18px 0 0 !important;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.16) !important;
    z-index: 1003 !important;
    transform: translateY(105%);
    transition: transform 0.22s ease;
    pointer-events: none;
  }

  body.crmchat-mobile-kefu.crmchat-mobile-info-open .kefu-layouts .right_menu {
    transform: translateY(0);
    pointer-events: auto;
  }

  body.crmchat-mobile-kefu .kefu-layouts .right_menu .crmchat_link {
    display: none !important;
  }

  body.crmchat-mobile-kefu .mobile-info-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.22);
    z-index: 1002;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  body.crmchat-mobile-kefu.crmchat-mobile-info-open .mobile-info-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  body.crmchat-mobile-kefu .kefu-layouts .ivu-modal {
    width: calc(100vw - 16px) !important;
    margin: 8px auto !important;
    top: 8px !important;
  }

  body.crmchat-mobile-kefu .kefu-layouts .ivu-modal-content {
    max-height: calc(100dvh - 16px);
    overflow: auto;
    border-radius: 14px !important;
  }
}
