/* ==========================================================================
   Chatbot feedback widget styles

   1. SETTINGS         colours, sizes, fonts: change these first
   2. Widget position  launcher + panel placement
   3. Header
   4. Messages         chat bubbles and avatar
   5. Choice buttons   "Report an issue" etc.
   6. Context bar      page + "reporting as"
   7. Composer         text box, paperclip, send button
   8. Typing indicator
   9. Small screens
   ========================================================================== */


/* 1. SETTINGS
   The three --feedback-*-colour values below are overridden by appsettings.json
   (PrimaryColour, PrimaryTextColour, BubbleColour), so change those there instead. */
.feedback-widget {
    /* Colours */
    --feedback-primary-colour: #e30613; /* launcher, user bubbles, main buttons */
    --feedback-on-primary-colour: #ffffff; /* text/icons that sit on the primary colour */
    --feedback-bubble-colour: #f0f1f3; /* the widget's reply bubbles */
    --feedback-text-colour: #1d2127;
    --feedback-muted-text-colour: #6a717b;
    --feedback-border-colour: #e4e6ea;
    --feedback-notice-background: #f4f5f7;
    --feedback-panel-background: #ffffff;
    --feedback-focus-colour: #1a73e8; /* keyboard focus ring */
    /* Sizes */
    --feedback-panel-width: 380px;
    --feedback-panel-height: 600px;
    --feedback-panel-radius: 18px;
    --feedback-bubble-radius: 16px;
    --feedback-button-radius: 10px;
    --feedback-launcher-size: 56px;
    --feedback-edge-gap: 20px; /* distance from the screen edge */
    /* Text */
    --feedback-font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --feedback-font-size: 14px;
}


/* 2. WIDGET POSITION */
.feedback-widget {
    position: fixed;
    bottom: var(--feedback-edge-gap);
    z-index: 2147483000;
    font: var(--feedback-font-size) / 1.45 var(--feedback-font);
    color: var(--feedback-text-colour);
}

    .feedback-widget * {
        box-sizing: border-box;
    }

.feedback-widget--right {
    right: var(--feedback-edge-gap);
}

.feedback-widget--left {
    left: var(--feedback-edge-gap);
}

.feedback-launcher {
    width: var(--feedback-launcher-size);
    height: var(--feedback-launcher-size);
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 16px;
    background: var(--feedback-primary-colour);
    color: var(--feedback-on-primary-colour);
    box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
    cursor: pointer;
}

.feedback-panel {
    position: absolute;
    bottom: calc(var(--feedback-launcher-size) + 12px);
    width: var(--feedback-panel-width);
    max-width: calc(100vw - 24px);
    height: var(--feedback-panel-height);
    max-height: calc(100vh - 100px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--feedback-panel-background);
    border-radius: var(--feedback-panel-radius);
    box-shadow: 0 12px 40px rgba(0, 0, 0, .28);
}

    .feedback-panel[hidden] {
        display: none;
    }

.feedback-widget--right .feedback-panel {
    right: 0;
}

.feedback-widget--left .feedback-panel {
    left: 0;
}

/* All icons share one look */
.feedback-widget svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.feedback-launcher svg {
    width: 24px;
    height: 24px;
}

.feedback-launcher__icon {
    grid-area: 1 / 1;
}

.feedback-launcher__icon--close {
    opacity: 0;
    transform: rotate(-90deg) scale(.6);
}

.feedback-widget--open .feedback-launcher__icon--chat {
    opacity: 0;
    transform: rotate(90deg) scale(.6);
}

.feedback-widget--open .feedback-launcher__icon--close {
    opacity: 1;
    transform: none;
}

@media (prefers-reduced-motion: no-preference) {
    .feedback-launcher__icon {
        transition: opacity .2s ease, transform .2s ease;
    }
}

/* 3. HEADER */
.feedback-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 16px 12px;
}

.feedback-logo {
    flex: none;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: var(--feedback-primary-colour);
    color: var(--feedback-on-primary-colour);
}

    .feedback-logo svg {
        width: 24px;
        height: 24px;
    }

.feedback-header__text {
    flex: 1;
    min-width: 0;
}

.feedback-title {
    margin: 0;
    font-size: 17px;
    font-weight: 650;
}

.feedback-subtitle {
    margin: 0;
    color: var(--feedback-muted-text-colour);
}

.feedback-close-button {
    padding: 6px;
    border: 0;
    background: none;
    color: var(--feedback-text-colour);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.feedback-notice {
    margin: 0 16px 8px;
    padding: 9px 12px;
    border-radius: 10px;
    background: var(--feedback-notice-background);
    color: var(--feedback-muted-text-colour);
    font-size: 13px;
    text-align: center;
}


/* 4. MESSAGES */
.feedback-messages {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 8px 16px;
    overflow-y: auto;
}

.feedback-message {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.feedback-message--user {
    justify-content: flex-end;
}

.feedback-avatar {
    flex: none;
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--feedback-primary-colour);
    color: var(--feedback-on-primary-colour);
}

    .feedback-avatar svg {
        width: 15px;
        height: 15px;
    }

.feedback-bubble {
    max-width: 78%;
    padding: 10px 14px;
    border-radius: var(--feedback-bubble-radius);
    background: var(--feedback-bubble-colour);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.feedback-message--bot .feedback-bubble {
    border-bottom-left-radius: 4px;
}

.feedback-message--user .feedback-bubble {
    border-bottom-right-radius: 4px;
    background: var(--feedback-primary-colour);
    color: var(--feedback-on-primary-colour);
}

/* Screenshot preview bubble */
.feedback-bubble--image {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.feedback-screenshot-image {
    display: block;
    width: 100%;
    max-height: 160px;
    object-fit: cover;
    object-position: top;
    border-radius: 8px;
    background: #fff;
}

@media (prefers-reduced-motion: no-preference) {
    .feedback-message {
        animation: feedback-fade-in .18s ease-out;
    }

    @keyframes feedback-fade-in {
        from {
            opacity: 0;
            transform: translateY(4px);
        }
    }
}


/* 5. CHOICE BUTTONS */
.feedback-choices {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-left: 38px; /* lines up with the bubbles, past the avatar */
}

.feedback-choice-button {
    padding: 9px 16px;
    border: 1px solid #c9ced6;
    border-radius: var(--feedback-button-radius);
    background: #fff;
    color: var(--feedback-text-colour);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.feedback-choice-button--primary {
    border-color: var(--feedback-primary-colour);
    background: var(--feedback-primary-colour);
    color: var(--feedback-on-primary-colour);
}

.feedback-choice-button:hover {
    filter: brightness(.96);
}


/* 6. CONTEXT BAR */
.feedback-context {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 6px 16px 0;
    padding: 10px 0;
    border-top: 1px solid var(--feedback-border-colour);
    color: var(--feedback-muted-text-colour);
    font-size: 12.5px;
}

    .feedback-context strong {
        color: var(--feedback-text-colour);
        font-weight: 600;
    }

    .feedback-context > span {
        min-width: 0;
        overflow-wrap: anywhere;
    }

        .feedback-context > span:first-child {
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

.feedback-link-button {
    padding: 0;
    border: 0;
    background: none;
    color: var(--feedback-primary-colour);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}


/* 7. COMPOSER (text box row) */
.feedback-composer {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 16px;
    padding: 8px;
    border: 1px solid var(--feedback-border-colour);
    border-radius: 14px;
}

    .feedback-composer:focus-within {
        border-color: var(--feedback-primary-colour);
    }

.feedback-composer__input {
    flex: 1;
    min-width: 0;
    padding: 6px 0;
    border: 0;
    outline: 0;
    background: none;
    font: inherit;
    font-size: 16px;
}

.feedback-attach-button {
    display: grid;
    padding: 6px;
    border: 0;
    background: none;
    color: var(--feedback-muted-text-colour);
    cursor: pointer;
}

    .feedback-attach-button svg {
        width: 20px;
        height: 20px;
    }

.feedback-send-button {
    flex: none;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: var(--feedback-primary-colour);
    color: var(--feedback-on-primary-colour);
    cursor: pointer;
}

    .feedback-send-button svg {
        width: 18px;
        height: 18px;
        stroke-width: 2.2;
    }

    .feedback-send-button:disabled {
        opacity: .5;
        cursor: default;
    }

.feedback-footer {
    margin: 0;
    padding: 10px 0 14px;
    color: var(--feedback-muted-text-colour);
    font-size: 12px;
    text-align: center;
}


/* 8. TYPING INDICATOR (three dots) */
.feedback-typing {
    display: flex;
    gap: 4px;
    padding: 14px 16px;
}

    .feedback-typing i {
        width: 6px;
        height: 6px;
        display: block;
        border-radius: 50%;
        background: #8a919b;
    }

@media (prefers-reduced-motion: no-preference) {
    .feedback-typing i {
        animation: feedback-dot-pulse 1s infinite ease-in-out;
    }

        .feedback-typing i:nth-child(2) {
            animation-delay: .15s;
        }

        .feedback-typing i:nth-child(3) {
            animation-delay: .3s;
        }

    @keyframes feedback-dot-pulse {
        0%, 60%, 100% {
            opacity: .3;
        }

        30% {
            opacity: 1;
        }
    }
}

/* 8b. STATUS MESSAGE (spinner + text, e.g. while capturing the page) */
.feedback-status {
    display: flex;
    align-items: center;
    gap: 10px;
}

.feedback-spinner {
    flex: none;
    width: 16px;
    height: 16px;
    border: 2px solid #c9ced6;
    border-top-color: var(--feedback-primary-colour);
    border-radius: 50%;
}

@media (prefers-reduced-motion: no-preference) {
    .feedback-spinner {
        animation: feedback-spin .8s linear infinite;
    }

    @keyframes feedback-spin {
        to {
            transform: rotate(360deg);
        }
    }
}

/* Keyboard focus ring (accessibility: please keep) */
.feedback-widget button:focus-visible {
    outline: 3px solid var(--feedback-focus-colour);
    outline-offset: 2px;
}


/* 9. SMALL SCREENS */
@media (max-width: 480px) {
    .feedback-widget {
        --feedback-edge-gap: 12px;
    }

    .feedback-panel {
        width: calc(100vw - 24px);
    }
}
