/* ILOVEPDF.IO: send button dark (#0a0a0a) + icon (arrow/stop) white.
   The bundle colors via CSS variables AND highly specific !important rules
   (body … button.aipkit_chat_action_btn.aipkit_send_btn:not(:hover):not(:active):not(.has-background)).
   So: set the variables AND override with a body prefix (higher specificity). */
.aipkit_chat_container {
    --aipkit-chat-send-button-bg-color: #0a0a0a;
    --aipkit-chat-send-button-border-color: #0a0a0a;
    --aipkit-chat-send-button-hover-bg-color: #262626;
    --aipkit-chat-send-button-hover-border-color: #262626;
    --aipkit-chat-send-button-disabled-bg-color: #0a0a0a;
    --aipkit-chat-send-button-disabled-border-color: #0a0a0a;
    --aipkit-chat-send-button-text-color: #ffffff;
}
body .aipkit_chat_container button.aipkit_chat_action_btn.aipkit_send_btn:not(:hover):not(:active):not(.has-background) {
    background-color: #0a0a0a !important;
    background: #0a0a0a !important;
    border-color: #0a0a0a !important;
    color: #ffffff !important;
}
body .aipkit_chat_container button.aipkit_chat_action_btn.aipkit_send_btn:hover:not(:disabled),
body .aipkit_chat_container button.aipkit_chat_action_btn.aipkit_send_btn:active {
    background-color: #262626 !important;
    background: #262626 !important;
    border-color: #262626 !important;
}
/* Inactive/locked: dark but matte. The selector matches the specific bundle disabled rule
   (…:disabled:not(:hover):not(:active):not(.has-background)) + body prefix -> wins. */
body .aipkit_chat_container button.aipkit_chat_action_btn.aipkit_send_btn:disabled,
body .aipkit_chat_container button.aipkit_chat_action_btn.aipkit_send_btn:disabled:not(:hover):not(:active):not(.has-background) {
    background-color: #0a0a0a !important;
    background: #0a0a0a !important;
    border-color: #0a0a0a !important;
    color: #ffffff !important;
    opacity: .5 !important;
}
.aipkit_chat_container .aipkit_send_btn svg,
.aipkit_chat_container .aipkit_send_btn .aipkit_send_icon,
.aipkit_chat_container .aipkit_send_btn .aipkit_stop_icon {
    color: #ffffff !important;
}
/* ILOVEPDF.IO: clean circle with a smooth edge on the send button.
   Cause of the "pixelated" edge: border + border-radius = two slightly offset,
   individually anti-aliased edges at high black/white contrast. So remove the border
   (only ONE clean fill edge), force a real circle, keep the size via border-box. */
body .aipkit_chat_container button.aipkit_chat_action_btn.aipkit_send_btn {
    border: 0 !important;
    outline: none !important;
    border-radius: 50% !important;
    box-sizing: border-box !important;
    box-shadow: 0 1px 3px rgba(0,0,0,.22) !important;
}

/* ILOVEPDF.IO: credit balance in the chat footer as a green buy link. */
.aipkit_chat_footer .dsgt-balance-buy { color: #10a37f !important; font-weight: 700; text-decoration: none; cursor: pointer; }
.aipkit_chat_footer .dsgt-balance-buy:hover { color: #0e8e6e !important; }

/* Stop state: show only the stop icon, hide the spinner and timer overlay */
.aipkit_chat_container .aipkit_chat_action_btn.aipkit_send_btn.aipkit_btn-stop-state .aipkit_spinner,
.aipkit_chat_container .aipkit_chat_action_btn.aipkit_send_btn.aipkit_btn-stop-state .aipkit_chat_action_timer {
    display: none !important;
}
.aipkit_chat_container .aipkit_chat_action_btn.aipkit_send_btn.aipkit_btn-stop-state .aipkit_stop_icon {
    display: inline-block !important;
}
/* If AIPKit sets the stop state late: also generally hide the spinner/timer in the send button */
.aipkit_chat_container .aipkit_chat_action_btn.aipkit_send_btn .aipkit_chat_action_timer,
.aipkit_chat_container .aipkit_chat_action_btn.aipkit_send_btn .aipkit_spinner {
    display: none !important;
}

/* Clear state: the button shows the normal send icon (arrow) instead of an eraser.
   The click handler is suppressed via JS — clearing data runs via the footer link. */
.aipkit_chat_container .aipkit_chat_action_btn.aipkit_send_btn.aipkit_btn-clear-state .aipkit_clear_icon {
    display: none !important;
}
.aipkit_chat_container .aipkit_chat_action_btn.aipkit_send_btn.aipkit_btn-clear-state .aipkit_send_icon {
    display: inline-block !important;
    opacity: 0.55;
}
.aipkit_chat_container .aipkit_chat_action_btn.aipkit_send_btn.aipkit_btn-clear-state {
    cursor: not-allowed !important;
}

/* More compact header: buttons 44px → 32px, padding 8px → 2px, min-height 60px → 36px,
   subtle 1px divider at the bottom, icons further right (padding-right reduced) */
.aipkit_chat_container .aipkit_chat_header {
    padding-top: 2px !important;
    padding-bottom: 2px !important;
    padding-right: 4px !important;
    min-height: 36px !important;
    border-bottom: 1px solid #e5e5e5 !important;
}
/* Hide the header entirely when there are no visible icon buttons in normal mode.
   The sidebar toggle doesn't count — we hide it via CSS (except in fullscreen).
   As soon as the sidebar toggle becomes visible in fullscreen OR the user enables
   e.g. the download button in the plugin admin, the header is shown again automatically. */
.aipkit_chat_container:not(.aipkit-fullscreen) .aipkit_chat_header:not(:has(.aipkit_header_btn:not(.aipkit_sidebar_toggle_btn))) {
    display: none !important;
}
.aipkit_chat_container .aipkit_header_btn {
    width: 32px !important;
    height: 32px !important;
}

/* Footer actions on the right: download + delete data */
.aipkit_chat_footer {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.aipkit_chat_footer .dsbx-footer-actions {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}
.aipkit_chat_footer .dsbx-footer-actions button {
    font-size: 11px;
    text-decoration: underline;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
}
.aipkit_chat_footer .dsbx-download-link,
.aipkit_chat_footer .dsbx-fullscreen-link {
    color: #555 !important;
}
.aipkit_chat_footer .dsbx-download-link:hover,
.aipkit_chat_footer .dsbx-fullscreen-link:hover {
    color: #000 !important;
    text-decoration: none;
}
.aipkit_chat_footer .dsbx-clear-link {
    color: #c00 !important;
}
.aipkit_chat_footer .dsbx-clear-link:hover {
    color: #800 !important;
    text-decoration: none;
}
.aipkit_chat_footer .dsbx-fullscreen-link,
.aipkit_chat_footer .dsbx-download-link,
.aipkit_chat_footer .dsbx-clear-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.aipkit_chat_footer .dsbx-fullscreen-link svg,
.aipkit_chat_footer .dsbx-download-link svg,
.aipkit_chat_footer .dsbx-clear-link svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    display: block;
    /* Important: otherwise the SVG swallows the click, which then doesn't bubble to the button parent.
       With text there was a <span> next to it that forwarded the click. */
    pointer-events: none;
}

/* ILOVEPDF.IO: download + delete as small round #f7f7f7 buttons (instead of bare icons). */
.aipkit_chat_footer .dsbx-download-link,
.aipkit_chat_footer .dsbx-clear-link {
    width: 25px !important;
    height: 25px !important;
    padding: 0 !important;
    border-radius: 50% !important;
    background: #f7f7f7 !important;
    justify-content: center !important;
    gap: 0 !important;
    text-decoration: none !important;
    transition: background-color .15s ease, color .15s ease;
}
.aipkit_chat_footer .dsbx-download-link:hover { background: #ececec !important; color: #000 !important; }
.aipkit_chat_footer .dsbx-clear-link:hover { background: #f6dada !important; color: #800 !important; }

/* ILOVEPDF.IO: fullscreen icon as a small corner icon top right (instead of in the footer). */
.aipkit_chat_container:not(.aipkit-fullscreen) { position: relative; }
.aipkit_chat_container .dsbx-fs-corner {
    position: absolute; top: 6px; right: 6px; z-index: 30;
    width: 28px; height: 28px; padding: 0; margin: 0;
    display: inline-flex; align-items: center; justify-content: center;
    background: transparent; border: none; border-radius: 6px; cursor: pointer;
    color: #e4e4e4; opacity: .9;
    transition: opacity .15s ease, color .15s ease, background-color .15s ease;
}
.aipkit_chat_container .dsbx-fs-corner:hover { opacity: 1; color: #ffffff; background-color: rgba(255,255,255,.08); }
.aipkit_chat_container .dsbx-fs-corner svg { width: 16px; height: 16px; display: block; pointer-events: none; }

/* ILOVEPDF.IO: input action icons (file upload, web search, voice icons) compact + round.
   Previously 44x44 with a square (8px) hover box -> lots of space. Now: small circles, NO
   background at rest, background (circle) only on hover. Icon size stays.
   The send button (.aipkit_send_btn) is explicitly excluded (stays a green pill).
   AIPKit rules are highly specific + !important -> body prefix matches their selectors. */
body .aipkit_chat_container button.aipkit_input_action_btn:not(.aipkit_send_btn):not(.aipkit_web_search_toggle):not(.aipkit_google_search_grounding_toggle),
body .aipkit_chat_container button.aipkit_input_action_btn:not(.aipkit_send_btn):not(.aipkit_web_search_toggle):not(.aipkit_google_search_grounding_toggle):not(:hover):not(:active):not(.has-background),
body .aipkit_chat_container button.aipkit_input_action_btn:not(.aipkit_send_btn):not(.aipkit_web_search_toggle):not(.aipkit_google_search_grounding_toggle).has-background {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    min-height: 32px !important;
    border-radius: 50% !important;
    border-color: transparent !important;
}
body .aipkit_chat_container button.aipkit_input_action_btn:not(.aipkit_send_btn):not(.aipkit_web_search_toggle):not(.aipkit_google_search_grounding_toggle):not(.aipkit_recording):not(:hover):not(:active):not(.has-background) {
    background: transparent !important;
    background-color: transparent !important;
}
/* The microphone's recording state MUST stay visible — a clearly red, pulsing circle. */
body .aipkit_chat_container button.aipkit_input_action_btn.aipkit_voice_input_btn.aipkit_recording {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    min-height: 32px !important;
    border-radius: 50% !important;
    background: #ef4444 !important;
    background-color: #ef4444 !important;
    color: #ffffff !important;
    border-color: #ef4444 !important;
    animation: ds-mic-pulse 1.3s ease-out infinite !important;
}
body .aipkit_chat_container button.aipkit_input_action_btn.aipkit_voice_input_btn.aipkit_recording svg {
    color: #ffffff !important;
}
@keyframes ds-mic-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(239,68,68,.5); }
    70%  { box-shadow: 0 0 0 4px rgba(239,68,68,0); }
    100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); }
}

/* ILOVEPDF.IO: web search toggle as text "Web search: On/Off" instead of an icon.
   The state comes from AIPKit via .aipkit_active (click toggles as before).
   Classes chained multiple times -> beats AIPKit's highly specific 44px !important rules. */
body .aipkit_chat_container button.aipkit_input_action_btn.aipkit_web_search_toggle.aipkit_web_search_toggle.aipkit_web_search_toggle,
body .aipkit_chat_container button.aipkit_input_action_btn.aipkit_google_search_grounding_toggle.aipkit_google_search_grounding_toggle.aipkit_google_search_grounding_toggle {
    width: auto !important;
    min-width: 0 !important;
    height: 30px !important;
    min-height: 30px !important;
    padding: 0 11px !important;
    border-radius: 15px !important;
    border: 1px solid #e2e8f0 !important;
    background: #f8fafc !important;
    background-color: #f8fafc !important;
    color: #64748b !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    white-space: nowrap !important;
    gap: 0 !important;
    transition: background-color .15s, color .15s, border-color .15s !important;
}
body .aipkit_chat_container button.aipkit_web_search_toggle svg,
body .aipkit_chat_container button.aipkit_google_search_grounding_toggle svg { display: none !important; }
body .aipkit_chat_container button.aipkit_web_search_toggle::after { content: "Web search: Off"; }
body .aipkit_chat_container button.aipkit_google_search_grounding_toggle::after { content: "Web search: Off"; }
/* On = green */
body .aipkit_chat_container button.aipkit_input_action_btn.aipkit_web_search_toggle.aipkit_active.aipkit_active.aipkit_active,
body .aipkit_chat_container button.aipkit_input_action_btn.aipkit_google_search_grounding_toggle.aipkit_active.aipkit_active.aipkit_active {
    background: #e7f5ef !important;
    background-color: #e7f5ef !important;
    color: #10a37f !important;
    border-color: #b6e3d4 !important;
}
body .aipkit_chat_container button.aipkit_web_search_toggle.aipkit_active::after,
body .aipkit_chat_container button.aipkit_google_search_grounding_toggle.aipkit_active::after { content: "Web search: On"; }
body .aipkit_chat_container button.aipkit_web_search_toggle:hover,
body .aipkit_chat_container button.aipkit_google_search_grounding_toggle:hover { filter: brightness(.97); }
body .aipkit_chat_container button.aipkit_input_action_btn:not(.aipkit_send_btn):not(.aipkit_web_search_toggle):not(.aipkit_google_search_grounding_toggle):hover:not(:disabled),
body .aipkit_chat_container button.aipkit_input_action_btn:not(.aipkit_send_btn):not(.aipkit_web_search_toggle):not(.aipkit_google_search_grounding_toggle):focus,
body .aipkit_chat_container button.aipkit_input_action_btn:not(.aipkit_send_btn):not(.aipkit_web_search_toggle):not(.aipkit_google_search_grounding_toggle):active {
    border-radius: 50% !important;
    background: rgba(0,0,0,.06) !important;
    background-color: rgba(0,0,0,.06) !important;
    border-color: transparent !important;
}