/* =============================================================================
   CHATBOT WIDGET STYLES
   =============================================================================
   GOV.UK-compatible styling for the compliance assistant chat widget.
   Uses design tokens from the main stylesheet.
   ============================================================================= */

/* Container - floating bottom-right */
.chatbot-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 1000;
    font-family: "Noto Sans", Arial, sans-serif;
}

/* Toggle button (minimised state) */
.chatbot-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background-color: var(--color-gov-blue);
    color: white;
    border: none;
    border-radius: 2rem;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.chatbot-toggle:hover {
    background-color: var(--color-gov-blue-dark);
    transform: translateY(-2px);
}

.chatbot-toggle:focus {
    outline: 3px solid var(--color-focus);
    outline-offset: 2px;
}

.chatbot-icon {
    width: 1.5rem;
    height: 1.5rem;
}

.chatbot-toggle-text {
    white-space: nowrap;
}

/* Hide toggle when expanded */
.chatbot-container:not(.chatbot-minimised) .chatbot-toggle {
    display: none;
}

/* Panel (expanded state) */
.chatbot-panel {
    display: none;
    flex-direction: column;
    width: 400px;
    max-width: calc(100vw - 2rem);
    height: 600px;
    max-height: calc(100vh - 3rem);
    background-color: white;
    border-radius: 0.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.chatbot-container:not(.chatbot-minimised) .chatbot-panel {
    display: flex;
}

/* Header */
.chatbot-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 1rem;
    background-color: var(--color-gov-blue);
    color: white;
}

.chatbot-header-content {
    flex: 1;
}

.chatbot-title {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 700;
    line-height: 1.25;
}

.chatbot-subtitle {
    margin: 0.25rem 0 0;
    font-size: 0.875rem;
    opacity: 0.9;
}

.chatbot-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    border-radius: 0.25rem;
    margin-left: 0.5rem;
}

.chatbot-close:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.chatbot-close:focus {
    outline: 3px solid var(--color-focus);
    outline-offset: 2px;
}

.chatbot-close svg {
    width: 1.25rem;
    height: 1.25rem;
}

/* Messages area */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background-color: var(--color-bg-light);
}

/* Individual message */
.chatbot-message {
    margin-bottom: 1rem;
    max-width: 85%;
}

.chatbot-message:last-child {
    margin-bottom: 0;
}

.chatbot-message-user {
    margin-left: auto;
}

.chatbot-message-assistant {
    margin-right: auto;
}

.chatbot-message-content {
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.9375rem;
    line-height: 1.5;
}

.chatbot-message-user .chatbot-message-content {
    background-color: var(--color-gov-blue);
    color: white;
    border-bottom-right-radius: 0.125rem;
}

.chatbot-message-assistant .chatbot-message-content {
    background-color: white;
    color: var(--color-text-primary);
    border: 1px solid var(--color-border);
    border-bottom-left-radius: 0.125rem;
}

.chatbot-message-content p {
    margin: 0 0 0.5rem;
}

.chatbot-message-content p:last-child {
    margin-bottom: 0;
}

.chatbot-message-content ul {
    margin: 0.5rem 0;
    padding-left: 1.25rem;
}

.chatbot-message-content li {
    margin-bottom: 0.25rem;
}

.chatbot-message-content a {
    color: var(--color-gov-blue);
    text-decoration: underline;
}

.chatbot-message-content a:hover {
    text-decoration: none;
}

/* Loading indicator */
.chatbot-message-loading .chatbot-message-content {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.chatbot-loading-dot {
    width: 0.5rem;
    height: 0.5rem;
    background-color: var(--color-text-secondary);
    border-radius: 50%;
    animation: chatbot-bounce 1.4s ease-in-out infinite both;
}

.chatbot-loading-dot:nth-child(1) { animation-delay: -0.32s; }
.chatbot-loading-dot:nth-child(2) { animation-delay: -0.16s; }
.chatbot-loading-dot:nth-child(3) { animation-delay: 0s; }

@keyframes chatbot-bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* Error message */
.chatbot-message-error .chatbot-message-content {
    background-color: var(--color-warning);
    color: white;
}

/* Form */
.chatbot-form {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    padding: 0.75rem;
    background-color: white;
    border-top: 1px solid var(--color-border);
}

.chatbot-input {
    flex: 1;
    min-height: 2.5rem;
    max-height: 8rem;
    padding: 0.625rem 0.75rem;
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.25;
    border: 2px solid var(--color-text-primary);
    border-radius: 0;
    resize: none;
}

.chatbot-input:focus {
    outline: 3px solid var(--color-focus);
    outline-offset: 0;
    border-color: var(--color-text-primary);
}

.chatbot-input::placeholder {
    color: var(--color-text-secondary);
}

.chatbot-send {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    background-color: var(--color-success);
    color: white;
    border: none;
    cursor: pointer;
}

.chatbot-send:hover {
    background-color: var(--color-success-dark);
}

.chatbot-send:focus {
    outline: 3px solid var(--color-focus);
    outline-offset: 0;
}

.chatbot-send:disabled {
    background-color: var(--color-border);
    cursor: not-allowed;
}

.chatbot-send svg {
    width: 1.25rem;
    height: 1.25rem;
}

/* Footer */
.chatbot-footer {
    padding: 0.5rem 0.75rem;
    background-color: var(--color-bg-light);
    border-top: 1px solid var(--color-border);
}

.chatbot-disclaimer {
    margin: 0;
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    text-align: center;
}

.chatbot-disclaimer-link {
    color: var(--color-gov-blue);
}

/* Suggested prompts */
.chatbot-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0 0 0.5rem;
}

.chatbot-suggestions:empty {
    display: none;
}

.chatbot-suggestion {
    display: inline-block;
    padding: 0.5rem 1rem;
    font-family: inherit;
    font-size: 0.875rem;
    line-height: 1.3;
    color: var(--color-gov-blue);
    background-color: white;
    border: 1px solid var(--color-border);
    border-radius: 1.25rem;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease;
    text-align: left;
}

.chatbot-suggestion:hover {
    border-color: var(--color-gov-blue);
    background-color: var(--color-bg-light);
}

.chatbot-suggestion:focus {
    outline: 3px solid var(--color-focus);
    outline-offset: 1px;
}

/* Accessibility */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Mobile responsive */
@media (max-width: 480px) {
    .chatbot-container {
        top: 0;
        bottom: 0;
        right: 0;
        left: 0;
        z-index: 10000; /* Above facet overlay (9999) when expanded */
    }

    .chatbot-container.chatbot-minimised {
        top: auto;
        bottom: 1rem;
        right: 1rem;
        left: auto;
        z-index: 1000; /* Below facet overlay when minimised */
    }

    .chatbot-panel {
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .chatbot-toggle-text {
        display: none;
    }

    .chatbot-toggle {
        width: 3.5rem;
        height: 3.5rem;
        padding: 0;
        justify-content: center;
        border-radius: 50%;
    }

    .chatbot-icon {
        width: 1.75rem;
        height: 1.75rem;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .chatbot-toggle,
    .chatbot-loading-dot {
        animation: none;
        transition: none;
    }
}
