/* ==========================================================================
   KenMeet Ultra-Modern Universal Popup & Modal System
   Based on modern glassmorphism reference: 28px radius, ambient corner blobs,
   circular avatar badges, context notice boxes, and pill action buttons.
   ========================================================================== */

/* 1. Modal Overlay & Container */
.km-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    padding: 20px;
}

.km-popup-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Floating Notification Container (for Non-blocking approval toasts e.g. join requests) */
.km-floating-requests-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 16px;
    pointer-events: none;
    max-width: 540px;
    width: calc(100vw - 48px);
}

.km-floating-requests-container .km-popup-card {
    pointer-events: auto;
    position: relative;
    box-shadow: 0 25px 60px -10px rgba(15, 23, 42, 0.25), 0 0 0 1px rgba(226, 232, 240, 0.9);
}

/* 2. Main Popup Card */
.km-popup-card {
    position: relative;
    background: #ffffff;
    border-radius: 28px;
    padding: 32px 36px 28px;
    width: 100%;
    max-width: 560px;
    box-shadow: 0 25px 60px -15px rgba(15, 23, 42, 0.2), 0 0 0 1px rgba(226, 232, 240, 0.85);
    overflow: hidden;
    transform: scale(0.92) translateY(16px);
    opacity: 0;
    transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.28s ease;
    font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #0F172A;
}

.km-popup-overlay.active .km-popup-card,
.km-floating-requests-container .km-popup-card.active,
.modal.show .km-popup-card,
.modal.in .km-popup-card,
.modal .modal-content.km-popup-card {
    transform: scale(1) translateY(0) !important;
    opacity: 1 !important;
}

/* Ambient Corner Blobs (Top-right & Bottom-left) */
.km-popup-card::before {
    content: '';
    position: absolute;
    top: -60px;
    right: -60px;
    width: 220px;
    height: 220px;
    background: radial-gradient(circle, rgba(199, 210, 254, 0.7) 0%, rgba(224, 231, 255, 0.35) 45%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
    filter: blur(15px);
}

.km-popup-card::after {
    content: '';
    position: absolute;
    bottom: -60px;
    left: -60px;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(199, 210, 254, 0.6) 0%, rgba(224, 242, 254, 0.3) 45%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
    filter: blur(15px);
}

/* Ensure inner content sits above ambient blobs */
.km-popup-inner {
    position: relative;
    z-index: 1;
}

/* 3. Close Button (Top-Right Circular) */
.km-popup-close {
    position: absolute;
    top: 22px;
    right: 22px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #EEF2F6;
    color: #475569;
    border: none;
    outline: none !important;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 2;
}

.km-popup-close:hover {
    background: #E2E8F0;
    color: #0F172A;
    transform: scale(1.06);
}

.km-popup-close:active {
    transform: scale(0.95);
}

/* 4. Header Area (Avatar Badge + Title + Subtitle) */
.km-popup-header {
    display: flex;
    align-items: flex-start;
    gap: 18px;
    margin-bottom: 20px;
    padding-right: 42px; /* space for close button */
}

/* Circular Avatar with Gradient & Sub-badge */
.km-avatar-badge {
    position: relative;
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: linear-gradient(135deg, #DBEAFE 0%, #BFDBFE 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #2563EB;
    font-size: 26px;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.15);
}

.km-avatar-badge.warning {
    background: linear-gradient(135deg, #FEF3C7 0%, #FDE68A 100%);
    color: #D97706;
    box-shadow: 0 4px 14px rgba(217, 119, 6, 0.15);
}

.km-avatar-badge.danger {
    background: linear-gradient(135deg, #FEE2E2 0%, #FECACA 100%);
    color: #DC2626;
    box-shadow: 0 4px 14px rgba(220, 38, 38, 0.15);
}

.km-avatar-subbadge {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #2563EB;
    font-size: 11px;
    border: 1.5px solid #ffffff;
}

.km-avatar-badge.warning .km-avatar-subbadge {
    color: #D97706;
}

.km-avatar-badge.danger .km-avatar-subbadge {
    color: #DC2626;
}

.km-header-texts {
    flex: 1;
    min-width: 0;
}

.km-popup-title {
    font-size: 1.45rem;
    font-weight: 800;
    color: #0F172A;
    line-height: 1.25;
    letter-spacing: -0.025em;
    margin: 0 0 6px 0;
}

.km-popup-subtitle {
    font-size: 1.02rem;
    font-weight: 500;
    color: #64748B;
    line-height: 1.4;
    margin: 0;
    word-break: break-word;
}

/* 5. Notice Banner Callout */
.km-popup-notice {
    background: #F1F5F9;
    border-radius: 16px;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
}

.km-notice-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #2563EB;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.km-popup-notice.warning .km-notice-icon {
    background: #D97706;
}

.km-popup-notice.danger .km-notice-icon {
    background: #DC2626;
}

.km-notice-content {
    flex: 1;
}

.km-notice-primary {
    font-weight: 600;
    color: #1E293B;
    font-size: 0.94rem;
    line-height: 1.35;
    margin: 0;
}

.km-notice-secondary {
    font-size: 0.86rem;
    color: #64748B;
    line-height: 1.35;
    margin: 3px 0 0 0;
}

/* 6. Action Buttons Area */
.km-popup-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Primary Approve Button */
.km-btn-approve {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    height: 52px;
    padding: 0 32px;
    border-radius: 9999px;
    background: linear-gradient(180deg, #3B82F6 0%, #1D4ED8 100%);
    box-shadow: 0 8px 24px -4px rgba(37, 99, 235, 0.42), inset 0 1px 1px rgba(255, 255, 255, 0.35);
    color: #ffffff !important;
    font-weight: 700;
    font-size: 1.02rem;
    border: none;
    cursor: pointer;
    text-decoration: none !important;
    outline: none !important;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.km-btn-approve:hover {
    background: linear-gradient(180deg, #2563EB 0%, #1E40AF 100%);
    box-shadow: 0 10px 28px -4px rgba(37, 99, 235, 0.55), inset 0 1px 1px rgba(255, 255, 255, 0.4);
    transform: translateY(-1px);
    color: #ffffff !important;
}

.km-btn-approve:active {
    transform: translateY(1px);
    box-shadow: 0 4px 14px -2px rgba(37, 99, 235, 0.4);
}

.km-btn-approve.danger {
    background: linear-gradient(180deg, #EF4444 0%, #B91C1C 100%);
    box-shadow: 0 8px 24px -4px rgba(239, 68, 68, 0.42), inset 0 1px 1px rgba(255, 255, 255, 0.35);
}

.km-btn-approve.danger:hover {
    background: linear-gradient(180deg, #DC2626 0%, #991B1B 100%);
    box-shadow: 0 10px 28px -4px rgba(239, 68, 68, 0.55);
}

/* White Circle Icon Badge inside Approve Button */
.km-icon-badge-check {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #ffffff;
    color: #2563EB;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 900;
    flex-shrink: 0;
}

.km-btn-approve.danger .km-icon-badge-check {
    color: #DC2626;
}

/* Secondary Decline / Cancel Button */
.km-btn-decline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    height: 52px;
    padding: 0 32px;
    border-radius: 9999px;
    background: #ffffff;
    border: 1.5px solid #E2E8F0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    color: #1E293B !important;
    font-weight: 700;
    font-size: 1.02rem;
    cursor: pointer;
    text-decoration: none !important;
    outline: none !important;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.km-btn-decline:hover {
    background: #F8FAFC;
    border-color: #CBD5E1;
    color: #0F172A !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.km-btn-decline:active {
    transform: translateY(1px);
}

/* Red Circle Icon Badge inside Decline Button */
.km-icon-badge-cross {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #EF4444;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 900;
    flex-shrink: 0;
}

/* ==========================================================================
   Standard Bootstrap Modals Overhaul (Matching 28px radius & ambient blobs)
   ========================================================================== */
.modal-content {
    border-radius: 28px !important;
    border: 1px solid rgba(226, 232, 240, 0.8) !important;
    box-shadow: 0 25px 60px -15px rgba(15, 23, 42, 0.2) !important;
    overflow: hidden !important;
    position: relative !important;
    background: #ffffff !important;
    font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
}

.modal-content::before {
    content: '';
    position: absolute;
    top: -50px;
    right: -50px;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(199, 210, 254, 0.6) 0%, rgba(224, 231, 255, 0.3) 45%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
    filter: blur(14px);
}

.modal-content::after {
    content: '';
    position: absolute;
    bottom: -50px;
    left: -50px;
    width: 180px;
    height: 180px;
    background: radial-gradient(circle, rgba(199, 210, 254, 0.5) 0%, rgba(224, 242, 254, 0.25) 45%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
    filter: blur(14px);
}

.modal-header {
    border-bottom: 1px solid rgba(241, 245, 249, 0.8) !important;
    padding: 24px 30px !important;
    position: relative !important;
    z-index: 1 !important;
}

.modal-header .modal-title {
    font-size: 1.35rem !important;
    font-weight: 800 !important;
    color: #0F172A !important;
    letter-spacing: -0.02em !important;
}

.modal-header .close {
    width: 38px !important;
    height: 38px !important;
    border-radius: 50% !important;
    background: #EEF2F6 !important;
    color: #475569 !important;
    opacity: 1 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    margin: 0 !important;
    font-size: 20px !important;
    line-height: 1 !important;
    border: none !important;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

.modal-header .close:hover {
    background: #E2E8F0 !important;
    color: #0F172A !important;
    transform: scale(1.06) !important;
}

.modal-body {
    position: relative !important;
    z-index: 1 !important;
    padding: 26px 30px !important;
    color: #334155 !important;
}

.modal-footer {
    border-top: 1px solid rgba(241, 245, 249, 0.8) !important;
    padding: 20px 30px !important;
    position: relative !important;
    z-index: 1 !important;
    display: flex !important;
    align-items: center !important;
    gap: 14px !important;
}

/* Modal Buttons inside Bootstrap modal-footer */
.modal-footer .btn-primary {
    border-radius: 9999px !important;
    height: 48px !important;
    padding: 0 28px !important;
    background: linear-gradient(180deg, #3B82F6 0%, #1D4ED8 100%) !important;
    box-shadow: 0 6px 20px -3px rgba(37, 99, 235, 0.4) !important;
    border: none !important;
    font-weight: 700 !important;
    font-size: 0.98rem !important;
}

.modal-footer .btn-secondary,
.modal-footer .btn-default {
    border-radius: 9999px !important;
    height: 48px !important;
    padding: 0 28px !important;
    background: #ffffff !important;
    border: 1.5px solid #E2E8F0 !important;
    color: #1E293B !important;
    font-weight: 700 !important;
    font-size: 0.98rem !important;
}

/* Responsive adjustment for small screens */
@media (max-width: 576px) {
    .km-popup-card {
        padding: 24px 20px 20px;
        border-radius: 22px;
    }
    .km-popup-header {
        gap: 14px;
    }
    .km-avatar-badge {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
    .km-popup-title {
        font-size: 1.2rem;
    }
    .km-popup-subtitle {
        font-size: 0.92rem;
    }
    .km-popup-actions {
        flex-direction: column;
        width: 100%;
    }
    .km-btn-approve, .km-btn-decline {
        width: 100%;
        justify-content: center;
    }
}
