/* ═══════════════════════════════════════════
   TOAST NOTIFICATION SYSTEM
   ═══════════════════════════════════════════ */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    pointer-events: all;
    min-width: 320px;
    max-width: 420px;
    padding: 14px 16px 14px 14px;
    border-radius: 14px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    box-shadow: 0 12px 40px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.03) inset;

    /* Entry animation */
    animation: toastSlideIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    transform: translateX(120%);
}

.toast.removing {
    animation: toastSlideOut 0.4s cubic-bezier(0.55, 0, 1, 0.45) forwards;
}

@keyframes toastSlideIn {
    0% { transform: translateX(120%) scale(0.9); opacity: 0; }
    100% { transform: translateX(0) scale(1); opacity: 1; }
}

@keyframes toastSlideOut {
    0% { transform: translateX(0) scale(1); opacity: 1; }
    100% { transform: translateX(120%) scale(0.9); opacity: 0; }
}

/* Progress bar at bottom */
.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    border-radius: 0 0 14px 14px;
    animation: toastProgress linear forwards;
}

@keyframes toastProgress {
    0% { width: 100%; }
    100% { width: 0%; }
}

/* Icon container */
.toast-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.toast-icon svg {
    width: 18px;
    height: 18px;
}

/* Content */
.toast-content {
    flex: 1;
    min-width: 0;
}
.toast-title {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 2px;
}
.toast-message {
    font-size: 11.5px;
    color: var(--text-dim);
    line-height: 1.4;
}
.toast-message code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10.5px;
    padding: 1px 5px;
    border-radius: 4px;
    background: rgba(255,255,255,0.06);
}

/* Close button */
.toast-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    opacity: 0;
}
.toast:hover .toast-close { opacity: 1; }
.toast-close:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text);
}

/* ── Toast Types ── */

/* Success */
.toast.success {
    background: linear-gradient(135deg, rgba(14,14,30,0.95), rgba(14,30,20,0.95));
    border-color: rgba(74,222,128,0.2);
}
.toast.success .toast-icon {
    background: linear-gradient(135deg, rgba(74,222,128,0.15), rgba(74,222,128,0.05));
    color: var(--green);
}
.toast.success .toast-title { color: var(--green); }
.toast.success .toast-progress { background: linear-gradient(90deg, var(--green), transparent); }

/* Error */
.toast.error {
    background: linear-gradient(135deg, rgba(14,14,30,0.95), rgba(30,14,18,0.95));
    border-color: rgba(251,113,133,0.2);
}
.toast.error .toast-icon {
    background: linear-gradient(135deg, rgba(251,113,133,0.15), rgba(251,113,133,0.05));
    color: var(--red);
}
.toast.error .toast-title { color: var(--red); }
.toast.error .toast-progress { background: linear-gradient(90deg, var(--red), transparent); }

/* Warning */
.toast.warning {
    background: linear-gradient(135deg, rgba(14,14,30,0.95), rgba(30,26,14,0.95));
    border-color: rgba(251,191,36,0.2);
}
.toast.warning .toast-icon {
    background: linear-gradient(135deg, rgba(251,191,36,0.15), rgba(251,191,36,0.05));
    color: var(--amber);
}
.toast.warning .toast-title { color: var(--amber); }
.toast.warning .toast-progress { background: linear-gradient(90deg, var(--amber), transparent); }

/* Info */
.toast.info {
    background: linear-gradient(135deg, rgba(14,14,30,0.95), rgba(14,20,30,0.95));
    border-color: rgba(139,92,246,0.2);
}
.toast.info .toast-icon {
    background: linear-gradient(135deg, rgba(139,92,246,0.15), rgba(139,92,246,0.05));
    color: var(--purple-soft);
}
.toast.info .toast-title { color: var(--purple-soft); }
.toast.info .toast-progress { background: linear-gradient(90deg, var(--purple), transparent); }


/* ═══════════════════════════════════════════
   CONFIRM MODAL SYSTEM
   ═══════════════════════════════════════════ */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 10001;
    background: var(--backdrop);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}
.modal-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.modal-card {
    position: relative;
    width: 90%;
    max-width: 420px;
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: 0 24px 80px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.03) inset;
    transform: scale(0.9) translateY(20px);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s;
    opacity: 0;
}
.modal-backdrop.active .modal-card {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* ── Confirm: Default (Purple) ── */
.modal-card.default {
    background: linear-gradient(180deg, rgba(20,16,40,0.98), rgba(12,12,26,0.98));
}
.modal-card.default .modal-header-accent {
    height: 3px;
    background: linear-gradient(90deg, var(--purple), #c084fc, var(--purple));
}

/* ── Confirm: Danger (Red) ── */
.modal-card.danger {
    background: linear-gradient(180deg, rgba(30,14,18,0.98), rgba(12,12,26,0.98));
}
.modal-card.danger .modal-header-accent {
    height: 3px;
    background: linear-gradient(90deg, var(--red), #f43f5e, var(--red));
}

/* ── Confirm: Warning (Amber) ── */
.modal-card.warning {
    background: linear-gradient(180deg, rgba(30,26,14,0.98), rgba(12,12,26,0.98));
}
.modal-card.warning .modal-header-accent {
    height: 3px;
    background: linear-gradient(90deg, var(--amber), #f59e0b, var(--amber));
}

.modal-body {
    padding: 28px 24px 20px;
    text-align: center;
}

.modal-icon {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}
.modal-icon svg {
    width: 26px;
    height: 26px;
}

.modal-card.default .modal-icon {
    background: linear-gradient(135deg, rgba(139,92,246,0.2), rgba(139,92,246,0.05));
    color: var(--purple-soft);
    box-shadow: 0 0 30px rgba(139,92,246,0.15);
}
.modal-card.danger .modal-icon {
    background: linear-gradient(135deg, rgba(251,113,133,0.2), rgba(251,113,133,0.05));
    color: var(--red);
    box-shadow: 0 0 30px rgba(251,113,133,0.15);
}
.modal-card.warning .modal-icon {
    background: linear-gradient(135deg, rgba(251,191,36,0.2), rgba(251,191,36,0.05));
    color: var(--amber);
    box-shadow: 0 0 30px rgba(251,191,36,0.15);
}

.modal-title {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}
.modal-desc {
    font-size: 13px;
    color: var(--text-dim);
    line-height: 1.6;
    margin-bottom: 4px;
}
.modal-desc strong {
    color: var(--text);
    font-weight: 600;
}
.modal-desc code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    padding: 2px 6px;
    border-radius: 5px;
    background: rgba(255,255,255,0.06);
    color: var(--purple-soft);
}

.modal-actions {
    display: flex;
    gap: 10px;
    padding: 0 24px 24px;
}
.modal-btn {
    flex: 1;
    padding: 12px 20px;
    border-radius: 12px;
    font-family: 'Outfit', sans-serif;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}
.modal-btn.cancel {
    background: rgba(255,255,255,0.06);
    color: var(--text-dim);
    border: 1px solid rgba(255,255,255,0.08);
}
.modal-btn.cancel:hover {
    background: rgba(255,255,255,0.1);
    color: var(--text);
}
.modal-btn.confirm-purple {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    color: #fff;
    box-shadow: 0 4px 16px rgba(139,92,246,0.3);
}
.modal-btn.confirm-purple:hover {
    background: linear-gradient(135deg, #9b6ff6, #8b5cf6);
    box-shadow: 0 6px 24px rgba(139,92,246,0.4);
    transform: translateY(-1px);
}
.modal-btn.confirm-red {
    background: linear-gradient(135deg, #f43f5e, #e11d48);
    color: #fff;
    box-shadow: 0 4px 16px rgba(244,63,94,0.3);
}
.modal-btn.confirm-red:hover {
    background: linear-gradient(135deg, #fb7185, #f43f5e);
    box-shadow: 0 6px 24px rgba(244,63,94,0.4);
    transform: translateY(-1px);
}
.modal-btn.confirm-amber {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #1a1a1a;
    box-shadow: 0 4px 16px rgba(245,158,11,0.3);
}
.modal-btn.confirm-amber:hover {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    box-shadow: 0 6px 24px rgba(245,158,11,0.4);
    transform: translateY(-1px);
}

/* Keyboard hint */
.modal-hint {
    text-align: center;
    padding: 0 24px 16px;
    font-size: 10px;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}
.modal-hint kbd {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.08);
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
}

/* Top-center toast container for trade notifications */
.toast-container-center {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    align-items: center;
}

/* Center toast animations - slide from top */
.toast-container-center .toast {
    animation: toastSlideDown 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    transform: translateY(-120%);
}
.toast-container-center .toast.removing {
    animation: toastSlideUp 0.4s cubic-bezier(0.55, 0, 1, 0.45) forwards;
}

@keyframes toastSlideDown {
    0% { transform: translateY(-120%) scale(0.9); opacity: 0; }
    100% { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes toastSlideUp {
    0% { transform: translateY(0) scale(1); opacity: 1; }
    100% { transform: translateY(-120%) scale(0.9); opacity: 0; }
}

/* ── Back button (Partial Close) ── */
.modal-back-btn {
    position: absolute;
    top: 14px;
    left: 14px;
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.10);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(.4,0,.2,1);
    z-index: 1;
    padding: 0;
}
.modal-back-btn:hover {
    background: rgba(139,92,246,0.12);
    border-color: rgba(139,92,246,0.35);
    color: #a78bfa;
    transform: translateX(-2px);
    box-shadow: 0 0 12px rgba(139,92,246,0.15);
}
.modal-back-btn:active {
    transform: scale(0.88);
    transition-duration: 0.06s;
}

/* Responsive */
@media (max-width: 480px) {
    .toast { min-width: unset; max-width: calc(100vw - 40px); }
    .toast-container { left: 20px; right: 20px; }
    .toast-container-center { top: 10px; width: calc(100vw - 40px); left: 50%; }
    .modal-card { width: 94%; }
}


/* ═══════════════════════════════════════════
   ACTION TOAST — progress / succeed / fail
   ═══════════════════════════════════════════ */

/* ── Shared action toast base ── */
.toast.action-loading,
.toast.action-success,
.toast.action-error {
    border-left: 3px solid;
    transition: border-color 0.3s ease, background 0.3s ease, box-shadow 0.3s ease;
}

/* ── Icon box shared ── */
.toast .action-icon-box {
    position: relative;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

/* Hide result icons by default */
.toast .action-check,
.toast .action-x {
    position: absolute;
    width: 20px;
    height: 20px;
    opacity: 0;
    transition: opacity 0.15s ease;
    stroke-width: 2;
}

/* ── LOADING state ── */
.toast.action-loading {
    background: linear-gradient(135deg, rgba(14,14,30,0.95), rgba(18,16,36,0.95));
    border-left-color: #818cf8;
    border-color: rgba(129,140,248,0.2);
    box-shadow: 0 12px 40px rgba(0,0,0,0.4), 0 0 20px rgba(129,140,248,0.06), 0 0 0 1px rgba(255,255,255,0.03) inset;
}
.toast.action-loading .action-icon-box {
    background: linear-gradient(135deg, rgba(129,140,248,0.15), rgba(129,140,248,0.05));
    box-shadow: 0 0 16px rgba(129,140,248,0.1);
}
.toast.action-loading .toast-title { color: #a5b4fc; }
.toast.action-loading .action-spinner { display: block; }
.toast.action-loading .action-check,
.toast.action-loading .action-x { opacity: 0; }

/* ── Spinner ── */
.action-spinner {
    display: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: conic-gradient(from 0deg, transparent 0%, transparent 30%, #818cf8 100%);
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2.5px), #000 calc(100% - 2px));
    mask: radial-gradient(farthest-side, transparent calc(100% - 2.5px), #000 calc(100% - 2px));
    animation: actionSpin 1s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes actionSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ── SUCCESS state ── */
.toast.action-success {
    background: linear-gradient(135deg, rgba(14,14,30,0.95), rgba(14,30,20,0.95));
    border-left-color: #4ade80;
    border-color: rgba(74,222,128,0.2);
    box-shadow: 0 12px 40px rgba(0,0,0,0.4), 0 0 20px rgba(74,222,128,0.08), 0 0 0 1px rgba(255,255,255,0.03) inset;
}
.toast.action-success .action-icon-box {
    background: linear-gradient(135deg, rgba(74,222,128,0.15), rgba(74,222,128,0.05));
    box-shadow: 0 0 16px rgba(74,222,128,0.12);
}
.toast.action-success .toast-title { color: #4ade80; }
.toast.action-success .action-spinner { display: none; }
.toast.action-success .action-check {
    opacity: 1;
    stroke: #4ade80;
    stroke-dasharray: 80;
    stroke-dashoffset: 80;
    animation: actionDraw 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.1s forwards;
}

/* ── ERROR state ── */
.toast.action-error {
    background: linear-gradient(135deg, rgba(14,14,30,0.95), rgba(30,14,18,0.95));
    border-left-color: #fb7185;
    border-color: rgba(251,113,133,0.2);
    box-shadow: 0 12px 40px rgba(0,0,0,0.4), 0 0 20px rgba(251,113,133,0.08), 0 0 0 1px rgba(255,255,255,0.03) inset;
}
.toast.action-error .action-icon-box {
    background: linear-gradient(135deg, rgba(251,113,133,0.15), rgba(251,113,133,0.05));
    box-shadow: 0 0 16px rgba(251,113,133,0.12);
}
.toast.action-error .toast-title { color: #fb7185; }
.toast.action-error .action-spinner { display: none; }
.toast.action-error .action-x {
    opacity: 1;
    stroke: #fb7185;
    stroke-dasharray: 80;
    stroke-dashoffset: 80;
    animation: actionDraw 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.1s forwards;
}

/* ── SVG draw animation ── */
@keyframes actionDraw {
    0% { stroke-dashoffset: 80; }
    100% { stroke-dashoffset: 0; }
}

/* ── Inline button spinner (shared across all pages) ── */
.btn-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: conic-gradient(from 0deg, transparent 0%, transparent 30%, #fff 100%);
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 1.5px));
    mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 1.5px));
    animation: actionSpin 1s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    flex-shrink: 0;
    vertical-align: middle;
}
