/* ==========================================
   15. 提示通知膠囊與浮動操作按鈕 (Toasts & FAB)
   ========================================== */
/* 浮動新增按鈕（兼具提示通知膠囊功能，電腦版與手機版全面統一） */
.fab-actions {
    position: fixed;
    right: 30px;
    bottom: 30px;
    z-index: 1003;
    display: flex;
    align-items: center;
    gap: 10px;
}

.fab-secondary-actions {
    display: flex;
    align-items: center;
    border-radius: 32px;
    position: relative;
    transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.2s ease, visibility 0.25s;
}

@media (min-width: 769px) {
    .fab-actions {
        flex-direction: column;
        align-items: flex-end;
    }

    .fab-secondary-actions {
        flex-direction: column;
        position: fixed;
        right: 30px;
        top: calc(50% - 48px);
        translate: 0 -50%;
    }

    header {
        padding-bottom: 16px;
    }

    .main-header-left {
        gap: 24px;
    }

    #tag-tabs {
        margin-bottom: 32px;
    }
}

.fab-secondary-actions.overlaps-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: var(--popup-bg);
    box-shadow: var(--glass-shadow-soft);
    pointer-events: none;
}

.fab-secondary-actions .fab-action-btn {
    width: 64px;
    height: 48px;
    border-radius: 32px;
    position: relative;
}

.fab-action-btn svg {
    width: 28px;
    height: 28px;
}

body.selection-mode-active #header-sort-btn {
    visibility: hidden;
}

@media (min-width: 769px) and (max-width: 1000px) {
    .selection-bottom-bar.active {
        bottom: 104px;
    }
}

@media (max-width: 1000px) {
    body.selection-mode-active #content-container {
        padding-bottom: calc(192px + var(--chapter-extra-space, 0px)) !important;
    }
}

.fab-main-btn {
    width: 64px;
    height: 64px;
    border-radius: 32px;
    background: var(--primary);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(154, 135, 30, 0.5);
    transition: width 0.24s cubic-bezier(0.25, 1, 0.5, 1),
        border-radius 0.24s ease,
        transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275),
        box-shadow 0.3s ease,
        opacity 0.3s ease;
    position: relative;
    flex-shrink: 0;
    transform: scale(1) translateZ(0);
    -webkit-user-select: none;
    user-select: none;
    overflow: hidden;
    padding: 0;
    box-sizing: border-box;
    max-width: calc(100vw - 40px);
}

/* 加號圖標容器：幾何正方形鎖定，強制消除任何拉長變形 */
.fab-icon-wrapper {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1);
    transform-origin: center center;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important;
    min-height: 28px !important;
    aspect-ratio: 1 / 1 !important;
    pointer-events: none;
    will-change: transform, opacity;
    transition: none !important;
}

.fab-icon-wrapper svg {
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important;
    min-height: 28px !important;
    aspect-ratio: 1 / 1 !important;
    color: #FAF6EE;
    display: block;
    transform-origin: center center;
}

/* 按鈕內置通知文字容器 */
.fab-toast-text {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
    box-sizing: border-box;
    color: #FAF6EE;
    font-weight: 600;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 提示窗彈出：加號等比例彈簧放大再縮小消失動效 */
@keyframes fabIconZoomOut {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }

    35% {
        transform: translate(-50%, -50%) scale(1.32);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 0;
    }
}

/* 提示窗收起：加號等比例彈簧放大再縮回原大小動效 */
@keyframes fabIconZoomIn {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 0;
    }

    60% {
        transform: translate(-50%, -50%) scale(1.32);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

.fab-main-btn.icon-zoom-out .fab-icon-wrapper {
    animation: fabIconZoomOut 0.20s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.fab-main-btn.icon-zoom-in .fab-icon-wrapper {
    animation: fabIconZoomIn 0.30s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* 提示窗彈出時的形變變扁擠壓動畫（彈出受衝擊變扁、快速回彈成原樣，與收起擠壓相呼應） */
@keyframes fabSpringMorphExpand {
    0% {
        transform: scale(1, 1) translateZ(0);
    }

    30% {
        /* 彈出衝出受阻變扁：水平拉伸延伸、垂直受壓變扁（變扁形變） */
        transform: scale(1.08, 0.90) translateZ(0);
    }

    58% {
        /* 快速回彈：垂直拉伸回彈、水平微縮 */
        transform: scale(0.97, 1.05) translateZ(0);
    }

    78% {
        /* 次級微幅震盪平復 */
        transform: scale(1.01, 0.985) translateZ(0);
    }

    92% {
        transform: scale(0.998, 1.004) translateZ(0);
    }

    100% {
        /* 恢復原本比例 */
        transform: scale(1, 1) translateZ(0);
    }
}

/* 展開為提示通知膠囊狀態 */
.fab-main-btn.toast-mode {
    transform-origin: right center !important;
    transition: width 0.38s cubic-bezier(0.34, 1.42, 0.64, 1),
        border-radius 0.28s ease,
        box-shadow 0.3s ease;
    animation: fabSpringMorphExpand 0.44s cubic-bezier(0.25, 1, 0.5, 1) forwards !important;
}

.fab-main-btn.toast-mode .fab-icon-wrapper {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0);
}

.fab-main-btn.toast-mode .fab-toast-text {
    opacity: 1;
    pointer-events: auto;
}

/* 提示窗收起時的彈簧形變擠壓動畫（受兩側內收擠壓、柔和反彈、最後恢復正圓比例） */
@keyframes fabSpringMorphCollapse {
    0% {
        transform: scale(1, 1) translateZ(0);
    }

    25% {
        /* 兩側內收撞擊，水平受壓凹陷、垂直適度拉長（柔和自然的擠壓形變） */
        transform: scale(0.90, 1.10) translateZ(0);
    }

    50% {
        /* 彈性柔和回彈：適度回彈，去除過強的變形感 */
        transform: scale(1.05, 0.96) translateZ(0);
    }

    75% {
        /* 次級微幅震盪 */
        transform: scale(0.985, 1.012) translateZ(0);
    }

    90% {
        transform: scale(1.005, 0.998) translateZ(0);
    }

    100% {
        /* 徹底恢復原本正圓比例 */
        transform: scale(1, 1) translateZ(0);
    }
}

.fab-main-btn.fab-morph-squeeze {
    animation: fabSpringMorphCollapse 0.44s cubic-bezier(0.25, 1, 0.5, 1) forwards !important;
}

.fab-main-btn:active {
    transform: scale(0.92) translateZ(0) !important;
    box-shadow: 0 2px 8px rgba(154, 135, 30, 0.5) !important;
}

.settings-action-btn {
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    width: 54px;
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    transform: translateZ(0);
    transform-origin: center center;
    will-change: transform;
    transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), background 0.25s ease, color 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
    padding: 0;
    outline: none;
}

#settings-modal div:has(> .settings-action-btn) span {
    display: inline-block;
    transform: translateZ(0);
    transform-origin: center center;
    transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), color 0.25s ease;
    will-change: transform;
}

.avatar-status-dot {
    display: inline-block;
    border-radius: 50%;
    flex-shrink: 0;
    box-sizing: border-box;
    background-color: rgba(160, 160, 160, 0.65);
    transition: background-color 0.25s ease, opacity 0.2s ease, transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.avatar-status-dot.auth-status-disconnected {
    background-color: rgba(160, 160, 160, 0.65);
}

.avatar-status-dot.auth-status-expired {
    background-color: #ac4252;
}

.avatar-status-dot.auth-status-connected {
    background-color: var(--primary);
}

.avatar-name-dot {
    width: 10px;
    height: 10px;
    min-width: 10px;
    min-height: 10px;
}

.avatar-corner-dot {
    position: absolute;
    bottom: -1px;
    right: -1px;
    z-index: 4;
    width: 14px;
    height: 14px;
    min-width: 14px;
    min-height: 14px;
    border: 2px solid var(--sidebar-bg);
    pointer-events: none;
}

.time-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    width: 100%;
    text-align: right;
}

.status-text {
    font-size: 14px;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
    font-weight: 600;
    user-select: none;
    -webkit-user-select: none;
    text-align: right;
}

.status-text.mono {
    font-family: 'Share Tech Mono', monospace, Consolas, Courier;
    min-width: auto;
    color: var(--text);
    font-size: 14px;
    text-align: right;
}

