.taiwani-fc{
  position: fixed;
  bottom: var(--fc-b, 120px);
  z-index: 99999;
  width: var(--fc-size, 56px);
  height: var(--fc-size, 56px);
  pointer-events: none;
}
.taiwani-fc[data-side="left"]{ left: var(--fc-x, 16px); }
.taiwani-fc[data-side="right"]{ right: var(--fc-x, 16px); }

/* Stack is absolutely positioned above toggle so toggle NEVER moves */
.taiwani-fc__stack{
  position: absolute;
  left: 0;
  bottom: calc(var(--fc-size, 56px) + var(--fc-gap, 12px));
  display:flex;
  flex-direction: column;
  gap: var(--fc-gap, 12px);
  pointer-events: auto;
  transform-origin: bottom center;
  transition: transform .22s ease, opacity .22s ease;
}

.taiwani-fc__btn, .taiwani-fc__toggle{
  width: var(--fc-size, 56px);
  height: var(--fc-size, 56px);
  border-radius: var(--fc-radius, 999px);
  display:flex;
  align-items:center;
  justify-content:center;
  box-shadow: 0 12px 28px rgba(0,0,0,.18);
  text-decoration:none;
  border: none;
  cursor: pointer;
  overflow: hidden;
}

.taiwani-fc__btn{
  background: var(--fc-bg, #333333);
  position: relative;
}
.taiwani-fc__btn::after{
  content:"";
  position:absolute;
  inset:-30%;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,.30), rgba(255,255,255,0) 55%);
  pointer-events:none;
}

.taiwani-fc__icon{
  width: 100%;
  height: 100%;
  display:flex;
  align-items:center;
  justify-content:center;
}
.taiwani-fc__icon img{
  width: var(--btn-icon-size, 80%);
  height: var(--btn-icon-size, 80%);
  object-fit: contain;
  display:block;
  margin:auto;
}


.taiwani-fc__toggle{
  position: relative;
  z-index: 3;
  pointer-events: auto;
  background: var(--fc-toggle-open, rgba(255,255,255,.85));
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* collapsed state: use closed background */
.taiwani-fc.is-collapsed .taiwani-fc__toggle{
  background: var(--fc-toggle-closed, #6ccf93) !important;
}

.taiwani-fc__toggle-icon{
  position: absolute;
  inset: 0;
  z-index: 5;
  font-size: 28px;
  line-height: 1;
  font-weight: 800;
  color: rgba(0,0,0,.6);
  display:flex;
  align-items:center;
  justify-content:center;
}
.taiwani-fc__toggle-icon--chat{
  inset: auto;
  width: var(--fc-icon-size, 70%);
  height: var(--fc-icon-size, 70%);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: rgba(0,0,0,.55);
  display:none; /* show only when collapsed */
}
.taiwani-fc__toggle-icon--chat svg{
  width:100%;
  height:100%;
  display:block;
}

/* collapsed state: hide stack, swap icon to chat bubble */
.taiwani-fc.is-collapsed .taiwani-fc__stack{
  transform: scale(.86);
  opacity: 0;
  pointer-events: none;
}
.taiwani-fc.is-collapsed .taiwani-fc__toggle-icon--close{ display:none !important; }
.taiwani-fc.is-collapsed .taiwani-fc__toggle-icon--chat{ display:inline-flex !important; color:#fff !important; }

@media (max-width: 480px){
  .taiwani-fc{ bottom: calc(var(--fc-b, 120px) * .85); }
}


/* Cute contact bubble (shown only when collapsed) */
.taiwani-fc__bubble{
  visibility: hidden;
  z-index: 2;
  display:block;
  position:absolute;
  bottom: 50%;
  transform: translateY(50%) translateX(0) scale(.98);
  white-space:nowrap;
  padding: 10px 16px;
  border-radius: 16px;
  background:#fff;
  border: 1px solid rgba(0,0,0,.06);
  box-shadow: 0 14px 30px rgba(0,0,0,.18);
  font-size:14px;
  font-weight:700;
  color:#333;
  pointer-events:none;
  opacity:0;
  visibility: hidden;
  transition: opacity .22s ease, transform .22s ease;
}
.taiwani-fc[data-side="left"] .taiwani-fc__bubble{
  visibility: hidden;
  z-index: 2;
  display:block;
  left: calc(var(--fc-size,56px) + 14px);
}
.taiwani-fc[data-side="right"] .taiwani-fc__bubble{
  visibility: hidden;
  z-index: 2;
  display:block;
  right: calc(var(--fc-size,56px) + 14px);
}

/* rounded tail */
.taiwani-fc__bubble::after{
  content:"";
  position:absolute;
  width:12px;
  height:12px;
  background:#fff;
  border-left: 1px solid rgba(0,0,0,.06);
  border-bottom: 1px solid rgba(0,0,0,.06);
  top: 50%;
  transform: translateY(-50%) rotate(45deg);
  border-bottom-left-radius: 4px;
}
.taiwani-fc[data-side="left"] .taiwani-fc__bubble::after{
  left:-7px;
}
.taiwani-fc[data-side="right"] .taiwani-fc__bubble::after{
  right:-7px;
  transform: translateY(-50%) rotate(225deg);
}

.taiwani-fc.is-collapsed .taiwani-fc__bubble{
  visibility: hidden; opacity:1 !important; visibility:visible !important; }


.taiwani-fc__toggle-img{
  display:none;
  position: absolute;
  inset: auto;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 6;
  width: var(--fc-icon-size, 70%);
  height: var(--fc-icon-size, 70%);
  align-items:center;
  justify-content:center;
}
.taiwani-fc__toggle-img img{
  width:100%;
  height:100%;
  object-fit: contain;
  display:block;
}

/* If user uploaded toggle icons, show them and hide default glyphs */
.taiwani-fc.has-closed-toggle-icon.is-collapsed .taiwani-fc__toggle-img--closed{ display:flex !important; }
.taiwani-fc.has-closed-toggle-icon.is-collapsed .taiwani-fc__toggle-icon--chat{ display:none !important; }

.taiwani-fc.has-open-toggle-icon:not(.is-collapsed) .taiwani-fc__toggle-img--open{ display:flex !important; }
.taiwani-fc.has-open-toggle-icon:not(.is-collapsed) .taiwani-fc__toggle-icon--close{ display:none !important; }
