/**
 * 现代化 SweetAlert 提示框美化样式
 * Modern SweetAlert Beautify Styles
 * Design: Glassmorphism + Gradient + Smooth Animations
 */

/* ==================== CSS Variables ==================== */
:root {
    --swal-primary: #667eea;
    --swal-primary-dark: #5568d3;
    --swal-secondary: #764ba2;
    --swal-success: #4facfe;
    --swal-success-dark: #00d2ff;
    --swal-warning: #ff9f43;
    --swal-warning-dark: #ffc107;
    --swal-danger: #ff6b6b;
    --swal-danger-dark: #ee5a24;
    --swal-info: #54a0ff;
    --swal-bg: rgba(255, 255, 255, 0.95);
    --swal-shadow: 0 25px 80px rgba(0, 0, 0, 0.3);
    --swal-radius: 20px;
}

/* ==================== Overlay ==================== */
.sweet-overlay {
    background-color: rgba(0, 0, 0, 0.6) !important;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    display: none;
    z-index: 99999;
    animation: fadeInOverlay 0.3s ease;
}

@keyframes fadeInOverlay {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ==================== Alert Container ==================== */
.sweet-alert {
    background: var(--swal-bg) !important;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif !important;
    width: 420px !important;
    max-width: 90vw;
    padding: 0 !important;
    border-radius: var(--swal-radius) !important;
    text-align: center;
    position: fixed;
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
    margin: 0 !important;
    overflow: hidden;
    display: none;
    z-index: 100000;
    box-shadow: var(--swal-shadow) !important;
    border: 1px solid rgba(255, 255, 255, 0.3);
    animation: showSweetAlert 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes showSweetAlert {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.02);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Hide SweetAlert Animation */
.hideSweetAlert {
    animation: hideSweetAlert 0.3s ease forwards !important;
}

@keyframes hideSweetAlert {
    from {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    to {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
}

/* ==================== Card Content ==================== */
.swal-card {
    padding: 35px 30px 30px;
}

.swal-card__icon {
    width: 90px;
    height: 90px;
    margin: 0 auto 25px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.swal-card__icon::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    animation: pulseRing 1.5s infinite;
    opacity: 0;
}

.swal-card__icon i {
    font-size: 42px;
    color: #fff;
}

/* Success Icon */
.swal-card__icon--success {
    background: linear-gradient(135deg, var(--swal-success) 0%, var(--swal-success-dark) 100%);
    box-shadow: 0 10px 30px rgba(79, 172, 254, 0.4);
}

.swal-card__icon--success::before {
    background: rgba(79, 172, 254, 0.3);
}

.swal-card__icon--success .sa-icon.sa-success {
    border: none !important;
    background: transparent !important;
    width: 100% !important;
    height: 100% !important;
    border-radius: 50% !important;
    animation: none !important;
}

.swal-card__icon--success .sa-icon.sa-success::before,
.swal-card__icon--success .sa-icon.sa-success::after {
    display: none !important;
}

.swal-card__icon--success .sa-placeholder,
.swal-card__icon--success .sa-fix {
    display: none !important;
}

.swal-card__icon--success .sa-line {
    display: none !important;
}

/* Success Checkmark SVG */
.swal-card__icon--success .sa-icon.sa-success::after {
    content: '' !important;
    display: block !important;
    width: 30px;
    height: 50px;
    border: solid #fff;
    border-width: 0 4px 4px 0;
    transform: rotate(45deg);
    position: absolute;
    left: 30px;
    top: 20px;
}

@keyframes pulseRing {
    0% {
        transform: scale(1);
        opacity: 0.5;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

/* Error Icon */
.swal-card__icon--error {
    background: linear-gradient(135deg, var(--swal-danger) 0%, var(--swal-danger-dark) 100%);
    box-shadow: 0 10px 30px rgba(255, 107, 107, 0.4);
}

.swal-card__icon--error::before {
    background: rgba(255, 107, 107, 0.3);
}

.swal-card__icon--error .sa-icon.sa-error {
    border: none !important;
    background: transparent !important;
    width: 100% !important;
    height: 100% !important;
}

.swal-card__icon--error .sa-icon.sa-error .sa-x-mark,
.swal-card__icon--error .sa-icon.sa-error .sa-line {
    display: none !important;
}

/* Error X */
.swal-card__icon--error .sa-icon.sa-error::before,
.swal-card__icon--error .sa-icon.sa-error::after {
    content: '' !important;
    position: absolute !important;
    width: 4px !important;
    height: 35px !important;
    background: #fff !important;
    border-radius: 2px !important;
    left: 50% !important;
    top: 50% !important;
    margin-left: -2px !important;
    margin-top: -17px !important;
}

.swal-card__icon--error .sa-icon.sa-error::before {
    transform: rotate(45deg) !important;
}

.swal-card__icon--error .sa-icon.sa-error::after {
    transform: rotate(-45deg) !important;
}

/* Warning Icon */
.swal-card__icon--warning {
    background: linear-gradient(135deg, var(--swal-warning) 0%, var(--swal-warning-dark) 100%);
    box-shadow: 0 10px 30px rgba(255, 159, 67, 0.4);
}

.swal-card__icon--warning::before {
    background: rgba(255, 159, 67, 0.3);
}

.swal-card__icon--warning .sa-icon.sa-warning {
    border: none !important;
    background: transparent !important;
    width: 100% !important;
    height: 100% !important;
}

.swal-card__icon--warning .sa-icon.sa-warning .sa-body,
.swal-card__icon--warning .sa-icon.sa-warning .sa-dot {
    display: none !important;
}

/* Warning Exclamation */
.swal-card__icon--warning .sa-icon.sa-warning::before {
    content: '!' !important;
    font-size: 42px !important;
    font-weight: 700 !important;
    color: #fff !important;
    position: absolute !important;
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
    margin: 0 !important;
    background: transparent !important;
    width: auto !important;
    height: auto !important;
    border-radius: 0 !important;
}

/* Info Icon */
.swal-card__icon--info {
    background: linear-gradient(135deg, var(--swal-info) 0%, #2e86de 100%);
    box-shadow: 0 10px 30px rgba(84, 160, 255, 0.4);
}

.swal-card__icon--info::before {
    background: rgba(84, 160, 255, 0.3);
}

.swal-card__icon--info .sa-icon.sa-info {
    border: none !important;
    background: transparent !important;
    width: 100% !important;
    height: 100% !important;
}

.swal-card__icon--info .sa-icon.sa-info::before,
.swal-card__icon--info .sa-icon.sa-info::after {
    display: none !important;
}

/* Info i */
.swal-card__icon--info .sa-icon.sa-info::before {
    content: 'i' !important;
    font-size: 42px !important;
    font-weight: 700 !important;
    font-style: italic !important;
    color: #fff !important;
    position: absolute !important;
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
    margin: 0 !important;
    background: transparent !important;
    width: auto !important;
    height: auto !important;
    border-radius: 0 !important;
}

/* Question Icon */
.swal-card__icon--question {
    background: linear-gradient(135deg, var(--swal-primary) 0%, var(--swal-secondary) 100%);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.4);
}

.swal-card__icon--question::before {
    background: rgba(102, 126, 234, 0.3);
}

/* ==================== Title & Content ==================== */
.sweet-alert h2 {
    color: #2c3e50 !important;
    font-size: 24px !important;
    font-weight: 700 !important;
    margin: 0 0 15px !important;
    padding: 0 !important;
    line-height: 1.3 !important;
    text-transform: none !important;
}

.sweet-alert p {
    color: #606f7b !important;
    font-size: 15px !important;
    font-weight: 400 !important;
    margin: 0 !important;
    padding: 0 10px !important;
    line-height: 1.6 !important;
    text-align: center !important;
    float: none !important;
}

/* ==================== Error Container ==================== */
.sweet-alert .sa-error-container {
    background: linear-gradient(135deg, rgba(255, 107, 107, 0.1) 0%, rgba(238, 90, 36, 0.1) 100%);
    margin: 15px -30px 0 !important;
    padding: 15px 20px !important;
    border-radius: 12px !important;
    display: none;
    animation: slideInError 0.3s ease;
}

.sweet-alert .sa-error-container.show {
    display: block !important;
}

@keyframes slideInError {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.sweet-alert .sa-error-container .icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--swal-danger);
    color: white;
    font-size: 16px;
    font-weight: 700;
    margin-right: 10px;
}

.sweet-alert .sa-error-container p {
    display: inline;
    color: var(--swal-danger);
    font-weight: 500;
}

/* ==================== Input Field ==================== */
.sweet-alert fieldset {
    border: none;
    padding: 0;
    margin: 25px 0 0;
}

.sweet-alert .sa-input-container {
    margin: 0;
}

.sweet-alert input {
    width: 100% !important;
    box-sizing: border-box !important;
    border: 2px solid #e0e0e0 !important;
    border-radius: 12px !important;
    padding: 14px 18px !important;
    font-size: 16px !important;
    color: #2c3e50 !important;
    transition: all 0.3s ease !important;
    margin: 0 !important;
    background: #f8f9fa !important;
    box-shadow: none !important;
}

.sweet-alert input:focus {
    outline: none !important;
    border-color: var(--swal-primary) !important;
    background: #fff !important;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1) !important;
    transform: translateY(-2px);
}

.sweet-alert input::-webkit-input-placeholder {
    color: #95a5a6;
}

.sweet-alert input::-moz-placeholder {
    color: #95a5a6;
}

/* ==================== Buttons ==================== */
.sweet-alert .sa-button-container {
    display: flex !important;
    justify-content: center;
    gap: 12px;
    margin: 30px 0 0;
    padding: 0 30px 30px;
}

.sweet-alert button {
    background: linear-gradient(135deg, var(--swal-primary) 0%, var(--swal-secondary) 100%) !important;
    color: white !important;
    border: none !important;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.35) !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    border-radius: 12px !important;
    padding: 14px 35px !important;
    margin: 0 !important;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.sweet-alert button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s ease;
}

.sweet-alert button:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.45) !important;
}

.sweet-alert button:hover::before {
    left: 100%;
}

.sweet-alert button:active {
    transform: translateY(0);
}

.sweet-alert button:focus {
    outline: none !important;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.35), 0 0 0 3px rgba(102, 126, 234, 0.2) !important;
}

/* Cancel Button */
.sweet-alert button.cancel {
    background: #f0f2f5 !important;
    color: #606f7b !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08) !important;
}

.sweet-alert button.cancel:hover {
    background: #e9ecef !important;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12) !important;
}

.sweet-alert button.cancel::before {
    background: linear-gradient(90deg, transparent, rgba(0,0,0,0.05), transparent);
}

/* Confirm Button (success style) */
.sweet-alert button.confirm {
    background: linear-gradient(135deg, var(--swal-success) 0%, var(--swal-success-dark) 100%) !important;
    box-shadow: 0 6px 20px rgba(79, 172, 254, 0.35) !important;
}

.sweet-alert button.confirm:hover {
    box-shadow: 0 10px 30px rgba(79, 172, 254, 0.45) !important;
}

/* Danger Button */
.sweet-alert button.danger {
    background: linear-gradient(135deg, var(--swal-danger) 0%, var(--swal-danger-dark) 100%) !important;
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.35) !important;
}

.sweet-alert button.danger:hover {
    box-shadow: 0 10px 30px rgba(255, 107, 107, 0.45) !important;
}

/* Warning Button */
.sweet-alert button.warning {
    background: linear-gradient(135deg, var(--swal-warning) 0%, var(--swal-warning-dark) 100%) !important;
    box-shadow: 0 6px 20px rgba(255, 159, 67, 0.35) !important;
}

.sweet-alert button.warning:hover {
    box-shadow: 0 10px 30px rgba(255, 159, 67, 0.45) !important;
}

/* Disabled State */
.sweet-alert button[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.sweet-alert button[disabled]:hover {
    transform: none !important;
}

/* ==================== Loading Animation ==================== */
.sweet-alert .la-ball-fall {
    position: absolute;
    left: 50%;
    top: 50%;
    margin-left: -27px;
    margin-top: 4px;
    opacity: 0;
    visibility: hidden;
}

.sweet-alert button.confirm[disabled] {
    color: transparent !important;
}

.sweet-alert button.confirm[disabled] ~ .la-ball-fall {
    opacity: 1;
    visibility: visible;
    color: #fff;
}

.la-ball-fall > div {
    background-color: #fff !important;
}

/* ==================== Input Error ==================== */
.sweet-alert .sa-input-error {
    position: absolute;
    top: 50%;
    right: 15px;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    opacity: 0;
    transition: all 0.3s ease;
}

.sweet-alert .sa-input-error.show {
    opacity: 1;
    transform: translateY(-50%) scale(1);
}

.sweet-alert .sa-input-error::before,
.sweet-alert .sa-input-error::after {
    background-color: var(--swal-danger);
}

/* ==================== Custom Icon Style ==================== */
.sweet-alert .sa-icon.sa-custom {
    background-size: contain;
    border-radius: 50%;
    border: none;
    width: 90px !important;
    height: 90px !important;
    margin: 0 auto 25px;
}

/* ==================== Responsive ==================== */
@media all and (max-width: 480px) {
    .sweet-alert {
        width: calc(100vw - 40px) !important;
        max-width: none !important;
        border-radius: 16px !important;
    }
    
    .swal-card {
        padding: 30px 25px 25px;
    }
    
    .swal-card__icon {
        width: 75px;
        height: 75px;
    }
    
    .swal-card__icon i {
        font-size: 36px;
    }
    
    .sweet-alert h2 {
        font-size: 20px !important;
    }
    
    .sweet-alert p {
        font-size: 14px !important;
    }
    
    .sweet-alert .sa-button-container {
        flex-direction: column;
        padding: 0 25px 25px;
    }
    
    .sweet-alert button {
        width: 100%;
    }
    
    .sweet-alert .sa-error-container {
        margin: 15px -25px 0 !important;
    }
}

@media all and (max-width: 360px) {
    .swal-card {
        padding: 25px 20px 20px;
    }
    
    .sweet-alert button {
        padding: 12px 25px !important;
        font-size: 14px !important;
    }
}

/* ==================== Animation Overrides ==================== */
.showSweetAlert[data-animation=pop] {
    animation: showSweetAlert 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
}

.showSweetAlert[data-animation=slide-from-top] {
    animation: slideFromTop 0.4s ease !important;
}

.showSweetAlert[data-animation=slide-from-bottom] {
    animation: slideFromBottom 0.4s ease !important;
}

@keyframes slideFromTop {
    0% {
        top: 0%;
        opacity: 0;
        transform: translate(-50%, 0) scale(0.9);
    }
    100% {
        top: 50%;
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

@keyframes slideFromBottom {
    0% {
        top: 100%;
        opacity: 0;
        transform: translate(-50%, 0) scale(0.9);
    }
    100% {
        top: 50%;
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.hideSweetAlert[data-animation=pop] {
    animation: hideSweetAlert 0.3s ease forwards !important;
}

.hideSweetAlert[data-animation=slide-from-top] {
    animation: hideToTop 0.3s ease forwards !important;
}

.hideSweetAlert[data-animation=slide-from-bottom] {
    animation: hideToBottom 0.3s ease forwards !important;
}

@keyframes hideToTop {
    0% {
        top: 50%;
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        top: 0%;
        opacity: 0;
        transform: translate(-50%, -100%) scale(0.9);
    }
}

@keyframes hideToBottom {
    0% {
        top: 50%;
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        top: 100%;
        opacity: 0;
        transform: translate(-50%, 0) scale(0.9);
    }
}

/* ==================== Success Animation ==================== */
.animateSuccessTip {
    -webkit-animation: animateSuccessTip 0.75s;
    animation: animateSuccessTip 0.75s;
}

@keyframes animateSuccessTip {
    0% {
        width: 0;
        left: 1px;
        top: 19px;
    }
    54% {
        width: 0;
        left: 1px;
        top: 19px;
    }
    70% {
        width: 50px;
        left: -8px;
        top: 37px;
    }
    84% {
        width: 17px;
        left: 21px;
        top: 48px;
    }
    100% {
        width: 25px;
        left: 14px;
        top: 45px;
    }
}

.animateSuccessLong {
    -webkit-animation: animateSuccessLong 0.75s;
    animation: animateSuccessLong 0.75s;
}

@keyframes animateSuccessLong {
    0% {
        width: 0;
        right: 46px;
        top: 54px;
    }
    65% {
        width: 0;
        right: 46px;
        top: 54px;
    }
    84% {
        width: 55px;
        right: 0px;
        top: 35px;
    }
    100% {
        width: 47px;
        right: 8px;
        top: 38px;
    }
}

/* ==================== Error Animation ==================== */
.animateErrorIcon {
    -webkit-animation: animateErrorIcon 0.5s;
    animation: animateErrorIcon 0.5s;
}

@keyframes animateErrorIcon {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.animateXMark {
    -webkit-animation: animateXMark 0.5s;
    animation: animateXMark 0.5s;
}

@keyframes animateXMark {
    0% {
        transform: scale(0);
        opacity: 0;
        margin-top: 26px;
    }
    50% {
        transform: scale(1.2);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        margin-top: 0;
    }
}

/* ==================== Warning Pulse ==================== */
.pulseWarning {
    -webkit-animation: pulseWarning 0.75s infinite alternate;
    animation: pulseWarning 0.75s infinite alternate;
}

@keyframes pulseWarning {
    0% {
        transform: scale(0.95);
    }
    100% {
        transform: scale(1.05);
    }
}

.pulseWarningIns {
    -webkit-animation: pulseWarningIns 0.75s infinite alternate;
    animation: pulseWarningIns 0.75s infinite alternate;
}

/* ==================== Dark Mode Support ==================== */
@media (prefers-color-scheme: dark) {
    body.dark-swal .sweet-alert {
        background: rgba(30, 30, 40, 0.98) !important;
    }
    
    body.dark-swal .sweet-alert h2 {
        color: #fff !important;
    }
    
    body.dark-swal .sweet-alert p {
        color: rgba(255, 255, 255, 0.7) !important;
    }
}

/* ==================== Type-specific Styles ==================== */

/* Success */
.sweet-alert[data-type="success"] .sa-icon {
    border-color: var(--swal-success) !important;
}

/* Error */
.sweet-alert[data-type="error"] .sa-icon {
    border-color: var(--swal-danger) !important;
}

/* Warning */
.sweet-alert[data-type="warning"] .sa-icon {
    border-color: var(--swal-warning) !important;
}

/* Info */
.sweet-alert[data-type="info"] .sa-icon {
    border-color: var(--swal-info) !important;
}
