:root {
    --ash-primary: #6366f1; /* Modern Indigo */
    --ash-primary-dark: #4f46e5;
    --ash-bg: #0f172a;
    --ash-surface: #1e293b;
    --ash-border: rgba(255, 255, 255, 0.1);
    --ash-text: #f8fafc;
    --ash-text-muted: #94a3b8;
    --ash-font: 'Inter', sans-serif;
    --ash-radius: 16px;
    --ash-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
}

/* Reset */
#ashley-bot-root * {
    box-sizing: border-box;
}

#ashley-bot-root {
    position: fixed;
    bottom: 110px;
    right: 30px; /* Standard bottom-right placement */
    z-index: 10000;
    font-family: var(--ash-font);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 15px;
    pointer-events: none; /* Let clicks pass through empty space */
}

/* -----------------------------
   The Bubble
----------------------------- */
#ashley-bubble {
    pointer-events: auto;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--ash-primary), var(--ash-primary-dark));
    border-radius: 50%;
    box-shadow: 0 10px 25px rgba(99, 102, 241, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}

#ashley-bubble:hover {
    transform: scale(1.1);
}

#ashley-bubble i {
    font-size: 28px;
    transition: transform 0.3s ease, opacity 0.3s ease;
    position: absolute;
}

/* Icon Swapping Animation */
.ashley-icon-opened { opacity: 0; transform: rotate(-90deg); }
.ashley-icon-closed { opacity: 1; transform: rotate(0); }

#ashley-bot-root.active #ashley-bubble .ashley-icon-opened { opacity: 1; transform: rotate(0); }
#ashley-bot-root.active #ashley-bubble .ashley-icon-closed { opacity: 0; transform: rotate(90deg); }

/* Notification Badge on Bubble */
.ashley-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #ef4444;
    color: white;
    font-size: 11px;
    font-weight: 700;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--ash-bg);
    opacity: 0;
    transform: scale(0);
    transition: 0.3s ease;
}
.ashley-badge.show { opacity: 1; transform: scale(1); }

/* -----------------------------
   The Chat Panel
----------------------------- */
#ashley-panel {
    pointer-events: auto;
    width: 360px;
    height: 550px;
    max-height: calc(100vh - 120px);
    background: rgba(15, 23, 42, 0.95); /* Semi-transparent dark */
    backdrop-filter: blur(12px); /* Glass effect */
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--ash-border);
    border-radius: 24px;
    box-shadow: var(--ash-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    
    /* Animation State: Closed */
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transform-origin: bottom right;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    visibility: hidden;
}

#ashley-bot-root.active #ashley-panel {
    opacity: 1;
    transform: translateY(0) scale(1);
    visibility: visible;
}

/* Header */
#ashley-header {
    padding: 18px 20px;
    background: rgba(255,255,255,0.03);
    border-bottom: 1px solid var(--ash-border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.ashley-avatar-lg {
    position: relative;
    width: 42px;
    height: 42px;
}
.ashley-avatar-lg img {
    width: 100%;
    height: 100%;
    border-radius: 12px;
    object-fit: cover;
}
.ashley-status-dot {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    background: #10b981; /* Online Green */
    border: 2px solid var(--ash-surface);
    border-radius: 50%;
}

.ashley-meta { flex: 1; }
.ashley-name { font-weight: 600; color: var(--ash-text); font-size: 15px; }
.ashley-sub { font-size: 12px; color: var(--ash-text-muted); }

.ashley-controls button {
    background: transparent;
    border: none;
    color: var(--ash-text-muted);
    font-size: 18px;
    cursor: pointer;
    padding: 5px;
    transition: color 0.2s;
}
.ashley-controls button:hover { color: var(--ash-text); }
.ashley-controls button.active { color: #ef4444; animation: pulse-red 1.5s infinite; }

@keyframes pulse-red { 0% { opacity: 1; } 50% { opacity: 0.5; } 100% { opacity: 1; } }

/* Body */
#ashley-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

#ashley-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

/* Custom Scrollbar */
#ashley-messages::-webkit-scrollbar { width: 6px; }
#ashley-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }
#ashley-messages::-webkit-scrollbar-track { background: transparent; }

/* Messages */
.ashley-msg-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    animation: fadeUp 0.3s ease forwards;
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.ashley-msg-row.user { justify-content: flex-end; }

/* Avatars in Chat */
.ashley-avatar-xs {
    width: 28px;
    height: 28px;
    background: var(--ash-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    flex-shrink: 0;
}

.ashley-msg-bubble {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
}

/* Bot Bubble Style */
.ashley-msg-row.bot .ashley-msg-bubble {
    background: var(--ash-surface);
    color: var(--ash-text);
    border-bottom-left-radius: 4px; /* Tail effect */
}

/* User Bubble Style */
.ashley-msg-row.user .ashley-msg-bubble {
    background: var(--ash-primary);
    color: white;
    border-bottom-right-radius: 4px; /* Tail effect */
}

.ashley-timestamp {
    display: block;
    font-size: 10px;
    margin-top: 4px;
    opacity: 0.7;
    text-align: right;
}

/* Typing Animation */
.ashley-typing-container {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 0 20px 20px;
    display: none; /* Hidden by default */
}
.ashley-typing-container.active { display: flex; }

.ashley-typing-bubble {
    background: var(--ash-surface);
    padding: 12px 16px;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    display: flex;
    gap: 4px;
}
.ashley-typing-bubble span {
    width: 6px;
    height: 6px;
    background: var(--ash-text-muted);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}
.ashley-typing-bubble span:nth-child(1) { animation-delay: -0.32s; }
.ashley-typing-bubble span:nth-child(2) { animation-delay: -0.16s; }
@keyframes typing { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }

/* Footer Input */
#ashley-footer {
    padding: 15px;
    background: rgba(255,255,255,0.02);
    border-top: 1px solid var(--ash-border);
}

#ashley-input-wrap {
    display: flex;
    background: var(--ash-bg);
    border: 1px solid var(--ash-border);
    border-radius: 99px; /* Pill shape */
    padding: 4px;
    transition: border-color 0.2s;
}
#ashley-input-wrap:focus-within { border-color: var(--ash-primary); }

#ashley-input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 10px 16px;
    color: white;
    font-size: 14px;
    outline: none;
    font-family: var(--ash-font);
}

#ashley-send {
    background: var(--ash-primary);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}
#ashley-send:hover { transform: scale(1.05); }

/* Mobile */
@media (max-width: 480px) {
    #ashley-bot-root {
        bottom: 110px;
        right: 20px;
        z-index: 99999999;
    }
    #ashley-panel {
        width: calc(100vw - 40px);
        height: 60vh;
        position: fixed;
        bottom: 185px;
        right: 20px;
    }
}