/**
 * ═══════════════════════════════════════════════════════════════════════════════
 * SIANOR ENTERPRISE TOAST & CUSTOM MODAL SYSTEM
 * High-performance, lightweight, zero-dependency, floating & accessible.
 * ═══════════════════════════════════════════════════════════════════════════════
 */

/* ── 1. Floating Toast Notification Container ── */
.sianor-toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 999999;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
    max-width: 420px;
    width: calc(100% - 48px);
    box-sizing: border-box;
}

/* ── 2. Toast Card Component ── */
.sianor-toast {
    pointer-events: auto;
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px 18px 18px;
    border-radius: 16px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 20px 40px -10px rgba(15, 23, 42, 0.16),
                0 0 0 1px rgba(241, 245, 249, 0.8);
    color: #0f172a;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: 0.88rem;
    line-height: 1.45;
    overflow: hidden;
    box-sizing: border-box;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    animation: sianorToastSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.sianor-toast.sianor-toast-hiding {
    animation: sianorToastSlideOut 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes sianorToastSlideIn {
    from {
        opacity: 0;
        transform: translateX(110%) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes sianorToastSlideOut {
    from {
        opacity: 1;
        transform: translateX(0) scale(1);
        max-height: 200px;
        margin-bottom: 0;
    }
    to {
        opacity: 0;
        transform: translateX(110%) scale(0.9);
        max-height: 0;
        padding-top: 0;
        padding-bottom: 0;
        margin-bottom: -12px;
        border-width: 0;
    }
}

/* ── 3. Toast Types & Color Coding ── */
/* Success */
.sianor-toast-success {
    background: #0f172a;
    border-color: rgba(16, 185, 129, 0.35);
    color: #ffffff;
    box-shadow: 0 20px 40px -10px rgba(15, 23, 42, 0.4), 0 0 0 1px rgba(16, 185, 129, 0.2);
}
.sianor-toast-success .sianor-toast-icon {
    color: #10b981;
    background: rgba(16, 185, 129, 0.15);
}
.sianor-toast-success .sianor-toast-progress-fill {
    background: #10b981;
}
.sianor-toast-success .sianor-toast-close {
    color: #94a3b8;
}
.sianor-toast-success .sianor-toast-close:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
}
.sianor-toast-success .sianor-toast-title {
    color: #ffffff;
}
.sianor-toast-success .sianor-toast-msg {
    color: #cbd5e1;
}

/* Error */
.sianor-toast-error {
    background: #ffffff;
    border-color: #fecaca;
    color: #0f172a;
    border-left: 4px solid #ef4444;
}
.sianor-toast-error .sianor-toast-icon {
    color: #ef4444;
    background: #fef2f2;
}
.sianor-toast-error .sianor-toast-progress-fill {
    background: #ef4444;
}

/* Warning */
.sianor-toast-warning {
    background: #ffffff;
    border-color: #fde68a;
    color: #0f172a;
    border-left: 4px solid #f59e0b;
}
.sianor-toast-warning .sianor-toast-icon {
    color: #d97706;
    background: #fffbeb;
}
.sianor-toast-warning .sianor-toast-progress-fill {
    background: #f59e0b;
}

/* Info */
.sianor-toast-info {
    background: #ffffff;
    border-color: #bae6fd;
    color: #0f172a;
    border-left: 4px solid #0284c7;
}
.sianor-toast-info .sianor-toast-icon {
    color: #0284c7;
    background: #f0f9ff;
}
.sianor-toast-info .sianor-toast-progress-fill {
    background: #0284c7;
}

/* ── 4. Toast Internal Anatomy ── */
.sianor-toast-icon {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    margin-top: 1px;
}

.sianor-toast-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding-right: 6px;
}

.sianor-toast-title {
    font-weight: 700;
    font-size: 0.88rem;
    color: #0f172a;
    letter-spacing: -0.2px;
}

.sianor-toast-msg {
    font-size: 0.84rem;
    color: #475569;
    word-break: break-word;
}

.sianor-toast-close {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    width: 26px;
    height: 26px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    transition: all 0.15s ease;
    flex-shrink: 0;
    margin-top: -2px;
    margin-right: -4px;
}
.sianor-toast-close:hover {
    color: #0f172a;
    background: #f1f5f9;
}

/* ── 5. Toast Progress Timeout Bar ── */
.sianor-toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: rgba(0, 0, 0, 0.05);
}
.sianor-toast-progress-fill {
    height: 100%;
    width: 100%;
    transform-origin: left;
    transition: transform linear;
}

/* Pause on Hover / Focus */
.sianor-toast:hover .sianor-toast-progress-fill,
.sianor-toast:focus-within .sianor-toast-progress-fill {
    animation-play-state: paused !important;
}

/* ── 6. Custom Modal Dialog System ── */
.sianor-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000000;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.25s;
}
.sianor-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.sianor-modal-dialog {
    width: 100%;
    max-width: 480px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 22px;
    box-shadow: 0 25px 60px -15px rgba(15, 23, 42, 0.25), 0 0 0 1px rgba(241, 245, 249, 0.9);
    padding: 28px 26px 24px;
    position: relative;
    box-sizing: border-box;
    transform: scale(0.94) translateY(12px);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}
.sianor-modal-overlay.active .sianor-modal-dialog {
    transform: scale(1) translateY(0);
}

.sianor-modal-head {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 16px;
}
.sianor-modal-icon-badge {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}
.sianor-modal-icon-badge.danger {
    background: #fef2f2;
    color: #ef4444;
    border: 1px solid #fecaca;
}
.sianor-modal-icon-badge.warning {
    background: #fffbeb;
    color: #d97706;
    border: 1px solid #fde68a;
}
.sianor-modal-icon-badge.info {
    background: #f0f9ff;
    color: #0284c7;
    border: 1px solid #bae6fd;
}
.sianor-modal-icon-badge.success {
    background: #ecfdf5;
    color: #059669;
    border: 1px solid #a7f3d0;
}

.sianor-modal-head-text {
    flex: 1;
    min-width: 0;
}
.sianor-modal-title {
    font-family: 'Space Grotesk', -apple-system, sans-serif;
    font-size: 1.2rem;
    font-weight: 800;
    color: #0f172a;
    margin: 0 0 4px;
    line-height: 1.25;
    letter-spacing: -0.4px;
}
.sianor-modal-sub {
    font-size: 0.8rem;
    color: #64748b;
    margin: 0;
}

.sianor-modal-close {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.15s ease;
    flex-shrink: 0;
}
.sianor-modal-close:hover {
    color: #0f172a;
    background: #f1f5f9;
}

.sianor-modal-body {
    font-size: 0.92rem;
    color: #334155;
    line-height: 1.55;
    margin-bottom: 24px;
    overflow-y: auto;
    padding-right: 4px;
}
.sianor-modal-body ul {
    margin: 8px 0 0 0;
    padding-left: 20px;
    color: #dc2626;
    font-size: 0.85rem;
}
.sianor-modal-body ul li {
    margin-bottom: 4px;
}

.sianor-modal-foot {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid #f1f5f9;
}

.sianor-modal-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 12px;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    text-decoration: none;
    border: none;
    min-width: 100px;
    box-sizing: border-box;
}
.sianor-modal-btn.cancel {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
}
.sianor-modal-btn.cancel:hover {
    background: #e2e8f0;
    color: #0f172a;
}
.sianor-modal-btn.danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}
.sianor-modal-btn.danger:hover {
    background: linear-gradient(135deg, #f87171 0%, #dc2626 100%);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(239, 68, 68, 0.4);
}
.sianor-modal-btn.primary {
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3);
}
.sianor-modal-btn.primary:hover {
    background: linear-gradient(135deg, #fb923c 0%, #ea580c 100%);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(249, 115, 22, 0.4);
}

/* ── 7. Responsive Adjustments ── */
@media (max-width: 640px) {
    .sianor-toast-container {
        top: 12px;
        left: 12px;
        right: 12px;
        width: calc(100% - 24px);
        max-width: none;
    }
    .sianor-toast {
        padding: 14px 14px 16px;
        border-radius: 14px;
    }
    .sianor-modal-dialog {
        padding: 22px 18px 18px;
        border-radius: 18px;
    }
    .sianor-modal-foot {
        flex-direction: column-reverse;
        gap: 8px;
    }
    .sianor-modal-btn {
        width: 100%;
    }
}
