/* ============================================
   Metsuda Corp - Notifications & Loading System
   ============================================ */

/* ---- Toast Notifications ---- */
.metsuda-toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    max-width: 420px;
    width: calc(100% - 40px);
}

.metsuda-toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 20px;
    border-radius: 12px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 32px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.08);
    pointer-events: auto;
    transform: translateX(120%);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.22, 1, 0.36, 1);
    position: relative;
    overflow: hidden;
}

.metsuda-toast.show {
    transform: translateX(0);
    opacity: 1;
}

.metsuda-toast.hiding {
    transform: translateX(120%);
    opacity: 0;
}

.metsuda-toast-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.metsuda-toast-body {
    flex: 1;
    min-width: 0;
}

.metsuda-toast-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.metsuda-toast-message {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
    word-wrap: break-word;
}

.metsuda-toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    font-size: 16px;
    line-height: 1;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.metsuda-toast-close:hover {
    opacity: 1;
}

.metsuda-toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    border-radius: 0 0 12px 12px;
    transition: width linear;
}

/* Toast Types */
.metsuda-toast.toast-success .metsuda-toast-icon {
    background: rgba(16, 185, 129, 0.12);
    color: var(--success-color);
}
.metsuda-toast.toast-success .metsuda-toast-progress {
    background: var(--success-color);
}

.metsuda-toast.toast-error .metsuda-toast-icon {
    background: rgba(239, 68, 68, 0.12);
    color: var(--error-color);
}
.metsuda-toast.toast-error .metsuda-toast-progress {
    background: var(--error-color);
}

.metsuda-toast.toast-warning .metsuda-toast-icon {
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
}
.metsuda-toast.toast-warning .metsuda-toast-progress {
    background: #f59e0b;
}

.metsuda-toast.toast-info .metsuda-toast-icon {
    background: rgba(37, 99, 235, 0.12);
    color: var(--primary-color);
}
.metsuda-toast.toast-info .metsuda-toast-progress {
    background: var(--primary-color);
}

/* ---- Page Loading Overlay ---- */
.metsuda-page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 99998;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.metsuda-page-loader.active {
    opacity: 1;
    visibility: visible;
}

.metsuda-loader-content {
    background: var(--surface);
    border-radius: 16px;
    padding: 32px 40px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    text-align: center;
    min-width: 200px;
}

.metsuda-spinner {
    width: 44px;
    height: 44px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: metsudaSpin 0.8s linear infinite;
}

.metsuda-loader-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.metsuda-loader-subtext {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: -8px;
}

@keyframes metsudaSpin {
    to { transform: rotate(360deg); }
}

/* ---- Success Animation Overlay ---- */
.metsuda-success-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 99998;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.metsuda-success-overlay.active {
    opacity: 1;
    visibility: visible;
}

.metsuda-success-content {
    background: var(--surface);
    border-radius: 20px;
    padding: 40px 48px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    text-align: center;
    transform: scale(0.8);
    transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.metsuda-success-overlay.active .metsuda-success-content {
    transform: scale(1);
}

.metsuda-success-circle {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: rgba(16, 185, 129, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.metsuda-success-circle svg {
    width: 36px;
    height: 36px;
}

.metsuda-success-circle .checkmark-path {
    stroke: var(--success-color);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
}

.metsuda-success-overlay.active .metsuda-success-circle .checkmark-path {
    animation: metsudaCheckDraw 0.5s 0.3s ease forwards;
}

.metsuda-success-circle .circle-path {
    stroke: var(--success-color);
    stroke-width: 2.5;
    fill: none;
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    opacity: 0.3;
}

.metsuda-success-overlay.active .metsuda-success-circle .circle-path {
    animation: metsudaCircleDraw 0.6s 0.1s ease forwards;
}

.metsuda-success-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.metsuda-success-message {
    font-size: 14px;
    color: var(--text-secondary);
    max-width: 280px;
    line-height: 1.5;
}

@keyframes metsudaCheckDraw {
    to { stroke-dashoffset: 0; }
}

@keyframes metsudaCircleDraw {
    to { stroke-dashoffset: 0; }
}

/* ---- Pulse ring on success circle ---- */
.metsuda-success-circle::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid var(--success-color);
    opacity: 0;
}

.metsuda-success-overlay.active .metsuda-success-circle::after {
    animation: metsudaPulseRing 0.8s 0.5s ease forwards;
}

@keyframes metsudaPulseRing {
    0% { transform: scale(1); opacity: 0.6; }
    100% { transform: scale(1.5); opacity: 0; }
}

/* ---- Button Loading States ---- */
.btn.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.75;
}

.btn.btn-loading .btn-text {
    visibility: hidden;
}

.btn.btn-loading::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: metsudaSpin 0.6s linear infinite;
}

.btn-outline.btn-loading::after {
    border-color: rgba(37, 99, 235, 0.2);
    border-top-color: var(--primary-color);
}

.btn-danger.btn-loading::after {
    border-color: rgba(255,255,255,0.3);
    border-top-color: #fff;
}

/* ---- Top Progress Bar ---- */
.metsuda-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color), #8b5cf6, var(--primary-color));
    background-size: 200% 100%;
    z-index: 99999;
    transition: width 0.3s ease;
    animation: metsudaProgressShimmer 1.5s linear infinite;
    border-radius: 0 2px 2px 0;
    opacity: 0;
    visibility: hidden;
}

.metsuda-progress-bar.active {
    opacity: 1;
    visibility: visible;
}

@keyframes metsudaProgressShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ---- Enhanced Alert Styles (upgrade existing) ---- */
.alert {
    animation: metsudaSlideDown 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.alert-success i {
    animation: metsudaBounceIn 0.5s 0.2s ease both;
}

@keyframes metsudaSlideDown {
    from {
        opacity: 0;
        transform: translateY(-16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes metsudaBounceIn {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* ---- Confirm Dialog ---- */
.metsuda-confirm-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 99998;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.metsuda-confirm-overlay.active {
    opacity: 1;
    visibility: visible;
}

.metsuda-confirm-box {
    background: var(--surface);
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    max-width: 400px;
    width: calc(100% - 40px);
    text-align: center;
    transform: scale(0.9) translateY(10px);
    transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.metsuda-confirm-overlay.active .metsuda-confirm-box {
    transform: scale(1) translateY(0);
}

.metsuda-confirm-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.metsuda-confirm-icon.confirm-danger {
    background: rgba(239, 68, 68, 0.12);
    color: var(--error-color);
}

.metsuda-confirm-icon.confirm-warning {
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
}

.metsuda-confirm-icon.confirm-info {
    background: rgba(37, 99, 235, 0.12);
    color: var(--primary-color);
}

.metsuda-confirm-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.metsuda-confirm-message {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 24px;
}

.metsuda-confirm-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.metsuda-confirm-actions .btn {
    min-width: 100px;
    padding: 10px 20px;
    font-size: 14px;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .metsuda-toast-container {
        top: 12px;
        right: 12px;
        left: 12px;
        max-width: none;
        width: auto;
    }

    .metsuda-toast {
        padding: 12px 16px;
    }

    .metsuda-loader-content {
        padding: 24px 32px;
    }

    .metsuda-success-content {
        padding: 32px;
    }
}
