/* ============================================================
   Modern Toast Notifications
   ------------------------------------------------------------
   Overrides toastr's default look while keeping its JS API
   intact (toastr.success / .error / .warning / .info still
   work everywhere). Loaded once via core/templates/header.php.
   ============================================================ */

:root {
    --tx-text:        #0f172a;
    --tx-muted:       #475569;
    --tx-surface:     #ffffff;
    --tx-border:      rgba(15, 23, 42, 0.08);
    --tx-radius:      12px;
    --tx-shadow:      0 12px 32px -8px rgba(15, 23, 42, 0.25),
                      0 4px 12px -2px rgba(15, 23, 42, 0.10);
    --tx-ease:        cubic-bezier(0.16, 1, 0.3, 1);

    --tx-success:     #1bca3f;
    --tx-success-bg:  #ecfdf5;
    --tx-success-2:   #92df48;

    --tx-error:       #ef4444;
    --tx-error-bg:    #fef2f2;

    --tx-warning:     #f59e0b;
    --tx-warning-bg:  #fffbeb;

    --tx-info:        #3b82f6;
    --tx-info-bg:     #eff6ff;
}

/* ----- Container positioning ------------------------------ */
#toast-container {
    pointer-events: none;
    z-index: 1200;
}
#toast-container > div {
    pointer-events: auto;
}

#toast-container.toast-top-right,
#toast-container.toast-top-left,
#toast-container.toast-bottom-right,
#toast-container.toast-bottom-left,
#toast-container.toast-top-center,
#toast-container.toast-bottom-center {
    padding: 16px;
}

@media (max-width: 600px) {
    #toast-container.toast-top-right,
    #toast-container.toast-top-left,
    #toast-container.toast-bottom-right,
    #toast-container.toast-bottom-left,
    #toast-container.toast-top-full-width,
    #toast-container.toast-bottom-full-width,
    #toast-container.toast-top-center,
    #toast-container.toast-bottom-center {
        top: auto !important;
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
        width: 100% !important;
        padding: 10px 10px max(10px, env(safe-area-inset-bottom)) !important;
    }
    #toast-container > div { width: 100% !important; max-width: 100% !important; }
}

/* ----- Base toast card ------------------------------------ */
#toast-container > .toast {
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
    width: 360px;
    max-width: calc(100vw - 32px);
    min-height: 56px;
    padding: 14px 38px 14px 56px;          /* room for left icon + right close button */
    margin: 0 0 12px 0;
    background: var(--tx-surface) !important;
    background-image: none !important;
    color: var(--tx-text) !important;
    border: 1px solid var(--tx-border) !important;
    border-left-width: 4px !important;
    border-radius: var(--tx-radius) !important;
    box-shadow: var(--tx-shadow) !important;
    opacity: 1 !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, Oxygen, sans-serif;
    backdrop-filter: blur(6px);
}

/* Hover lift (subtle) */
#toast-container > .toast:hover {
    box-shadow: 0 16px 36px -8px rgba(15, 23, 42, 0.28), 0 6px 16px -2px rgba(15, 23, 42, 0.14) !important;
    transform: translateY(-1px);
    transition: transform 0.15s var(--tx-ease), box-shadow 0.15s var(--tx-ease);
}

/* ----- Title + message ----------------------------------- */
#toast-container > .toast .toast-title {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--tx-text);
    margin-bottom: 2px;
    letter-spacing: -0.1px;
}
#toast-container > .toast .toast-message {
    font-size: 13px;
    line-height: 1.5;
    color: var(--tx-muted);
    word-wrap: break-word;
    white-space: normal;
}
#toast-container > .toast .toast-message a {
    color: var(--tx-text);
    text-decoration: underline;
    font-weight: 500;
}

/* ----- Left icon (per variant) --------------------------- */
#toast-container > .toast::before {
    content: "";
    position: absolute;
    top: 14px;
    left: 14px;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-position: center;
    background-repeat: no-repeat;
    background-size: 18px 18px;
}

/* ----- Variant: SUCCESS ---------------------------------- */
#toast-container > .toast-success {
    border-left-color: var(--tx-success) !important;
}
#toast-container > .toast-success::before {
    background-color: var(--tx-success-bg);
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%231bca3f' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='M20 6 9 17l-5-5'/></svg>");
}

/* ----- Variant: ERROR ------------------------------------ */
#toast-container > .toast-error {
    border-left-color: var(--tx-error) !important;
}
#toast-container > .toast-error::before {
    background-color: var(--tx-error-bg);
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23ef4444' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='M18 6 6 18M6 6l12 12'/></svg>");
}

/* ----- Variant: WARNING ---------------------------------- */
#toast-container > .toast-warning {
    border-left-color: var(--tx-warning) !important;
}
#toast-container > .toast-warning::before {
    background-color: var(--tx-warning-bg);
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23f59e0b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0Z'/><path d='M12 9v4'/><path d='M12 17h.01'/></svg>");
}

/* ----- Variant: INFO ------------------------------------- */
#toast-container > .toast-info {
    border-left-color: var(--tx-info) !important;
}
#toast-container > .toast-info::before {
    background-color: var(--tx-info-bg);
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%233b82f6' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><circle cx='12' cy='12' r='10'/><path d='M12 16v-4'/><path d='M12 8h.01'/></svg>");
}

/* ----- Close button -------------------------------------- */
#toast-container > .toast .toast-close-button {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    padding: 0;
    color: var(--tx-muted) !important;
    background: transparent !important;
    border: 0 !important;
    border-radius: 6px;
    font-size: 18px;
    font-weight: 400;
    line-height: 1;
    text-shadow: none !important;
    opacity: 0.7;
    cursor: pointer;
    transition: opacity 0.2s var(--tx-ease), background 0.2s var(--tx-ease), transform 0.2s var(--tx-ease);
    float: none;
}
#toast-container > .toast .toast-close-button:hover,
#toast-container > .toast .toast-close-button:focus {
    color: var(--tx-text) !important;
    background: rgba(15, 23, 42, 0.05) !important;
    opacity: 1;
    transform: rotate(90deg);
    outline: none;
}

/* ----- Progress bar -------------------------------------- */
#toast-container > .toast .toast-progress {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    background: var(--tx-success);
    opacity: 0.7;
    border-radius: 0 0 var(--tx-radius) var(--tx-radius);
}
#toast-container > .toast-success .toast-progress { background: linear-gradient(90deg, var(--tx-success-2) 0%, var(--tx-success) 100%); }
#toast-container > .toast-error   .toast-progress { background: var(--tx-error);   }
#toast-container > .toast-warning .toast-progress { background: var(--tx-warning); }
#toast-container > .toast-info    .toast-progress { background: var(--tx-info);    }

/* ----- Entrance / exit animations ------------------------ */
/* Override toastr's default jQuery animation by tweaking the
   pre-rendered visual state. Toastr inlines display:none/block,
   so we ride on a transition on transform/opacity. */
#toast-container > .toast {
    animation: tx-slide-in 0.36s var(--tx-ease) both;
}
@keyframes tx-slide-in {
    from { opacity: 0; transform: translateX(20px) scale(0.96); }
    to   { opacity: 1; transform: translateX(0)    scale(1);     }
}
#toast-container.toast-top-left > .toast,
#toast-container.toast-bottom-left > .toast {
    animation-name: tx-slide-in-left;
}
@keyframes tx-slide-in-left {
    from { opacity: 0; transform: translateX(-20px) scale(0.96); }
    to   { opacity: 1; transform: translateX(0)     scale(1);     }
}
#toast-container.toast-top-center > .toast,
#toast-container.toast-bottom-center > .toast,
#toast-container.toast-top-full-width > .toast,
#toast-container.toast-bottom-full-width > .toast {
    animation-name: tx-slide-in-top;
}
@keyframes tx-slide-in-top {
    from { opacity: 0; transform: translateY(-16px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0)     scale(1);     }
}
@media (max-width: 600px) {
    #toast-container > .toast { animation-name: tx-slide-in-mobile; }
    @keyframes tx-slide-in-mobile {
        from { opacity: 0; transform: translateY(20px) scale(0.97); }
        to   { opacity: 1; transform: translateY(0)    scale(1);     }
    }
}

@media (prefers-reduced-motion: reduce) {
    #toast-container > .toast { animation: none !important; }
}

/* Full-width position class (top/bottom) — make it not stretch ugly */
#toast-container.toast-top-full-width > .toast,
#toast-container.toast-bottom-full-width > .toast {
    width: min(560px, calc(100vw - 32px));
    margin-left: auto;
    margin-right: auto;
}
