/* ================================================
   Toast 컴포넌트
   디자인 토큰: artisthub-base.css
   다크모드: body.theme-dark
   ================================================ */

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    max-width: 400px;
    width: 100%;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    position: relative;
    display: flex;
    align-items: flex-start;
    padding: 18px 20px;
    border-radius: var(--radius-xl);
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.04);
    box-shadow: var(--shadow-dropdown);
    font-family: 'Pretendard Variable', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    pointer-events: all;
    transform: translateX(calc(100% + 20px));
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1),
                opacity 0.3s ease,
                box-shadow var(--ease-default);
    cursor: pointer;
    overflow: hidden;
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast.hide {
    transform: translateX(calc(100% + 20px));
    opacity: 0;
}

/* 호버 효과 */
.toast:hover {
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.15);
}

.toast-content {
    display: flex;
    align-items: flex-start;
    flex: 1;
    min-width: 0;
}

.toast-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    margin-top: 2px;
}

.toast-text {
    flex: 1;
    min-width: 0;
    margin-left: 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.toast-title {
    color: var(--text-main);
    font-weight: 700;
    font-size: 14px;
    margin: 0;
    line-height: 1.4;
}

.toast-message {
    color: var(--text-sub);
    font-weight: 400;
    font-size: 13px;
    margin: 0;
    line-height: 1.5;
    white-space: pre-line;
}

.toast-close {
    flex-shrink: 0;
    margin-left: 4px;
    margin-top: -2px;
    padding: 0;
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    color: var(--text-desc);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all var(--ease-default);
    line-height: 1;
}

.toast-close:hover {
    background: var(--gray-100);
    color: var(--text-main);
}

/* ---- 프로그레스 바 ---- */
.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 1px;
    transition: width linear;
    z-index: 1;
    opacity: 0.45;
}

/* ================================================
   타입별 스타일 — 아이콘 배경 + 프로그레스 바 색상
   ================================================ */

/* Success */
.toast.success .toast-icon { color: #10b981; }
.toast.success .toast-progress { background: linear-gradient(90deg, #10b981, #34d399); }

/* Error */
.toast.error .toast-icon { color: #E85A5A; }
.toast.error .toast-progress { background: linear-gradient(90deg, #E85A5A, #f87171); }

/* Warning */
.toast.warning .toast-icon { color: #f59e0b; }
.toast.warning .toast-progress { background: linear-gradient(90deg, #f59e0b, #fbbf24); }

/* Info */
.toast.info .toast-icon { color: var(--ai-accent); }
.toast.info .toast-progress { background: linear-gradient(90deg, #3b82f6, #60a5fa); }

/* ================================================
   진입 애니메이션
   ================================================ */
@keyframes slide-in-right {
    from {
        transform: translateX(calc(100% + 20px));
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.show {
    animation: slide-in-right 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ================================================
   버블 토스트 — 채팅 알림 스타일
   ================================================ */
.toast-bubble-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast-bubble {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    min-width: 280px;
    max-width: 380px;
    padding: 16px 18px;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-dropdown);
    transform: translateY(16px) scale(0.97);
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1),
                opacity 0.25s ease;
    pointer-events: all;
    cursor: pointer;
}

.toast-bubble.show {
    transform: translateY(0) scale(1);
    opacity: 1;
}

/* ---- 아바타 ---- */
.toast-bubble__avatar-wrap {
    position: relative;
    flex-shrink: 0;
}

.toast-bubble__avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-xl);
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid var(--gray-200);
}

/* ---- 채팅 아이콘 (아바타 없을 때) ---- */
.toast-bubble__icon-wrap {
    position: relative;
    flex-shrink: 0;
}

.toast-bubble__icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-xl);
    background: var(--gray-50);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--ai-accent);
}

/* ---- 본문 ---- */
.toast-bubble__body {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
    min-width: 0;
}

.toast-bubble__title {
    font-weight: 700;
    font-size: 14px;
    color: var(--text-main);
    line-height: 1.4;
    margin: 0;
}

.toast-bubble__message {
    font-size: 13px;
    color: var(--text-sub);
    line-height: 1.5;
    margin: 0;
    white-space: pre-line;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.toast-bubble__meta {
    font-size: 11px;
    color: var(--text-desc);
    margin-top: 2px;
}

/* ---- 닫기 버튼 ---- */
.toast-bubble .toast-close {
    color: var(--text-desc);
    margin-top: -2px;
}

.toast-bubble .toast-close:hover {
    background: var(--gray-100);
    color: var(--text-main);
}

/* ---- 읽지 않음 도트 ---- */
.toast-bubble__dot {
    position: absolute;
    right: -2px;
    top: -2px;
    width: 10px;
    height: 10px;
    background: var(--ai-accent);
    border: 2px solid #ffffff;
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4);
    animation: toast-bubble-pulse 2s infinite;
}

.toast-bubble__dot--floating {
    position: absolute;
    right: 8px;
    top: 8px;
    width: 8px;
    height: 8px;
    background: var(--ai-accent);
    border: none;
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4);
    animation: toast-bubble-pulse 2s infinite;
}

@keyframes toast-bubble-pulse {
    0% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.35); }
    70% { box-shadow: 0 0 0 6px rgba(59, 130, 246, 0); }
    100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
}

/* ---- 버블 다크모드 ---- */
body.theme-dark .toast-bubble {
    background: var(--surface-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-default);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45),
                inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

body.theme-dark .toast-bubble:hover {
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55),
                inset 0 1px 0 rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.14);
}

body.theme-dark .toast-bubble__title {
    color: var(--text-main);
}

body.theme-dark .toast-bubble__message {
    color: var(--text-sub);
}

body.theme-dark .toast-bubble__meta {
    color: var(--text-desc);
}

body.theme-dark .toast-bubble__avatar {
    border-color: rgba(255, 255, 255, 0.12);
}

body.theme-dark .toast-bubble__icon {
    background: rgba(59, 130, 246, 0.12);
    color: #60a5fa;
}

body.theme-dark .toast-bubble__dot {
    border-color: var(--surface-0);
    background: #60a5fa;
    box-shadow: 0 0 0 0 rgba(96, 165, 250, 0.4);
}

body.theme-dark .toast-bubble__dot--floating {
    background: #60a5fa;
}

body.theme-dark .toast-bubble .toast-close {
    color: var(--text-desc);
}

body.theme-dark .toast-bubble .toast-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* ================================================
   퇴장 애니메이션
   ================================================ */
.toast-removing {
    pointer-events: none;
}

.toast-slide-out {
    transform: translateX(calc(100% + 20px)) !important;
    opacity: 0 !important;
    transition: transform 0.3s cubic-bezier(0.4, 0, 1, 1),
                opacity 0.25s ease-out !important;
}

/* ================================================
   반응형 — 모바일
   ================================================ */
@media (max-width: 768px) {
    .toast-container {
        top: 12px;
        right: 12px;
        left: 12px;
        max-width: none;
    }

    .toast {
        padding: 12px 14px;
        border-radius: var(--radius-lg);
    }

    .toast-icon {
        font-size: 16px;
    }

    .toast-bubble-container {
        bottom: 12px;
        right: 12px;
        left: 12px;
    }

    .toast-bubble {
        min-width: 0;
        max-width: none;
        padding: 14px 16px;
    }
}

/* ================================================
   다크모드 — body.theme-dark
   ================================================ */
body.theme-dark .toast {
    background: var(--surface-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-default);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45),
                inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

body.theme-dark .toast:hover {
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55),
                inset 0 1px 0 rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.14);
}

body.theme-dark .toast-title {
    color: var(--text-main);
}

body.theme-dark .toast-message {
    color: var(--text-sub);
}

body.theme-dark .toast-close {
    color: var(--text-desc);
}

body.theme-dark .toast-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

body.theme-dark .toast-progress { opacity: 0.6; }
body.theme-dark .toast.success .toast-progress { box-shadow: 0 0 6px rgba(52, 211, 153, 0.4); }
body.theme-dark .toast.error .toast-progress { box-shadow: 0 0 6px rgba(248, 113, 113, 0.4); }
body.theme-dark .toast.warning .toast-progress { box-shadow: 0 0 6px rgba(251, 191, 36, 0.4); }
body.theme-dark .toast.info .toast-progress { box-shadow: 0 0 6px rgba(96, 165, 250, 0.4); }

/* 다크모드 타입별 아이콘 — 밝은 톤 + 미세 글로우 */
body.theme-dark .toast.success .toast-icon {
    color: #34d399;
    text-shadow: 0 0 12px rgba(52, 211, 153, 0.4);
}

body.theme-dark .toast.error .toast-icon {
    color: #f87171;
    text-shadow: 0 0 12px rgba(248, 113, 113, 0.5);
}

body.theme-dark .toast.warning .toast-icon {
    color: #fbbf24;
    text-shadow: 0 0 12px rgba(251, 191, 36, 0.4);
}

body.theme-dark .toast.info .toast-icon {
    color: #60a5fa;
    text-shadow: 0 0 12px rgba(96, 165, 250, 0.5);
}

/* 모션 감소 설정 */
@media (prefers-reduced-motion: reduce) {
    .toast,
    .toast.show,
    .toast-slide-out {
        animation: none !important;
        transition-duration: 0.01ms !important;
    }
}
