/* AI Copilot bubble - self-contained on public pages; inherits branding vars when present */
#copilot-bubble-root,
.copilot-bubble-root {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: rgb(var(--primary_text, 226 232 240));
    -webkit-font-smoothing: antialiased;
}

#copilot-bubble-root *,
#copilot-bubble-root *::before,
#copilot-bubble-root *::after {
    box-sizing: border-box;
}

#copilot-bubble-root button.copilot-toggle,
#copilot-bubble-root button.copilot-btn-primary,
#copilot-bubble-root button.copilot-btn-ghost,
#copilot-bubble-root button.copilot-btn-icon,
#copilot-bubble-root button.copilot-option-btn,
#copilot-bubble-root button.copilot-card-btn,
#copilot-bubble-root button.copilot-quick-btn,
#copilot-bubble-root button.copilot-send-inline,
#copilot-bubble-root button.copilot-technical-ticket-btn,
#copilot-bubble-root .copilot-task-btn {
    appearance: none;
    -webkit-appearance: none;
}

#copilot-bubble-root button,
#copilot-bubble-root input,
#copilot-bubble-root select,
#copilot-bubble-root textarea {
    font: inherit;
}

#copilot-bubble-root a.copilot-zoom-join-link {
    color: #fff;
    text-decoration: none;
}

/* Layout utilities (public pages do not load Tailwind) */
#copilot-bubble-root .copilot-stack > * + * {
    margin-top: 12px;
}

#copilot-bubble-root .copilot-actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

#copilot-bubble-root .copilot-mt-3 {
    margin-top: 12px;
}

#copilot-bubble-root .copilot-mb-3 {
    margin-bottom: 12px;
}

#copilot-bubble-root .copilot-w-full {
    width: 100%;
}

#copilot-bubble-root .copilot-icon-sm,
#copilot-bubble-root .copilot-icon-sm svg {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
}

#copilot-bubble-root .copilot-icon-md,
#copilot-bubble-root .copilot-icon-md svg {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
}

/* Hidden until bubble script runs (deferred load) - prevents layout shift and sidebar conflicts */
.copilot-bubble-root.copilot-deferred {
    visibility: hidden !important;
    pointer-events: none !important;
}

.copilot-toggle {
    position: relative;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgb(var(--primary_main_color, 59 130 246));
    color: white;
    border: none;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
}
.copilot-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}
.copilot-toggle-icon {
    width: 28px;
    height: 28px;
}

.copilot-toggle-has-chat::after {
    content: '';
    position: absolute;
    top: 4px;
    right: 4px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgb(var(--accent_2, 34 197 94));
    border: 2px solid rgb(var(--primary_main_color, 59 130 246));
    box-shadow: 0 0 0 1px rgb(15 23 42 / 0.35);
}

.copilot-panel {
    position: absolute;
    bottom: calc(56px + 12px);
    right: 0;
    width: 400px;
    max-width: calc(100vw - 2rem);
    max-height: 85vh;
    background: rgb(var(--primary_background, 15 23 42));
    border: 1px solid rgb(var(--primary_main_color, 59 130 246) / 0.3);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.96);
    transition: opacity 0.2s, visibility 0.2s, transform 0.2s;
}
#copilot-bubble-root .copilot-panel.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.copilot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid rgb(var(--primary_main_color, 59 130 246) / 0.15);
    flex-shrink: 0;
}
.copilot-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: rgb(var(--primary_text, 226 232 240));
    margin: 0;
}
.copilot-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}
.copilot-btn-ghost {
    background: none;
    border: none;
    color: rgb(148 163 184);
    font-size: 0.8rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
}
.copilot-btn-ghost:hover {
    color: rgb(var(--primary_main_color, 59 130 246));
    background: rgb(var(--primary_main_color, 59 130 246) / 0.1);
}
.copilot-btn-icon {
    background: none;
    border: none;
    color: rgb(148 163 184);
    padding: 6px;
    border-radius: 8px;
    cursor: pointer;
}
.copilot-btn-icon:hover {
    color: rgb(226 232 240);
    background: rgba(255, 255, 255, 0.08);
}

.copilot-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
}

.copilot-body:has(.copilot-chat-view:not(.hidden)) {
    overflow: hidden;
}

.copilot-coming-soon-message {
    font-size: 0.9rem;
    line-height: 1.5;
    color: rgb(var(--primary_text, 226 232 240) / 0.82);
    margin: 0 0 0.5rem;
}

.copilot-welcome-text {
    font-size: 0.95rem;
    color: rgb(var(--primary_main_color, 59 130 246));
    margin: 0 0 14px 0;
}
.copilot-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.copilot-option-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: rgb(var(--primary_main_color, 59 130 246) / 0.08);
    border: 1px solid rgb(var(--primary_main_color, 59 130 246) / 0.2);
    border-radius: 10px;
    color: rgb(var(--primary_main_color, 59 130 246));
    font-size: 0.9rem;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s, border-color 0.15s;
}
.copilot-option-btn:hover {
    background: rgb(var(--primary_main_color, 59 130 246) / 0.15);
    border-color: rgb(var(--primary_main_color, 59 130 246) / 0.4);
}

.copilot-analytics-cards .copilot-options {
    margin-bottom: 0;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

/* Card buttons (Analytics Support) – each looks like a proper button with icon */
.copilot-card-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: rgb(var(--primary_main_color, 59 130 246) / 0.12);
    border: 1px solid rgb(var(--primary_main_color, 59 130 246) / 0.35);
    border-radius: 10px;
    color: rgb(var(--primary_main_color, 59 130 246));
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.copilot-card-btn:hover {
    background: rgb(var(--primary_main_color, 59 130 246) / 0.2);
    border-color: rgb(var(--primary_main_color, 59 130 246) / 0.5);
    transform: translateY(-1px);
}
.copilot-card-btn:active {
    transform: translateY(0);
}
.copilot-card-btn-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    color: rgb(var(--primary_main_color, 59 130 246) / 0.95);
}
.copilot-card-btn-label {
    flex: 1;
}

.copilot-support-form .copilot-label,
#copilot-bubble-root .copilot-label {
    display: block;
    font-size: 0.8rem;
    color: rgb(148 163 184);
    margin-bottom: 4px;
}
.copilot-form.copilot-stack > * + *,
.copilot-form.space-y-3 > * + * {
    margin-top: 12px;
}
.copilot-field {
    position: relative;
}
.copilot-field-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: rgb(100 116 139);
    pointer-events: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}
.copilot-field-icon-textarea {
    top: 14px;
    transform: none;
}
.copilot-input-inline {
    width: 100%;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid rgb(var(--primary_main_color, 59 130 246) / 0.25);
    background: rgba(15, 23, 42, 0.6);
    color: rgb(226 232 240);
    font-size: 0.9rem;
}
.copilot-input-inline.copilot-input-icon {
    padding-left: 36px;
}
.copilot-input-inline.copilot-textarea {
    min-height: 96px;
    resize: vertical;
}
.copilot-input-inline.copilot-input-readonly {
    opacity: 0.9;
    cursor: default;
}
.copilot-input-inline::placeholder {
    color: rgb(100 116 139);
}
select.copilot-input-inline {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, rgb(148 163 184) 50%), linear-gradient(135deg, rgb(148 163 184) 50%, transparent 50%);
    background-position: calc(100% - 18px) calc(50% - 2px), calc(100% - 12px) calc(50% - 2px);
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
    padding-right: 32px;
}
.copilot-btn-primary {
    padding: 8px 16px;
    background: rgb(var(--primary_main_color, 59 130 246));
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}
.copilot-btn-primary:hover {
    filter: brightness(1.1);
}

.copilot-chat-view {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}
.copilot-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: auto;
    overscroll-behavior: contain;
}

.copilot-technical-ticket-btn {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgb(var(--primary_main_color, 59 130 246) / 0.25);
    background: rgb(var(--primary_main_color, 59 130 246) / 0.1);
    color: rgb(var(--primary_main_color, 59 130 246));
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
.copilot-technical-ticket-btn:hover {
    background: rgb(var(--primary_main_color, 59 130 246) / 0.18);
    border-color: rgb(var(--primary_main_color, 59 130 246) / 0.45);
}
.copilot-msg {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.45;
    max-width: 92%;
}
.copilot-msg-user {
    align-self: flex-end;
    background: rgb(var(--primary_main_color, 59 130 246) / 0.05);
    border: 1px solid rgb(var(--primary_main_color, 59 130 246) / 0.3);
    color: rgb(var(--primary_main_color, 59 130 246));
}
.copilot-msg-assistant {
    align-self: flex-start;
    background: rgb(var(--accent_1, 226 232 240) / 0.05);
    border: 1px solid rgb(var(--primary_main_color, 59 130 246) / 0.15);
    color: rgb(var(--accent_1, 226 232 240));
    white-space: pre-wrap;
}

/* In-thread “assistant is working” row */
.copilot-msg-thinking {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 0.88rem;
    font-style: italic;
    color: rgb(var(--accent_2, 34 197 94));
    border-style: dashed !important;
    background: rgb(var(--accent_2, 34 197 94) / 0.08) !important;
    animation: copilot-thinking-pulse 2s ease-in-out infinite;
}
.copilot-thinking-label {
    flex: 1;
    min-width: 0;
}
.copilot-thinking-dots {
    display: inline-flex;
    gap: 2px;
    font-weight: 700;
    letter-spacing: 2px;
}
.copilot-thinking-dots span {
    display: inline-block;
    animation: copilot-dot-bounce 1.2s ease-in-out infinite;
}
.copilot-thinking-dots span:nth-child(1) {
    animation-delay: 0s;
}
.copilot-thinking-dots span:nth-child(2) {
    animation-delay: 0.15s;
}
.copilot-thinking-dots span:nth-child(3) {
    animation-delay: 0.3s;
}
@keyframes copilot-dot-bounce {
    0%,
    100% {
        opacity: 0.25;
        transform: translateY(0);
    }
    50% {
        opacity: 1;
        transform: translateY(-3px);
    }
}
@keyframes copilot-thinking-pulse {
    0%,
    100% {
        border-color: rgb(var(--primary_main_color, 59 130 246) / 0.25);
    }
    50% {
        border-color: rgb(var(--accent_2, 34 197 94) / 0.45);
    }
}

/* SEO task proposal / result cards
   Scoped under #copilot-bubble-root so assistant bubble styles (e.g. white-space: pre-wrap)
   and global button resets cannot flatten Confirm / Dismiss into plain text. */
#copilot-bubble-root .copilot-task-proposal,
#copilot-bubble-root .copilot-task-result {
    max-width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    white-space: normal;
}
#copilot-bubble-root .copilot-task-proposal-title,
#copilot-bubble-root .copilot-task-result-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: rgb(var(--primary_main_color, 59 130 246));
}
#copilot-bubble-root .copilot-task-proposal-rationale,
#copilot-bubble-root .copilot-task-result-body,
#copilot-bubble-root .copilot-task-proposal-note,
#copilot-bubble-root .copilot-task-result-meta {
    margin: 0;
    font-size: 0.82rem;
    line-height: 1.4;
    color: rgb(var(--accent_1, 226 232 240));
    white-space: normal;
}
#copilot-bubble-root .copilot-task-proposal-note {
    opacity: 0.75;
    font-style: italic;
}
#copilot-bubble-root .copilot-task-proposal-meta {
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 0.8rem;
    color: rgb(var(--accent_2, 34 197 94));
    white-space: normal;
}
#copilot-bubble-root .copilot-task-proposal-meta li + li {
    margin-top: 2px;
}
#copilot-bubble-root .copilot-task-proposal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    align-items: center;
}
#copilot-bubble-root .copilot-task-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1.2;
    cursor: pointer;
    border: 1px solid transparent;
    white-space: nowrap;
    text-decoration: none;
    appearance: none;
    -webkit-appearance: none;
    transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease, filter 0.15s ease;
}
#copilot-bubble-root .copilot-task-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}
#copilot-bubble-root .copilot-task-btn-confirm {
    background: rgb(var(--primary_main_color, 59 130 246));
    color: #fff;
    border-color: rgb(var(--primary_main_color, 59 130 246));
}
#copilot-bubble-root .copilot-task-btn-confirm:hover:not(:disabled) {
    filter: brightness(1.05);
}
#copilot-bubble-root .copilot-task-btn-dismiss {
    background: transparent;
    color: rgb(var(--accent_1, 226 232 240));
    border-color: rgb(var(--primary_main_color, 59 130 246) / 0.35);
}
#copilot-bubble-root .copilot-task-btn-dismiss:hover:not(:disabled) {
    background: rgb(var(--primary_main_color, 59 130 246) / 0.06);
}
.copilot-task-result-link {
    font-size: 0.82rem;
    font-weight: 600;
    color: rgb(var(--primary_main_color, 59 130 246));
    text-decoration: underline;
    text-underline-offset: 2px;
}
.copilot-task-result-link:hover {
    opacity: 0.85;
}

.copilot-panel-busy .copilot-quick-buttons-wrap button,
.copilot-panel-busy .copilot-quick-buttons-wrap .copilot-quick-btn-wrap,
.copilot-panel-busy #copilot-new-chat {
    pointer-events: none;
    opacity: 0.55;
}

.copilot-footer-loading .copilot-input:disabled {
    opacity: 0.82;
    cursor: wait;
    border-color: rgb(var(--accent_2, 34 197 94) / 0.35);
}

.copilot-footer {
    padding: 12px 16px;
    border-top: 1px solid rgb(var(--primary_main_color, 59 130 246) / 0.2);
    flex-shrink: 0;
    background: rgb(30 41 59);
    display: block;
}
.copilot-footer.hidden {
    display: none !important;
}
.copilot-disclaimer {
    font-size: 0.7rem;
    color: rgb(100 116 139);
    margin: 0 0 10px 0;
}
.copilot-input-wrap {
    position: relative;
    width: 100%;
    display: block;
}
.copilot-input {
    width: 100%;
    box-sizing: border-box;
    min-height: 48px;
    max-height: 160px;
    padding: 12px 48px 44px 14px;
    border-radius: 12px;
    border: 2px solid rgb(var(--primary_main_color, 59 130 246) / 0.4);
    background: rgb(51 65 85);
    color: rgb(226 232 240);
    font-size: 0.95rem;
    line-height: 1.4;
    resize: vertical;
    transition: border-color 0.2s, box-shadow 0.2s;
    display: block;
}
.copilot-input::placeholder {
    color: rgb(148 163 184);
}
.copilot-input:focus {
    outline: none;
    border-color: rgb(var(--primary_main_color, 59 130 246));
    box-shadow: 0 0 0 3px rgb(var(--primary_main_color, 59 130 246) / 0.35);
}
.copilot-char-count {
    position: absolute;
    left: 14px;
    bottom: 14px;
    font-size: 0.7rem;
    color: rgb(148 163 184);
    pointer-events: none;
}
.copilot-send-inline {
    position: absolute;
    right: 8px;
    bottom: 8px;
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 10px;
    background: rgb(var(--primary_main_color, 59 130 246));
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: filter 0.2s, transform 0.1s;
}
.copilot-send-inline:hover:not(:disabled) {
    filter: brightness(1.15);
    transform: scale(1.05);
}
.copilot-send-inline:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}
.copilot-send-inline .copilot-icon-md,
.copilot-quick-btn .copilot-icon-md {
    width: 1.25rem;
    height: 1.25rem;
}

.copilot-quick-buttons {
    padding: 0;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 6px;
    justify-content: flex-start;
    align-items: flex-start;
}
.copilot-quick-buttons-wrap {
    border-top: 1px solid rgb(var(--primary_main_color, 59 130 246) / 0.1);
    padding: 10px 16px;
}
.copilot-quick-buttons-wrap .copilot-disclaimer {
    margin: 0 0 8px 0;
}
.copilot-quick-btn-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    width: 56px;
    min-width: 56px;
}
.copilot-quick-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 10px;
    background: rgb(var(--primary_main_color, 59 130 246) / 0.12);
    border: 1px solid rgb(var(--primary_main_color, 59 130 246) / 0.25);
    color: rgb(var(--primary_main_color, 59 130 246));
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}
.copilot-quick-btn:hover {
    background: rgb(var(--primary_main_color, 59 130 246) / 0.25);
    color: rgb(var(--primary_main_color, 59 130 246));
}
.copilot-quick-btn .copilot-icon-md {
    width: 1.25rem;
    height: 1.25rem;
}
.copilot-quick-btn-label {
    font-size: 0.65rem;
    color: rgb(100 116 139);
    text-align: left;
    line-height: 1.2;
    width: 100%;
    padding: 0 2px;
    box-sizing: border-box;
}

/* Only hide .hidden inside the bubble - do not affect Tailwind .hidden on the rest of the page (e.g. sidebar) */
.copilot-bubble-root .hidden {
    display: none !important;
}

.copilot-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    color: rgb(148 163 184);
    font-size: 0.85rem;
}
.copilot-loading-dots::after {
    content: '';
    animation: copilot-dots 1.2s steps(4, end) infinite;
}
@keyframes copilot-dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

.copilot-zoom-type-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-top: 6px;
}
.copilot-zoom-type-option {
    display: flex;
    flex-direction: column;
    gap: 2px;
    position: relative;
    padding: 10px 12px;
    border: 1.5px solid rgb(var(--primary_main_color, 59 130 246) / 0.2);
    border-radius: 10px;
    cursor: pointer;
    background: rgb(var(--primary_main_color, 59 130 246) / 0.06);
}
.copilot-zoom-type-option:has(input:checked) {
    border-color: rgb(var(--primary_main_color, 59 130 246));
    background: rgb(var(--primary_main_color, 59 130 246) / 0.12);
}
.copilot-zoom-type-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.copilot-zoom-type-option span {
    font-size: 0.85rem;
    font-weight: 700;
    color: rgb(var(--primary_text, 226 232 240));
}
.copilot-zoom-type-option small {
    font-size: 0.72rem;
    color: rgb(var(--primary_text, 226 232 240) / 0.65);
    line-height: 1.35;
}
.copilot-zoom-status-card {
    border: 1.5px solid rgb(var(--primary_main_color, 59 130 246) / 0.22);
    border-radius: 12px;
    padding: 14px;
    background: rgb(var(--primary_main_color, 59 130 246) / 0.06);
}
.copilot-zoom-status-ready {
    border-color: rgb(34 197 94 / 0.35);
    background: rgb(34 197 94 / 0.08);
}
.copilot-zoom-status-title {
    font-size: 0.92rem;
    font-weight: 700;
    color: rgb(var(--primary_text, 226 232 240));
    margin-bottom: 6px;
}
.copilot-zoom-status-detail {
    font-size: 0.8rem;
    color: rgb(var(--primary_text, 226 232 240) / 0.72);
    line-height: 1.45;
    margin-bottom: 10px;
}
.copilot-zoom-join-link {
    display: inline-flex;
    text-decoration: none;
    margin-top: 4px;
}
.copilot-zoom-status-error {
    font-size: 0.78rem;
    color: rgb(220 38 38);
}
