/**
 * dFlexi Universal PWA User AI Assistant Styling
 *
 * Implements:
 * - Ultra-modern dark glassmorphic container aesthetics
 * - Touch target compliance (>=44x44px per Law #6)
 * - Zero horizontal overflow
 * - Mobile responsive scaling across all 7 PWA themes
 * - Strict Law #7 branding ("dFlexi" / "ডি ফ্লেক্সি")
 *
 * @package dFlexi
 */

/* 1. Floating Launcher Button */
.dflexi-user-ai-launcher-btn {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 54px;
    height: 54px;
    min-width: 44px;
    min-height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    box-shadow: 0 8px 24px rgba(2, 132, 199, 0.45), 0 2px 6px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 99990;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.dflexi-user-ai-launcher-btn:hover {
    transform: scale(1.08) translateY(-2px);
    box-shadow: 0 12px 30px rgba(2, 132, 199, 0.6);
}

.dflexi-user-ai-launcher-btn:active {
    transform: scale(0.95);
}

.dflexi-user-ai-launcher-pulse {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid rgba(56, 189, 248, 0.7);
    animation: dflexiUserPulse 2.4s infinite cubic-bezier(0.24, 0, 0.38, 1);
    pointer-events: none;
}

@keyframes dflexiUserPulse {
    0% { transform: scale(1); opacity: 0.9; }
    50% { transform: scale(1.35); opacity: 0; }
    100% { transform: scale(1.35); opacity: 0; }
}

.dflexi-user-ai-launcher-inner {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: #ffffff;
}

.dflexi-user-ai-status-dot {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 8px;
    height: 8px;
    background: #10b981;
    border: 2px solid #ffffff;
    border-radius: 50%;
}

/* 2. Modal Overlay & Container */
.dflexi-user-ai-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99995;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    pointer-events: none;
}

.dflexi-user-ai-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: auto;
}

.dflexi-user-ai-modal-overlay.active .dflexi-user-ai-backdrop {
    opacity: 1;
}

.dflexi-user-ai-glass-container {
    position: relative;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 110px);
    margin: 0 20px 85px 0;
    background: rgba(15, 23, 42, 0.94);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.08) inset;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    pointer-events: auto;
    animation: dflexiUserSlideUp 0.32s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 99996;
}

@keyframes dflexiUserSlideUp {
    0% { transform: translateY(30px) scale(0.96); opacity: 0; }
    100% { transform: translateY(0) scale(1); opacity: 1; }
}

/* 3. Header */
.dflexi-user-ai-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: rgba(30, 41, 59, 0.65);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.dflexi-user-ai-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dflexi-user-ai-avatar {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.35);
}

.dflexi-user-ai-title-wrap {
    display: flex;
    flex-direction: column;
}

.dflexi-user-ai-title {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: #f8fafc;
    line-height: 1.2;
}

.dflexi-user-ai-badge {
    font-size: 10px;
    font-weight: 500;
    color: #38bdf8;
    margin-top: 2px;
}

.dflexi-user-ai-header-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* 4. Language Switcher Pill */
.dflexi-user-ai-lang-pill {
    display: flex;
    align-items: center;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 20px;
    padding: 2px;
    cursor: pointer;
    min-height: 44px;
    min-width: 44px;
    justify-content: center;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.dflexi-user-lang-opt {
    padding: 6px 9px;
    font-size: 11px;
    font-weight: 600;
    color: #94a3b8;
    border-radius: 14px;
    transition: all 0.2s ease;
}

.dflexi-user-lang-opt.active {
    background: #0284c7;
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(2, 132, 199, 0.4);
}

/* Icon Buttons */
.dflexi-user-ai-btn-icon {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    border: none;
    background: transparent;
    color: #94a3b8;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

.dflexi-user-ai-btn-icon:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #f8fafc;
}

/* 5. Messages Stream */
.dflexi-user-ai-messages-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.dflexi-user-ai-messages-scroll::-webkit-scrollbar {
    width: 4px;
}
.dflexi-user-ai-messages-scroll::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

.dflexi-user-ai-msg-bubble {
    max-width: 86%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.48;
    word-break: break-word;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.dflexi-user-ai-msg-assistant {
    align-self: flex-start;
    background: rgba(30, 41, 59, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
    border-bottom-left-radius: 4px;
}

.dflexi-user-ai-msg-user {
    align-self: flex-end;
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    color: #ffffff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 14px rgba(2, 132, 199, 0.3);
}

.dflexi-user-ai-msg-time {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.5);
    align-self: flex-end;
}

/* Interactive Action Buttons & Cards inside chat */
.dflexi-user-ai-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 10px 14px;
    min-height: 44px;
    background: #0284c7;
    color: #ffffff;
    border: none;
    border-radius: 10px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(2, 132, 199, 0.35);
    transition: transform 0.2s, background 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.dflexi-user-ai-action-btn:hover {
    background: #0369a1;
    transform: translateY(-1px);
}

.dflexi-user-ai-card-item {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 8px 10px;
    margin-top: 6px;
    font-size: 12px;
}

/* 6. Typing Indicator */
.dflexi-user-ai-typing-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 14px 6px;
}

.dflexi-user-ai-typing-bubble {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
}

.dflexi-user-dot {
    width: 6px;
    height: 6px;
    background: #38bdf8;
    border-radius: 50%;
    animation: dflexiUserDots 1.4s infinite ease-in-out both;
}

.dflexi-user-dot:nth-child(1) { animation-delay: -0.32s; }
.dflexi-user-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes dflexiUserDots {
    0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

.dflexi-user-typing-label {
    font-size: 11px;
    color: #64748b;
}

/* 7. Quick Prompt Chips */
.dflexi-user-ai-chips-scroll {
    display: flex;
    gap: 6px;
    padding: 6px 14px;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
}

.dflexi-user-ai-chips-scroll::-webkit-scrollbar {
    display: none;
}

.dflexi-user-ai-chip {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    min-height: 44px;
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    color: #cbd5e1;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.dflexi-user-ai-chip:hover {
    background: rgba(2, 132, 199, 0.25);
    border-color: #0284c7;
    color: #ffffff;
}

/* 8. Input Footer Bar */
.dflexi-user-ai-input-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(30, 41, 59, 0.65);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.dflexi-user-ai-input-field {
    flex: 1;
    height: 44px;
    min-height: 44px;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 0 14px;
    color: #f8fafc;
    font-size: 13.5px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.dflexi-user-ai-input-field:focus {
    border-color: #0284c7;
    box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.25);
}

.dflexi-user-ai-send-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    border: none;
    border-radius: 12px;
    background: #0284c7;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(2, 132, 199, 0.35);
    transition: background 0.2s, transform 0.2s;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

.dflexi-user-ai-send-btn:hover {
    background: #0369a1;
    transform: scale(1.05);
}

.dflexi-user-ai-send-btn:active {
    transform: scale(0.95);
}

/* 9. Mobile Responsiveness */
@media (max-width: 600px) {
    .dflexi-user-ai-glass-container {
        width: calc(100vw - 24px);
        margin: 0 12px 75px 12px;
        height: 72vh;
        max-height: 520px;
    }
    .dflexi-user-ai-launcher-btn {
        bottom: 75px;
        right: 16px;
    }
}
