/* 화면 우측 하단의 일반 알림 컨테이너 */
.toast-container {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 13050;
    display: flex;
    flex-direction: column;
    gap: var(--new-theme-space-2);
    max-width: calc(100vw - 40px);
    pointer-events: auto;
}

/* 확인·입력·선택 알림을 화면 중앙에 표시하는 오버레이 */
.toast-container-center {
    inset: 0;
    align-items: center;
    justify-content: center;
    width: auto;
    height: auto;
    max-width: none;
    background: color-mix(in srgb, var(--color-overlay-default) 72%, transparent);
}

/* 일반 토스트 알림 골격 */
.toast {
    --toast-accent: var(--color-status-info-text);
    --toast-accent-bg: var(--color-status-info-bg);
    --toast-accent-border: var(--color-status-info-border);

    position: relative;
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr) 24px;
    align-items: start;
    gap: 10px;
    width: 100%;
    min-width: 360px;
    max-width: 460px;
    padding: 12px 12px 12px 14px;
    overflow: hidden;
    border: 1px solid var(--color-border-strong);
    border-left: 5px solid var(--toast-accent);
    border-radius: var(--new-theme-radius-sm);
    background: var(--color-bg-surface);
    box-shadow: var(--new-theme-shadow-lg);
    color: var(--color-text-primary);
    box-sizing: border-box;
    pointer-events: auto;
    opacity: 0;
    transform: translateY(4px);
    transition: border-color 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease;
    animation: new-toast-fade-in 0.2s ease-out forwards;
}

/* Bootstrap가 사용하는 show 클래스와 무관하게 공통 알림을 표시한다. */
.toast-container > .toast {
    display: grid;
}

/* 알림 종류별 의미 색상 */
.toast-info {
    --toast-accent: var(--color-status-info-text);
    --toast-accent-bg: var(--color-status-info-bg);
    --toast-accent-border: var(--color-status-info-border);
}

.toast-success {
    --toast-accent: var(--color-status-success-text);
    --toast-accent-bg: var(--color-status-success-bg);
    --toast-accent-border: var(--color-status-success-border);
}

.toast-warning {
    --toast-accent: var(--color-status-warning-text);
    --toast-accent-bg: var(--color-status-warning-bg);
    --toast-accent-border: color-mix(
        in srgb,
        var(--color-status-warning-text) 38%,
        var(--color-border-default)
    );
}

.toast-error {
    --toast-accent: var(--color-status-danger-text);
    --toast-accent-bg: var(--color-status-danger-bg);
    --toast-accent-border: var(--color-status-danger-border);
}

/* 일반 알림 아이콘과 본문 */
.toast-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border: 1px solid var(--toast-accent-border);
    border-radius: var(--new-theme-radius-sm);
    background: var(--toast-accent-bg);
    color: var(--toast-accent);
    font-size: 13px;
}

.toast-body {
    min-width: 0;
}

.toast-title {
    margin: 0 0 3px;
    color: var(--color-text-primary);
    font-size: 13px;
    font-weight: 700;
    line-height: 1.35;
}

.toast-message {
    margin: 0;
    color: var(--color-text-secondary);
    font-size: 14px;
    line-height: 1.55;
    white-space: pre-line;
    word-break: break-word;
}

.toast-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: var(--new-theme-radius-sm);
    background: transparent;
    color: var(--color-text-muted);
    font-size: 18px;
    cursor: pointer;
}

.toast-close:hover {
    border-color: var(--color-border-default);
    background: var(--color-bg-hover);
    color: var(--color-text-primary);
}

/* 자동 닫힘 시간을 보여주는 진행 표시 */
.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--toast-accent);
    animation: new-toast-progress linear forwards;
}

.toast-paused .toast-progress {
    animation-play-state: paused;
}

/* 중앙 확인·입력·선택 알림 골격 */
.toast-confirm,
.toast-prompt,
.toast-select {
    grid-template-columns: 40px minmax(0, 1fr);
    align-items: start;
    min-width: 420px;
    max-width: 520px;
    padding: 24px;
    border-left: 5px solid var(--toast-accent);
    border-radius: var(--new-theme-radius-md);
    column-gap: 14px;
    text-align: left;
    transform: translateY(6px);
    animation: new-toast-pop-in 0.2s ease-out forwards;
}

.toast-confirm .toast-body,
.toast-prompt .toast-body,
.toast-select .toast-body {
    display: flex;
    grid-column: 2;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    min-width: 0;
}

.toast-confirm .toast-icon,
.toast-prompt .toast-icon,
.toast-select .toast-icon {
    grid-row: 1;
    grid-column: 1;
    width: 38px;
    height: 38px;
    margin-top: 1px;
    font-size: 17px;
}

.toast-confirm .toast-title,
.toast-prompt .toast-title,
.toast-select .toast-title {
    margin: 0;
    font-size: 16px;
}

.toast-confirm .toast-message,
.toast-prompt .toast-message,
.toast-select .toast-message {
    margin-top: var(--new-theme-space-1);
    color: var(--color-text-secondary);
    font-size: 14px;
}

/* 확인·입력·선택 알림의 액션 버튼 */
.toast-actions {
    display: flex;
    gap: var(--new-theme-space-2);
    margin-top: var(--new-theme-space-2);
}

.toast-confirm .toast-actions,
.toast-prompt .toast-actions,
.toast-select .toast-actions {
    justify-content: flex-end;
    width: 100%;
    margin-top: var(--new-theme-space-6);
}

.toast-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: 0 10px;
    border: 1px solid transparent;
    border-radius: var(--new-theme-radius-sm);
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.toast-confirm .toast-action,
.toast-prompt .toast-action,
.toast-select .toast-action {
    flex: 0 0 auto;
    min-width: 78px;
    min-height: 36px;
    padding: 0 14px;
    font-size: 13px;
}

.toast-action-confirm {
    border-color: var(--color-accent-fill);
    background: var(--color-accent-fill);
    color: var(--color-accent-contrast);
    box-shadow: var(--new-theme-shadow-sm);
}

.toast-action-confirm:hover {
    border-color: var(--color-accent-fill-hover);
    background: var(--color-accent-fill-hover);
}

.toast-action-cancel {
    border-color: var(--color-border-strong);
    background: var(--color-bg-surface);
    color: var(--color-text-secondary);
}

.toast-action-cancel:hover {
    border-color: var(--color-text-muted);
    background: var(--color-bg-hover);
    color: var(--color-text-primary);
}

/* 문자열 입력 알림 */
.toast-input {
    width: 100%;
    min-height: 36px;
    margin-top: var(--new-theme-space-2);
    padding: 6px 8px;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--new-theme-radius-sm);
    background: var(--color-bg-surface);
    color: var(--color-text-primary);
    font: inherit;
    font-size: 12px;
    box-sizing: border-box;
}

.toast-prompt .toast-input {
    margin-top: var(--new-theme-space-4);
    padding: 9px 12px;
    font-size: 14px;
}

.toast-input:focus {
    outline: none;
    border-color: var(--color-accent-fill);
    box-shadow: 0 0 0 2px var(--color-focus-ring);
}

/* 여러 항목 중 하나를 고르는 선택 알림 */
.toast-select .toast-title {
    margin-bottom: var(--new-theme-space-2);
}

.toast-select .toast-message {
    margin-bottom: var(--new-theme-space-6);
}

.toast-select-options {
    display: flex;
    flex-direction: column;
    gap: var(--new-theme-space-2);
    width: 100%;
    text-align: left;
}

.toast-select-option {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--new-theme-space-1);
    padding: var(--new-theme-space-3);
    border: 1px solid var(--color-border-default);
    border-radius: var(--new-theme-radius-sm);
    background: var(--color-bg-surface);
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.toast-select-option:hover {
    border-color: var(--color-border-strong);
    background: var(--color-bg-surface-alt);
}

.toast-select-option:has(input:checked) {
    border-color: var(--color-accent-border-strong);
    background: var(--color-accent-surface);
    box-shadow: inset 3px 0 0 var(--color-accent-fill);
}

.toast-select-title {
    display: flex;
    align-items: center;
    gap: var(--new-theme-space-2);
}

.toast-select-option input[type="radio"] {
    width: auto;
    min-height: 0;
    margin: 0;
    accent-color: var(--color-accent-fill);
    cursor: pointer;
}

.toast-select-label {
    display: inline-flex;
    align-items: center;
    gap: var(--new-theme-space-2);
    color: var(--color-text-primary);
    font-size: 15px;
    font-weight: 600;
}

.toast-select-desc {
    display: block;
    padding-left: 24px;
    color: var(--color-text-muted);
    font-size: 13px;
}

/* 위험 항목 선택 표시 */
.toast-select-warning {
    border-color: var(--color-status-danger-border);
    background: var(--color-status-danger-bg);
}

.toast-select-warning:hover {
    border-color: var(--color-status-danger-text);
    background: color-mix(
        in srgb,
        var(--color-status-danger-bg) 84%,
        var(--color-status-danger-text)
    );
}

.toast-select-warning:has(input:checked) {
    border-color: var(--color-status-danger-text);
    background: var(--color-status-danger-bg);
    box-shadow: inset 3px 0 0 var(--color-status-danger-text);
}

.toast-select-warning .toast-select-label,
.toast-select-warning .toast-select-desc {
    color: var(--color-status-danger-text);
}

/* 클릭 가능한 결재 알림 토스트 */
.toast-approval-notification {
    cursor: pointer;
}

.toast-approval-notification:not(.toast-exit):hover,
.toast-approval-notification:not(.toast-exit):focus-visible {
    border-color: var(--color-accent-border-strong);
    background: var(--color-accent-surface);
    box-shadow: var(--new-theme-shadow-lg);
}

.toast-approval-notification:focus-visible {
    outline: 2px solid var(--color-accent-fill);
    outline-offset: 2px;
}

/* 토스트 종료 상태와 애니메이션 */
.toast-exit {
    animation: new-toast-fade-out 0.22s ease forwards;
}

.toast-container-center.fade-out {
    pointer-events: none;
    animation: new-toast-container-fade-out 0.2s ease forwards;
}

@keyframes new-toast-fade-in {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes new-toast-pop-in {
    0% {
        opacity: 0;
        transform: translateY(6px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes new-toast-progress {
    from { width: 100%; }
    to { width: 0; }
}

@keyframes new-toast-fade-out {
    to {
        opacity: 0;
        transform: translateY(8px);
    }
}

@keyframes new-toast-container-fade-out {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
        background: transparent;
    }
}

/* 모바일 알림 배치 */
@media (max-width: 520px) {
    .toast-container:not(.toast-container-center) {
        right: 12px;
        bottom: 12px;
        left: 12px;
        max-width: none;
    }

    .toast {
        min-width: 0;
        max-width: none;
    }

    .toast-confirm,
    .toast-prompt,
    .toast-select {
        grid-template-columns: 36px minmax(0, 1fr);
        min-width: 0;
        max-width: calc(100vw - 24px);
        padding: 20px;
        column-gap: 12px;
    }

    .toast-confirm .toast-icon,
    .toast-prompt .toast-icon,
    .toast-select .toast-icon {
        width: 34px;
        height: 34px;
        font-size: 15px;
    }

    .toast-confirm .toast-actions,
    .toast-prompt .toast-actions,
    .toast-select .toast-actions {
        flex-wrap: wrap;
    }

    .toast-confirm .toast-action,
    .toast-prompt .toast-action,
    .toast-select .toast-action {
        flex: 1 1 0;
        min-width: 0;
    }
}
