<?php
/**
 * theme.php — Shared Auth Theme
 * Include this file in any auth page AFTER defining $themeColor and $rgbColor.
 * It outputs: <style> block + <canvas> element + particle/animation <script>
 *
 * Usage in any page:
 *   require_once '../includes/theme.php'; // adjust path as needed
 *
 * The page must define before including:
 *   $themeColor  (e.g. getSetting('theme_color', '#7b2fd4'))
 *   $rgbColor    (e.g. hexToRgb($themeColor))
 */
?>
<style>
    /* ═══════════════════════════════════════════════════════
       EARNOVIX SHARED AUTH THEME
       All CSS variables, background, animations, card styles,
       form elements, buttons, toast — used by every auth page.
    ═══════════════════════════════════════════════════════ */

    *, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

    :root {
        --accent:       <?php echo $themeColor; ?>;
        --accent-rgb:   <?php echo $rgbColor; ?>;
        --gold:         #ffd700;
        --gold-dim:     rgba(255,215,0,0.35);
        --card-bg:      rgba(255,255,255,0.06);
        --card-border:  rgba(255,255,255,0.1);
        --input-bg:     rgba(255,255,255,0.07);
        --input-border: rgba(255,255,255,0.15);
        --text:         #ffffff;
        --text-soft:    rgba(255,255,255,0.65);
        --text-muted:   rgba(255,255,255,0.35);
        --green:        #22c55e;
        --green-dim:    rgba(34,197,94,0.15);
        --red:          #ef4444;
        --red-dim:      rgba(239,68,68,0.1);
        --yellow:       #fbbf24;
        --yellow-dim:   rgba(251,191,36,0.08);
        --blue:         #38bdf8;
        --blue-dim:     rgba(14,165,233,0.1);
    }

    /* ── Scrollbar ── */
    ::-webkit-scrollbar { width: 4px; }
    ::-webkit-scrollbar-thumb { background: #3d0070; border-radius: 4px; }

    html, body { height: 100%; font-family: 'Poppins', sans-serif; color: var(--text); }

    /* ── Page background ── */
    body {
        background:
            radial-gradient(ellipse 80% 55% at 50% 0%,   #5a0fa0 0%, transparent 60%),
            radial-gradient(ellipse 55% 40% at 10% 80%,  #3d0070 0%, transparent 55%),
            radial-gradient(ellipse 45% 35% at 90% 80%,  #2d0060 0%, transparent 55%),
            radial-gradient(ellipse 100% 100% at 50% 50%,#140025 0%, #06000e 100%);
        background-attachment: fixed;
        display: flex; align-items: center; justify-content: center;
        min-height: 100vh; padding: 20px 12px;
        overflow-x: hidden; position: relative;
    }

    /* ── Twinkling stars layer ── */
    body::before {
        content: ''; position: fixed; inset: 0; z-index: 0; pointer-events: none;
        background-image:
            radial-gradient(1px 1px at 8%  12%, rgba(255,215,0,0.7)   0%, transparent 100%),
            radial-gradient(1px 1px at 22% 38%, rgba(255,255,255,0.5) 0%, transparent 100%),
            radial-gradient(1.5px 1.5px at 37%  7%, rgba(255,215,0,0.5)   0%, transparent 100%),
            radial-gradient(1px 1px at 55% 20%, rgba(255,255,255,0.4) 0%, transparent 100%),
            radial-gradient(2px 2px at 67%  4%, rgba(255,215,0,0.6)   0%, transparent 100%),
            radial-gradient(1px 1px at 80% 32%, rgba(255,255,255,0.5) 0%, transparent 100%),
            radial-gradient(1px 1px at 14% 63%, rgba(255,255,255,0.3) 0%, transparent 100%),
            radial-gradient(1px 1px at 45% 87%, rgba(255,215,0,0.5)   0%, transparent 100%),
            radial-gradient(2px 2px at 72% 75%, rgba(255,255,255,0.4) 0%, transparent 100%),
            radial-gradient(2px 2px at 95% 54%, rgba(255,215,0,0.6)   0%, transparent 100%);
        animation: twinkle 4s ease-in-out infinite alternate;
    }
    @keyframes twinkle { 0% { opacity: 0.5; } 100% { opacity: 1; } }

    /* Particle canvas */
    #particle-canvas { position: fixed; inset: 0; z-index: 1; pointer-events: none; }

    /* ── Card ── */
    .card {
        position: relative; z-index: 10;
        background: var(--card-bg);
        border: 1px solid var(--card-border);
        border-radius: 16px;
        padding: 20px 20px 16px;
        width: 100%; max-width: 390px;
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        box-shadow: 0 8px 32px rgba(0,0,0,0.5);
        animation: cardIn 0.6s cubic-bezier(0.22,1,0.36,1) both;
    }
    @keyframes cardIn {
        from { opacity: 0; transform: translateY(30px) scale(0.97); }
        to   { opacity: 1; transform: translateY(0) scale(1); }
    }

    /* ── Logo row ── */
    .logo-area { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; }
    .logo-ring {
        width: 38px; height: 38px; flex-shrink: 0; border-radius: 50%;
        background: conic-gradient(from 0deg, var(--gold), var(--accent), var(--gold));
        padding: 2px; display: flex; align-items: center; justify-content: center;
        box-shadow: 0 0 14px rgba(var(--accent-rgb),0.55), 0 0 28px rgba(255,215,0,0.2);
        animation: ringRotate 6s linear infinite;
    }
    @keyframes ringRotate { to { filter: hue-rotate(360deg); } }
    .logo-inner {
        width: 100%; height: 100%; border-radius: 50%;
        background: #1a0030;
        display: flex; align-items: center; justify-content: center; overflow: hidden;
    }
    .logo-inner img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
    .logo-inner i   { font-size: 15px; color: var(--gold); }
    .logo-text { flex: 1; min-width: 0; }
    .site-title { font-size: 13.5px; font-weight: 700; color: var(--text); line-height: 1.2; }
    .site-sub   { font-size: 10px; color: var(--text-muted); }

    /* ── Gold divider ── */
    .gold-divider {
        height: 1px; margin: 0 0 13px;
        background: linear-gradient(90deg, transparent, var(--gold-dim), transparent);
    }

    /* ── Info / tip badges ── */
    .info-tip {
        display: flex; align-items: center; gap: 5px;
        background: rgba(255,215,0,0.05); border: 1px solid rgba(255,215,0,0.15);
        border-radius: 5px; padding: 3px 8px; margin-bottom: 9px;
        font-size: 10.5px; color: rgba(255,215,0,0.75);
    }
    .info-tip i { font-size: 9px; color: var(--gold); flex-shrink: 0; }
    .info-tip strong { color: rgba(255,215,0,0.95); }

    /* ── Alerts ── */
    .alert {
        display: flex; align-items: center; gap: 8px;
        padding: 8px 11px; border-radius: 8px;
        font-size: 12px; font-weight: 500; margin-bottom: 10px;
    }
    .alert i { font-size: 13px; flex-shrink: 0; }
    .alert-error   { background: rgba(239,68,68,0.12);  color: #fca5a5; border: 1px solid rgba(239,68,68,0.25); }
    .alert-warning { background: rgba(251,191,36,0.1);  color: #fcd34d; border: 1px solid rgba(251,191,36,0.25); }
    .alert-info    { background: rgba(var(--accent-rgb),0.1); color: rgba(255,255,255,0.8); border: 1px solid rgba(var(--accent-rgb),0.25); }
    .alert-success { background: rgba(34,197,94,0.1);   color: #86efac; border: 1px solid rgba(34,197,94,0.25); }

    /* ── Form fields ── */
    .field { margin-bottom: 9px; }
    label {
        display: block; font-size: 10.5px; font-weight: 600;
        color: var(--text-soft); margin-bottom: 3px; letter-spacing: 0.2px;
    }
    .field-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 3px; }
    .field-top label { margin-bottom: 0; }
    .link-small { font-size: 10.5px; color: var(--gold); font-weight: 500; text-decoration: none; opacity: 0.85; }
    .link-small:hover { opacity: 1; text-decoration: underline; }

    .input-wrap { position: relative; }

    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="password"],
    select {
        width: 100%; height: 40px;
        padding: 0 34px 0 11px;
        background: var(--input-bg);
        border: 1.5px solid var(--input-border);
        border-radius: 8px;
        font-family: 'Poppins', sans-serif;
        font-size: 12.5px; color: var(--text);
        outline: none;
        transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
        appearance: none;
    }
    input::placeholder { color: var(--text-muted); font-size: 12px; }
    input:focus, select:focus {
        border-color: var(--accent);
        box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.22);
        background: rgba(255,255,255,0.09);
    }
    input.f-valid   { border-color: var(--green); background: rgba(34,197,94,0.06); }
    input.f-invalid, select.f-invalid { border-color: var(--red); background: rgba(239,68,68,0.06); }
    input.f-checking { border-color: var(--yellow); }
    input.f-valid:focus   { box-shadow: 0 0 0 2px rgba(34,197,94,0.18); }
    input.f-invalid:focus { box-shadow: 0 0 0 2px rgba(239,68,68,0.15); }
    input.err { border-color: var(--red); background: rgba(239,68,68,0.07); }

    /* Select chevron */
    .select-wrap { position: relative; }
    .select-wrap::after {
        content: ''; position: absolute; right: 10px; top: 50%;
        transform: translateY(-50%);
        border-left: 4px solid transparent; border-right: 4px solid transparent;
        border-top: 5px solid rgba(255,255,255,0.35); pointer-events: none;
    }
    select option { background: #1a0030; color: #fff; }

    /* Status icons inside inputs */
    .f-status {
        position: absolute; right: 8px; top: 50%;
        transform: translateY(-50%);
        font-size: 12px; pointer-events: none; display: none; line-height: 1;
    }
    .pw-status { right: 30px; }

    /* Inline feedback */
    .f-msg {
        font-size: 10px; font-weight: 500;
        margin-top: 2px; max-height: 0; overflow: hidden;
        display: flex; align-items: center; gap: 3px;
        transition: max-height 0.15s;
    }
    .f-msg.show { max-height: 20px; }
    .f-msg.ok  { color: #4ade80; }
    .f-msg.err { color: #f87171; }
    .f-msg.chk { color: #fbbf24; }

    @keyframes spin-icon { to { transform: rotate(360deg); } }
    .spin-anim { display: inline-block; animation: spin-icon 0.7s linear infinite; }

    /* Password eye toggle */
    .toggle-pwd {
        position: absolute; right: 8px; top: 50%;
        transform: translateY(-50%);
        background: none; border: none; cursor: pointer;
        color: var(--text-muted); font-size: 13px; padding: 2px;
        transition: color 0.15s;
    }
    .toggle-pwd:hover { color: var(--gold); }
    #password { padding-right: 56px; }

    /* Remember me row */
    .remember-row { display: flex; align-items: center; margin: 5px 0 10px; }
    .remember { display: flex; align-items: center; gap: 6px; }
    .remember input[type="checkbox"] { width: 13px; height: 13px; accent-color: var(--accent); cursor: pointer; flex-shrink: 0; }
    .remember label { font-size: 11px; color: var(--text-soft); cursor: pointer; margin-bottom: 0; font-weight: 400; letter-spacing: 0; }

    /* Terms box */
    .terms-box {
        border: 1.5px solid var(--input-border); border-radius: 7px;
        padding: 6px 9px; margin-bottom: 8px; background: var(--input-bg);
    }
    .terms-box.error { border-color: var(--red); background: rgba(239,68,68,0.06); }
    .terms-box:focus-within { border-color: var(--accent); }
    .terms-row { display: flex; align-items: flex-start; gap: 8px; }
    .terms-row input[type="checkbox"] { width: 13px; height: 13px; min-width: 13px; margin-top: 2px; accent-color: var(--accent); cursor: pointer; }
    .terms-text { font-size: 11px; color: var(--text-soft); line-height: 1.5; }
    .terms-text a { color: var(--gold); font-weight: 600; text-decoration: none; border-bottom: 1px solid rgba(255,215,0,0.25); }

    /* Referrer badge */
    .referrer-badge {
        display: flex; align-items: center; gap: 5px;
        background: rgba(var(--accent-rgb), 0.08);
        border: 1px solid rgba(var(--accent-rgb), 0.18);
        border-radius: 5px; padding: 3px 7px; margin-bottom: 6px;
        font-size: 11px; color: var(--text-soft);
    }
    .referrer-badge.default { background: rgba(255,255,255,0.04); border-color: rgba(255,255,255,0.08); }
    .ref-icon { width: 16px; height: 16px; border-radius: 3px; flex-shrink: 0; background: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 8px; color: #fff; }
    .referrer-badge.default .ref-icon { background: rgba(255,255,255,0.1); }
    .ref-inline strong { color: var(--text); font-weight: 600; }

    /* ── Buttons ── */
    .btn {
        width: 100%; height: 40px; background: var(--accent);
        color: #fff; border: none; border-radius: 9px;
        font-family: 'Poppins', sans-serif; font-size: 13px; font-weight: 700;
        cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 7px;
        box-shadow: 0 4px 16px rgba(var(--accent-rgb),0.4);
        transition: filter 0.15s; margin-top: 4px;
    }
    .btn:hover:not(:disabled) { filter: brightness(1.08); }
    .btn:disabled { opacity: 0.5; cursor: not-allowed; }

    .spinner {
        display: none; width: 15px; height: 15px;
        border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff;
        border-radius: 50%; animation: spin 0.6s linear infinite;
    }
    .btn.loading .btn-label { display: none; }
    .btn.loading .spinner   { display: block; }
    @keyframes spin { to { transform: rotate(360deg); } }

    .btn-secondary {
        display: flex; align-items: center; justify-content: center; gap: 7px;
        width: 100%; height: 40px;
        background: rgba(255,255,255,0.07);
        color: var(--text-soft); border: 1px solid rgba(255,255,255,0.12);
        border-radius: 9px; font-family: 'Poppins', sans-serif;
        font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none;
        transition: background 0.15s, color 0.15s;
    }
    .btn-secondary:hover { background: rgba(255,255,255,0.12); color: var(--text); }

    /* ── Or divider ── */
    .or-divider { display: flex; align-items: center; gap: 10px; margin: 12px 0; }
    .or-line { flex: 1; height: 1px; background: rgba(255,255,255,0.1); }
    .or-text  { font-size: 10.5px; color: var(--text-muted); }

    /* ── Social row ── */
    .social-row { display: flex; gap: 8px; }
    .social-btn {
        flex: 1; height: 36px;
        border: 1px solid rgba(255,255,255,0.12); border-radius: 8px;
        background: rgba(255,255,255,0.05);
        display: flex; align-items: center; justify-content: center;
        color: var(--text-soft); font-size: 14px;
        cursor: pointer; text-decoration: none;
        transition: border-color 0.15s, color 0.15s, background 0.15s;
    }
    .social-btn:hover { border-color: var(--gold); color: var(--gold); background: rgba(255,215,0,0.06); }

    /* ── Form divider ── */
    .form-divider { height: 1px; margin: 6px 0 8px; background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent); }

    /* ── Card footer ── */
    .card-footer { text-align: center; margin-top: 10px; font-size: 11.5px; color: var(--text-muted); }
    .card-footer a { color: var(--gold); text-decoration: none; font-weight: 600; }
    .card-footer a:hover { text-decoration: underline; }
    .copy-line { text-align: center; margin-top: 8px; padding-top: 8px; border-top: 1px solid rgba(255,255,255,0.07); font-size: 9.5px; color: rgba(255,255,255,0.18); }

    /* ── Status boxes ── */
    .status-box { border-radius: 11px; padding: 13px 14px; margin-bottom: 14px; }
    .status-box.green  { background: rgba(34,197,94,0.1);  border: 1px solid rgba(34,197,94,0.3); }
    .status-box.yellow { background: var(--yellow-dim);    border: 1px solid rgba(251,191,36,0.25); }
    .status-box.red    { background: var(--red-dim);       border: 1px solid rgba(239,68,68,0.25); }
    .status-box.free   { background: var(--blue-dim);      border: 1px solid rgba(14,165,233,0.25); }
    .box-label { font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px; }
    .status-box.green  .box-label { color: #4ade80; }
    .status-box.yellow .box-label { color: #fbbf24; }
    .status-box.red    .box-label { color: #f87171; }
    .status-box.free   .box-label { color: #38bdf8; }
    .amount { font-size: 28px; font-weight: 700; letter-spacing: -1px; line-height: 1; margin-bottom: 4px; color: var(--text); }
    .note { font-size: 11.5px; color: var(--text-muted); }
    .status-box.green .note { color: rgba(74,222,128,0.7); }
    .hint { font-size: 10px; color: var(--text-muted); text-align: center; margin-top: 4px; }

    /* ── Error box ── */
    .err-box { background: var(--red-dim); border: 1px solid rgba(239,68,68,0.25); border-radius: 9px; padding: 11px 13px; font-size: 12px; color: #fca5a5; margin-bottom: 12px; line-height: 1.7; }
    .err-box code { background: rgba(239,68,68,0.15); padding: 1px 5px; border-radius: 4px; font-size: 10.5px; }

    /* ── Toast ── */
    .toast {
        position: fixed; top: -100px; left: 50%; transform: translateX(-50%);
        min-width: 280px; max-width: 88%;
        background: #1e0038; border: 1px solid rgba(255,255,255,0.1);
        border-radius: 11px; padding: 10px 36px 10px 11px;
        box-shadow: 0 8px 28px rgba(0,0,0,0.45); z-index: 10000;
        display: flex; align-items: center; gap: 9px;
        transition: top 0.3s ease; backdrop-filter: blur(12px);
    }
    .toast.show { top: 14px; }
    .toast-icon { width: 19px; height: 19px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 9px; color: #fff; font-weight: 700; }
    .toast.success { border-left: 3px solid var(--green); } .toast.success .toast-icon { background: var(--green); }
    .toast.error   { border-left: 3px solid var(--red);   } .toast.error   .toast-icon { background: var(--red); }
    .toast.info    { border-left: 3px solid var(--accent); } .toast.info   .toast-icon { background: var(--accent); }
    .toast-msg { font-size: 12px; color: var(--text); font-weight: 500; flex: 1; }
    .toast-x { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: none; border: none; font-size: 14px; color: var(--text-muted); cursor: pointer; }

    /* ── Modal (terms) ── */
    .modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 9999; align-items: center; justify-content: center; padding: 14px; backdrop-filter: blur(4px); }
    .modal-overlay.open { display: flex; }
    .modal { background: #1a0030; border: 1px solid rgba(255,215,0,0.2); border-radius: 14px; max-width: 390px; width: 100%; max-height: 88vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
    .modal-head { display: flex; align-items: center; justify-content: space-between; padding: 13px 16px 11px; border-bottom: 1px solid rgba(255,255,255,0.08); }
    .modal-head h3 { font-size: 13.5px; font-weight: 700; color: var(--gold); }
    .modal-close { width: 26px; height: 26px; border-radius: 6px; background: rgba(255,255,255,0.08); border: none; cursor: pointer; font-size: 16px; color: var(--text-soft); display: flex; align-items: center; justify-content: center; }
    .modal-body { overflow-y: auto; padding: 14px 16px; flex: 1; }
    .terms-section { margin-bottom: 12px; }
    .terms-section h4 { font-size: 10px; font-weight: 700; color: var(--gold); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
    .terms-section p { font-size: 11.5px; color: var(--text-soft); line-height: 1.6; }
    .terms-highlight { background: rgba(255,215,0,0.05); border: 1px solid rgba(255,215,0,0.18); border-radius: 8px; padding: 10px 12px; }
    .modal-foot { padding: 10px 16px 14px; border-top: 1px solid rgba(255,255,255,0.08); display: flex; gap: 8px; }
    .btn-accept { flex: 1; height: 38px; background: var(--accent); color: #fff; border: none; border-radius: 8px; font-family: 'Poppins',sans-serif; font-size: 12.5px; font-weight: 700; cursor: pointer; }
    .btn-accept:hover { filter: brightness(1.08); }
    .btn-decline { height: 38px; padding: 0 13px; background: rgba(255,255,255,0.07); color: var(--text-soft); border: 1px solid rgba(255,255,255,0.1); border-radius: 8px; font-family: 'Poppins',sans-serif; font-size: 12.5px; font-weight: 500; cursor: pointer; }

    /* ── Responsive ── */
    @media (max-width: 380px) { .card { padding: 14px 13px 12px; } body { padding: 12px 10px; } }
</style>

<!-- Particle canvas (rendered behind everything) -->
<canvas id="particle-canvas"></canvas>

<script>
/* ═══════════════════════════════════════════════════════
   SHARED PARTICLE + TOAST SYSTEM
   Auto-initialises on DOMContentLoaded.
═══════════════════════════════════════════════════════ */
(function () {
    'use strict';

    /* ── Particle System ──────────────────────────────── */
    var canvas = document.getElementById('particle-canvas');
    var ctx    = canvas.getContext('2d');
    var W, H, particles = [];
    var COLORS = ['rgba(255,215,0,','rgba(200,130,255,','rgba(255,255,255,','rgba(255,165,0,'];

    function resize() { W = canvas.width = window.innerWidth; H = canvas.height = window.innerHeight; }
    function rand(a, b) { return Math.random() * (b - a) + a; }

    function Particle() { this.reset(); }
    Particle.prototype.reset = function () {
        this.x = rand(0, W); this.y = rand(H + 10, H + 60);
        this.r = rand(1, 2.5); this.speedY = rand(0.4, 1.2); this.speedX = rand(-0.3, 0.3);
        this.color = COLORS[Math.floor(Math.random() * COLORS.length)];
        this.alpha = rand(0.4, 1); this.decay = rand(0.003, 0.008);
        this.twinkleSpeed = rand(0.02, 0.06); this.twinklePhase = rand(0, Math.PI * 2);
        this.glowSize = rand(3, 8);
    };
    Particle.prototype.update = function (t) {
        this.y -= this.speedY; this.x += this.speedX; this.alpha -= this.decay;
        var tw = Math.sin(t * this.twinkleSpeed + this.twinklePhase) * 0.3 + 0.7;
        this.currentAlpha = Math.max(0, this.alpha * tw);
        if (this.alpha <= 0 || this.y < -10) this.reset();
    };
    Particle.prototype.draw = function () {
        var g = ctx.createRadialGradient(this.x, this.y, 0, this.x, this.y, this.glowSize);
        g.addColorStop(0, this.color + this.currentAlpha + ')');
        g.addColorStop(1, this.color + '0)');
        ctx.beginPath(); ctx.fillStyle = g;
        ctx.arc(this.x, this.y, this.glowSize, 0, Math.PI * 2); ctx.fill();
        ctx.beginPath(); ctx.arc(this.x, this.y, this.r, 0, Math.PI * 2);
        ctx.fillStyle = this.color + Math.min(1, this.currentAlpha * 1.5) + ')'; ctx.fill();
    };

    function initParticles() {
        resize(); particles = [];
        for (var i = 0; i < 55; i++) {
            var p = new Particle(); p.y = rand(0, H); p.alpha = rand(0.2, 0.9); particles.push(p);
        }
    }
    var t = 0;
    function loop() {
        ctx.clearRect(0, 0, W, H); t++;
        for (var i = 0; i < particles.length; i++) { particles[i].update(t); particles[i].draw(); }
        requestAnimationFrame(loop);
    }
    window.addEventListener('resize', resize);
    initParticles(); loop();

    /* ── Global Toast ─────────────────────────────────── */
    var toastTimer = null;
    window.showToast = function (type, msg, redirectUrl) {
        var t = document.getElementById('toast');
        if (!t) return;
        clearTimeout(toastTimer);
        t.className = 'toast ' + type;
        document.getElementById('toastIcon').textContent = type === 'success' ? '✓' : type === 'error' ? '✕' : 'i';
        document.getElementById('toastMsg').textContent  = msg;
        t.classList.add('show');
        if (redirectUrl) { setTimeout(function () { window.location.href = redirectUrl; }, 2500); }
        else { toastTimer = setTimeout(window.hideToast, 3500); }
    };
    window.hideToast = function () {
        var t = document.getElementById('toast');
        if (t) t.classList.remove('show');
    };

}());
</script>