/* RKR Voice Assistant — frontend widget */

.rkr-va-root {
    --rkr-va-accent: #3a9e4a;
    --rkr-va-icon: #ffffff;
    --rkr-va-bg: #ffffff;
    --rkr-va-fg: #1d2327;
    --rkr-va-muted: #6b7280;
    --rkr-va-bubble-user: #eef6ef;
    --rkr-va-bubble-bot: #f5f5f3;
    --rkr-va-radius: 18px;
    --rkr-va-shadow: 0 12px 40px rgba(0, 0, 0, .18);
    position: fixed;
    bottom: 24px;
    z-index: 99990;
    font-family: "Barlow", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.45;
}

.rkr-va-root.rkr-va-right { right: 24px; }
.rkr-va-root.rkr-va-left  { left: 24px; }

/* Floating action button */
.rkr-va-fab {
    width: 60px;
    height: 60px;
    border: 0;
    border-radius: 50%;
    background: var(--rkr-va-accent);
    color: var(--rkr-va-icon);
    cursor: pointer;
    display: grid;
    place-items: center;
    box-shadow: var(--rkr-va-shadow);
    transition: transform .18s ease, box-shadow .18s ease;
    position: relative;
    margin-left: auto;
}
.rkr-va-fab:hover { transform: scale(1.06); }
.rkr-va-fab:active { transform: scale(.96); }
.rkr-va-fab svg {
    width: 26px;
    height: 26px;
    fill: none;
    stroke: var(--rkr-va-icon);
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.rkr-va-fab .rkr-va-ic-close { display: none; }
.rkr-va-root[data-state="open"] .rkr-va-fab .rkr-va-ic-mic { display: none; }
.rkr-va-root[data-state="open"] .rkr-va-fab .rkr-va-ic-close { display: block; }

/* Panel */
.rkr-va-panel {
    position: absolute;
    bottom: 76px;
    width: min(380px, calc(100vw - 32px));
    max-height: min(620px, calc(100vh - 120px));
    background: var(--rkr-va-bg);
    color: var(--rkr-va-fg);
    border-radius: var(--rkr-va-radius);
    box-shadow: var(--rkr-va-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    animation: rkr-va-in .2s ease;
}
.rkr-va-root.rkr-va-right .rkr-va-panel { right: 0; }
.rkr-va-root.rkr-va-left  .rkr-va-panel { left: 0; transform-origin: bottom left; }

@keyframes rkr-va-in {
    from { opacity: 0; transform: translateY(10px) scale(.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.rkr-va-panel-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: var(--rkr-va-accent);
    color: #fff;
}
.rkr-va-dot {
    width: 9px; height: 9px;
    border-radius: 50%;
    background: #fff;
    opacity: .9;
    box-shadow: 0 0 0 0 rgba(255,255,255,.6);
    animation: rkr-va-pulse 2.4s infinite;
}
@keyframes rkr-va-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(255,255,255,.55); }
    70%  { box-shadow: 0 0 0 9px rgba(255,255,255,0); }
    100% { box-shadow: 0 0 0 0 rgba(255,255,255,0); }
}
.rkr-va-panel-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    flex: 1;
    color: #fff;
}
.rkr-va-panel-close {
    background: transparent; border: 0; color: #fff;
    font-size: 24px; line-height: 1; cursor: pointer; opacity: .85;
    padding: 0 4px;
}
.rkr-va-panel-close:hover { opacity: 1; }

/* Conversation log */
.rkr-va-log {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 120px;
}
.rkr-va-msg {
    max-width: 86%;
    padding: 10px 14px;
    border-radius: 14px;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.rkr-va-msg.user {
    align-self: flex-end;
    background: var(--rkr-va-bubble-user);
    border-bottom-right-radius: 4px;
}
.rkr-va-msg.bot {
    align-self: flex-start;
    background: var(--rkr-va-bubble-bot);
    border-bottom-left-radius: 4px;
}
.rkr-va-msg.bot.is-typing { color: var(--rkr-va-muted); font-style: italic; }
.rkr-va-sources {
    align-self: flex-start;
    font-size: 12px;
    color: var(--rkr-va-muted);
    max-width: 86%;
}
.rkr-va-sources a { color: var(--rkr-va-accent); text-decoration: none; }
.rkr-va-sources a:hover { text-decoration: underline; }

/* Status line */
.rkr-va-status {
    min-height: 20px;
    padding: 0 16px;
    font-size: 13px;
    color: var(--rkr-va-muted);
    text-align: center;
}
.rkr-va-status.error { color: #c0392b; }

/* Controls */
.rkr-va-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px 16px;
    border-top: 1px solid rgba(0,0,0,.06);
}
.rkr-va-mic {
    flex: 0 0 auto;
    width: 48px; height: 48px;
    border: 0; border-radius: 50%;
    background: var(--rkr-va-accent);
    color: #fff; cursor: pointer;
    display: grid; place-items: center;
    transition: transform .15s ease;
}
.rkr-va-mic svg {
    width: 22px; height: 22px;
    fill: none; stroke: #fff; stroke-width: 1.8;
    stroke-linecap: round; stroke-linejoin: round;
}
.rkr-va-mic:hover { transform: scale(1.05); }
.rkr-va-mic.recording {
    background: #c0392b;
    animation: rkr-va-rec 1.2s infinite;
}
@keyframes rkr-va-rec {
    0%   { box-shadow: 0 0 0 0 rgba(192,57,43,.5); }
    70%  { box-shadow: 0 0 0 12px rgba(192,57,43,0); }
    100% { box-shadow: 0 0 0 0 rgba(192,57,43,0); }
}
.rkr-va-mic[disabled] { opacity: .4; cursor: not-allowed; }

.rkr-va-form {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f1f1ef;
    border-radius: 24px;
    padding: 4px 4px 4px 14px;
}
.rkr-va-input {
    flex: 1;
    border: 0; background: transparent;
    font: inherit; color: var(--rkr-va-fg);
    outline: none;
    padding: 8px 0;
}
.rkr-va-send {
    flex: 0 0 auto;
    width: 38px; height: 38px;
    border: 0; border-radius: 50%;
    background: var(--rkr-va-accent);
    color: #fff; cursor: pointer;
    display: grid; place-items: center;
}
.rkr-va-send svg {
    width: 18px; height: 18px;
    fill: #fff; stroke: none;
}

/* Sound wave indicator while speaking */
.rkr-va-root[data-state="speaking"] .rkr-va-dot { animation-duration: .8s; }

@media (max-width: 480px) {
    .rkr-va-root { bottom: 16px; }
    .rkr-va-root.rkr-va-right { right: 16px; }
    .rkr-va-root.rkr-va-left  { left: 16px; }
    .rkr-va-panel { bottom: 72px; }
}

@media (prefers-reduced-motion: reduce) {
    .rkr-va-panel, .rkr-va-dot, .rkr-va-mic.recording, .rkr-va-fab { animation: none; transition: none; }
}
