/* AI Knowledge Base – custom styles (UIkit handles layout/components) */

/* Status indicator */
.untz-chat__status {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    font-size: 0.8em;
    color: #999;
}

.untz-chat__status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ccc;
    flex-shrink: 0;
    position: relative;
    transition: background 0.4s ease;
}

.untz-chat__status-text {
    transition: color 0.4s ease;
}

/* Connecting state */
.untz-chat__status--connecting .untz-chat__status-dot {
    background: #f0a500;
    animation: untz-blink 1s ease-in-out infinite;
}

.untz-chat__status--connecting .untz-chat__status-text {
    color: #f0a500;
}

/* Online / active state */
.untz-chat__status--online .untz-chat__status-dot {
    background: #32d296;
}

.untz-chat__status--online .untz-chat__status-dot::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    background: rgba(50, 210, 150, 0.5);
    animation: untz-pulse 2s ease-in-out infinite;
}

.untz-chat__status--online .untz-chat__status-text {
    color: #32d296;
}

/* Away state */
.untz-chat__status--away .untz-chat__status-dot {
    background: #999;
}

.untz-chat__status--away .untz-chat__status-text {
    color: #999;
}

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

@keyframes untz-blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.4; }
}

/* Card header — bot identity */
.untz-chat__header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
}

.untz-chat__header-avatar--placeholder {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    background: rgba(128, 128, 128, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.untz-chat__header-avatar--placeholder svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
    opacity: 0.6;
}

.untz-chat__header-name {
    font-weight: 600;
    font-size: 0.95em;
    line-height: 1.2;
}

.untz-chat__header-row {
    gap: 12px;
}

/* Status indicator inside header — remove bottom margin */
.untz-chat__header .untz-chat__status {
    margin-bottom: 0;
}

/* Header info/options menu (disclaimer + actions) */
.untz-chat__menu {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}

.untz-chat__menu-toggle {
    display: inline-flex;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.15s ease;
}

.untz-chat__menu-toggle:hover,
.untz-chat__menu-toggle:focus {
    opacity: 1;
}

.untz-chat__dropdown {
    max-width: 280px;
}

.untz-chat__disclaimer-text {
    line-height: 1.45;
}

/* Messages area — height only; card-body handles padding */
.untz-chat__messages {
    height: 320px;
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
    transition: scrollbar-color 0.2s ease;
}

.untz-chat__messages:hover {
    scrollbar-color: rgba(128, 128, 128, 0.4) transparent;
}

.untz-chat__messages::-webkit-scrollbar {
    width: 4px;
}

.untz-chat__messages::-webkit-scrollbar-track {
    background: transparent;
}

.untz-chat__messages::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.untz-chat__messages:hover::-webkit-scrollbar-thumb {
    background: rgba(128, 128, 128, 0.4);
}

.untz-chat__messages:hover::-webkit-scrollbar-thumb:hover {
    background: rgba(128, 128, 128, 0.65);
}

.untz-chat__list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Message bubbles */
.untz-chat__message {
    display: flex;
    max-width: 80%;
}

.untz-chat__message--user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.untz-chat__message--assistant {
    align-self: flex-start;
}

.untz-chat__bubble {
    padding: 8px 14px;
    border-radius: 18px;
    line-height: 1.5;
    word-break: break-word;
}

.untz-chat__message--user .untz-chat__bubble {
    border-bottom-right-radius: 4px;
}

.untz-chat__message--user .untz-chat__bubble:not([class*="uk-background"]):not([class*="uk-card"]):not([class*="uk-tile"]) {
    background: #1e87f0; /* UIkit primary */
    color: #fff;
}

.untz-chat__message--assistant .untz-chat__bubble {
    border-bottom-left-radius: 4px;
}

.untz-chat__message--assistant .untz-chat__bubble:not([class*="uk-background"]):not([class*="uk-card"]):not([class*="uk-tile"]) {
    background: #f8f8f8;
    color: #333;
}

.untz-chat__bubble.uk-tile {
    padding: 8px 14px;
}

/* Typing indicator */
.untz-chat__typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 0;
}

.untz-chat__dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #999;
    animation: untz-bounce 1.2s infinite;
}

.untz-chat__dot:nth-child(2) { animation-delay: 0.2s; }
.untz-chat__dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes untz-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%           { transform: translateY(-5px); }
}

/* Markdown typography inside assistant bubbles */
.untz-chat__message--assistant .untz-chat__bubble p {
    margin: 0 0 6px;
}

.untz-chat__message--assistant .untz-chat__bubble p:last-child {
    margin-bottom: 0;
}

.untz-chat__message--assistant .untz-chat__bubble ul,
.untz-chat__message--assistant .untz-chat__bubble ol {
    margin: 4px 0 6px;
    padding-left: 20px;
}

.untz-chat__message--assistant .untz-chat__bubble li {
    margin-bottom: 2px;
}

.untz-chat__message--assistant .untz-chat__bubble h2 {
    font-size: 1.05em;
    font-weight: 700;
    margin: 0 0 6px;
    line-height: 1.3;
}

.untz-chat__message--assistant .untz-chat__bubble strong {
    font-weight: 600;
}

.untz-chat__message--assistant .untz-chat__bubble em {
    font-style: italic;
}

.untz-chat__message--assistant .untz-chat__bubble code {
    font-family: monospace;
    background: rgba(0, 0, 0, 0.07);
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 0.9em;
}

.untz-chat__message--assistant .untz-chat__bubble a {
    text-decoration: underline;
    color: inherit;
}

/* Quick-start prompt buttons */
.untz-chat__prompts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.untz-chat__prompt-btn {
    background: transparent;
    border: 1px solid #1e87f0;
    color: #1e87f0;
    border-radius: 18px;
    padding: 6px 14px;
    font-size: 0.875em;
    cursor: pointer;
    line-height: 1.4;
    transition: background 0.15s, color 0.15s;
}

.untz-chat__prompt-btn:hover,
.untz-chat__prompt-btn:focus {
    background: #1e87f0;
    color: #fff;
    outline: none;
}

/* Char counter + meta row */
.untz-chat__meta {
    margin-top: 5px !important;
    font-size: 10px;
    /* The privacy notice can run to two lines in a narrow panel while the
       counter never does, so align on the first baseline rather than stretching
       the counter down the side of a wrapped sentence. */
    align-items: baseline;
    gap: 12px;
}

.untz-chat__chars {
    margin-left: auto;
    flex: 0 0 auto;
    white-space: nowrap;
}

.untz-chat__chars--warn {
    color: #f0506e;
}

/* Privacy notice, sharing the meta row with the counter. Size and colour come
   from .untz-chat__meta, so it stays quiet by default; it takes the leftover
   width and wraps inside its own column instead of pushing the counter around. */
.untz-chat__privacy {
    flex: 1 1 auto;
    min-width: 0;
    line-height: 1.45;
    opacity: 0.75;
}

.untz-chat__privacy a {
    color: inherit;
    text-decoration: underline;
}

/* =====================================================
   Floating Chat Bubble  (templates/chat-bubble.php)
   ===================================================== */

.untz-bubble-wrap {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9998;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
}

.untz-bubble-wrap--bottom-left {
    right: auto;
    left: 24px;
    align-items: flex-start;
}

/* FAB toggle button — shape and shadow only; color comes from UIkit classes */
.untz-bubble-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    flex-shrink: 0;
}

.untz-bubble-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.32);
}

.untz-bubble-icon {
    width: 24px;
    height: 24px;
    fill: currentColor;
    pointer-events: none;
}

/* Panel — positioning and animation only; card style comes from UIkit classes on the inner widget */
.untz-bubble-panel {
    width: 360px;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    transform: translateY(16px) scale(0.97);
    opacity: 0;
    transition: transform 0.25s ease, opacity 0.25s ease;
    pointer-events: none;
}

.untz-bubble-panel.is-open {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
}

/* The chat widget inside the bubble needs its border-radius to match the panel */
.untz-bubble-panel .untz-chat {
    border-radius: 16px;
}

/* Shrink message area inside the bubble */
.untz-bubble-panel .untz-chat__messages {
    height: 260px;
}

/* Mobile: full-screen panel */
@media (max-width: 480px) {
    .untz-bubble-wrap {
        bottom: 16px;
        right: 16px;
    }

    .untz-bubble-wrap--bottom-left {
        left: 16px;
    }

    /* position: fixed on a child of a position: fixed parent (without transform)
       is still viewport-relative, so this breaks out to full screen. */
    .untz-bubble-panel {
        position: fixed;
        inset: 0;
        width: auto;
        border-radius: 0;
        transform: translateY(100%);
    }

    .untz-bubble-panel .untz-chat {
        border-radius: 0;
    }

    .untz-bubble-panel.is-open {
        transform: translateY(0);
    }
}
