/* Website chat: the button, the window and the panel (task 683, 2026-11-05; ChatKit removed).
   Colours of this site: */
#chatkit-container {
    --cz-accent: #157535;
    --cz-accent-ink: #ffffff;
    --cz-link: #157535;
    --cz-icon: #157535;
    --cz-focus: rgba(21, 117, 53, 0.15);
}

#chatkit-container {
    position: fixed;
    bottom: 100px;
    right: 20px;
    width: 400px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 120px);
    z-index: 1000;
    display: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border-radius: 12px;
    overflow: hidden;
    transition: opacity 0.3s ease, transform 0.3s ease;
    opacity: 0;
    transform: translateY(10px) scale(0.95);
    box-sizing: border-box;
    contain: layout style paint;
}

#chatkit-container.open {
    display: block;
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Close control, top left (the panel header leaves room for it) */
#chatkit-close-button {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 20;
    width: 40px;
    height: 40px;
    padding: 0;
    margin: 0;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    transition: background 0.15s ease, box-shadow 0.15s ease;
}

#chatkit-close-button:hover {
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

#chatkit-close-button:focus-visible {
    outline: 2px solid #eab308;
    outline-offset: 2px;
}

#chatkit-close-button svg {
    width: 22px;
    height: 22px;
    fill: #1a1a1a;
}

/* Toggle button */
#chat-toggle-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    min-width: 200px;
    height: 70px;
    padding: 12px 16px;
    border-radius: 12px;
    background: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    z-index: 1001;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#chat-toggle-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

#chat-toggle-button:active {
    transform: translateY(0);
}

/* Robot icon container */
#chat-toggle-button .robot-icon-container {
    position: relative;
    flex-shrink: 0;
    width: 48px;
    height: 48px;
}

/* Robot icon circle */
#chat-toggle-button .robot-icon-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #157535;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Robot icon SVG */
#chat-toggle-button .robot-icon-circle svg {
    width: 32px;
    height: 32px;
    fill: white;
}

/* Online status indicator */
#chat-toggle-button .online-indicator {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #4CAF50;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Text content */
#chat-toggle-button .button-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    min-width: 0;
}

#chat-toggle-button .button-title {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a1a;
    line-height: 1.2;
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

#chat-toggle-button .button-status {
    font-size: 13px;
    font-weight: 400;
    color: #666;
    line-height: 1.2;
    margin: 2px 0 0 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Hide old chat/close icons */
#chat-toggle-button .chat-icon,
#chat-toggle-button .close-icon {
    display: none;
}

/* Responsive design */
@media (max-width: 768px) {
    #chatkit-container {
        width: calc(100vw - 20px);
        max-width: calc(100vw - 20px);
        top: 10px;
        bottom: 83px;
        right: 10px;
        left: 10px;
        height: auto;
        max-height: none;
    }

    #chatkit-close-button {
        top: 8px;
        left: 8px;
        width: 38px;
        height: 38px;
    }

    #chatkit-close-button svg {
        width: 20px;
        height: 20px;
    }
    
    #chat-toggle-button {
        bottom: 15px;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        min-width: 180px;
        height: 64px;
        padding: 10px 14px;
        z-index: 1002;
        position: fixed;
    }
    
    #chat-toggle-button:hover {
        transform: translateX(-50%) translateY(-2px);
    }
    
    #chat-toggle-button:active {
        transform: translateX(-50%);
    }
    
    #chat-toggle-button .robot-icon-container {
        width: 44px;
        height: 44px;
    }
    
    #chat-toggle-button .robot-icon-circle {
        width: 44px;
        height: 44px;
    }
    
    #chat-toggle-button .robot-icon-circle svg {
        width: 28px;
        height: 28px;
    }
    
    #chat-toggle-button .button-title {
        font-size: 15px;
    }
    
    #chat-toggle-button .button-status {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    #chatkit-container {
        width: calc(100vw - 16px);
        max-width: calc(100vw - 16px);
        top: 8px;
        bottom: 76px;
        right: 8px;
        left: 8px;
        height: auto;
        max-height: none;
    }

    #chatkit-close-button {
        top: 6px;
        left: 6px;
        width: 36px;
        height: 36px;
    }

    #chatkit-close-button svg {
        width: 18px;
        height: 18px;
    }
    
    #chat-toggle-button {
        bottom: 12px;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        min-width: 160px;
        height: 60px;
        padding: 8px 12px;
        z-index: 1002;
        position: fixed;
    }
    
    #chat-toggle-button:hover {
        transform: translateX(-50%) translateY(-2px);
    }
    
    #chat-toggle-button:active {
        transform: translateX(-50%);
    }
    
    #chat-toggle-button .robot-icon-container {
        width: 40px;
        height: 40px;
    }
    
    #chat-toggle-button .robot-icon-circle {
        width: 40px;
        height: 40px;
    }
    
    #chat-toggle-button .robot-icon-circle svg {
        width: 24px;
        height: 24px;
    }
    
    #chat-toggle-button .button-title {
        font-size: 14px;
    }
    
    #chat-toggle-button .button-status {
        font-size: 11px;
    }
}

/* ------------------------------------------------------------------ the chat panel (task 683, replaces ChatKit) */

#chatkit-container {
    background: #fff;
    color: #1a1a1a;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.cz-chat { display: flex; flex-direction: column; height: 100%; }

.cz-head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 60px;
    padding: 0 10px 0 60px;
    border-bottom: 1px solid #eee;
    box-sizing: border-box;
}
.cz-title { flex: 1; min-width: 0; font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cz-new {
    flex: 0 0 auto;
    width: 38px; height: 38px;
    padding: 0; border: none; border-radius: 10px;
    background: transparent; color: #1a1a1a; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.cz-new[hidden] { display: none; }
.cz-new:hover { background: #f2f2f2; }
.cz-new svg { width: 20px; height: 20px; stroke: currentColor; }

.cz-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 18px 16px; box-sizing: border-box; }
/* The sites colour every scrollbar (SRM: 8px green); the chat keeps a thin grey one. */
.cz-body, .cz-input { scrollbar-width: thin; scrollbar-color: #c8c8c8 transparent; }
.cz-body::-webkit-scrollbar, .cz-input::-webkit-scrollbar { width: 6px; }
.cz-body::-webkit-scrollbar-track, .cz-input::-webkit-scrollbar-track { background: transparent; }
.cz-body::-webkit-scrollbar-thumb, .cz-input::-webkit-scrollbar-thumb { background: #c8c8c8; border-radius: 3px; }

.cz-start { display: flex; flex-direction: column; justify-content: flex-end; min-height: 100%; gap: 16px; }
.cz-start[hidden] { display: none; }
.cz-greeting { margin: 0; font-size: 22px; line-height: 1.3; font-weight: 600; color: #1a1a1a; }
.cz-prompts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.cz-prompt {
    width: 100%;
    display: flex; align-items: center; gap: 10px;
    padding: 11px 14px;
    border: 1px solid #e3e3e3; border-radius: 12px;
    background: #fff; color: #1a1a1a;
    font: inherit; font-size: 15px; line-height: 1.35; text-align: left;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.cz-prompt:hover { border-color: var(--cz-accent); background: #fafafa; }
.cz-prompt svg { flex: 0 0 18px; width: 18px; height: 18px; stroke: var(--cz-icon); }

.cz-messages { display: flex; flex-direction: column; gap: 12px; }
.cz-msg { max-width: 88%; font-size: 15px; line-height: 1.5; overflow-wrap: anywhere; }
.cz-user {
    align-self: flex-end;
    padding: 9px 14px;
    border-radius: 18px 18px 4px 18px;
    background: var(--cz-accent); color: var(--cz-accent-ink);
    white-space: pre-wrap;
}
.cz-bot { align-self: flex-start; }
.cz-bot p, .cz-note p { margin: 0 0 8px; }
.cz-bot p:last-child, .cz-note p:last-child { margin-bottom: 0; }
.cz-bot ul, .cz-bot ol { margin: 0 0 8px; padding-left: 22px; }
.cz-bot li { margin: 2px 0; }
.cz-bot a, .cz-note a { color: var(--cz-link); text-decoration: underline; }
.cz-note {
    align-self: stretch; max-width: none;
    padding: 10px 14px; border-radius: 12px;
    background: #f5f5f5; color: #444; font-size: 14px;
}
.cz-note-action {
    margin-top: 8px; padding: 6px 12px;
    border: 1px solid #d6d6d6; border-radius: 8px;
    background: #fff; color: #1a1a1a; font: inherit; font-size: 14px; cursor: pointer;
}

.cz-pending .cz-text:empty { display: none; }
.cz-typing { display: inline-flex; gap: 5px; padding: 6px 0; }
.cz-has-text .cz-typing { display: none; }
.cz-typing span { width: 7px; height: 7px; border-radius: 50%; background: #9a9a9a; animation: cz-blink 1.2s infinite ease-in-out; }
.cz-typing span:nth-child(2) { animation-delay: 0.15s; }
.cz-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes cz-blink { 0%, 80%, 100% { opacity: 0.25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }
@media (prefers-reduced-motion: reduce) { .cz-typing span { animation: none; opacity: 0.6; } }

.cz-composer {
    flex: 0 0 auto;
    display: flex; align-items: flex-end; gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #eee; background: #fff;
}
.cz-input {
    flex: 1; min-width: 0;
    height: 40px;
    max-height: 120px;
    padding: 8px 14px;
    border: 1px solid #d9d9d9; border-radius: 20px;
    font: inherit; font-size: 16px; line-height: 22px; color: #1a1a1a;
    resize: none; outline: none; box-sizing: border-box;
    overflow-y: hidden; /* one line = exactly 40px; a scrollbar only once the box is full (chat.js grow) */
}
.cz-input:focus { border-color: var(--cz-accent); box-shadow: 0 0 0 3px var(--cz-focus); }
.cz-send {
    flex: 0 0 40px;
    width: 40px; height: 40px;
    padding: 0; border: none; border-radius: 50%;
    background: var(--cz-accent); color: var(--cz-accent-ink);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
}
.cz-send:disabled { opacity: 0.35; cursor: default; }
.cz-send svg { width: 20px; height: 20px; stroke: currentColor; }
.cz-prompt:focus-visible, .cz-new:focus-visible, .cz-send:focus-visible, .cz-note-action:focus-visible { outline: 2px solid var(--cz-accent); outline-offset: 2px; }

/* the proof of work runs invisibly */
.cz-proof { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

@media (max-width: 480px) {
    .cz-head { height: 54px; padding-left: 52px; }
    .cz-greeting { font-size: 20px; }
}
