////
///
/// Toast Component Mixins
/// ===========================================================================
///
/// Toast notification mixins for displaying feedback messages.
///
/// @group Mixins.BodyMolecules.Feedback
/// @author Scape Agency
/// @link https://scape.style
/// @since 0.1.0 initial release
/// @access public
///
////

// ============================================================================
// Use
// ============================================================================

@use "../../../dev" as *;
@use "../../../variables" as *;
@use "../../head_layout" as *;
@use "../../soul_type" as *;

// ============================================================================
// Toast Mixins
// ============================================================================

/// Base toast styling
/// @group Toast
@mixin toast--base {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: q(400);
    padding: q(12) q(16);
    background-color: var(--color_fill_secondary);
    color: var(--color_text_primary);
    border-radius: q(4);
    box-shadow:
        0 q(4) q(12) rgba(0, 0, 0, 0.15),
        0 q(1) q(4) rgba(0, 0, 0, 0.1);
    pointer-events: auto;

    &.showing {
        opacity: 0;
    }

    &:not(.show) {
        display: none;
    }
}

/// Toast container positioning (absolute)
/// @group Toast
@mixin toast--container {
    position: absolute;
    z-index: 10000;
    width: max-content;
    max-width: 100%;
    pointer-events: none;

    > :not(:last-child) {
        margin-bottom: q(8);
    }
}

/// Toast container with fixed positioning
/// @group Toast
@mixin toast--fixed-container {
    display: block;
    position: fixed;
    z-index: 10000;
    top: q(16);
    right: q(16);
    max-width: calc(100% - q(32));
}

/// Toast header styling
/// @group Toast
@mixin toast--header {
    display: flex;
    align-items: center;
    padding: q(8) q(12);
    border-bottom: q(1) solid var(--color_line_primary);
    font-weight: 600;
}

/// Toast body styling
/// @group Toast
@mixin toast--body {
    padding: q(12);
    word-wrap: break-word;
    flex: 1;
}

/// Toast action button styling
/// @group Toast
@mixin toast--action {
    font-weight: 500;
    margin-left: q(16);
    cursor: pointer;
    text-decoration: underline;
}

/// Toast close button styling
/// @group Toast
@mixin toast--close {
    margin-left: q(12);
    cursor: pointer;
    opacity: 0.7;

    &:hover {
        opacity: 1;
    }
}

// ============================================================================
// Toast Variant Mixins
// ============================================================================

/// Info toast variant
/// @group Toast
@mixin toast--info {
    background-color: var(--color_log_info);
    color: var(--color_fill_primary);
}

/// Success toast variant
/// @group Toast
@mixin toast--success {
    background-color: var(--color_log_success);
    color: var(--color_fill_primary);
}

/// Warning toast variant
/// @group Toast
@mixin toast--warning {
    background-color: var(--color_log_warning);
    color: var(--color_fill_primary);
}

/// Error toast variant
/// @group Toast
@mixin toast--error {
    background-color: var(--color_log_error);
    color: var(--color_fill_primary);
}

/// Rounded toast variant
/// @group Toast
@mixin toast--rounded {
    border-radius: q(24);
}
// ============================================================================
// Bootstrap-style Toast Enhancements
// ============================================================================

/// Toast stacking container with placement options
/// @group Toast
@mixin toast--container-placement($position: "top-end") {
    position: fixed;
    z-index: 10000;
    width: max-content;
    max-width: 100%;
    pointer-events: none;

    @if $position == "top-start" {
        top: q(16);
        left: q(16);
    } @else if $position == "top-center" {
        top: q(16);
        left: 50%;
        transform: translateX(-50%);
    } @else if $position == "top-end" {
        top: q(16);
        right: q(16);
    } @else if $position == "middle-start" {
        top: 50%;
        left: q(16);
        transform: translateY(-50%);
    } @else if $position == "middle-center" {
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
    } @else if $position == "middle-end" {
        top: 50%;
        right: q(16);
        transform: translateY(-50%);
    } @else if $position == "bottom-start" {
        bottom: q(16);
        left: q(16);
    } @else if $position == "bottom-center" {
        bottom: q(16);
        left: 50%;
        transform: translateX(-50%);
    } @else if $position == "bottom-end" {
        bottom: q(16);
        right: q(16);
    }

    > :not(:last-child) {
        margin-bottom: q(12);
    }
}

/// Toast container top-start placement
/// @group Toast
@mixin toast_container--top-start {
    @include toast--container-placement("top-start");
}

/// Toast container top-center placement
/// @group Toast
@mixin toast_container--top-center {
    @include toast--container-placement("top-center");
}

/// Toast container top-end placement
/// @group Toast
@mixin toast_container--top-end {
    @include toast--container-placement("top-end");
}

/// Toast container middle-start placement
/// @group Toast
@mixin toast_container--middle-start {
    @include toast--container-placement("middle-start");
}

/// Toast container middle-center placement
/// @group Toast
@mixin toast_container--middle-center {
    @include toast--container-placement("middle-center");
}

/// Toast container middle-end placement
/// @group Toast
@mixin toast_container--middle-end {
    @include toast--container-placement("middle-end");
}

/// Toast container bottom-start placement
/// @group Toast
@mixin toast_container--bottom-start {
    @include toast--container-placement("bottom-start");
}

/// Toast container bottom-center placement
/// @group Toast
@mixin toast_container--bottom-center {
    @include toast--container-placement("bottom-center");
}

/// Toast container bottom-end placement
/// @group Toast
@mixin toast_container--bottom-end {
    @include toast--container-placement("bottom-end");
}

/// Toast with icon
/// @group Toast
@mixin toast--with-icon {
    .toast_icon {
        display: flex;
        align-items: center;
        justify-content: center;
        width: q(24);
        height: q(24);
        margin-right: q(12);
        flex-shrink: 0;
    }
}

/// Translucent/semi-transparent toast
/// @group Toast
@mixin toast--translucent {
    background-color: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/// Dark toast
/// @group Toast
@mixin toast--dark {
    background-color: var(--color_fill_04);
    color: var(--color_fill_01);

    .toast_header {
        background-color: rgba(0, 0, 0, 0.2);
        border-color: rgba(255, 255, 255, 0.1);
        color: var(--color_fill_01);
    }
}

/// Toast animation - fade in
/// @group Toast
@mixin toast--fade {
    opacity: 0;
    transition: opacity 0.15s linear;

    &.show {
        opacity: 1;
    }
}

/// Toast animation - slide in from right
/// @group Toast
@mixin toast--slide-right {
    transform: translateX(100%);
    transition: transform 0.3s ease-out;

    &.show {
        transform: translateX(0);
    }
}

/// Toast animation - slide in from top
/// @group Toast
@mixin toast--slide-top {
    transform: translateY(-100%);
    transition: transform 0.3s ease-out;

    &.show {
        transform: translateY(0);
    }
}

/// Toast autohide timer indicator
/// @group Toast
@mixin toast--timer-indicator {
    position: relative;
    overflow: hidden;

    &::after {
        content: "";
        position: absolute;
        bottom: 0;
        left: 0;
        height: q(3);
        background-color: currentColor;
        opacity: 0.3;
        width: 100%;
        animation: toast-timer var(--toast-autohide-delay, 5s) linear forwards;
    }
}

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