/**
 * GilGamez Extension (`mod_toast`) — Configurable Toast Notification Stylesheet
 * Enforces Rule #1 (Technology Separation), Rule #6 (5-Tier Responsive), Rule #8 (Toast Module), Rule #13 (Extension Isolation).
 */

:root {
    --toast-z-index: 999999;
    --toast-width: 380px;
    --toast-bg: rgba(15, 17, 23, 0.95);
    --toast-border: rgba(255, 255, 255, 0.12);
    --toast-text: #f8fafc;
    --toast-text-muted: #94a3b8;
    --toast-shadow: 0 16px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
    
    /* Type Colors */
    --toast-success-bg: rgba(52, 211, 153, 0.12);
    --toast-success-border: rgba(52, 211, 153, 0.4);
    --toast-success-color: #34d399;
    
    --toast-error-bg: rgba(248, 113, 113, 0.12);
    --toast-error-border: rgba(248, 113, 113, 0.4);
    --toast-error-color: #f87171;
    
    --toast-warning-bg: rgba(251, 191, 36, 0.12);
    --toast-warning-border: rgba(251, 191, 36, 0.4);
    --toast-warning-color: #fbbf24;
    
    --toast-info-bg: rgba(99, 102, 241, 0.12);
    --toast-info-border: rgba(99, 102, 241, 0.4);
    --toast-info-color: #818cf8;
}

/* ── Positional Containers ── */
#toast-container {
    position: fixed;
    z-index: var(--toast-z-index);
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: var(--toast-width);
    width: calc(100vw - 48px);
    pointer-events: none;
    transition: all 0.25s ease;
}

/* Position: Top Right (Default) */
#toast-container.toast-pos-top-right {
    top: 24px;
    right: 24px;
    bottom: auto;
    left: auto;
    align-items: flex-end;
}

/* Position: Top Left */
#toast-container.toast-pos-top-left {
    top: 24px;
    left: 24px;
    bottom: auto;
    right: auto;
    align-items: flex-start;
}

/* Position: Top Center */
#toast-container.toast-pos-top-center {
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    bottom: auto;
    right: auto;
    align-items: center;
}

/* Position: Bottom Right */
#toast-container.toast-pos-bottom-right {
    bottom: 24px;
    right: 24px;
    top: auto;
    left: auto;
    align-items: flex-end;
    flex-direction: column-reverse;
}

/* Position: Bottom Left */
#toast-container.toast-pos-bottom-left {
    bottom: 24px;
    left: 24px;
    top: auto;
    right: auto;
    align-items: flex-start;
    flex-direction: column-reverse;
}

/* Position: Bottom Center */
#toast-container.toast-pos-bottom-center {
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    top: auto;
    right: auto;
    align-items: center;
    flex-direction: column-reverse;
}

/* ── Toast Card ── */
.toast-card {
    position: relative;
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 18px;
    border-radius: 12px;
    background: var(--toast-bg);
    border: 1px solid var(--toast-border);
    color: var(--toast-text);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 13.5px;
    line-height: 1.5;
    box-shadow: var(--toast-shadow);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    overflow: hidden;
    max-width: 100%;
    box-sizing: border-box;
    will-change: transform, opacity;
}

/* ── Themes ── */
/* Theme: Dark (Default) */
.toast-theme-dark .toast-card {
    background: rgba(15, 17, 23, 0.96);
    border-color: rgba(255, 255, 255, 0.12);
    color: #f8fafc;
}

/* Theme: Glass */
.toast-theme-glass .toast-card {
    background: rgba(18, 20, 32, 0.65);
    border-color: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

/* Theme: Light */
.toast-theme-light .toast-card {
    background: rgba(255, 255, 255, 0.96);
    border-color: rgba(0, 0, 0, 0.1);
    color: #0f172a;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.15);
}
.toast-theme-light .toast-title {
    color: #0f172a;
}
.toast-theme-light .toast-message {
    color: #475569;
}
.toast-theme-light .toast-close-btn {
    color: #64748b;
}

/* Theme: Accent */
.toast-theme-accent .toast-card {
    background: rgba(20, 24, 38, 0.95);
    border-color: var(--primary-color, #6366f1);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5), 0 0 20px rgba(99, 102, 241, 0.2);
}

/* ── Animations ── */
/* Animation: Slide (Default) */
.toast-anim-slide .toast-card {
    transform: translateX(120%);
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.35s ease, margin 0.25s ease;
}
.toast-pos-top-left.toast-anim-slide .toast-card,
.toast-pos-bottom-left.toast-anim-slide .toast-card {
    transform: translateX(-120%);
}
.toast-pos-top-center.toast-anim-slide .toast-card {
    transform: translateY(-120%);
}
.toast-pos-bottom-center.toast-anim-slide .toast-card {
    transform: translateY(120%);
}

.toast-anim-slide .toast-card.is-visible {
    transform: translate(0, 0);
    opacity: 1;
}

.toast-anim-slide .toast-card.is-dismissing {
    transform: translateX(120%);
    opacity: 0;
}
.toast-pos-top-left.toast-anim-slide .toast-card.is-dismissing,
.toast-pos-bottom-left.toast-anim-slide .toast-card.is-dismissing {
    transform: translateX(-120%);
}
.toast-pos-top-center.toast-anim-slide .toast-card.is-dismissing {
    transform: translateY(-120%);
}
.toast-pos-bottom-center.toast-anim-slide .toast-card.is-dismissing {
    transform: translateY(120%);
}

/* Animation: Fade */
.toast-anim-fade .toast-card {
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.toast-anim-fade .toast-card.is-visible {
    opacity: 1;
}
.toast-anim-fade .toast-card.is-dismissing {
    opacity: 0;
}

/* Animation: Pop / Scale */
.toast-anim-pop .toast-card {
    transform: scale(0.7);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
}
.toast-anim-pop .toast-card.is-visible {
    transform: scale(1);
    opacity: 1;
}
.toast-anim-pop .toast-card.is-dismissing {
    transform: scale(0.8);
    opacity: 0;
}

/* Animation: Bounce */
.toast-anim-bounce .toast-card {
    transform: scale(0.3) translateY(20px);
    opacity: 0;
    transition: transform 0.45s cubic-bezier(0.68, -0.55, 0.265, 1.55), opacity 0.3s ease;
}
.toast-anim-bounce .toast-card.is-visible {
    transform: scale(1) translateY(0);
    opacity: 1;
}
.toast-anim-bounce .toast-card.is-dismissing {
    transform: scale(0.5) translateY(-20px);
    opacity: 0;
}

/* ── Type Variants ── */
.toast-card.toast-success {
    border-color: var(--toast-success-border);
}
.toast-card.toast-error {
    border-color: var(--toast-error-border);
}
.toast-card.toast-warning {
    border-color: var(--toast-warning-border);
}
.toast-card.toast-info {
    border-color: var(--toast-info-border);
}

/* ── Icon Badge ── */
.toast-icon-badge {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
    margin-top: 1px;
}

.toast-success .toast-icon-badge {
    background: var(--toast-success-bg);
    color: var(--toast-success-color);
    border: 1px solid var(--toast-success-border);
}

.toast-error .toast-icon-badge {
    background: var(--toast-error-bg);
    color: var(--toast-error-color);
    border: 1px solid var(--toast-error-border);
}

.toast-warning .toast-icon-badge {
    background: var(--toast-warning-bg);
    color: var(--toast-warning-color);
    border: 1px solid var(--toast-warning-border);
}

.toast-info .toast-icon-badge {
    background: var(--toast-info-bg);
    color: var(--toast-info-color);
    border: 1px solid var(--toast-info-border);
}

/* ── Content Wrap ── */
.toast-content-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.toast-title {
    font-weight: 600;
    font-size: 13.5px;
    color: #ffffff;
    letter-spacing: -0.01em;
}

.toast-message {
    color: var(--toast-text-muted);
    font-size: 13px;
    word-break: break-word;
}

/* ── Close Button ── */
.toast-close-btn {
    background: none;
    border: none;
    color: #64748b;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    margin-top: -2px;
    margin-right: -4px;
    transition: color 0.15s ease;
    flex-shrink: 0;
}

.toast-close-btn:hover {
    color: #f1f5f9;
}

/* ── Progress Bar ── */
.toast-progress-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3.5px;
    transform-origin: left center;
    transform: scaleX(1);
    z-index: 10;
    pointer-events: none;
    border-radius: 0 0 12px 12px;
}

.toast-success .toast-progress-bar {
    background: var(--toast-success-color, #34d399);
    box-shadow: 0 0 8px rgba(52, 211, 153, 0.6);
}
.toast-error .toast-progress-bar {
    background: var(--toast-error-color, #f87171);
    box-shadow: 0 0 8px rgba(248, 113, 113, 0.6);
}
.toast-warning .toast-progress-bar {
    background: var(--toast-warning-color, #fbbf24);
    box-shadow: 0 0 8px rgba(251, 191, 36, 0.6);
}
.toast-info .toast-progress-bar {
    background: var(--toast-info-color, #818cf8);
    box-shadow: 0 0 8px rgba(129, 140, 248, 0.6);
}

/* ── Mobile 5-Tier Responsive Tier (320px - 480px) ── */
@media (max-width: 480px) {
    #toast-container {
        width: calc(100vw - 24px);
        max-width: calc(100vw - 24px);
    }
    #toast-container.toast-pos-top-right,
    #toast-container.toast-pos-top-left,
    #toast-container.toast-pos-top-center {
        top: 12px;
        left: 12px;
        right: 12px;
        transform: none;
        align-items: stretch;
    }
    #toast-container.toast-pos-bottom-right,
    #toast-container.toast-pos-bottom-left,
    #toast-container.toast-pos-bottom-center {
        bottom: 12px;
        left: 12px;
        right: 12px;
        transform: none;
        align-items: stretch;
    }
    .toast-card {
        padding: 12px 14px;
        font-size: 13px;
        gap: 10px;
    }
}
