/**
 * SweetAlert2 Theme - Design Token Integration
 *
 * All styling uses project design tokens from variables.css.
 * Theme switching (light/dark) works automatically via semantic tokens.
 * Button colors are CSS-driven - no inline styles from JS.
 */


/* =============================================================================
   1. SWAL-SPECIFIC CUSTOM PROPERTIES
   ============================================================================= */

:root {
    --swal-bg: var(--bg-primary);
    --swal-text: var(--text-primary);
    --swal-text-secondary: var(--text-secondary);
    --swal-border: var(--border-default);
    --swal-overlay: var(--overlay-bg);
    --swal-radius: var(--radius-xl);
    --swal-shadow: var(--shadow-xl);
    --swal-font: var(--font-family-body);
    --swal-heading-font: var(--font-family-heading);
}


/* =============================================================================
   1b. PREVENT SCROLL-TO-TOP
   SweetAlert2 sets overflow:hidden on body.swal2-shown and height:auto on
   body.swal2-height-auto - both cause the browser to lose scroll position.
   Override to preserve position and keep scrollbar visible.
   ============================================================================= */

body.swal2-shown:not(.swal2-no-backdrop):not(.swal2-toast-shown) {
    overflow: visible !important;
}


/* =============================================================================
   2. CONTAINER / OVERLAY
   ============================================================================= */

.swal2-container {
    background-color: var(--swal-overlay) !important;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    /* Top of the stack: SweetAlert is a blocking confirmation, so it must
     * sit above Bootstrap modals (1055), the mobile menu (1085), and any
     * toast/tooltip layers. --z-max ensures the dialog is reachable when
     * triggered from inside another modal (e.g. variant delete inside the
     * Manage variants modal). !important guarantees we beat the vendor
     * sweetalert2.min.css rule (z-index: 1060) regardless of cascade order. */
    z-index: var(--z-max) !important;
}


/* =============================================================================
   3. POPUP
   ============================================================================= */

.swal2-popup {
    background-color: var(--swal-bg) !important;
    color: var(--swal-text) !important;
    border-radius: var(--swal-radius) !important;
    box-shadow: var(--swal-shadow) !important;
    font-family: var(--swal-font) !important;
    border: 1px solid transparent;
    padding: var(--space-8) var(--space-6) var(--space-6) !important;
}


/* =============================================================================
   4. TITLE & TEXT
   ============================================================================= */

.swal2-title {
    color: var(--swal-text) !important;
    font-family: var(--swal-heading-font) !important;
    font-weight: var(--font-weight-semibold) !important;
    font-size: var(--font-size-xl) !important;
}

.swal2-html-container {
    color: var(--swal-text-secondary) !important;
    font-size: var(--font-size-base) !important;
    line-height: var(--line-height-normal) !important;
}


/* =============================================================================
   5. ICON COLORS (semantic)
   ============================================================================= */

.swal2-icon.swal2-success {
    border-color: var(--color-success-500) !important;
    color: var(--color-success-500) !important;
}

.swal2-icon.swal2-success .swal2-success-line-long,
.swal2-icon.swal2-success .swal2-success-line-tip {
    background-color: var(--color-success-500) !important;
}

.swal2-icon.swal2-success .swal2-success-ring {
    border-color: var(--color-success-100) !important;
}

.swal2-icon.swal2-error {
    border-color: var(--color-error-500) !important;
    color: var(--color-error-500) !important;
}

.swal2-icon.swal2-error .swal2-x-mark-line-left,
.swal2-icon.swal2-error .swal2-x-mark-line-right {
    background-color: var(--color-error-500) !important;
}

.swal2-icon.swal2-warning {
    border-color: var(--color-warning-500) !important;
    color: var(--color-warning-500) !important;
}

.swal2-icon.swal2-info {
    border-color: var(--color-info-500) !important;
    color: var(--color-info-500) !important;
}

.swal2-icon.swal2-question {
    border-color: var(--color-primary-500) !important;
    color: var(--color-primary-500) !important;
}


/* =============================================================================
   6. BUTTON BASE
   ============================================================================= */

.swal2-actions button {
    border-radius: var(--button-radius) !important;
    font-weight: var(--font-weight-medium) !important;
    font-family: var(--swal-font) !important;
    font-size: var(--font-size-base) !important;
    padding: var(--space-2) var(--space-5) !important;
    transition: background-color var(--duration-200) var(--ease-in-out),
                border-color var(--duration-200) var(--ease-in-out),
                box-shadow var(--duration-200) var(--ease-in-out) !important;
    border: 1px solid transparent !important;
    outline: none !important;
    min-width: 6rem;
}

.swal2-actions button:focus {
    box-shadow: 0 0 0 3px rgba(var(--color-primary-500-rgb), 0.3) !important;
}


/* =============================================================================
   7. BUTTON VARIANTS (applied via customClass from JS)
   ============================================================================= */

/* --- Primary (blue) --- */
.swal-btn-primary {
    background-color: var(--color-primary-500) !important;
    color: var(--color-neutral-0) !important;
}

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

.swal-btn-primary:focus {
    box-shadow: 0 0 0 3px rgba(var(--color-primary-500-rgb), 0.3) !important;
}

/* --- Danger (red) --- */
.swal-btn-danger {
    background-color: var(--color-error-500) !important;
    color: var(--color-neutral-0) !important;
}

.swal-btn-danger:hover {
    background-color: var(--color-error-600) !important;
}

.swal-btn-danger:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.3) !important;
}

/* --- Warning (amber) --- */
.swal-btn-warning {
    background-color: var(--color-warning-500) !important;
    color: var(--color-neutral-0) !important;
}

.swal-btn-warning:hover {
    background-color: var(--color-warning-600) !important;
}

.swal-btn-warning:focus {
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.3) !important;
}

/* --- Info (cyan) --- */
.swal-btn-info {
    background-color: var(--color-info-500) !important;
    color: var(--color-neutral-0) !important;
}

.swal-btn-info:hover {
    background-color: var(--color-info-600) !important;
}

.swal-btn-info:focus {
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.3) !important;
}

/* --- Cancel (neutral) --- */
.swal-btn-cancel {
    background-color: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-default) !important;
}

.swal-btn-cancel:hover {
    background-color: var(--border-default) !important;
}

.swal-btn-cancel:focus {
    box-shadow: 0 0 0 3px rgba(var(--border-default-rgb), 0.3) !important;
}


/* =============================================================================
   8. FALLBACK BUTTON STYLES (when no customClass is applied)
   ============================================================================= */

.swal2-confirm:not([class*="swal-btn-"]) {
    background-color: var(--button-primary-bg) !important;
    color: var(--button-primary-text) !important;
}

.swal2-confirm:not([class*="swal-btn-"]):hover {
    background-color: var(--button-primary-hover) !important;
}

.swal2-cancel:not([class*="swal-btn-"]) {
    background-color: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-default) !important;
}

.swal2-cancel:not([class*="swal-btn-"]):hover {
    background-color: var(--border-default) !important;
}


/* =============================================================================
   9. INPUTS
   ============================================================================= */

.swal2-input,
.swal2-textarea,
.swal2-select {
    background-color: var(--input-bg) !important;
    color: var(--swal-text) !important;
    border: 1px solid var(--input-border) !important;
    border-radius: var(--button-radius) !important;
    font-family: var(--swal-font) !important;
    font-size: var(--font-size-base) !important;
    transition: border-color var(--duration-200) var(--ease-in-out),
                box-shadow var(--duration-200) var(--ease-in-out) !important;
}

.swal2-input:focus,
.swal2-textarea:focus,
.swal2-select:focus {
    border-color: var(--input-focus) !important;
    box-shadow: 0 0 0 3px rgba(var(--color-primary-500-rgb), 0.2) !important;
    outline: none !important;
}


/* =============================================================================
   10. CLOSE BUTTON
   ============================================================================= */

.swal2-close {
    color: var(--text-muted) !important;
    transition: color var(--duration-200) var(--ease-in-out) !important;
}

.swal2-close:hover {
    color: var(--color-error-500) !important;
}


/* =============================================================================
   11. ANIMATIONS
   ============================================================================= */

.swal2-show {
    animation: swal2-show var(--duration-300) var(--ease-bounce) !important;
}

.swal2-hide {
    animation: swal2-hide var(--duration-200) var(--ease-in-out) !important;
}


/* =============================================================================
   12. DARK MODE ADJUSTMENT
   ============================================================================= */

[data-theme="dark"] .swal2-popup {
    border-color: var(--swal-border);
}


/* =============================================================================
   13. YOUTUBE PLAYLIST CHOICE CARDS
   Token-driven option cards used by the block editor's playlist-paste dialog
   (web/js/content-editor.js -> promptPlaylistChoice). Theme-aware via tokens.
   ============================================================================= */

.yt-choice-popup .swal2-html-container {
    margin: var(--space-2) 0 0 !important;
    overflow: visible;
}

.yt-choice-sub {
    margin: 0 0 var(--space-4) !important;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    text-align: center;
}

.yt-choice-grid {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    text-align: left;
}

.yt-choice-card {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    width: 100%;
    padding: var(--space-4);
    background: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    cursor: pointer;
    text-align: left;
    transition: border-color .15s ease, background-color .15s ease,
                transform .1s ease, box-shadow .15s ease;
}

.yt-choice-card:hover {
    border-color: var(--color-primary-500);
    background: var(--bg-tertiary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.yt-choice-card:focus-visible {
    outline: 2px solid var(--color-primary-500);
    outline-offset: 2px;
}

.yt-choice-ico {
    flex: 0 0 auto;
    width: 2.75rem;
    height: 2.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    color: var(--color-primary-500);
    font-size: 1.15rem;
    transition: background-color .15s ease, color .15s ease;
}

.yt-choice-card:hover .yt-choice-ico {
    background: var(--color-primary-500);
    color: #fff;
}

.yt-choice-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1 1 auto;
    min-width: 0;
}

.yt-choice-title {
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    line-height: 1.25;
}

.yt-choice-desc {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    line-height: 1.35;
}

.yt-choice-go {
    flex: 0 0 auto;
    color: var(--text-tertiary);
    opacity: 0;
    transform: translateX(-4px);
    transition: opacity .15s ease, transform .15s ease, color .15s ease;
}

.yt-choice-card:hover .yt-choice-go {
    opacity: 1;
    transform: translateX(0);
    color: var(--color-primary-500);
}
