/* ===== Sugaro Native App Experience ===== */
/* 仿生 APP 設計系統 */

/* ===== 1. 頁面轉場動畫 ===== */
@keyframes pageSlideIn {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pageFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.page-transition {
    animation: pageSlideIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 主要內容區域自動套用 */
.container, .history-container, .profile-container, .chat-container {
    animation: pageFadeIn 0.3s ease-out;
}

/* ===== 2. 骨架屏載入效果 ===== */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeletonShimmer 1.5s infinite;
    border-radius: 8px;
}

@keyframes skeletonShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-circle {
    border-radius: 50%;
}

.skeleton-text {
    height: 14px;
    margin-bottom: 8px;
}

.skeleton-text.short { width: 60%; }
.skeleton-text.medium { width: 80%; }
.skeleton-text.long { width: 100%; }

.skeleton-card {
    background: #fff;
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.06);
}

.skeleton-avatar {
    width: 60px;
    height: 60px;
}

.skeleton-image {
    width: 100%;
    padding-top: 120%;
    position: relative;
}

/* ===== 3. 觸摸漣漪效果 ===== */
.ripple-effect {
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

.ripple-effect::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 75, 120, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: width 0.4s, height 0.4s, opacity 0.4s;
    pointer-events: none;
}

.ripple-effect:active::after {
    width: 200%;
    height: 200%;
    opacity: 0;
    transition: 0s;
}

/* 白色漣漪（用於深色背景按鈕）*/
.ripple-light::after {
    background: rgba(255, 255, 255, 0.4);
}

/* ===== 4. 下拉刷新 ===== */
.pull-to-refresh {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%) translateY(-100%);
    background: #fff;
    padding: 12px 24px;
    border-radius: 30px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 1060;
    transition: transform 0.3s, opacity 0.3s;
    opacity: 0;
}

.pull-to-refresh.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.pull-to-refresh .spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #f0f0f0;
    border-top-color: #ff4b78;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.pull-to-refresh span {
    color: #666;
    font-size: 0.85rem;
    font-weight: 500;
}

/* ===== 5. 圖片漸進載入 ===== */
.img-lazy {
    opacity: 0;
    filter: blur(10px);
    transition: opacity 0.5s ease, filter 0.5s ease;
}

.img-lazy.loaded {
    opacity: 1;
    filter: blur(0);
}

.img-placeholder {
    background: linear-gradient(135deg, #f5f5f5 0%, #e8e8e8 100%);
    position: relative;
}

.img-placeholder::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    animation: imgShimmer 1.5s infinite;
}

@keyframes imgShimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ===== 6. 底部彈出選單 ===== */
.bottom-sheet-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0);
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.bottom-sheet-overlay.active {
    background: rgba(0, 0, 0, 0.5);
    opacity: 1;
    visibility: visible;
}

.bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-radius: 24px 24px 0 0;
    padding: 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
    z-index: 2001;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 80vh;
    overflow-y: auto;
}

.bottom-sheet.active {
    transform: translateY(0);
}

.bottom-sheet-handle {
    width: 40px;
    height: 4px;
    background: #ddd;
    border-radius: 2px;
    margin: 0 auto 20px;
}

.bottom-sheet-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 20px;
    text-align: center;
}

.bottom-sheet-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    border-radius: 12px;
    color: #333;
    text-decoration: none;
    transition: all 0.2s;
}

.bottom-sheet-item:hover {
    background: #f8f8f8;
}

.bottom-sheet-item i {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff0f3;
    color: #ff4b78;
    border-radius: 10px;
    font-size: 1rem;
}

.bottom-sheet-item span {
    font-weight: 500;
}

.bottom-sheet-item.danger {
    color: #dc3545;
}

.bottom-sheet-item.danger i {
    background: #ffebee;
    color: #dc3545;
}

/* ===== 7. Toast 通知 ===== */
.toast-container {
    position: fixed;
    top: 90px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: rgba(40, 40, 40, 0.95);
    backdrop-filter: blur(10px);
    color: #fff;
    padding: 14px 24px;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 10px;
    transform: translateY(-20px);
    opacity: 0;
    animation: toastIn 0.3s forwards, toastOut 0.3s 2.7s forwards;
    pointer-events: auto;
}

@keyframes toastIn {
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes toastOut {
    to {
        transform: translateY(-20px);
        opacity: 0;
    }
}

.toast.success { border-left: 4px solid #4ade80; }
.toast.error { border-left: 4px solid #ef4444; }
.toast.warning { border-left: 4px solid #fbbf24; }
.toast.info { border-left: 4px solid #3b82f6; }

.toast i {
    font-size: 1.1rem;
}

.toast.success i { color: #4ade80; }
.toast.error i { color: #ef4444; }
.toast.warning i { color: #fbbf24; }
.toast.info i { color: #3b82f6; }

/* ===== 8. 全局觸摸優化 ===== */
* {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

/* 滾動優化 */
html, body {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: none;
}

/* 禁止選取（更像 APP）*/
.no-select {
    user-select: none;
    -webkit-user-select: none;
}

/* 安全區域適配 */
.safe-area-top {
    padding-top: env(safe-area-inset-top);
}

.safe-area-bottom {
    padding-bottom: env(safe-area-inset-bottom);
}

/* ===== 9. 卡片按壓效果 ===== */
.card-pressable {
    transition: transform 0.15s, box-shadow 0.15s;
    cursor: pointer;
}

.card-pressable:active {
    transform: scale(0.98);
    box-shadow: 0 2px 10px rgba(0,0,0,0.08) !important;
}

/* ===== 10. 載入狀態按鈕 ===== */
.btn-loading {
    position: relative;
    pointer-events: none;
    color: transparent !important;
}

.btn-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ===== 11. 滑動刪除提示 ===== */
.swipe-hint {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 80px;
    background: linear-gradient(90deg, transparent, #ff4b78);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.2rem;
    opacity: 0;
    transition: opacity 0.2s;
}

/* ===== 12. 浮動操作按鈕 (FAB) ===== */
.fab {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #ff4b78, #ff758c);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.4rem;
    box-shadow: 0 8px 25px rgba(255, 75, 120, 0.45);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1030;
}

.fab:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 35px rgba(255, 75, 120, 0.55);
}

.fab:active {
    transform: scale(0.95);
}

/* ===== 13. 空狀態動畫 ===== */
.empty-animation {
    animation: emptyBounce 2s ease-in-out infinite;
}

@keyframes emptyBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* ===== 14. 數字跳動動畫 ===== */
.number-animate {
    display: inline-block;
    animation: numberPop 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes numberPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* ===== 15. 手勢提示 ===== */
.gesture-hint {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.7);
    color: #fff;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 1000;
}

.gesture-hint.show {
    opacity: 1;
}

.gesture-hint i {
    animation: swipeHint 1s ease-in-out infinite;
}

@keyframes swipeHint {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(10px); }
}
