/*
 * ═══════════════════════════════════════════════════════════════════════════
 * wezunu · askeddi KI-Avatar Widget
 * Developed by Toni Sciacca - mail@tonisciacca.com
 * ═══════════════════════════════════════════════════════════════════════════
 */

/* ── Widget Root ─────────────────────────────────────────────────────────── */
#askeddi {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9500;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    font-family: Outfit, sans-serif;
}

/* ── Toggle Button ───────────────────────────────────────────────────────── */
#askeddi-toggle {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #0f0f14;
    border: 1.5px solid rgba(255,56,92,0.35);
    box-shadow: 0 0 24px rgba(255,56,92,0.15), 0 4px 20px rgba(0,0,0,0.4);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease, border-color 0.3s ease, box-shadow 0.3s ease;
    flex-shrink: 0;
}
#askeddi-toggle:hover {
    transform: scale(1.08);
    border-color: rgba(255,56,92,0.7);
    box-shadow: 0 0 32px rgba(255,56,92,0.28), 0 4px 24px rgba(0,0,0,0.5);
}
#askeddi-toggle canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
    border-radius: 50%;
}

/* Listening pulse ring */
#askeddi-toggle.listening {
    border-color: rgba(34,197,94,0.8);
    box-shadow: 0 0 0 0 rgba(34,197,94,0.4), 0 4px 20px rgba(0,0,0,0.4);
    animation: askeddi-ring 1.4s ease-out infinite;
}
#askeddi-toggle.thinking {
    border-color: rgba(99,102,241,0.8);
    box-shadow: 0 0 24px rgba(99,102,241,0.3), 0 4px 20px rgba(0,0,0,0.4);
}
#askeddi-toggle.speaking {
    border-color: rgba(255,56,92,0.9);
    box-shadow: 0 0 28px rgba(255,56,92,0.35), 0 4px 20px rgba(0,0,0,0.4);
}

@keyframes askeddi-ring {
    0%   { box-shadow: 0 0 0 0 rgba(34,197,94,0.5), 0 4px 20px rgba(0,0,0,0.4); }
    70%  { box-shadow: 0 0 0 14px rgba(34,197,94,0), 0 4px 20px rgba(0,0,0,0.4); }
    100% { box-shadow: 0 0 0 0 rgba(34,197,94,0), 0 4px 20px rgba(0,0,0,0.4); }
}

/* ── Panel ───────────────────────────────────────────────────────────────── */
#askeddi-panel {
    width: 320px;
    max-height: 480px;
    background: #0f0f14;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(12px) scale(0.97);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}
#askeddi-panel.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Panel Header */
.askeddi-hdr {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}
.askeddi-hdr-title {
    font-size: 14px;
    font-weight: 700;
    color: #f1f5f9;
    letter-spacing: 0.02em;
}
.askeddi-hdr-sub {
    font-size: 11px;
    color: #64748b;
    margin-left: auto;
}
.askeddi-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px;
    color: #64748b;
    display: flex;
    align-items: center;
    transition: color 0.15s;
}
.askeddi-close:hover { color: #94a3b8; }
.askeddi-close svg { width: 16px; height: 16px; }

/* Messages */
.askeddi-msgs {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.08) transparent;
}
.askeddi-msg {
    max-width: 88%;
    padding: 9px 12px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.5;
    word-break: break-word;
}
.askeddi-msg--user {
    background: rgba(255,56,92,0.12);
    border: 1px solid rgba(255,56,92,0.2);
    color: #f1f5f9;
    align-self: flex-end;
    border-radius: 12px 12px 3px 12px;
}
.askeddi-msg--ai {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.06);
    color: #cbd5e1;
    align-self: flex-start;
    border-radius: 3px 12px 12px 12px;
}
.askeddi-msg--typing {
    display: flex;
    gap: 5px;
    align-items: center;
    padding: 12px 16px;
}
.askeddi-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255,56,92,0.6);
    animation: askeddi-bounce 1.2s ease-in-out infinite;
}
.askeddi-dot:nth-child(2) { animation-delay: 0.2s; }
.askeddi-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes askeddi-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
    40%           { transform: translateY(-6px); opacity: 1; }
}

/* Input Area */
.askeddi-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}
.askeddi-input {
    flex: 1;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 13px;
    font-family: Outfit, sans-serif;
    color: #f1f5f9;
    outline: none;
    resize: none;
    transition: border-color 0.15s;
}
.askeddi-input:focus { border-color: rgba(255,56,92,0.4); }
.askeddi-input::placeholder { color: #475569; }

.askeddi-btn-mic,
.askeddi-btn-send {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, transform 0.1s;
    flex-shrink: 0;
}
.askeddi-btn-mic {
    background: rgba(255,255,255,0.05);
    color: #64748b;
}
.askeddi-btn-mic:hover { background: rgba(34,197,94,0.15); color: #22c55e; }
.askeddi-btn-mic.active { background: rgba(34,197,94,0.2); color: #22c55e; animation: askeddi-ring 1.4s ease-out infinite; }
.askeddi-btn-mic svg, .askeddi-btn-send svg { width: 15px; height: 15px; }

.askeddi-btn-send {
    background: rgba(255,56,92,0.15);
    color: #FF385C;
}
.askeddi-btn-send:hover { background: rgba(255,56,92,0.25); transform: scale(1.05); }
.askeddi-btn-send:active { transform: scale(0.95); }

/* ── Mobile ──────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    #askeddi { bottom: 80px; right: 16px; }
    #askeddi-panel { width: calc(100vw - 32px); }
}
