/* =========================================================
   AI-ассистент — виджет и внутренние стили
   ========================================================= */
:root {
    --ai-primary: #1a73e8;
    --ai-primary-dark: #0d47a1;
    --ai-success: #34a853;
    --ai-light: #f8f9fa;
    --ai-border: #dadce0;
    --ai-radius: 12px;
}

#ai-widget {
    position: fixed; bottom: 20px; right: 20px;
    width: 380px; height: 600px;
    background: #fff; border-radius: var(--ai-radius);
    box-shadow: 0 8px 32px rgba(0,0,0,.15);
    display: flex; flex-direction: column;
    z-index: 9999;
    overflow: hidden;
    transition: all .3s ease;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
#ai-widget.minimized { height: 60px; width: 60px; border-radius: 50%; }
#ai-widget.hidden { transform: translateY(120%); opacity: 0; pointer-events: none; }

.ai-header {
    background: linear-gradient(135deg, var(--ai-primary), var(--ai-primary-dark));
    color: #fff; padding: 14px 18px;
    display: flex; align-items: center; justify-content: space-between;
    cursor: pointer;
}
.ai-header-title { display: flex; align-items: center; gap: 10px; }
.ai-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    background: rgba(255,255,255,.2);
    display: flex; align-items: center; justify-content: center; font-size: 1.2rem;
}
.ai-status { font-size: .75rem; opacity: .85; }
.ai-status::before {
    content: ''; display: inline-block;
    width: 8px; height: 8px; border-radius: 50%;
    background: #34a853; margin-right: 5px; animation: ai-pulse 2s infinite;
}
@keyframes ai-pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }

.ai-controls { display: flex; gap: 6px; }
.ai-btn {
    background: rgba(255,255,255,.2); border: none; color: #fff;
    width: 28px; height: 28px; border-radius: 50%; cursor: pointer;
    display: flex; align-items: center; justify-content: center; font-size: .95rem;
}
.ai-btn:hover { background: rgba(255,255,255,.35); }

.ai-messages {
    flex: 1; overflow-y: auto; padding: 16px;
    background: var(--ai-light);
    display: flex; flex-direction: column; gap: 12px;
}
.ai-msg { max-width: 85%; padding: 10px 14px; border-radius: 16px; font-size: .9rem; line-height: 1.45; animation: ai-fade .3s; word-wrap: break-word; }
.ai-msg.user { align-self: flex-end; background: var(--ai-primary); color: #fff; border-bottom-right-radius: 4px; }
.ai-msg.bot  { align-self: flex-start; background: #fff; border: 1px solid var(--ai-border); border-bottom-left-radius: 4px; }
.ai-msg.bot a { color: var(--ai-primary); }
@keyframes ai-fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.ai-typing { display: flex; gap: 4px; padding: 10px 14px; background: #fff; border: 1px solid var(--ai-border); border-radius: 16px; align-self: flex-start; }
.ai-typing span { width: 7px; height: 7px; border-radius: 50%; background: #999; animation: ai-typing 1.4s infinite; }
.ai-typing span:nth-child(2) { animation-delay: .2s; }
.ai-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes ai-typing { 0%,60%,100% { transform: scale(.6); opacity: .5; } 30% { transform: scale(1); opacity: 1; } }

.ai-input-area { padding: 12px 14px; border-top: 1px solid var(--ai-border); background: #fff; }
.ai-input-row { display: flex; gap: 8px; }
#ai-input {
    flex: 1; padding: 10px 14px;
    border: 2px solid var(--ai-border); border-radius: 22px;
    font-size: .9rem; outline: none;
}
#ai-input:focus { border-color: var(--ai-primary); }
#ai-send {
    width: 42px; height: 42px; border-radius: 50%; border: none;
    background: var(--ai-primary); color: #fff; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
#ai-send:hover { background: var(--ai-primary-dark); }

.ai-quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ai-quick button {
    background: #fff; border: 1px solid var(--ai-border); border-radius: 16px;
    padding: 5px 12px; font-size: .75rem; color: var(--ai-primary); cursor: pointer;
}
.ai-quick button:hover { background: var(--ai-primary); color: #fff; }

.ai-footer { padding: 6px 14px; font-size: .7rem; color: #999; text-align: center; }

@media (max-width: 768px) {
    #ai-widget { width: 100%; height: 100%; bottom: 0; right: 0; border-radius: 0; }
}
