/**
 * SweetAlert2 Custom Styling
 * Matches the existing jquery-confirm design and theme
 */

/* ===== Toast Notifications ===== */

/* Toast container - allow stacking */
.swal2-container.swal2-top-end,
.swal2-container.toast-container-custom {
    z-index: 10000 !important;
    pointer-events: none !important;
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    width: auto !important;
    height: auto !important;
}

/* Hide backdrop for toasts completely */
.swal2-container.swal2-top-end > .swal2-backdrop-show,
.swal2-container.toast-container-custom > .swal2-backdrop-show {
    display: none !important;
}

body.swal2-toast-shown .swal2-container {
    background-color: transparent !important;
}

.swal2-toast {
    box-sizing: border-box;
    padding: 16px 20px !important;
    border-radius: 8px !important;
    font-family: 'Inter', sans-serif !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
    pointer-events: auto !important;
    position: fixed !important;
    transition: top 0.3s ease !important; /* Smooth repositioning */
}

.swal2-toast .swal2-title {
    font-size: 14px !important;
    font-weight: 500 !important;
    margin: 0 !important;
    line-height: 1.4 !important;
}

/* Toast icons */
.swal2-toast .swal2-icon {
    width: 24px !important;
    height: 24px !important;
    margin: 0 8px 0 0 !important;
}

.swal2-toast .swal2-icon .swal2-icon-content {
    font-size: 16px !important;
}

/* Success toast - use accent color */
.swal2-toast.swal2-icon-success {
    background: var(--accent-color) !important;
    color: #1a1a1a !important;
}

.swal2-toast.swal2-icon-success .swal2-icon,
.swal2-toast.swal2-icon-success .swal2-title {
    color: #1a1a1a !important;
}

/* Error toast */
.swal2-toast.swal2-icon-error {
    background: #ef4444 !important;
    color: white !important;
}

.swal2-toast.swal2-icon-error .swal2-icon,
.swal2-toast.swal2-icon-error .swal2-title {
    color: white !important;
}

/* Warning toast */
.swal2-toast.swal2-icon-warning {
    background: #f59e0b !important;
    color: #1a1a1a !important;
}

.swal2-toast.swal2-icon-warning .swal2-icon,
.swal2-toast.swal2-icon-warning .swal2-title {
    color: #1a1a1a !important;
}

/* Info toast - adapt to theme */
.swal2-toast.swal2-icon-info {
    background: var(--bg-tertiary) !important;
    color: white !important;
}

.swal2-toast.swal2-icon-info .swal2-icon,
.swal2-toast.swal2-icon-info .swal2-title {
    color: white !important;
}

/* Light mode adjustments for info toast */
body.light-mode .swal2-toast.swal2-icon-info {
    background: #1a1a1a !important;
    color: white !important;
}

/* Timer progress bar */
.swal2-toast .swal2-timer-progress-bar {
    background: rgba(0, 0, 0, 0.2) !important;
}

/* Success and warning toasts - darker progress bar */
.swal2-toast.swal2-icon-success .swal2-timer-progress-bar,
.swal2-toast.swal2-icon-warning .swal2-timer-progress-bar {
    background: rgba(0, 0, 0, 0.3) !important;
}

/* Error toast - lighter progress bar */
.swal2-toast.swal2-icon-error .swal2-timer-progress-bar {
    background: rgba(255, 255, 255, 0.3) !important;
}

/* ===== End Toast Notifications ===== */

/* ===== Toastify.js Custom Styles ===== */

/* Toast content wrapper */
.toast-content {
    position: relative;
    width: 100%;
}

.toast-message {
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    line-height: 1.5;
    letter-spacing: 0.01em;
}

/* Progress bar at bottom of toast */
.toast-progress-bar {
    position: absolute;
    bottom: -8px;
    left: -20px;
    right: -20px;
    height: 4px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 0 0 8px 8px;
    overflow: hidden;
}

.toast-progress-bar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    transform-origin: left;
}

/* Progress bar animation */
@keyframes toast-progress {
    from {
        transform: scaleX(1);
    }
    to {
        transform: scaleX(0);
    }
}

/* Apply animation to the ::before pseudo-element */
.toast-progress-bar::before {
    animation-timing-function: linear;
    animation-fill-mode: forwards;
}

/* ===== End Toastify.js Custom Styles ===== */

/* Modern popup styling */
.swal-modern.swal2-popup {
    background: var(--bg-primary) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 12px !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5) !important;
    padding: 0 !important;
    width: 500px !important;
    max-width: calc(100vw - 40px) !important;
}

/* Dark theme popup */
body.dark-theme .swal-modern.swal2-popup {
    background: #2c2c2c !important;
    border-color: #3f3f3f !important;
}

/* Title styling */
.swal-modern .swal2-title {
    color: var(--text-primary) !important;
    font-size: 18px !important;
    font-weight: 600 !important;
    padding: 20px 20px 12px 20px !important;
    border-bottom: 1px solid var(--border-color) !important;
    margin: 0 !important;
}

body.dark-theme .swal-modern .swal2-title {
    color: #ffffff !important;
}

/* Content styling */
.swal-modern .swal2-html-container {
    color: var(--text-primary) !important;
    padding: 16px 20px !important;
    margin: 0 !important;
    line-height: 1.6 !important;
    font-size: 14px !important;
}

body.dark-theme .swal-modern .swal2-html-container {
    color: #b3b3b3 !important;
}

/* Icon container */
.swal-modern .swal2-icon {
    margin: 20px auto 10px !important;
}

/* Actions container */
.swal-modern .swal2-actions {
    padding: 0 20px 20px 20px !important;
    gap: 12px !important;
    justify-content: flex-end !important;
    margin: 0 !important;
}

/* Better button layout for 3-button dialogs */
.swal-modern.swal-choice .swal2-actions {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 10px !important;
    justify-content: space-between !important;
}

/* Button base styles */
.swal-btn {
    border-radius: 8px !important;
    font-weight: 500 !important;
    padding: 12px 24px !important;
    font-size: 14px !important;
    cursor: pointer !important;
    transition: all 0.2s !important;
    border: none !important;
    outline: none !important;
    margin: 0 !important;
}

.swal-btn:focus {
    box-shadow: 0 0 0 3px rgba(30, 136, 229, 0.3) !important;
}

/* Primary button (orange/blue) */
.swal-btn-primary {
    background: var(--accent-color) !important;
    color: white !important;
}

.swal-btn-primary:hover {
    background: var(--accent-hover) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(30, 136, 229, 0.3) !important;
}

/* Danger button (red) */
.swal-btn-danger {
    background: #ef4444 !important;
    color: white !important;
}

.swal-btn-danger:hover {
    background: #dc2626 !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4) !important;
}

/* Secondary button (default) */
.swal-btn-secondary {
    background: var(--bg-secondary) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
}

.swal-btn-secondary:hover {
    background: var(--bg-hover) !important;
    border-color: var(--accent-color) !important;
}

/* Cancel button */
.swal-btn-cancel {
    background: var(--bg-secondary) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-secondary) !important;
}

.swal-btn-cancel:hover {
    background: var(--bg-hover) !important;
    color: var(--text-primary) !important;
}

/* Orange warning buttons (KB mismatch) */
/* Primary button - full width on first row */
.swal-modern.swal-choice .swal-btn-primary {
    background: #f97316 !important;
    flex-basis: 100% !important;
    width: 100% !important;
}

.swal-modern.swal-choice .swal-btn-primary:hover {
    background: #ea580c !important;
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.4) !important;
}

/* Secondary and cancel buttons - share second row (50/50) */
.swal-modern.swal-choice .swal-btn-secondary,
.swal-modern.swal-choice .swal-btn-cancel {
    flex: 1 !important;
    min-width: 0 !important;
}

/* Backdrop */
.swal2-container.swal2-backdrop-show {
    background: rgba(0, 0, 0, 0.7) !important;
    backdrop-filter: blur(5px) !important;
}

/* Animations */
.swal2-show {
    animation: swal2-show 0.2s !important;
}

.swal2-hide {
    animation: swal2-hide 0.2s !important;
}

@keyframes swal2-show {
    0% {
        transform: scale(0.7);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes swal2-hide {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(0.7);
        opacity: 0;
    }
}

/* Z-index - above Speechify widget (9999) */
.swal2-container {
    z-index: 10000 !important;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .swal-modern.swal2-popup {
        width: 90% !important;
        max-width: calc(100vw - 30px) !important;
        margin: 20px !important;
    }
    
    .swal-modern .swal2-title {
        font-size: 16px !important;
        padding: 16px !important;
    }
    
    .swal-modern .swal2-html-container {
        padding: 0 16px 16px 16px !important;
        font-size: 14px !important;
    }
    
    .swal-modern .swal2-actions {
        padding: 0 16px 16px 16px !important;
        gap: 8px !important;
    }
    
    /* Stack buttons on mobile for 2-button dialogs */
    .swal-modern:not(.swal-choice) .swal2-actions {
        flex-direction: row !important;
        gap: 8px !important;
    }
    
    .swal-btn {
        padding: 10px 16px !important;
        font-size: 13px !important;
    }
    
    /* Full width buttons for 3-button choice dialogs */
    .swal-modern.swal-choice .swal2-actions button {
        width: 100% !important;
    }
}

/* Timer progress bar */
.swal2-timer-progress-bar {
    background: var(--accent-color) !important;
}
