/* Frank's AI Assistant Styles */
:root {
    --ai-size: 100px;
    --ai-size-mobile: 80px;
    --ai-primary: var(--primary-color, #ff4500);
    --ai-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
    
    /* Fallbacks that match the project's dark theme if variables are missing */
    --ai-bg: var(--card, #1a1a1a);
    --ai-fg: var(--foreground, #ececec);
    --ai-sub-bg: var(--muted, #252525);
    --ai-border: var(--border, #2d2d2d);
    --ai-input-bg: var(--secondary, #333333);
}

.ai-assistant-container {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    will-change: left, top, transform;
    transition: 
        left 0.5s var(--ai-spring),
        top 0.5s var(--ai-spring),
        bottom 0.5s var(--ai-spring),
        transform 0.5s var(--ai-spring);
}

.ai-assistant-container.dragging {
    transition: transform 0.1s ease-out !important;
    z-index: 3000;
    cursor: grabbing;
}

.ai-assistant-container.dragging .ai-assistant-trigger {
    transform: scale(1.1);
    box-shadow: 0 25px 50px rgba(0,0,0,0.4);
    border-color: #fff;
    animation: none;
}

.ai-assistant-trigger {
    width: var(--ai-size);
    height: var(--ai-size);
    border-radius: 50%;
    background: var(--ai-bg);
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    cursor: grab;
    overflow: hidden;
    transition: all 0.3s var(--ai-spring);
    border: 4px solid var(--ai-primary);
    position: relative;
    z-index: 2;
    user-select: none;
}

.ai-assistant-trigger:hover {
    transform: scale(1.05) translateY(-5px);
    box-shadow: 0 15px 35px rgba(255, 69, 0, 0.3);
}

.ai-assistant-trigger img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}

.ai-status-indicator {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 14px;
    height: 14px;
    background: #2ecc71;
    border: 2px solid var(--ai-bg);
    border-radius: 50%;
    z-index: 3;
}

.ai-assistant-container.dragging .ai-status-indicator {
    background: #f1c40f;
}

/* Greeting Bubble */
.ai-greeting-bubble {
    position: absolute;
    bottom: calc(100% + 15px);
    background: var(--ai-bg);
    color: var(--ai-fg);
    padding: 12px 18px;
    border-radius: 18px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
    width: 200px;
    text-align: center;
    pointer-events: none;
    opacity: 0;
    transform: translateY(10px) scale(0.9);
    transition: all 0.3s var(--ai-spring);
    border-bottom-left-radius: 4px;
}

.ai-greeting-bubble::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 8px 8px 0;
    border-style: solid;
    border-color: var(--ai-bg) transparent transparent;
}

.ai-assistant-container:hover .ai-greeting-bubble {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.ai-assistant-container.dragging .ai-greeting-bubble {
    opacity: 0 !important;
}

/* Chat Window */
.ai-chat-window {
    position: absolute;
    bottom: calc(100% + 20px);
    width: 350px;
    background: var(--ai-bg);
    color: var(--ai-fg);
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 1;
    transform-origin: bottom center;
    animation: chatOpen 0.4s var(--ai-spring);
    border: 1px solid var(--ai-border);
}

@keyframes chatOpen {
    from { opacity: 0; transform: scale(0.8) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.ai-chat-header {
    background: var(--ai-primary);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-chat-header img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: white;
}

.ai-chat-body {
    height: 350px;
    padding: 20px;
    overflow-y: auto;
    background: var(--ai-sub-bg);
}

.ai-message {
    background: var(--ai-bg);
    color: var(--ai-fg);
    padding: 12px 16px;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    margin-bottom: 12px;
    max-width: 85%;
    font-size: 0.9rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    position: relative;
    group: hover;
}

.btn-delete-msg {
    position: absolute;
    top: 5px;
    right: -30px;
    opacity: 0;
    transition: all 0.2s ease;
    color: var(--bs-danger);
    padding: 0;
}

.ai-message.ms-auto .btn-delete-msg {
    right: auto;
    left: -30px;
}

.ai-message:hover .btn-delete-msg {
    opacity: 0.7;
}

.btn-delete-msg:hover {
    opacity: 1 !important;
    transform: scale(1.1);
}

.ai-message.ms-auto {
    background: var(--ai-primary);
    color: white;
    border-bottom-left-radius: 16px;
    border-bottom-right-radius: 4px;
}

.ai-chat-footer {
    padding: 15px;
    background: var(--ai-bg);
    border-top: 1px solid var(--ai-border);
    display: flex;
    gap: 10px;
}

.ai-chat-input {
    flex: 1;
    background: var(--ai-input-bg);
    color: var(--ai-fg);
    border: 1px solid var(--ai-border);
    border-radius: 20px;
    padding: 10px 16px;
    outline: none;
}

.ai-send-btn {
    background: var(--ai-primary);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.ai-send-btn:hover {
    transform: scale(1.1);
}

/* Drag Overlay & Snap Zone */
.ai-drag-overlay {
    position: fixed;
    inset: 0;
    z-index: 2500;
    display: none;
    background: rgba(0,0,0,0.1);
    backdrop-filter: blur(2px);
    cursor: grabbing;
}

.ai-snap-zone {
    position: fixed;
    bottom: 25px;
    left: 50%;
    width: 130px;
    height: 130px;
    transform: translateX(-50%) scale(0.8);
    border: 2px dashed rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(4px);
    border-radius: 50%;
    z-index: 2600;
    opacity: 0;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-snap-zone::before {
    content: '';
    position: absolute;
    inset: -15px;
    border: 2px solid var(--ai-primary);
    border-radius: 50%;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.4s ease;
}

body.ai-dragging .ai-snap-zone {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

body.ai-dragging .ai-snap-zone.active {
    border-color: var(--ai-primary);
    background: rgba(255, 69, 0, 0.1);
    transform: translateX(-50%) scale(1.1);
}

body.ai-dragging .ai-snap-zone.active::before {
    opacity: 0.3;
    transform: scale(1);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 0.3; }
    100% { transform: scale(1.4); opacity: 0; }
}

.ai-snap-zone::after {
    content: 'SNAP';
    color: white;
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 2px;
}

/* Mobile Tweaks */
@media (max-width: 768px) {
    :root {
        --ai-size: var(--ai-size-mobile);
    }
    
    .ai-chat-window {
        width: calc(100vw - 40px);
        max-height: 70vh;
    }
}

/* Chat Window Resizer */
.ai-message.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 40px;
    width: 60px;
}

.ai-resizer {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    cursor: nwse-resize;
    z-index: 10;
    background: linear-gradient(135deg, transparent 50%, rgba(255,255,255,0.05) 50%);
    border-bottom-right-radius: 24px;
}

.ai-chat-window {
    min-width: 280px;
    min-height: 200px;
}
