/* Portable AI assistant presentation served by ai-service. */
.ai-assistant-launcher {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 2147483001;
    display: grid;
    place-items: center;
    width: 58px;
    height: 58px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: linear-gradient(145deg, #1976d2, #0d47a1);
    color: #fff;
    box-shadow: 0 10px 28px rgba(13, 71, 161, .32);
    cursor: pointer;
    transition: transform .2s ease, box-shadow .2s ease;
}
.ai-assistant-launcher:hover { transform: translateY(-2px) scale(1.03); box-shadow: 0 14px 32px rgba(13, 71, 161, .4); }
.ai-assistant-launcher:focus-visible { outline: 3px solid rgba(25, 118, 210, .3); outline-offset: 3px; }
.ai-assistant-launcher .material-icons { font-size: 30px; }
.ai-assistant-launcher svg { width: 30px; height: 30px; fill: currentColor; }
.ai-assistant-launcher.is-open .ai-launch-open,
.ai-assistant-launcher:not(.is-open) .ai-launch-close { display: none; }

.ai-assistant-panel {
    position: fixed;
    right: 24px;
    bottom: 94px;
    z-index: 2147483000;
    display: flex;
    flex-direction: column;
    width: min(390px, calc(100vw - 32px));
    height: min(600px, calc(100vh - 130px));
    overflow: hidden;
    border: 1px solid #dbe4ee;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 18px 55px rgba(31, 41, 55, .22);
    opacity: 0;
    visibility: hidden;
    transform: translateY(16px) scale(.97);
    transform-origin: right bottom;
    transition: opacity .2s ease, transform .2s ease, visibility .2s;
}
.ai-assistant-panel.is-open { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }
.ai-assistant-header { display: flex; align-items: center; gap: 11px; padding: 14px 16px; cursor: grab; user-select: none; touch-action: none; background: linear-gradient(135deg, #1976d2, #0d47a1); color: #fff; }
.ai-assistant-avatar { display: grid; place-items: center; width: 40px; height: 40px; flex: 0 0 40px; border-radius: 12px; background: rgba(255,255,255,.18); }
.ai-assistant-avatar .material-icons { font-size: 25px; }
.ai-assistant-avatar svg { width: 25px; height: 25px; fill: currentColor; }
.ai-assistant-heading { min-width: 0; flex: 1; }
.ai-assistant-title { margin: 0; color: #fff; font-size: 16px; font-weight: 700; }
.ai-assistant-status { display: flex; align-items: center; gap: 6px; margin-top: 2px; font-size: 12px; color: rgba(255,255,255,.86); }
.ai-assistant-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #69f0ae; }
.ai-assistant-panel.is-dragging { transition: none; }
.ai-assistant-panel.is-dragging .ai-assistant-header { cursor: grabbing; }
.ai-assistant-header-btn { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 9px; background: transparent; color: #fff; cursor: pointer; }
.ai-assistant-header-btn:hover { background: rgba(255,255,255,.16); }
.ai-assistant-header-btn .material-icons { font-size: 21px; }
.ai-assistant-header-btn svg { width: 21px; height: 21px; fill: currentColor; }

.ai-assistant-messages { flex: 1; overflow-y: auto; padding: 16px; background: #f6f8fb; scroll-behavior: smooth; }
.ai-message { display: flex; margin-bottom: 12px; }
.ai-message.user { justify-content: flex-end; }
.ai-message-bubble { max-width: 84%; padding: 10px 12px; border-radius: 14px; font-size: 14px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-message.assistant .ai-message-bubble { border: 1px solid #e1e7ef; border-bottom-left-radius: 4px; background: #fff; color: #263238; box-shadow: 0 3px 10px rgba(31,41,55,.05); }
.ai-message.user .ai-message-bubble { border-bottom-right-radius: 4px; background: #1976d2; color: #fff; }
.ai-message.error .ai-message-bubble { border-color: #ffcdd2; background: #fff2f3; color: #b71c1c; }
.ai-message.assistant .ai-message-content { white-space: normal; }
.ai-message-content > :first-child { margin-top: 0; }
.ai-message-content > :last-child { margin-bottom: 0; }
.ai-message-content p { margin: 0 0 8px; white-space: pre-line; }
.ai-message-content h3 { margin: 12px 0 6px; color: #174f83; font-size: 14px; font-weight: 700; line-height: 1.4; }
.ai-message-content ul, .ai-message-content ol { margin: 4px 0 9px; padding-left: 21px; }
.ai-message-content li { margin: 3px 0; }
.ai-message-content a { color: #1565c0; font-weight: 600; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
.ai-message-content a:hover { color: #0d47a1; }
.ai-message-content code { padding: 1px 4px; border-radius: 4px; background: #edf2f7; color: #9b2c2c; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .92em; }
.ai-message-content pre { max-width: 100%; margin: 7px 0; padding: 8px; overflow-x: auto; border-radius: 7px; background: #edf2f7; white-space: pre; }
.ai-message-content pre code { padding: 0; background: transparent; color: inherit; }
.ai-message-content blockquote { margin: 7px 0; padding: 5px 9px; border-left: 3px solid #90caf9; background: #f4f8fc; color: #52606d; }
.ai-message-content hr { margin: 9px 0; border: 0; border-top: 1px solid #e1e7ef; }
.ai-message-meta { margin-top: 4px; color: #8a96a3; font-size: 10px; text-align: right; }
.ai-message-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; padding-top: 9px; border-top: 1px solid #e7edf4; }
.ai-message-action { display: inline-flex; align-items: center; gap: 5px; min-height: 34px; padding: 6px 10px; border: 1px solid #1976d2; border-radius: 9px; background: #fff; color: #1565c0; font: inherit; font-size: 13px; font-weight: 600; line-height: 1.3; cursor: pointer; }
.ai-message-action:hover { background: #eaf3fc; }
.ai-message-action:focus-visible { outline: 3px solid rgba(25,118,210,.18); outline-offset: 2px; }
.ai-message-action:disabled { cursor: wait; opacity: .72; }
.ai-message-action.is-complete { border-color: #2e7d32; color: #2e7d32; cursor: default; opacity: 1; }
.ai-message-action .material-icons { font-size: 17px; }
.ai-message-action .ai-action-icon { width: 17px; height: 17px; flex: 0 0 17px; fill: currentColor; }
.ai-message-action.is-loading .material-icons,
.ai-message-action.is-loading .ai-action-icon { animation: ai-action-spin .8s linear infinite; }
@keyframes ai-action-spin { to { transform: rotate(360deg); } }
.ai-assistant-quick { display: flex; flex-wrap: wrap; gap: 7px; margin: 0 0 12px; }
.ai-assistant-quick button { min-height: 34px; padding: 6px 10px; border: 1px solid #90bdea; border-radius: 9px; background: #fff; color: #1565c0; font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.ai-assistant-quick button:hover { background: #eaf3fc; }
.ai-typing { display: inline-flex; align-items: center; gap: 4px; min-width: 52px; }
.ai-typing span { width: 7px; height: 7px; border-radius: 50%; background: #78909c; animation: ai-dot 1.1s infinite ease-in-out; }
.ai-typing span:nth-child(2) { animation-delay: .15s; }
.ai-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes ai-dot { 0%, 70%, 100% { transform: translateY(0); opacity: .45; } 35% { transform: translateY(-4px); opacity: 1; } }

.ai-assistant-composer { padding: 12px; border-top: 1px solid #e4e9ef; background: #fff; }
.ai-assistant-input-row { display: flex; align-items: flex-end; gap: 8px; }
.ai-assistant-input { min-height: 42px; max-height: 112px; flex: 1; resize: none; padding: 10px 12px; border: 1px solid #cfd8e3; border-radius: 12px; background: #fff; color: #263238; font: inherit; font-size: 14px; line-height: 1.45; outline: none; }
.ai-assistant-input:focus { border-color: #1976d2; box-shadow: 0 0 0 3px rgba(25,118,210,.12); }
.ai-assistant-send { display: grid; place-items: center; width: 42px; height: 42px; flex: 0 0 42px; padding: 0; border: 0; border-radius: 12px; background: #1976d2; color: #fff; cursor: pointer; }
.ai-assistant-send:hover { background: #1565c0; }
.ai-assistant-send:disabled { background: #aab7c4; cursor: wait; }
.ai-assistant-send .material-icons { font-size: 21px; }
.ai-assistant-send svg { width: 21px; height: 21px; fill: currentColor; }
.ai-assistant-footnote { margin-top: 7px; color: #8793a0; font-size: 10px; text-align: center; }
.ai-draft-field { border-color: #f59e0b !important; box-shadow: 0 0 0 3px rgba(245,158,11,.18) !important; background-color: #fffbeb !important; }

@media (max-width: 576px) {
    .ai-assistant-launcher { right: 16px; bottom: 16px; }
    .ai-assistant-panel { left: auto !important; top: auto !important; right: 8px; bottom: 84px; width: calc(100vw - 16px); height: min(620px, calc(100dvh - 100px)); border-radius: 15px; }
    .ai-assistant-header { cursor: default; touch-action: auto; }
}
@media (prefers-reduced-motion: reduce) {
    .ai-assistant-panel, .ai-assistant-launcher, .ai-typing span { transition: none; animation: none; }
}
