/**
 * YS CHAT Widgets — 前端浮動按鈕樣式
 *
 * @since 1.0.0
 */

.ysch-wrap {
    position: fixed;
    bottom: var(--ysch-bottom, 30px);
    z-index: 99998;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans TC", sans-serif;
}

.ysch-pos-right { right: var(--ysch-side, 20px); }
.ysch-pos-left  { left: var(--ysch-side, 20px); align-items: flex-start; }

/* ── App 清單 ─────────────────────────────── */
.ysch-items {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: inherit;
    /* 收合狀態 */
    visibility: hidden;
    pointer-events: none;
}

.ysch-item-row {
    margin: 0;
    padding: 0;
    opacity: 0;
    transform: translateY(8px) scale(0.9);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.ysch-wrap.ysch-open .ysch-items {
    visibility: visible;
    pointer-events: auto;
}

.ysch-wrap.ysch-open .ysch-item-row {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* 展開時逐一浮出 */
.ysch-wrap.ysch-open .ysch-item-row:nth-child(1) { transition-delay: 0.02s; }
.ysch-wrap.ysch-open .ysch-item-row:nth-child(2) { transition-delay: 0.06s; }
.ysch-wrap.ysch-open .ysch-item-row:nth-child(3) { transition-delay: 0.10s; }
.ysch-wrap.ysch-open .ysch-item-row:nth-child(4) { transition-delay: 0.14s; }
.ysch-wrap.ysch-open .ysch-item-row:nth-child(5) { transition-delay: 0.18s; }
.ysch-wrap.ysch-open .ysch-item-row:nth-child(n+6) { transition-delay: 0.22s; }

/* ── 單一 App 按鈕 ────────────────────────── */
.ysch-item {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    flex-direction: row-reverse;
}

.ysch-pos-left .ysch-item { flex-direction: row; }

.ysch-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: var(--ysch-app-color, #8fa8b8);
    color: var(--ysch-app-fg, #ffffff);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.18);
    transition: transform 0.15s ease;
    flex: 0 0 auto;
}

.ysch-icon svg {
    width: 24px;
    height: 24px;
    display: block;
}

.ysch-item:hover .ysch-icon { transform: scale(1.08); }

.ysch-label {
    background: #ffffff;
    color: #2c3e50;
    font-size: 13px;
    line-height: 1;
    padding: 8px 12px;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    white-space: nowrap;
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── 主開關按鈕 ───────────────────────────── */
.ysch-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    background: var(--ysch-color, #8fa8b8);
    color: #ffffff;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

.ysch-toggle:hover {
    transform: scale(1.06);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.26);
}

.ysch-toggle:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

.ysch-toggle-open,
.ysch-toggle-close {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.ysch-toggle-open svg,
.ysch-toggle-close svg {
    width: 26px;
    height: 26px;
    display: block;
}

/* cover：圖佔滿整圓（適合本身就是完整圓形的圖） */
.ysch-toggle-img.ysch-icon-cover img {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

/* contain（預設）：保留按鈕底色，圖縮 60% 置中（適合去背 icon） */
.ysch-toggle-img.ysch-icon-contain img {
    width: 60%;
    height: 60%;
    object-fit: contain;
    display: block;
}

.ysch-toggle-close {
    opacity: 0;
    transform: rotate(-90deg) scale(0.6);
}

.ysch-wrap.ysch-open .ysch-toggle-open {
    opacity: 0;
    transform: rotate(90deg) scale(0.6);
}

.ysch-wrap.ysch-open .ysch-toggle-close {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* ── 手機微調 ─────────────────────────────── */
@media (max-width: 480px) {
    .ysch-toggle { width: 52px; height: 52px; }
    .ysch-toggle-img.ysch-icon-cover img { width: 52px; height: 52px; }
    .ysch-icon { width: 44px; height: 44px; }
    .ysch-label { font-size: 12px; max-width: 180px; }
}

/* QR 卡片（popup 模式）樣式自 v1.1.4 起全部由 JS inline 輸出 —
   錨定 widget 同側角落、不依賴本檔（避免 CDN 快取舊樣式跑版）。 */

/* ── 降低動態偏好 ─────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .ysch-item-row,
    .ysch-toggle,
    .ysch-toggle-open,
    .ysch-toggle-close,
    .ysch-icon {
        transition: none !important;
        animation: none !important;
    }
}
