/* ==============================================================
   POPUPS & MODALS COMPONENT
   Standardized Popups for Desktop and Mobile
   Colors are inherited from the theme variables.
   ============================================================== */

/* Modal Overlay */
.modal-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0, 0, 0, 0.85) !important;
    backdrop-filter: blur(8px) !important;
    display: none;
    align-items: center !important;
    justify-content: center !important;
    z-index: 20000 !important;
    padding: 20px !important;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    display: flex !important;
    opacity: 1;
}

/* Modal Content Box */
.modal-content {
    background: var(--bg-surface) !important;
    border: 1px solid var(--border) !important;
    width: 100% !important;
    max-width: 550px !important;
    border-radius: var(--radius) !important;
    padding: 0 !important;
    position: relative !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5) !important;
    display: flex !important;
    flex-direction: column !important;
    max-height: 90vh !important;
    overflow: hidden !important;
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

/* Modal Header */
.modal-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 20px 24px !important;
    border-bottom: 1px solid var(--border) !important;
    background-color: var(--glass-bg) !important;
    flex-shrink: 0 !important;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
}

.close-modal {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
    transition: var(--transition);
}

.close-modal:hover {
    color: var(--accent);
    transform: rotate(90deg);
}

/* Modal Body */
#modal-body {
    padding: 24px !important;
    overflow-y: auto !important;
    flex: 1 !important;
    -webkit-overflow-scrolling: touch !important;
}

/* Modal Footer */
.modal-footer {
    background-color: var(--glass-bg) !important;
    padding: 20px 24px !important;
    border-top: 1px solid var(--border) !important;
    flex-shrink: 0 !important;
    display: flex !important;
    justify-content: flex-end !important;
    gap: 15px !important;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 30000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    background: rgba(var(--bg-sidebar-rgb, 20, 22, 28), 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-left: 5px solid var(--primary);
    padding: 16px 22px;
    border-radius: 14px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05) inset;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    min-width: 320px;
    max-width: 450px;
    position: relative;
    overflow: hidden;
    animation: toastSlideIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.toast i {
    font-size: 22px;
    flex-shrink: 0;
    filter: drop-shadow(0 0 8px currentColor);
}

.toast-message {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
}

.toast-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 22px;
    cursor: pointer;
    padding: 0 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
    line-height: 1;
    margin-left: 10px;
}

.toast-close:hover {
    color: #fff;
    transform: scale(1.1);
}

.toast::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.03));
    pointer-events: none;
}

.toast i {
    font-size: 22px;
    flex-shrink: 0;
    filter: drop-shadow(0 0 8px currentColor);
}

.toast.error {
    border-left-color: #ff4d4d;
    background: rgba(35, 15, 15, 0.9);
}

.toast.error i {
    color: #ff4d4d;
}

.toast.warning {
    border-left-color: #f59e0b;
    background: rgba(30, 24, 15, 0.9);
}

.toast.warning i {
    color: #f59e0b;
}

.toast.success {
    border-left-color: #10B981;
    background: rgba(15, 30, 25, 0.9);
}

.toast.success i {
    color: #10B981;
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(50px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Generic Animations */
@keyframes modalSlideIn {
    from {
        transform: translateY(30px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ==============================================================
   MOBILE POPUP RESPONSIVENESS
   ============================================================== */

@media (max-width: 768px) {
    .modal-overlay {
        padding: 15px !important;
    }

    .modal-content {
        max-width: 100% !important;
        width: 100% !important;
        height: auto !important;
        max-height: 90vh !important;
        border-radius: 20px !important;
        transform: translateY(20px);
    }

    .modal-overlay.active .modal-content {
        transform: translateY(0);
    }

    .modal-header {
        position: sticky !important;
        top: 0 !important;
        z-index: 10 !important;
    }

    .modal-footer {
        position: sticky !important;
        bottom: 0 !important;
        z-index: 10 !important;
        padding: 15px 20px !important;
    }

    .toast-container {
        top: 20px;
        bottom: auto;
        left: auto;
        right: 20px;
        width: auto;
        max-width: calc(100% - 40px);
    }

    .toast {
        min-width: auto;
        width: auto;
        max-width: 320px;
    }

    /* SweetAlert2 Mobile Toast Fix */
    .swal2-container.swal2-top-end,
    .swal2-container.swal2-top-right,
    body.swal2-toast-shown .swal2-container {
        top: 10px !important;
        right: 10px !important;
        left: auto !important;
        bottom: auto !important;
        width: auto !important;
        max-width: 400px !important;
        height: auto !important;
        min-height: auto !important;
        background: transparent !important;
        pointer-events: none !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-end !important;
        justify-content: flex-start !important;
        padding: 0 !important;
    }

    .swal2-popup.swal2-toast {
        width: auto !important;
        min-width: 280px !important;
        max-width: calc(100vw - 30px) !important;
        height: auto !important;
        min-height: auto !important;
        padding: 12px 15px !important;
        font-size: 13px !important;
        margin: 5px !important;
        pointer-events: auto !important;
        box-shadow: 0 10px 30px rgba(0,0,0,0.5) !important;
        display: flex !important;
        align-items: center !important;
        border-radius: 12px !important;
        background: #1a1b26 !important;
    }

    .swal2-popup.swal2-toast .swal2-title {
        margin: 0 10px !important;
        font-size: 14px !important;
        color: #fff !important;
    }

    body.swal2-toast-shown {
        overflow: auto !important;
    }
}

/* Prompt and QR Modal Components (Rule 36 - No inline styles) */
.prompt-container {
    padding: 5px 0;
}

.prompt-message {
    margin-bottom: 20px;
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.5;
}

.prompt-input {
    margin-bottom: 25px;
    height: 50px;
    font-size: 15px;
}

.prompt-buttons {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.prompt-btn-cancel {
    padding: 10px 25px;
    border-radius: 30px;
    font-weight: 600;
}

.prompt-btn-ok {
    padding: 10px 30px;
    border-radius: 30px;
    font-weight: 800;
}

.qr-modal-container {
    text-align: center;
    padding: 20px;
}

.qr-img-wrapper {
    background: #fff;
    padding: 20px;
    border-radius: 15px;
    display: inline-block;
    margin-bottom: 25px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.qr-img {
    width: 200px;
    height: 200px;
    display: block;
}

.qr-hint {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 25px;
}

.qr-url-input {
    text-align: center;
    background: rgba(255,255,255,0.03);
}

/* SweetAlert2 Visibility Overlays (Always on Top) */
.swal2-container {
    z-index: 999999 !important;
}

/* Timer progress bar styling adjustment */
.swal2-timer-progress-bar {
    background: var(--primary) !important;
}
