/* Modern Dialog — alert, confirm, toast (global) */
#mdOverlay {
    position: fixed;
    inset: 0;
    z-index: 20000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(6px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.22s ease, visibility 0.22s ease;
    pointer-events: none;
}

#mdOverlay.md-show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

#mdOverlay.md-toast-only {
    align-items: flex-start;
    justify-content: flex-end;
    background: transparent;
    backdrop-filter: none;
    pointer-events: none;
    padding: 1rem;
}

.md-card {
    background: linear-gradient(145deg, #ffffff, #f8fafc);
    border-radius: 20px;
    padding: 1.75rem 1.75rem 1.35rem;
    max-width: 420px;
    width: 100%;
    box-shadow: 0 24px 64px rgba(15, 23, 42, 0.22), 0 8px 24px rgba(15, 23, 42, 0.08);
    text-align: center;
    transform: scale(0.92) translateY(8px);
    transition: transform 0.24s cubic-bezier(0.21, 1.02, 0.73, 1);
}

#mdOverlay.md-show .md-card {
    transform: scale(1) translateY(0);
}

.md-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    margin: 0 auto 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: #fff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.md-icon.question { background: linear-gradient(135deg, #6366f1, #4f46e5); }
.md-icon.success { background: linear-gradient(135deg, #22c55e, #16a34a); }
.md-icon.error { background: linear-gradient(135deg, #ef4444, #dc2626); }
.md-icon.warning { background: linear-gradient(135deg, #f59e0b, #d97706); }
.md-icon.info { background: linear-gradient(135deg, #3b82f6, #2563eb); }

.md-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 0.5rem;
    line-height: 1.35;
}

.md-message {
    font-size: 0.95rem;
    color: #64748b;
    line-height: 1.55;
    margin-bottom: 1.25rem;
    white-space: pre-wrap;
    word-break: break-word;
}

.md-actions {
    display: flex;
    gap: 0.65rem;
    justify-content: center;
    flex-wrap: wrap;
}

.md-btn {
    border: none;
    border-radius: 12px;
    padding: 0.65rem 1.35rem;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
    min-width: 100px;
}

.md-btn:hover { transform: translateY(-1px); }
.md-btn:active { transform: translateY(0); }

.md-btn-primary {
    color: #fff;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

.md-btn-success {
    color: #fff;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    box-shadow: 0 4px 14px rgba(34, 197, 94, 0.35);
}

.md-btn-danger {
    color: #fff;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.35);
}

.md-btn-secondary {
    color: #475569;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
}

/* Toast stack — notifikasi global modern */
#mdToastStack {
    position: fixed;
    top: 1.15rem;
    right: 1.15rem;
    z-index: 20100;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: min(440px, calc(100vw - 2rem));
    pointer-events: none;
}

.md-toast {
    pointer-events: auto;
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 18px 18px 20px;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.96));
    border-radius: 18px;
    box-shadow:
        0 24px 56px rgba(15, 23, 42, 0.16),
        0 8px 20px rgba(15, 23, 42, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(226, 232, 240, 0.85);
    backdrop-filter: blur(16px) saturate(1.2);
    -webkit-backdrop-filter: blur(16px) saturate(1.2);
    overflow: hidden;
    animation: mdToastIn 0.42s cubic-bezier(0.21, 1.02, 0.73, 1);
    transform-origin: top right;
}

.md-toast.success {
    background: linear-gradient(145deg, rgba(240, 253, 244, 0.98), rgba(255, 255, 255, 0.97));
    border-color: rgba(34, 197, 94, 0.22);
}
.md-toast.error {
    background: linear-gradient(145deg, rgba(254, 242, 242, 0.98), rgba(255, 255, 255, 0.97));
    border-color: rgba(239, 68, 68, 0.22);
}
.md-toast.warning {
    background: linear-gradient(145deg, rgba(255, 251, 235, 0.98), rgba(255, 255, 255, 0.97));
    border-color: rgba(245, 158, 11, 0.25);
}
.md-toast.info {
    background: linear-gradient(145deg, rgba(239, 246, 255, 0.98), rgba(255, 255, 255, 0.97));
    border-color: rgba(59, 130, 246, 0.22);
}

[data-theme="dark"] .md-toast {
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.96), rgba(15, 23, 42, 0.94));
    border-color: rgba(71, 85, 105, 0.6);
    box-shadow: 0 24px 56px rgba(0, 0, 0, 0.35), 0 4px 16px rgba(0, 0, 0, 0.2);
}
[data-theme="dark"] .md-toast-title { color: #f1f5f9; }
[data-theme="dark"] .md-toast-msg { color: #94a3b8; }
[data-theme="dark"] .md-toast-close { background: rgba(51, 65, 85, 0.8); color: #cbd5e1; }

.md-toast.md-toast-out {
    animation: mdToastOut 0.28s ease forwards;
}

.md-toast::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    border-radius: 16px 0 0 16px;
    background: linear-gradient(180deg, #6366f1, #818cf8);
}

.md-toast.success::before { background: linear-gradient(180deg, #22c55e, #16a34a); }
.md-toast.error::before { background: linear-gradient(180deg, #ef4444, #dc2626); }
.md-toast.warning::before { background: linear-gradient(180deg, #f59e0b, #d97706); }
.md-toast.info::before { background: linear-gradient(180deg, #3b82f6, #2563eb); }

@keyframes mdToastIn {
    from { opacity: 0; transform: translateX(24px) scale(0.94); }
    to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes mdToastOut {
    from { opacity: 1; transform: translateX(0) scale(1); }
    to { opacity: 0; transform: translateX(24px) scale(0.94); }
}

.md-toast.success,
.md-toast.error,
.md-toast.warning,
.md-toast.info {
    border-left-color: transparent;
}

.md-toast-icon {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: #fff;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.14);
    margin-left: 4px;
    position: relative;
}

.md-toast-icon::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 16px;
    opacity: 0.35;
    z-index: -1;
    filter: blur(6px);
}

.md-toast.success .md-toast-icon::after { background: #22c55e; }
.md-toast.error .md-toast-icon::after { background: #ef4444; }
.md-toast.warning .md-toast-icon::after { background: #f59e0b; }
.md-toast.info .md-toast-icon::after { background: #3b82f6; }

.md-toast.success .md-toast-icon { background: linear-gradient(135deg, #22c55e, #16a34a); }
.md-toast.error .md-toast-icon { background: linear-gradient(135deg, #ef4444, #dc2626); }
.md-toast.warning .md-toast-icon { background: linear-gradient(135deg, #f59e0b, #d97706); }
.md-toast.info .md-toast-icon { background: linear-gradient(135deg, #3b82f6, #2563eb); }

.md-toast-body { flex: 1; min-width: 0; padding-top: 2px; }
.md-toast-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: #0f172a;
    margin-bottom: 4px;
    line-height: 1.35;
    letter-spacing: -0.01em;
}
.md-toast-msg {
    font-size: 0.86rem;
    color: #64748b;
    line-height: 1.5;
    word-break: break-word;
}

/* Sembunyikan toast Bootstrap lama (implementasi notifikasi sebelumnya) */
#toast-container,
#toastContainer {
    display: none !important;
    pointer-events: none !important;
}

.md-toast-close {
    background: #f1f5f9;
    border: none;
    color: #64748b;
    font-size: 1rem;
    line-height: 1;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}

.md-toast-close:hover {
    background: #e2e8f0;
    color: #334155;
}

.md-toast-progress {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    background: rgba(226, 232, 240, 0.6);
    overflow: hidden;
}

.md-toast-progress-bar {
    height: 100%;
    width: 100%;
    transform-origin: left;
    animation: mdToastProgress linear forwards;
}

.md-toast.success .md-toast-progress-bar { background: linear-gradient(90deg, #22c55e, #4ade80); }
.md-toast.error .md-toast-progress-bar { background: linear-gradient(90deg, #ef4444, #f87171); }
.md-toast.warning .md-toast-progress-bar { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.md-toast.info .md-toast-progress-bar { background: linear-gradient(90deg, #3b82f6, #60a5fa); }

@keyframes mdToastProgress {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

@media (max-width: 480px) {
    #mdToastStack {
        top: auto;
        bottom: 5.5rem;
        right: 0.75rem;
        left: 0.75rem;
        max-width: none;
    }
    .md-toast {
        border-radius: 14px;
    }
}

@media (max-width: 480px) {
    .md-card { padding: 1.35rem 1.15rem 1rem; border-radius: 16px; }
    .md-actions { flex-direction: column-reverse; }
    .md-btn { width: 100%; }
}
