/* ===== 阿腸浮動按鈕 前台樣式 ===== */

.achang-ft-root {
    font-size: 14px;
    line-height: 1;
    transition: opacity .3s ease, transform .3s ease;
}
.achang-ft-root.is-collapsed {
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
}

/* 角落按鈕容器 */
.achang-ft-col {
    display: flex;
    gap: .6em;
    align-items: flex-end;
    justify-content: flex-end;
}
.achang-ft-root[data-pos="bottom"] .achang-ft-col {
    align-items: center;
    justify-content: center;
}

/* 收合選單 */
.achang-ft-menu {
    position: absolute;
    bottom: calc(100% + .6em);
    right: 0;
    display: flex;
    flex-direction: column;
    gap: .6em;
    opacity: 0;
    visibility: hidden;
    transform: translateY(14px) scale(.88);
    transform-origin: bottom right;
    pointer-events: none;
    transition: opacity .25s cubic-bezier(.4, 0, .2, 1), transform .25s cubic-bezier(.4, 0, .2, 1), visibility .25s;
}
.achang-ft-root.is-menu-open .achang-ft-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
    transition: opacity .3s cubic-bezier(.16, 1, .3, 1), transform .3s cubic-bezier(.16, 1, .3, 1), visibility .3s;
}
/* 靠左版位適配 */
.achang-ft-root[data-pos="left"] .achang-ft-menu {
    right: auto;
    left: 0;
    transform-origin: bottom left;
}
.achang-ft-root[data-pos="left"] .achang-ft-launcher__label { right: auto; left: calc(100% + 10px); }
.achang-ft-root[data-pos="left"] .achang-ft-col { align-items: flex-start; }

/* 底部置中版位適配 */
.achang-ft-root[data-pos="bottom"] .achang-ft-menu {
    right: auto;
    left: 50%;
    transform: translate(-50%, 14px) scale(.88);
    transform-origin: bottom center;
}
.achang-ft-root[data-pos="bottom"].is-menu-open .achang-ft-menu {
    transform: translate(-50%, 0) scale(1);
}

.achang-ft-launcher {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    margin-top: 0;
    border: 0;
    border-radius: 50%;
    background: #044463;
    color: #fff;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,.25);
    z-index: 2;
}
/* launcher 圖示大小直接鎖定 26px（52px 按鈕之 50%），避免 SVG 百分比在 button 內循環塌陷。 */
.achang-ft-launcher svg,
.achang-ft-launcher img {
    width: 26px !important;
    height: 26px !important;
    max-width: 52% !important;
    max-height: 52% !important;
    object-fit: contain;
    display: block;
    margin: auto;
    transition: transform .35s ease;
}
.achang-ft-launcher:hover svg,
.achang-ft-launcher:hover img { transform: rotate(360deg); }
/* launcher__open / __close 設為絕對定位貼滿按鈕，杜絕 button 內部 inline shrinkwrap 塌陷 */
.achang-ft-launcher__open,
.achang-ft-launcher__close {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    pointer-events: none;
}
.achang-ft-launcher__close { display: none; }
.achang-ft-root.is-menu-open .achang-ft-launcher__open { display: none; }
.achang-ft-root.is-menu-open .achang-ft-launcher__close { display: flex; }
.achang-ft-launcher__label {
    position: absolute;
    right: calc(100% + 10px);
    white-space: nowrap;
    color: #fff;
    background: rgba(20,30,40,.9);
    padding: 6px 9px;
    border-radius: 6px;
    font-size: 13px;
    transition: opacity .2s ease;
}
.achang-ft-root.is-menu-open .achang-ft-launcher__label { opacity: 0; }
.achang-ft-service-label {
    position: absolute;
    right: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    white-space: nowrap;
    padding: 5px 8px;
    border-radius: 5px;
    background: rgba(20,30,40,.9);
    color: #fff;
    font-size: 12px;
    pointer-events: none;
}
.achang-ft-root[data-pos="left"] .achang-ft-service-label { right: auto; left: calc(100% + 10px); }
@media (prefers-reduced-motion: reduce) {
    .achang-ft-menu, .achang-ft-fab, .achang-ft-launcher { transition: none; }
    .achang-ft-menu { transition: opacity .15s ease; }
    .achang-ft-root.is-menu-open .achang-ft-menu { overflow: visible; }
}

/* 觸控裝置停用把手 hover 滑出 */
@media (hover: none) {
    #achang_btn:hover,
    .achang-ft-fb-tab:hover,
    .achang-ft-side:hover .achang-ft-fb-tab {
        left: -48px;
    }
}

/* 單一浮動按鈕 */
.achang-ft-fab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    position: relative;
    border-radius: 50%;
    overflow: visible;
    text-decoration: none;
    cursor: pointer;
    transition: transform .2s ease, box-shadow .2s ease, filter .2s ease;
    will-change: transform;
}
.achang-ft-fab svg {
    width: 68% !important;
    height: 68% !important;
    display: block;
}
.achang-ft-fab img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
    display: block;
}
.achang-ft-fab:hover {
    transform: translateY(-2px) scale(1.08);
    filter: brightness(1.06);
}
.achang-ft-fab:active {
    transform: scale(.94);
}

/* tooltip */
.achang-ft-fab[data-tip] {
    position: relative;
}
.achang-ft-fab[data-tip]::after {
    content: attr(data-tip);
    position: absolute;
    right: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%) translateX(6px);
    background: rgba(20, 30, 40, .92);
    color: #fff;
    font-size: 13px;
    font-family: -apple-system, "Segoe UI", "Microsoft JhengHei", sans-serif;
    padding: 6px 10px;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s ease, transform .15s ease;
    z-index: 1;
}
.achang-ft-fab[data-tip]:hover::after {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

/* 當浮動按鈕在左側時，提示文字顯示在右側 */
.achang-ft-root[data-pos="left"] .achang-ft-fab[data-tip]::after,
#achang-ft-root[data-pos="left"] .achang-ft-fab[data-tip]::after {
    right: auto;
    left: calc(100% + 10px);
    transform: translateY(-50%) translateX(-6px);
}
.achang-ft-root[data-pos="left"] .achang-ft-fab[data-tip]:hover::after,
#achang-ft-root[data-pos="left"] .achang-ft-fab[data-tip]:hover::after {
    transform: translateY(-50%) translateX(0);
}

/* FB 側邊面板與阿腸側滑把手（層級低於浮動按鈕） */
.achang-ft-side {
    position: fixed;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    z-index: 99990;
}

#achang_iframe_outter,
.achang-ft-fb-panel {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 50%;
    right: 0;
    transform: translateY(-50%) translateX(calc(100% - 10px));
    width: 340px;
    max-width: calc(100vw - 20px);
    height: 620px;
    max-height: 86vh;
    padding-left: 10px;
    box-sizing: border-box;
    background: #3B5998;
    border-top-left-radius: 10px;
    border-bottom-left-radius: 10px;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.25);
    transition: transform .7s cubic-bezier(.22, 1, .36, 1);
    z-index: 99990;
    overflow: visible;
}

/* 長版本（傳統整個瀏覽器高度吃滿） */
.achang-ft-side.is-layout-full {
    top: 0 !important;
    bottom: 0 !important;
    height: 100vh !important;
    height: 100% !important;
    transform: none !important;
}

.achang-ft-side.is-layout-full #achang_iframe_outter,
.achang-ft-side.is-layout-full .achang-ft-fb-panel {
    top: 0 !important;
    bottom: 0 !important;
    height: 100vh !important;
    height: 100% !important;
    max-height: 100vh !important;
    transform: translateX(calc(100% - 10px));
    border-radius: 0 !important;
}

.achang-ft-side.is-open {
    z-index: 100010;
}

.achang-ft-side.is-open #achang_iframe_outter,
.achang-ft-side.is-open .achang-ft-fb-panel {
    transform: translateY(-50%) translateX(0);
    z-index: 100010;
}

.achang-ft-side.is-layout-full.is-open #achang_iframe_outter,
.achang-ft-side.is-layout-full.is-open .achang-ft-fb-panel {
    transform: translateX(0) !important;
    z-index: 100010;
}

.achang-ft-side.is-layout-full .achang-ft-fb-panel__body {
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.achang-ft-side.is-layout-full .achang-ft-fb-panel__body iframe {
    flex: 1 1 0;
    min-height: 0;
    width: 100% !important;
    height: 100% !important;
    display: block;
}

/* 上框背景色與標題關閉列 */
.achang-ft-fb-panel__head {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 12px 14px 12px 18px !important;
    box-sizing: border-box !important;
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.3px;
    flex-shrink: 0;
}
.achang-ft-fb-panel__head strong {
    font-weight: 600;
    color: #ffffff;
    margin: 0 !important;
    padding: 0 !important;
    display: inline-block !important;
    line-height: 1.2;
}

/* 中間內容主體 */
.achang-ft-fb-panel__body {
    flex: 1 1 auto;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
    overflow: hidden;
    background: #ffffff;
    display: flex;
}

/* 底下包覆色條 */
.achang-ft-fb-panel__foot {
    width: 100% !important;
    height: 10px;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
    flex-shrink: 0;
    border-bottom-left-radius: 10px;
}
.achang-ft-side.is-layout-full .achang-ft-fb-panel__foot {
    display: none;
}

#achang_btn,
.achang-ft-fb-tab {
    display: block;
    position: absolute;
    top: 45%;
    left: -48px;
    margin-top: -67px;
    width: 87px;
    height: 184px;
    border-top-left-radius: 10px;
    border-bottom-left-radius: 10px;
    border: 0px;
    font-size: 0px;
    padding: 0;
    background-size: contain;
    background-repeat: no-repeat;
    box-shadow: -3px 2px 12px rgba(0, 0, 0, .22); /* 由 .aft-no-shadow 覆蓋 */
    cursor: pointer;
    overflow: hidden;
    transition: left 0.7s cubic-bezier(.22, 1, .36, 1);
    z-index: 2;
}

.achang-ft-side.is-layout-full #achang_btn,
.achang-ft-side.is-layout-full .achang-ft-fb-tab {
    top: 50%;
    margin-top: -92px;
}

#achang_btn:hover,
.achang-ft-fb-tab:hover,
.achang-ft-side:hover .achang-ft-fb-tab {
    cursor: pointer;
    left: -87px;
}

.achang-ft-side.is-open #achang_btn,
.achang-ft-side.is-open .achang-ft-fb-tab {
    left: -87px;
}

#achang_btn img,
.achang-ft-fb-tab img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

#achang_btn svg,
.achang-ft-fb-tab svg {
    width: 38px;
    height: 38px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    fill: #ffffff;
}

.achang-ft-fb-panel iframe {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
    border-radius: 0;
}
.achang-ft-fb-close {
    width: 24px !important;
    height: 24px !important;
    min-width: 24px !important;
    max-width: 24px !important;
    min-height: 24px !important;
    max-height: 24px !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    border-radius: 50% !important;
    background: rgba(255, 255, 255, .25);
    color: #fff;
    font-size: 16px;
    font-family: inherit;
    line-height: 1;
    cursor: pointer;
    display: flex !important;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-sizing: border-box !important;
    transition: background 0.15s ease;
}
.achang-ft-fb-close:hover {
    background: rgba(255, 255, 255, .4);
    color: #fff;
}

/* 裝置顯示控制（由後台 device 決定） */
.aft-dev-none { display: none !important; }
@media (max-width: 767px) {
    .aft-dev-desktop { display: none !important; }
}
@media (min-width: 768px) {
    .aft-dev-mobile { display: none !important; }
}

/* 小螢幕：FB 面板調整 */
@media (max-width: 480px) {
    #achang_iframe_outter,
    .achang-ft-fb-panel {
        width: calc(100vw - 30px);
    }
}

/* 全域陰影關閉（由後台 shadow=off 時 PHP 加上 .aft-no-shadow class） */
.aft-no-shadow .achang-ft-launcher,
.aft-no-shadow.achang-ft-launcher {
    box-shadow: none !important;
}
.aft-no-shadow .achang-ft-fb-tab,
.aft-no-shadow #achang_btn,
.achang-ft-side.aft-no-shadow .achang-ft-fb-tab,
.achang-ft-side.aft-no-shadow #achang_btn {
    box-shadow: none !important;
}
.aft-no-shadow .achang-ft-fb-panel,
.aft-no-shadow #achang_iframe_outter {
    box-shadow: none !important;
}
