/* ═══════════════════════════════════════════════════════════════════════
   Morphious AI Assistant (Powered by Claude) - Stylesheet
   ═══════════════════════════════════════════════════════════════════════ */

/* Floating Launcher Wrapper */
.ai-launcher-wrapper {
    position: fixed;
    bottom: 24px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 9999;
    touch-action: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    user-select: none;
    -webkit-user-select: none;
}

.ai-launcher-wrapper.hidden {
    display: none !important;
}

/* Floating Launcher Button */
.ai-launcher-btn {
    height: 44px;
    padding: 0 16px 0 12px;
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #312e81 100%);
    border: 1px solid rgba(129, 140, 248, 0.4);
    border-radius: 9999px;
    color: #f8fafc;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    box-shadow: 0 8px 25px -4px rgba(99, 102, 241, 0.4), 0 0 15px rgba(129, 140, 248, 0.2);
    backdrop-filter: blur(12px);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.ai-launcher-btn:hover {
    transform: translateY(-2px) scale(1.03);
    border-color: rgba(165, 180, 252, 0.8);
    box-shadow: 0 12px 28px -4px rgba(99, 102, 241, 0.6);
}

.ai-launcher-icon {
    font-size: 18px;
    line-height: 1;
}

.ai-pulse-dot {
    width: 8px;
    height: 8px;
    background-color: #10b981;
    border-radius: 50%;
    box-shadow: 0 0 8px #10b981;
    animation: ai-pulse 2s infinite;
}

@keyframes ai-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.2); }
}

.ai-launcher-minimize {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #94a3b8;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    backdrop-filter: blur(8px);
}

.ai-launcher-minimize:hover {
    background: rgba(239, 68, 68, 0.7);
    color: #fff;
    border-color: #ef4444;
}

/* Minimized Edge Tab */
.ai-edge-tab {
    position: fixed;
    bottom: 30px;
    right: 0;
    height: 40px;
    padding: 0 8px 0 10px;
    background: linear-gradient(135deg, rgba(30, 27, 75, 0.95), rgba(49, 46, 129, 0.95));
    border: 1px solid rgba(129, 140, 248, 0.4);
    border-right: none;
    border-radius: 12px 0 0 12px;
    color: #a5b4fc;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    box-shadow: -4px 0 15px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(12px);
    z-index: 9999;
    transition: all 0.25s ease;
}

.ai-edge-tab:hover {
    padding-right: 12px;
    color: #fff;
    border-color: #818cf8;
}

.ai-edge-tab.hidden {
    display: none !important;
}

/* Translucent unobtrusive state during active remote sessions */
body.session-active .ai-launcher-wrapper {
    opacity: 0.28;
    transform: scale(0.85);
}

body.session-active .ai-launcher-wrapper:hover,
body.session-active .ai-launcher-wrapper:focus-within {
    opacity: 1;
    transform: scale(1);
}

/* Chat Drawer Container */
.ai-chat-drawer {
    position: fixed;
    bottom: 90px;
    right: 24px;
    width: 420px;
    max-width: calc(100vw - 32px);
    height: 580px;
    max-height: calc(100vh - 120px);
    background: rgba(10, 8, 20, 0.94);
    border: 1px solid rgba(129, 140, 248, 0.3);
    border-radius: 18px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8), 0 0 30px rgba(99, 102, 241, 0.2);
    backdrop-filter: blur(20px);
    z-index: 10000;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: bottom right;
}

.ai-chat-drawer.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.9) translateY(20px);
}

/* Drawer Header */
.ai-chat-header {
    padding: 16px 20px;
    background: rgba(15, 23, 42, 0.8);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ai-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-header-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #4f46e5, #06b6d4);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.5);
}

.ai-header-title {
    font-size: 15px;
    font-weight: 700;
    color: #f8fafc;
    letter-spacing: -0.01em;
}

.ai-header-subtitle {
    font-size: 11px;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-close-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: 0.2s;
}

.ai-close-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

/* Chat Messages */
.ai-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
}

.ai-chat-body::-webkit-scrollbar {
    width: 6px;
}
.ai-chat-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

/* Message Bubbles */
.ai-msg {
    display: flex;
    gap: 10px;
    font-size: 13.5px;
    line-height: 1.55;
}

.ai-msg.user {
    flex-direction: row-reverse;
}

.ai-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
}

.ai-msg.bot .ai-msg-avatar {
    background: #312e81;
    color: #a5b4fc;
}

.ai-msg.user .ai-msg-avatar {
    background: #0369a1;
    color: #7dd3fc;
}

.ai-msg-content {
    max-width: 82%;
    padding: 12px 16px;
    border-radius: 14px;
    word-break: break-word;
}

.ai-msg.bot .ai-msg-content {
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
}

.ai-msg.user .ai-msg-content {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.ai-msg-content pre {
    background: rgba(0, 0, 0, 0.4);
    padding: 8px 12px;
    border-radius: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11.5px;
    overflow-x: auto;
    margin: 8px 0;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.ai-msg-content code {
    font-family: 'JetBrains Mono', monospace;
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 12px;
}

/* Auto-Fix Recommendation Card */
.ai-autofix-card {
    margin-top: 10px;
    padding: 12px 14px;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(6, 182, 212, 0.1) 100%);
    border: 1px solid rgba(16, 185, 129, 0.4);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-autofix-title {
    font-weight: 700;
    color: #34d399;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-autofix-desc {
    font-size: 12px;
    color: #cbd5e1;
    line-height: 1.4;
}

.ai-autofix-btn {
    background: linear-gradient(135deg, #059669, #0d9488);
    color: #fff;
    border: none;
    padding: 8px 14px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 12.5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: 0.2s;
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3);
}

.ai-autofix-btn:hover {
    background: linear-gradient(135deg, #10b981, #14b8a6);
    transform: translateY(-1px);
}

/* Quick Diagnostic Tools */
.ai-quick-tools {
    padding: 10px 16px;
    background: rgba(15, 23, 42, 0.5);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    gap: 8px;
    overflow-x: auto;
}

.ai-tool-chip {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #cbd5e1;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: 0.2s;
}

.ai-tool-chip:hover {
    background: rgba(99, 102, 241, 0.2);
    border-color: rgba(99, 102, 241, 0.4);
    color: #a5b4fc;
}

/* Chat Input Bar */
.ai-chat-input-bar {
    padding: 12px 16px;
    background: rgba(15, 23, 42, 0.9);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    gap: 8px;
    align-items: center;
}

.ai-chat-input {
    flex: 1;
    background: rgba(2, 6, 23, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    color: #f8fafc;
    padding: 10px 14px;
    font-size: 13.5px;
    outline: none;
    font-family: inherit;
    transition: 0.2s;
}

.ai-chat-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.ai-action-icon-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    transition: 0.2s;
    flex-shrink: 0;
}

.ai-action-icon-btn:hover {
    color: #f8fafc;
    background: rgba(255, 255, 255, 0.12);
}

.ai-send-btn {
    background: #4f46e5;
    border: none;
    color: #fff;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 15px;
    transition: 0.2s;
    flex-shrink: 0;
}

.ai-send-btn:hover {
    background: #4338ca;
    transform: scale(1.05);
}

/* Error Diagnostic Notification Banner */
.ai-error-banner {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid rgba(239, 68, 68, 0.4);
    border-radius: 12px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    color: #f8fafc;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 20px rgba(239, 68, 68, 0.2);
    backdrop-filter: blur(12px);
    z-index: 10001;
    animation: slide-down 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    max-width: 90vw;
}

@keyframes slide-down {
    from { opacity: 0; transform: translate(-50%, -20px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

.ai-error-banner-btn {
    background: #ef4444;
    color: #fff;
    border: none;
    padding: 6px 14px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 12.5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: 0.2s;
}

.ai-error-banner-btn:hover {
    background: #dc2626;
    transform: scale(1.03);
}

/* ═══════════════════════════════════════════════════════════════════════
   Mobile Responsive Adjustments for AI Assistant
   ═══════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    .ai-launcher-wrapper {
        bottom: 16px;
        right: 14px;
        gap: 0;
    }

    .ai-launcher-btn {
        width: 42px;
        height: 42px;
        padding: 0;
        border-radius: 50%;
        justify-content: center;
    }

    .ai-launcher-label {
        display: none !important;
    }

    .ai-pulse-dot {
        position: absolute;
        top: 3px;
        right: 3px;
        width: 8px;
        height: 8px;
    }

    .ai-launcher-minimize {
        display: none !important;
    }

    /* Mobile Chat Drawer -> Native Bottom Sheet */
    .ai-chat-drawer {
        position: fixed;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        width: 100% !important;
        max-width: 100% !important;
        height: 75vh !important;
        max-height: 85vh !important;
        border-radius: 22px 22px 0 0 !important;
        transform-origin: bottom center !important;
        border-bottom: none !important;
        border-left: none !important;
        border-right: none !important;
    }

    .ai-chat-drawer.hidden {
        transform: translateY(100%) !important;
        opacity: 0;
        pointer-events: none;
    }

    .ai-chat-drawer:not(.hidden) {
        transform: translateY(0) !important;
        opacity: 1;
    }

    .ai-quick-tools {
        padding: 8px 12px;
        gap: 6px;
    }

    .ai-tool-chip {
        font-size: 11px;
        padding: 5px 10px;
    }
}
