/* ============================================
   Catbot Widget - 로컬편의점 고객문의 챗봇
   ============================================ */

/* Fonts */
@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard/dist/web/static/pretendard.min.css');

@font-face {
  font-family: 'UNPEOPLE Gothic UNI';
  src: url('./assets/UnPeopleGothic.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* Reset & Container */
.catbot-overlay *,
.catbot-fab * {
  margin: 0; padding: 0; box-sizing: border-box;
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Malgun Gothic', '맑은고딕', sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Floating Action Button */
.catbot-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: none;
  border: none;
  cursor: pointer;
  z-index: 99998;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
  padding: 0;
  overflow: visible;
}
.catbot-fab:hover {
  transform: scale(1.08);
}
.catbot-fab svg {
  width: 30px; height: 30px; fill: #fff;
  transition: transform 0.3s ease, opacity 0.2s ease;
}
.catbot-fab .catbot-fab-icon-chat {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 50%;
  transition: opacity 0.3s ease;
}
.catbot-fab .catbot-fab-icon-close {
  position: absolute;
  opacity: 0;
  transform: rotate(-90deg);
}
.catbot-fab.catbot-active .catbot-fab-icon-chat {
  opacity: 0;
}
.catbot-fab.catbot-active {
  background: #3f75ff;
}
.catbot-fab.catbot-active .catbot-fab-icon-close {
  opacity: 1;
  transform: rotate(0deg);
}
.catbot-fab-badge {
  position: absolute;
  top: 0px;
  right: 0px;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background: #FF4757;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
  transform: translate(30%, -30%);
  pointer-events: none;
}
.catbot-fab-badge.catbot-show { display: flex; }

/* Overlay (floating popup - Channel Talk style) */
.catbot-overlay {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 480px; /* 380px */
  height: 840px; /* 620px */
  max-height: calc(100vh - 130px);
  background: #fff;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.16);
  overflow: hidden;
  transform: translateY(30px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.3s ease, opacity 0.3s ease;
}
.catbot-overlay.catbot-open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* Header */
.catbot-header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 20px;
  background: #fff;
  border-bottom: 1px solid #d9d9d9;
  position: relative;
  min-height: 56px;
}
.catbot-header-logo {
  display: flex;
  align-items: center;
}
.catbot-header-logo img {
  height: 24px;
  width: auto;
}
.catbot-header-back {
  position: absolute;
  left: 16px; top: 50%;
  transform: translateY(-50%);
  background: none; border: none;
  cursor: pointer;
  padding: 4px;
  color: #666;
}
.catbot-header-back svg {
  width: 22px; height: 22px;
}
.catbot-header-back:hover {
  color: #333;
}
.catbot-header-close {
  position: absolute;
  right: 16px; top: 50%;
  transform: translateY(-50%);
  background: none; border: none;
  cursor: pointer;
  padding: 4px;
  color: #666;
}
.catbot-header-close svg,
.catbot-header-close img {
  width: 17px; height: 17px;
}

/* Messages area */
.catbot-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  padding-top: 16px;
  background: #fff;
  -ms-overflow-style: none; /* IE, Edge */
  scrollbar-width: none;    /* Firefox */
}
/* 2. Chrome, Safari, Edge 전용 가상 요소 */
.catbot-body::-webkit-scrollbar {
    display: none; /* 스크롤바 영역 자체를 렌더링하지 않음 */
}
/* Bot avatar */
.catbot-avatar {
  width: 48px;
  height: 48px;
  overflow: hidden;
  flex-shrink: 0;
  margin-bottom: 12px;
  animation: catbot-pop-in 0.3s cubic-bezier(0.34, 1.4, 0.64, 1) both;
}
.catbot-avatar img {
  width: 100%; height: 100%;
  object-fit: cover;
}

/* Message bubbles */
.catbot-msg-row {
  display: flex;
  flex-direction: column;
  margin-bottom: 12px;
  animation: catbot-pop-in 0.3s cubic-bezier(0.34, 1.4, 0.64, 1) both;
}
.catbot-msg-row.catbot-msg-bot {
  align-items: flex-start;
  transform-origin: bottom left;
}
.catbot-msg-row.catbot-msg-user {
  align-items: flex-end;
  transform-origin: bottom right;
}

.catbot-bubble {
  max-width: 230px;
  padding: 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
  letter-spacing: -0.02em;
  word-break: break-word;
  white-space: pre-wrap;
}
.catbot-bubble.catbot-bubble-actions {
  min-width: 60%;
  width: 60%;
  max-width: 60%;
  box-sizing: border-box;
}
.catbot-msg-bot .catbot-bubble {
  background: #F2F2F2;
  color: #000;
  border-top-left-radius: 0;
}
.catbot-msg-user .catbot-bubble {
  background: #3f75ff;
  color: #fff;
  border-top-right-radius: 0;
}

/* Reference card (order/product/delivery card) */
.catbot-ref-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  background: #fff;
  border: 1px solid #3f75ff;
  border-radius: 10px;
  border-top-right-radius: 0;
  margin-bottom: 12px;
  max-width: 85%;
}
.catbot-ref-card img {
  width: 72px; height: 72px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}
.catbot-ref-card-info {
  flex: 1;
  min-width: 0;
}
.catbot-ref-card-info .catbot-ref-sub {
  font-size: 12px; color: #000;
  margin-bottom: 2px;
}
.catbot-ref-card-info .catbot-ref-title {
  font-size: 14px; font-weight: 400;
  color: #000; line-height: 20px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  margin-bottom: 4px;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  padding: 4px 0;
}
.catbot-ref-card-info .catbot-ref-meta {
  font-size: 14px; color: #000; font-weight: 400; line-height: 20px;
}

/* 입금대기, 결제완료 */
.catbot-ref-meta.delivery{
  color: #000;
  font-size: 16px;
  font-weight: 700;
  padding-bottom: 6px;
}
/* 배송완료, 구매확정 */
.catbot-ref-meta.cr_blue{
  color: #3F75FF;
}
/* 지연 */
.catbot-ref-meta.cr_orange{
  color: #FF6333;
}
/* 상품준비중, 배송준비중, 배송중 */
.catbot-ref-meta.cr_green{
  color: #26A90C;
}
/* Brand / Data selection card (inside bubble) */
.catbot-select-card {
  background: #f2f2f2;
  border-radius: 10px;
  border-top-left-radius: 0;
  padding: 16px;
  max-width: 83%;
  margin-bottom: 12px;
  animation: catbot-pop-in 0.35s cubic-bezier(0.34, 1.4, 0.64, 1) 0.1s both;
}
.catbot-search-box {
  display: flex;
  align-items: center;
  border: 1px solid #999;
  border-radius: 4px; 
  padding: 1px 12px;
  padding-right: 6px;
  margin-bottom: 12px;
  background: #fff;
}
.catbot-search-box input {
  border: none;
  outline: none;
  flex: 1;
  font-size: 14px;
  color: #666;
  background: transparent;
  padding: 0;
}
.catbot-search-box input::placeholder {
  color: #666;
}
.catbot-search-box svg {
  width: 30px;
  height: 28px;
  flex-shrink: 0;
  padding: 3px;
}

/* Scrollable list */
.catbot-select-list,
.catbot-input-bar textarea {
  background-color: #fff;
  max-height: 280px;
  overflow-y: auto;
  border-radius: 4px;
}
/* 1. 스크롤바 전체 너비 (얇게) */
.catbot-select-list::-webkit-scrollbar,
.catbot-input-bar textarea::-webkit-scrollbar {
    width: 6px;
}

/* 2. 스크롤바 막대(핸들) 디자인 */
.catbot-select-list::-webkit-scrollbar-thumb,
.catbot-input-bar textarea::-webkit-scrollbar-thumb {
    background-color: #999;    /* 이미지와 비슷한 회색 */
    border-radius: 10px;       /* 둥글게 */
    background-clip: padding-box; /* 여백을 주고 싶을 때 사용 */
}

/* 3. 스크롤바 트랙(바탕) - 투명하게 */
.catbot-select-list::-webkit-scrollbar-track {
    background-color: transparent;
}
.catbot-select-item {
  padding: 12px 14px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  font-size: 14px;
  font-weight: 400;
  color: #000;
  transition: background 0.15s;
}
.catbot-select-item:last-child { border-bottom: none; }
.catbot-select-item:hover { background: #ECF1FF; }
.catbot-select-item.catbot-selected {
  color: #3f75ff;
  font-weight: 700;
  background: #ECF1FF;
}

/* Data select item (with image) */
.catbot-data-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0 12px 12px;
  margin-right: 18px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  transition: background 0.15s;
}
.catbot-data-item:last-child { border-bottom: none; }
.catbot-data-item:hover { background: #ecf1ff; }
.catbot-data-item img {
  width: 68px; height: 68px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}
.catbot-data-item-info {
  flex: 1; min-width: 0;
}
.catbot-data-item-info .catbot-di-sub {
  font-size: 12px; color: #000; margin-bottom: 2px; line-height: 18px;
}
.catbot-data-item-info .catbot-di-title {
  font-size: 14px; font-weight: 400; color: #000; line-height: 20px;
  overflow: hidden; text-overflow: ellipsis; margin-bottom: 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.catbot-data-item-info .catbot-di-meta {
  font-size: 14px; color: #666; font-weight: 400; line-height: 20px;
}

/* Delivery status badge */
.catbot-delivery-badge {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 6px;
}
.catbot-delivery-badge.catbot-status-shipping { color: #333; }
.catbot-delivery-badge.catbot-status-delayed { color: #FF4757; }
.catbot-delivery-badge.catbot-status-done { color: #3f75ff; }
.catbot-delivery-badge.cr_green { color: #26A90C; }
/* Inquiry type chips */
.catbot-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  margin-bottom: 8px;
  animation: catbot-pop-in 0.35s cubic-bezier(0.34, 1.4, 0.64, 1) 0.1s both;
  max-width: 280px;
}
.catbot-chip {
  padding: 11px 20px;
  border-radius: 29.5px;
  border: 1px solid #666;
  background: #fff;
  font-size: 14px;
  color: #000;
  cursor: pointer;
  transition: all 0.15s;    
}
.catbot-chip:hover {
  border-color: #3f75ff;
  color: #3f75ff;
}
.catbot-chip.catbot-active {
  border-color: #3f75ff;
  background: #ecf1ff;
  color: #3f75ff;
  font-weight: 700;
}
.catbot-chip.catbot-disabled {
  opacity: 0.4;
  cursor: default;
}

/* Login prompt */
.catbot-login-card {
  display: none;
}
.catbot-login-card p {
  font-size: 14px; color: #333;
  margin-bottom: 14px;
}
.catbot-login-bubble {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.catbot-login-bubble .catbot-login-btn {
  display: inline-block;
  width: auto;
  padding: 9px;
  vertical-align: middle;
  border-radius: 0;
}
.catbot-login-btn {
  display: block;
  width: 100%;
  padding: 12px;
  border: 1.5px solid #3f75ff;
  border-radius: 5px;
  background: #fff;
  color: #3f75ff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: background 0.15s;
}
.catbot-login-btn:hover {
  background: #f0f5ff;
}

/* Reply action buttons */
.catbot-action-btns {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}
.catbot-action-btn {
  display: block;
  width: 100%;
  height: 48px;
  padding: 14px;
  border-radius: 0;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: opacity 0.15s;
  border: none;
}
.catbot-action-btn.catbot-btn-outline {
  border: 1.5px solid #ddd;
  background: #fff;
  color: #3f75ff;
}
.catbot-btn-outline:disabled{
  background: #FFFFFF;
  color: #AAAAAA;
  border-color: #DDDDDD;
}
.catbot-action-btn.catbot-btn-primary {
  background: #3f75ff;
  color: #fff;
}
.catbot-btn-primary:disabled{
  background: #DDDDDD;
  color: #FFFFFF;
}
.catbot-btn-primary{
  background: #ddd;
  color: #fff;
}
.catbot-action-btn:disabled {
  cursor: default;
  opacity: 1;
}

/* Input bar */
.catbot-input-bar {
  display: flex;
  align-items: stretch;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #f0f0f0;
  background: #fff;
}
.catbot-input-bar input,
.catbot-input-bar textarea {
  flex: 1;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  padding: 12px 14px;
  font-size: 14px;
  color: #333;
  outline: none;
  resize: none;
  box-sizing: border-box;
  min-height: 48px;
  max-height: 89px;
  transition: border-color 0.15s, height 0.15;
}
.catbot-input-bar textarea {
  line-height: 1.5;
  overflow-y: hidden;
}
.catbot-input-bar textarea:disabled{
  background: #f8f8f8;
}
.catbot-input-bar input::placeholder,
.catbot-input-bar textarea::placeholder {
  color: #aaa;
}
.catbot-input-bar input:focus,
.catbot-input-bar textarea:focus {
  border-color: #3f75ff;
}
.catbot-send-btn {
  width: 48px;
  min-height: 48px;
  border-radius: 4px;
  border: none;
  background: #ddd;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  align-self: stretch;
  transition: background 0.15s;
  white-space: nowrap;
}
.catbot-send-btn.catbot-active {
  background: #3f75ff;
}

/* Tab bar */
.catbot-tabs {
  display: flex;
  border-top: 1px solid #f0f0f0;
  background: #fff;
}
.catbot-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 11px 0;
  border: none;
  background: none;
  cursor: pointer;
  color: #999;
  font-size: 16px;
  transition: color 0.15s;
  font-weight: 400;
}
.catbot-tab.catbot-active {
  color: #3f75ff;
  font-weight: 600;
}
.catbot-tab svg {
  width: 22px; height: 22px;
}
.catbot-tab-icon {
  width: 30px; height: 30px;
  padding-bottom: 4px;
  object-fit: contain;
  transition: filter 0.15s;
}
.catbot-tab.catbot-active .catbot-tab-icon {
  filter: brightness(0) saturate(100%) invert(42%) sepia(93%) saturate(1350%) hue-rotate(213deg) brightness(99%) contrast(99%);
}
.catbot-tab {
  position: relative;
}
.catbot-tab-badge {
  position: absolute;
  top: 5px;
  right: 50%;
  margin-right: -22px;
  min-width: 17px;
  height: 17px;
  border-radius: 50px;
  background: #FF4757;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}
.catbot-tab-badge.catbot-show { display: flex; }

/* Inquiry History */
.catbot-history-title {
  font-family: 'UNPEOPLE Gothic UNI', 'Pretendard', sans-serif;
  font-size: 24px;
  font-weight: 400;
  line-height: 34px;
  letter-spacing: -0.02em;
  color: #111;
  padding: 0 0 24px;
  border-bottom: 1px solid #000;
  margin-bottom: 0;
}
.catbot-history-item {
  padding: 24px 16px;
  border-bottom: 1px solid #eee;
  cursor: pointer;
}
.catbot-history-item:hover { background: #fafbfc; }
.catbot-history-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.catbot-history-unread{
  position: absolute;
  display: flex;
  min-width: 20px;
  height: 20px;
  border-radius: 50px;
  background: #FF4757;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  justify-content: center;
  align-items: center;
  right: 30px;
}
.catbot-status-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 2px;
  width: 60px;
  box-sizing: border-box;
  font-family: 'Pretendard', sans-serif;
  font-size: 12px;
  font-weight: 700;
  line-height: 18px;
  letter-spacing: -4%;
  text-align: center;
}
.catbot-status-badge.catbot-badge-open {
  background: transparent;
  color: #3f75ff;
  border: 1.5px solid #3f75ff;
}
.catbot-status-badge.catbot-badge-closed {
  background: #3f75ff;
  color: #fff;
  border: 1.5px solid #3f75ff;
}
.catbot-history-type {
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
  letter-spacing: -0.02em;
  color: #000;
}
.catbot-history-preview {
  font-size: 14px;
  color: #666;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 10px;
}
.catbot-history-date {
  font-size: 14px;
  color: #666;
  font-weight: 400;
}

/* Timestamp in chat */
.catbot-time {
  font-size: 11px;
  color: #bbb;
  margin-top: 4px;
}
.catbot-msg-bot .catbot-time { text-align: left; }
.catbot-msg-user .catbot-time { text-align: right; }
.catbot-status-indicator {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid #f5c2c2;
  background: #fff3f3;
  color: #d63d3d;
  font-size: 13px;
  line-height: 1.4;
  margin-bottom: 12px;
  max-width: 90%;
}

/* Loading */
.catbot-loading {
  text-align: center;
  padding: 20px;
  color: #999;
  font-size: 13px;
}
.catbot-spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid #ddd;
  border-top-color: #3f75ff;
  border-radius: 50%;
  animation: catbot-spin 0.8s linear infinite;
}
@keyframes catbot-spin {
  to { transform: rotate(360deg); }
}

/* Bubble pop-in animation */
@keyframes catbot-pop-in {
  0% {
    opacity: 0;
    transform: scale(0.85) translateY(8px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Responsive - mobile full screen */
@media (max-width: 768px) {
  .catbot-overlay {
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    bottom: 0;
    right: 0;
    border-radius: 0;
    transform-origin: bottom right;
  }
  .catbot-overlay.catbot-open {
    transform: scale(1) translateY(0);
  }
  .catbot-search-box{
    margin-right: 18px;
  }
  .info_search{
    margin-right: 0;
  }
  .catbot-fab {
    bottom: 16px;
    right: 16px;
  }
  .catbot-action-btn{
    height: 40px;
  }
  .catbot-bubble {
    padding: 10px;
    max-width: 230px;
  }
  .catbot-bubble.catbot-bubble-actions {
    min-width: 60%;
    width: 60%;
    max-width: 60%;
  }
  .catbot-select-item {
    padding: 11px 14px;
  }
  .catbot-input-bar{
    padding: 16px 24px;
  }
  .catbot-input-bar textarea{
    min-height: 40px;
    max-height: 81px;
    padding: 8px 12px;
  }
  .catbot-send-btn{
    width: 40px;
    min-height: 40px;
  }
  .catbot-select-card {
    max-width: 90%;
  }
  .catbot-data-item-info .catbot-di-title{
    white-space: nowrap;
  }
  .catbot-data-item-info .catbot-di-meta{
    font-size: 12px;
    line-height: 18px;
  }
  .catbot-ref-card {
    gap: 8px;
    padding: 12px;
    max-width: 80%;
  }
  .catbot-ref-card-info .catbot-ref-sub{
    overflow-x: hidden;
    text-overflow: ellipsis;
  }
  .catbot-ref-card-info .catbot-ref-title{
    white-space: nowrap;
    padding: 0;
  }
  .catbot-ref-card-info .catbot-ref-meta{
    font-size: 12px;
    color: #666;
    line-height: 18px;
  }
  .cr_000{color: #000 !important;}
  .cr_666{color: #666 !important;}
  /* 입금대기, 결제완료 */
  .catbot-ref-meta.delivery{color: #000;}
  /* 배송완료, 구매확정 */
  .catbot-ref-meta.cr_blue{color: #3F75FF;}
  /* 지연 */
  .catbot-ref-meta.cr_orange{color: #FF6333;}
  /* 상품준비중, 배송준비중, 배송중 */
  .catbot-ref-meta.cr_green{color: #26A90C;}
  .catbot-tab {
    font-size: 12px;
  }
  .catbot-history-title {
    padding-bottom: 16px;
  }
  .catbot-tab.catbot-active{
    font-weight: 400;
  }
  .catbot-tab-icon {
    width: 24px;
    height: 24px;
    padding-bottom: 2px;
  }
  .catbot-delivery-badge{
    font-size: 14px;
  }
  .catbot-ref-meta.delivery{
    font-size: 14px;
  }
}
