/* Widget Container (Default position at bottom: 30px for home page and pages without AI Assistant) */
.nfc-widget-container {
    position: fixed;
    bottom: 30px;
    right: 24px;
    left: auto !important;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    direction: ltr !important; /* Locks flex axis so button & tooltip are consistently anchored to the right */
    font-family: inherit;
    pointer-events: none;
    transition: bottom 0.3s ease;
}

/* Position higher ONLY when AI Assistant trigger button is present on the page (e.g. Create NFC page) */
body:has(#publicAiTriggerBtn) .nfc-widget-container,
body:has(.public-ai-trigger) .nfc-widget-container,
body.has-ai-assistant .nfc-widget-container {
    bottom: 100px;
}

/* RTL / Arabic layout support (Stays strictly on the right edge, matching English/French) */
html[lang="ar"] .nfc-widget-container,
html[dir="rtl"] .nfc-widget-container {
    right: 24px !important;
    left: auto !important;
    align-items: flex-end !important;
    direction: ltr !important;
}

/* Tooltip / Message */
.nfc-widget-message {
    background: var(--surface);
    color: var(--text-main);
    padding: 14px 34px 14px 18px;
    border-radius: 14px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    font-size: 14px;
    line-height: 1.5;
    font-weight: 500;
    margin-bottom: 16px;
    max-width: 260px;
    text-align: left;
    position: relative;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1), transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
    border: 1px solid var(--border);
    align-self: flex-end !important;
}

html[lang="ar"] .nfc-widget-message,
html[dir="rtl"] .nfc-widget-message {
    direction: rtl !important;
    text-align: right !important;
    padding: 14px 18px 14px 34px !important;
}

.nfc-widget-message.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Close Button */
.nfc-widget-close-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: color 0.2s ease, background 0.2s ease;
}

html[lang="ar"] .nfc-widget-close-btn,
html[dir="rtl"] .nfc-widget-close-btn {
    right: auto !important;
    left: 8px !important;
}

.nfc-widget-close-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.1);
}

/* Arrow for the message (Centered over 54px button: 27px - 6px = 21px) */
.nfc-widget-message::after {
    content: '';
    position: absolute;
    bottom: -6px;
    right: 21px;
    width: 12px;
    height: 12px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    transform: rotate(45deg);
    border-bottom-right-radius: 3px;
    z-index: 10;
}

html[lang="ar"] .nfc-widget-message::after,
html[dir="rtl"] .nfc-widget-message::after {
    right: 21px !important;
    left: auto !important;
    background: var(--surface) !important;
    border-left: none !important;
    border-top: none !important;
    border-right: 1px solid var(--border) !important;
    border-bottom: 1px solid var(--border) !important;
}


/* Premium Action Button (Matches btn-primary) */
.nfc-widget-btn {
    width: 54px;
    height: 54px;
    background: var(--text-main);
    color: var(--bg);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 22px;
    box-shadow: 0 0 20px var(--glow);
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease, background 0.3s ease, color 0.3s ease;
    text-decoration: none;
    position: relative;
    z-index: 2;
    border: 1px solid var(--text-main);
    pointer-events: auto;
    align-self: flex-end !important;
    margin-left: auto !important;
    margin-right: 0 !important;
}

.nfc-widget-btn i {
    transition: transform 0.4s ease;
}

.nfc-widget-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 30px var(--glow);
    background: transparent;
    color: var(--text-main);
}

.nfc-widget-btn:hover i {
    transform: rotate(90deg);
}

/* Glow Effect */
.nfc-widget-btn::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: var(--text-main);
    border-radius: 50%;
    z-index: -1;
    opacity: 0.15;
    filter: blur(8px);
    animation: widget-pulse 3s infinite alternate;
}

@keyframes widget-pulse {
    0% {
        opacity: 0.05;
        transform: scale(1);
    }
    100% {
        opacity: 0.2;
        transform: scale(1.15);
    }
}

/* Mobile Responsiveness & Compact Mode */
@media (max-width: 768px) {
    .nfc-widget-container {
        bottom: 20px;
        right: 16px;
    }

    body:has(#publicAiTriggerBtn) .nfc-widget-container,
    body:has(.public-ai-trigger) .nfc-widget-container,
    body.has-ai-assistant .nfc-widget-container {
        bottom: 85px;
    }

    html[lang="ar"] .nfc-widget-container,
    html[dir="rtl"] .nfc-widget-container {
        right: 16px !important;
        left: auto !important;
    }

    .nfc-widget-btn {
        width: 44px;
        height: 44px;
        font-size: 16px;
    }

    .nfc-widget-message {
        font-size: 12px;
        padding: 10px 28px 10px 14px;
        max-width: 200px;
        margin-bottom: 10px;
        border-radius: 12px;
    }

    html[lang="ar"] .nfc-widget-message,
    html[dir="rtl"] .nfc-widget-message {
        padding: 10px 14px 10px 28px !important;
    }

    .nfc-widget-close-btn {
        top: 6px;
        right: 6px;
        font-size: 11px;
        width: 18px;
        height: 18px;
    }

    html[lang="ar"] .nfc-widget-close-btn,
    html[dir="rtl"] .nfc-widget-close-btn {
        right: auto !important;
        left: 6px !important;
    }

    .nfc-widget-message::after {
        right: 17px;
        width: 10px;
        height: 10px;
        bottom: -5px;
    }

    html[lang="ar"] .nfc-widget-message::after,
    html[dir="rtl"] .nfc-widget-message::after {
        right: 17px !important;
        left: auto !important;
    }
}




