/* ══════════════════════════════════════════════════════════════════════════
 *  TOASTR  ·  Enterprise SaaS Premium Redesign
 *  Design language : Glassmorphic surface · Colored icon pill
 *                    Spring entrance · Dark / Light aware
 *  Inspired by     : Linear · Raycast · Vercel · Framer · Stripe
 * ══════════════════════════════════════════════════════════════════════════ */

/* ── Design tokens (scoped — no global pollution) ───────────────────────── */
#toast-container {
    /* surface */
    --tk-bg       : #ffffff;
    --tk-border   : rgba(0, 0, 0, 0.08);
    --tk-shadow   :
        0 0 0 1px rgba(0, 0, 0, 0.04),
        0 2px  4px rgba(0, 0, 0, 0.04),
        0 8px 20px rgba(0, 0, 0, 0.08),
        0 24px 48px rgba(0, 0, 0, 0.10);
    /* text */
    --tk-title    : var(--text-primary,   #1a1a2e);
    --tk-msg      : var(--text-secondary, #9096B2);
    --tk-font     : var(--font, "Rubik", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif);
    /* geometry */
    --tk-radius   : 16px;
    --tk-width    : 380px;
    --tk-icon-sz  : 48px;
    --tk-icon-r   : 13px;
    --tk-prog-h   : 2.5px;
    /* palette — mirror project vars */
    --tk-success  : var(--green-color,  #058f00);
    --tk-error    : var(--red-color,    #dc3545);
    --tk-warning  : var(--orange-color, #fd7e14);
    --tk-info     : var(--blue-color,   #0d6efd);
}

/* ── Dark-mode surface swap ─────────────────────────────────────────────── */
[data-theme="dark"] #toast-container {
    --tk-bg     : #1a1a2e;
    --tk-border : rgba(255, 255, 255, 0.10);
    --tk-shadow :
        0 0 0 1px rgba(255, 255, 255, 0.05),
        0 2px  4px rgba(0, 0, 0, 0.30),
        0 8px 20px rgba(0, 0, 0, 0.45),
        0 24px 48px rgba(0, 0, 0, 0.55);
    --tk-title  : rgba(255, 255, 255, 0.96);
    --tk-msg    : rgba(255, 255, 255, 0.48);
}

/* ── Container ──────────────────────────────────────────────────────────── */
#toast-container {
    position: fixed;
    z-index: 999999;
    pointer-events: none;
}
#toast-container * {
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
}

/* ── Position helpers ───────────────────────────────────────────────────── */
.toast-top-right         { top: 20px; right: 20px; }
.toast-top-left          { top: 20px; left: 20px; }
.toast-bottom-right      { bottom: 20px; right: 20px; }
.toast-bottom-left       { bottom: 20px; left: 20px; }
.toast-top-center        { top: 20px; right: 0; width: 100%; }
.toast-bottom-center     { bottom: 20px; right: 0; width: 100%; }
.toast-top-full-width    { top: 0; right: 0; width: 100%; }
.toast-bottom-full-width { bottom: 0; right: 0; width: 100%; }

/* ── Base toast card ────────────────────────────────────────────────────── */
#toast-container > div {
    position: relative;
    pointer-events: auto;
    overflow: hidden;

    /* geometry */
    margin: 0 0 10px;
    padding: 15px 48px 17px 80px;
    min-height: 72px;
    width: var(--tk-width);
    border-radius: var(--tk-radius);

    /* surface — solid, no transparency */
    background: var(--tk-bg);
    background-image: none !important; /* kill default PNG icons */
    background-position: 0 0 !important;
    background-size: 0 !important;
    border: 1px solid var(--tk-border);
    box-shadow: var(--tk-shadow);

    /* type */
    color: var(--tk-title);
    font-family: var(--tk-font);
    font-size: 14px;
    line-height: 1.5;

    /* motion */
    -webkit-animation: tkSlideIn 0.42s cubic-bezier(0.34, 1.56, 0.64, 1) both;
    animation:         tkSlideIn 0.42s cubic-bezier(0.34, 1.56, 0.64, 1) both;
    -webkit-transition: box-shadow 0.22s ease, -webkit-transform 0.22s ease;
    transition:         box-shadow 0.22s ease, transform 0.22s ease;
}

/* hover lift */
#toast-container > :hover {
    -webkit-transform: translateY(-3px) scale(1.005);
    transform: translateY(-3px) scale(1.005);
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.05),
        0 4px  8px rgba(0, 0, 0, 0.07),
        0 16px 32px rgba(0, 0, 0, 0.14),
        0 40px 64px rgba(0, 0, 0, 0.12);
    cursor: pointer;
    opacity: 1;
}

[data-theme="dark"] #toast-container > :hover {
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.06),
        0 4px  8px rgba(0, 0, 0, 0.40),
        0 16px 32px rgba(0, 0, 0, 0.55),
        0 40px 64px rgba(0, 0, 0, 0.60);
}

/* center / full-width widths */
#toast-container.toast-top-center > div,
#toast-container.toast-bottom-center > div {
    width: 360px;
    margin: 0 auto 10px;
}
#toast-container.toast-top-full-width > div,
#toast-container.toast-bottom-full-width > div {
    width: 96%;
    margin: 0 auto 10px;
}

/* ── Icon pill  (position: absolute via ::before) ───────────────────────── */
#toast-container > div::before {
    content: '';
    position: absolute;
    left: 15px;
    top: 50%;
    -webkit-transform: translateY(-50%);
    transform: translateY(-50%);
    width: var(--tk-icon-sz);
    height: var(--tk-icon-sz);
    border-radius: var(--tk-icon-r);
    background-repeat: no-repeat;
    background-position: center;
    background-size: 26px 26px;
    /* background-color and background-image set per-type below */
    flex-shrink: 0;
}

/* ── Type: Success ──────────────────────────────────────────────────────── */
#toast-container > .toast-success {
    background-color: #edf7ed !important;
    border-color: rgba(5, 143, 0, 0.22);
    box-shadow:
        var(--tk-shadow),
        0 0 0 1px rgba(5, 143, 0, 0.06) inset;
}
#toast-container > .toast-success::before {
    background-color: rgba(5, 143, 0, 0.14);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M4 10.5l4.5 4.5L16 6' stroke='%23058f00' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* ── Type: Error ────────────────────────────────────────────────────────── */
#toast-container > .toast-error {
    background-color: #fdf3f4 !important;
    border-color: rgba(220, 53, 69, 0.22);
    box-shadow:
        var(--tk-shadow),
        0 0 0 1px rgba(220, 53, 69, 0.06) inset;
}
#toast-container > .toast-error::before {
    background-color: rgba(220, 53, 69, 0.14);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M5 5l10 10M15 5L5 15' stroke='%23dc3545' stroke-width='2.4' stroke-linecap='round'/%3E%3C/svg%3E");
}

/* ── Type: Warning ──────────────────────────────────────────────────────── */
#toast-container > .toast-warning {
    background-color: #fff5ec !important;
    border-color: rgba(253, 126, 20, 0.22);
    box-shadow:
        var(--tk-shadow),
        0 0 0 1px rgba(253, 126, 20, 0.06) inset;
}
#toast-container > .toast-warning::before {
    background-color: rgba(253, 126, 20, 0.14);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M10 7v5' stroke='%23fd7e14' stroke-width='2.4' stroke-linecap='round'/%3E%3Ccircle cx='10' cy='14.5' r='1.4' fill='%23fd7e14'/%3E%3C/svg%3E");
}

/* ── Type: Info ─────────────────────────────────────────────────────────── */
#toast-container > .toast-info {
    background-color: #f0f5ff !important;
    border-color: rgba(13, 110, 253, 0.22);
    box-shadow:
        var(--tk-shadow),
        0 0 0 1px rgba(13, 110, 253, 0.06) inset;
}
#toast-container > .toast-info::before {
    background-color: rgba(13, 110, 253, 0.14);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none'%3E%3Ccircle cx='10' cy='5.5' r='1.4' fill='%230d6efd'/%3E%3Cpath d='M10 9.5v6' stroke='%230d6efd' stroke-width='2.4' stroke-linecap='round'/%3E%3C/svg%3E");
}

/* ── Dark-mode: deeper tinted backgrounds ───────────────────────────────── */
[data-theme="dark"] #toast-container > .toast-success { background-color: #0d2b0d !important; }
[data-theme="dark"] #toast-container > .toast-error   { background-color: #2d0f11 !important; }
[data-theme="dark"] #toast-container > .toast-warning { background-color: #2b1a06 !important; }
[data-theme="dark"] #toast-container > .toast-info    { background-color: #071233 !important; }
[data-theme="dark"] #toast-container > .toast-success::before { background-color: rgba(5,   143,  0, 0.25); }
[data-theme="dark"] #toast-container > .toast-error::before   { background-color: rgba(220,  53, 69, 0.25); }
[data-theme="dark"] #toast-container > .toast-warning::before { background-color: rgba(253, 126, 20, 0.25); }
[data-theme="dark"] #toast-container > .toast-info::before    { background-color: rgba(13,  110,253, 0.25); }

/* ── Title ──────────────────────────────────────────────────────────────── */
.toast-title {
    font-weight: 600;
    font-size: 13.5px;
    letter-spacing: -0.01em;
    color: var(--tk-title, #1a1a2e);
    line-height: 1.4;
    margin-bottom: 2px;
}

/* ── Message ────────────────────────────────────────────────────────────── */
.toast-message {
    font-weight: 700;
    font-size: 15px;
    color: var(--tk-msg, #9096B2);
    line-height: 1.5;
    word-break: break-word;
    -ms-word-wrap: break-word;
    word-wrap: break-word;
}

/* when there is no title, message stays bold and uses type color (set below) */
.toast-message:only-child,
.toast-message:first-child {
    font-weight: 700;
    font-size: 15px;
}

/* ── Per-type message text color ────────────────────────────────────────── */
.toast-success .toast-message { color: var(--tk-success, #058f00); }
.toast-error   .toast-message { color: var(--tk-error,   #dc3545); }
.toast-warning .toast-message { color: var(--tk-warning, #fd7e14); }
.toast-info    .toast-message { color: var(--tk-info,    #0d6efd); }

.toast-message a,
.toast-message label {
    color: var(--primary-color, #1a1a2e);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-thickness: 1px;
}
.toast-message a:hover {
    opacity: 0.72;
    text-decoration: none;
}

/* ── Close button ───────────────────────────────────────────────────────── */
.toast-close-button {
    /* override float-based layout → absolute pin */
    position: absolute;
    top: 11px;
    right: 11px;
    float: none;

    /* pill shape */
    display: -webkit-inline-flex;
    display: inline-flex;
    -webkit-align-items: center;
    align-items: center;
    -webkit-justify-content: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 8px;
    padding: 0;
    border: none;
    -webkit-appearance: none;
    cursor: pointer;

    /* visual */
    background: rgba(0, 0, 0, 0.05);
    color: var(--tk-msg, #9096B2);
    font-size: 16px;
    font-weight: 300;
    line-height: 1;
    opacity: 0.65;
    -webkit-text-shadow: none;
    text-shadow: none;

    /* motion */
    -webkit-transition: background 0.15s ease, opacity 0.15s ease, color 0.15s ease;
    transition:         background 0.15s ease, opacity 0.15s ease, color 0.15s ease;
}

button.toast-close-button {
    padding: 0;
    border: none;
    background: rgba(0, 0, 0, 0.05);
    cursor: pointer;
    -webkit-appearance: none;
}

.toast-close-button:hover,
.toast-close-button:focus {
    background: rgba(0, 0, 0, 0.10);
    color: var(--tk-title, #1a1a2e);
    opacity: 1;
    cursor: pointer;
    text-decoration: none;
    -ms-filter: alpha(opacity=100);
    filter: alpha(opacity=100);
    outline: none;
}

[data-theme="dark"] .toast-close-button {
    background: rgba(255, 255, 255, 0.07);
    color: rgba(255, 255, 255, 0.40);
}
[data-theme="dark"] .toast-close-button:hover {
    background: rgba(255, 255, 255, 0.14);
    color: rgba(255, 255, 255, 0.90);
}

/* ── Progress bar ───────────────────────────────────────────────────────── */
.toast-progress {
    position: absolute;
    left: 0;
    bottom: 0;
    height: var(--tk-prog-h, 2.5px);
    border-radius: 0;          /* overflow:hidden on parent rounds corners */
    opacity: 1;
}

/* per-type gradient for a premium shimmer feel */
.toast-success .toast-progress {
    background: linear-gradient(90deg, rgba(5,143,0,0.5) 0%, var(--tk-success, #058f00) 100%);
}
.toast-error .toast-progress {
    background: linear-gradient(90deg, rgba(220,53,69,0.5) 0%, var(--tk-error, #dc3545) 100%);
}
.toast-warning .toast-progress {
    background: linear-gradient(90deg, rgba(253,126,20,0.5) 0%, var(--tk-warning, #fd7e14) 100%);
}
.toast-info .toast-progress {
    background: linear-gradient(90deg, rgba(13,110,253,0.5) 0%, var(--tk-info, #0d6efd) 100%);
}

/* ── Slide-in keyframes (right → left — default top-right position) ─────── */
@-webkit-keyframes tkSlideIn {
    from {
        opacity: 0;
        -webkit-transform: translateX(24px) scale(0.94);
        transform: translateX(24px) scale(0.94);
    }
    to {
        opacity: 1;
        -webkit-transform: translateX(0) scale(1);
        transform: translateX(0) scale(1);
    }
}
@keyframes tkSlideIn {
    from {
        opacity: 0;
        transform: translateX(24px) scale(0.94);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

/* left-positioned containers slide from left */
.toast-top-left    > div,
.toast-bottom-left > div {
    -webkit-animation-name: tkSlideInLeft;
    animation-name: tkSlideInLeft;
}
@-webkit-keyframes tkSlideInLeft {
    from {
        opacity: 0;
        -webkit-transform: translateX(-24px) scale(0.94);
        transform: translateX(-24px) scale(0.94);
    }
    to {
        opacity: 1;
        -webkit-transform: translateX(0) scale(1);
        transform: translateX(0) scale(1);
    }
}
@keyframes tkSlideInLeft {
    from {
        opacity: 0;
        transform: translateX(-24px) scale(0.94);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

/* center positions slide up */
.toast-top-center    > div,
.toast-bottom-center > div,
.toast-top-full-width    > div,
.toast-bottom-full-width > div {
    -webkit-animation-name: tkSlideUp;
    animation-name: tkSlideUp;
}
@-webkit-keyframes tkSlideUp {
    from {
        opacity: 0;
        -webkit-transform: translateY(12px) scale(0.96);
        transform: translateY(12px) scale(0.96);
    }
    to {
        opacity: 1;
        -webkit-transform: translateY(0) scale(1);
        transform: translateY(0) scale(1);
    }
}
@keyframes tkSlideUp {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media all and (max-width: 480px) {
    #toast-container > div {
        padding: 14px 44px 16px 74px;
        width: calc(100vw - 24px);
        min-height: 66px;
        border-radius: 14px;
    }
    #toast-container > div::before {
        width:  42px;
        height: 42px;
        left:   14px;
        border-radius: 11px;
        background-size: 22px 22px;
    }
    .toast-top-right     { top: 12px; right: 12px; }
    .toast-top-left      { top: 12px; left: 12px; }
    .toast-bottom-right  { bottom: 12px; right: 12px; }
    .toast-bottom-left   { bottom: 12px; left: 12px; }
}

@media all and (max-width: 240px) {
    #toast-container > div {
        padding: 12px 40px 14px 64px;
        width: 11em;
        border-radius: 12px;
    }
    #toast-container > div::before {
        width: 34px;
        height: 34px;
        left: 12px;
        border-radius: 9px;
        background-size: 18px 18px;
    }
    .toast-close-button {
        width: 22px;
        height: 22px;
        top: 9px;
        right: 9px;
    }
}

@media all and (min-width: 481px) and (max-width: 768px) {
    #toast-container > div { width: 340px; }
}
