/* ============================================
   ИИ Ассистент — Дизайн виджета
   Все JS-классы (.msg, .msg-user, .msg-manager,
   .msg-system, .msg-bubble, .msg-time) сохранены.
   ============================================ */
/* --- Контейнер --- */
.router-widget-container { font-family: Inter, SF Pro Display, Segoe UI, system-ui, -apple-system, sans-serif; }
/* =====================
   FAB (кнопка открытия)
   ===================== */
#router-widget-toggle.router-fab {
    position: fixed;
    bottom: 32px;
    right: 32px;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 35%, #E0E7FF, #C7D2FE);
    border: 4px solid #1E40AF;
    box-shadow: 0 10px 40px rgba(59,130,246,0.25);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    padding: 0;
    transition: transform 0.3s ease-out, opacity 0.3s ease-out;
    animation: rw-fab-bounce 3s ease-in-out infinite;
}
#router-widget-toggle.router-fab:hover { transform: scale(1.06); }
#router-widget-toggle.router-fab:active { transform: scale(0.96); }
#router-widget-toggle.router-fab::before {
    content: "";
    position: absolute;
    inset: -10px;
    border-radius: 50%;
    border: 2px solid rgba(59,130,246,0.3);
    animation: rw-fab-pulse 2.5s ease-in-out infinite;
    pointer-events: none;
}
@keyframes rw-fab-bounce { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-5px)} }
@keyframes rw-fab-pulse { 0%,100%{transform:scale(1);opacity:.6} 50%{transform:scale(1.15);opacity:0} }
.router-fab-avatar {
    width: 66px;
    height: 74px;
    margin-top: -8px;
    animation: rw-avatar-idle 4s ease-in-out infinite;
    filter: drop-shadow(0 4px 10px rgba(56,189,248,0.35));
    pointer-events: none;
}
@keyframes rw-avatar-idle { 0%,100%{transform:rotate(0) scale(1)} 25%{transform:rotate(2deg) scale(1.02)} 75%{transform:rotate(-2deg) scale(1)} }
.router-fab-label {
    position: absolute;
    bottom: -16px;
    background: #1E40AF;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 5px 14px;
    border-radius: 18px;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(30,64,175,0.4);
    line-height: 1.3;
    text-align: center;
    pointer-events: none;
}
/* =====================
   ОКНО ЧАТА
   ===================== */
.router-widget-window {
    position: fixed;
    bottom: 7px;
    right: 7px;
    width: 480px;
    height: 680px;
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 48px);
    border-radius: 40px;
    border: 4px solid #3B82F6;
    background: #fff;
    box-shadow: 0 20px 60px rgba(30,111,235,0.15), 0 10px 20px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    z-index: 9999;
    overflow: hidden;
    font-family: inherit;
    animation: rw-window-in 0.3s ease-out both;
}
@keyframes rw-window-in { from{opacity:0;transform:scale(0.92) translateY(16px)} to{opacity:1;transform:scale(1) translateY(0)} }
/* --- ХЕДЕР --- */
.router-widget-header {
    background: linear-gradient(135deg, #2563EB, #1D4ED8);
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 80px;
    min-height: 80px;
    flex-shrink: 0;
}
.router-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 16px;
}
.router-header-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid #fff;
    background: radial-gradient(circle at 40% 35%, #7DD3FC, #0EA5E9);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-shadow: 0 4px 14px rgba(56,189,248,0.35);
    flex-shrink: 0;
}
.router-header-avatar svg { width: 30px; height: 34px; }
.router-header-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.router-header-name {
    color: #fff;
    font-size: 17px;
    font-weight: 600;
    line-height: 1.3;
}
.router-header-status {
    color: #93C5FD;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.router-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #34D399;
    box-shadow: 0 0 6px rgba(52,211,153,0.5);
    display: inline-block;
}
.router-widget-header-buttons {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 16px;
}
/* Кнопки управления в хедере */
.router-header-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.12);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    padding: 0;
}
.router-header-btn:hover { background: rgba(255,255,255,0.25); }
.router-header-btn svg { width: 17px; height: 17px; color: #fff; }
/* =====================
   СООБЩЕНИЯ (JS-классы сохранены)
   ===================== */
.router-widget-messages {
    flex: 1;
    padding: 20px 22px 10px;
    overflow-y: auto;
    background: #F8FAFC;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.router-widget-messages::-webkit-scrollbar { width: 6px; }
.router-widget-messages::-webkit-scrollbar-track { background: transparent; }
.router-widget-messages::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 3px; }
/* Базовый ряд сообщения (JS создаёт .msg .msg-user / .msg-manager) */
.msg {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    animation: rw-msg-in 0.3s ease-out both;
}
.msg-user { justify-content: flex-end; }
.msg-manager { justify-content: flex-start; }
.msg-system {
    justify-content: center;
    font-size: 12px;
    color: #474E5A;
    font-style: normal;
    margin: 4px 0;
}
@keyframes rw-msg-in { from{opacity:0;transform:translateY(10px)} to{opacity:1;transform:translateY(0)} }
/* Пузырь (JS создаёт .msg-bubble внутри .msg) */
.msg-bubble {
    max-width: 78%;
    padding: 14px 18px;
    border-radius: 20px;
    font-size: 15px;
    line-height: 1.55;
    position: relative;
    word-break: break-word;
}
/* Пузырь пользователя */
.msg-user .msg-bubble {
    background: #FFFFFF;
    color: #374151;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
/* Пузырь менеджера/ИИ */
.msg-manager .msg-bubble {
    background: #EFF6FF;
    color: #1E3A8A;
    border-bottom-left-radius: 4px;
}
/* Время (JS создаёт .msg-time) */
.msg-time {
    display: block;
    font-size: 12px;
    color: #9CA3AF;
    opacity: 1;
    margin-top: 6px;
    text-align: right;
}
/* =====================
   ПОЛЕ ВВОДА
   ===================== */
.router-widget-input-area {
    padding: 14px 18px 18px;
    background: #fff;
    border-top: none;
    flex-shrink: 0;
}
.router-input-wrap {
    display: flex;
    align-items: center;
    background: #fff;
    border-radius: 30px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    padding: 4px 4px 4px 18px;
    border: 1px solid #E0E7FF;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.router-input-wrap:focus-within {
    border-color: #3B82F6;
    box-shadow: 0 4px 16px rgba(30,111,235,0.12);
}
.router-widget-input-area input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 15px;
    font-family: inherit;
    color: #1A1A2E;
    background: transparent;
    padding: 10px 0;
    line-height: 1.4;
}
.router-widget-input-area input::placeholder { color: #9CA3AF; }
/* Кнопка отправки (SVG внутри) */
#router-widget-send.router-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #1E6FEB;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
    transition: background 0.2s ease, transform 0.1s ease;
}
#router-widget-send.router-send-btn:hover { background: #2563EB; }
#router-widget-send.router-send-btn:active { transform: scale(0.93); }
#router-widget-send.router-send-btn svg { width: 20px; height: 20px; color: #fff; }
/* =====================
   ТУЛТИП (JS-класс)
   ===================== */
.router-tooltip {
    position: fixed;
    bottom: 80px;
    right: 20px;
    background: #1E40AF;
    color: #fff;
    padding: 10px 18px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    z-index: 9999;
    animation: rw-tooltip-in 0.25s ease-out;
    box-shadow: 0 4px 16px rgba(30,64,175,0.3);
}
@keyframes rw-tooltip-in { from{opacity:0;transform:translateY(6px)} to{opacity:1;transform:translateY(0)} }
/* =====================
   АДАПТИВНОСТЬ
   ===================== */
@media (max-width: 520px) {
    .router-widget-window {
        bottom: 0;
        right: 0;
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
        border: none;
    }
    #router-widget-toggle.router-fab {
        bottom: 20px;
        right: 20px;
        width: 100px;
        height: 100px;
    }
    .router-fab-avatar { width: 54px; height: 60px; }
    .router-fab-label { font-size: 11px; padding: 4px 12px; bottom: -14px; }
    .msg-bubble { max-width: 88%; }
}