@font-face {
  font-family: 'Open Sans';
  src: url('https://vm-c1112ec7.na4u.ru/assets/OpenSans-VariableFont_wdth,wght.ttf') format('truetype-variations');
  font-weight: 300 800;
  font-style: normal;
}
@font-face {
  font-family: 'Open Sans';
  src: url('https://vm-c1112ec7.na4u.ru/assets/OpenSans-Italic-VariableFont_wdth,wght.ttf') format('truetype-variations');
  font-weight: 300 800;
  font-style: italic;
}

/* ---- виджет чата (плавающая кнопка + окно) ---- */
.chat-widget {
    display: flex;
    position: fixed;
    flex-direction: column;
    align-items: flex-end;
    bottom: 24px;
    right: 24px;
    font-family: 'Open Sans', sans-serif;
    line-height: 1.5;
    z-index: 1000;
}

.chat-widget * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Кнопка открытия */
.chat-toggle-btn {
    width: 56px;
    height: 56px;
    border-radius: 28px;
    background: #3b82f6;
    border: none;
    cursor: pointer;
    box-shadow: 0 6px 14px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: white;
    font-size: 24px;
    position: relative;
}

.chat-toggle-btn:hover {
    background: #2563eb;
    transform: scale(1.03);
}

.chat-toggle-btn img {
  display: block;
  height: 24px;
  line-height: 0;
}

/* красный индикатор */
.unread-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: white;
    font-size: 11px;
    font-weight: bold;
    min-width: 20px;
    height: 20px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    border: 2px solid white;
    transition: 0.2s;
}

/* Окно чата (скрыто по умолчанию) */
.chat-panel {
    position: fixed;
    bottom: 90px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 570px;
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: 24px;
    box-shadow: 0 20px 35px -12px rgba(0,0,0,0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.95);
    opacity: 0;
    visibility: hidden;
    transform-origin: bottom right;
    transition: transform 0.25s cubic-bezier(0.2, 0.9, 0.4, 1.1), opacity 0.2s ease, visibility 0.2s;
    border: 1px solid #eef2ff;
}

.chat-panel.open {
    transform: scale(1);
    opacity: 1;
    visibility: visible;
}

/* шапка чата */
.chat-header {
    background: #ffffff;
    padding: 16px 20px;
    border-bottom: 1px solid #eef2f6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 1.1rem;
    color: #0f172a;
}

.chat-header span {
    background: linear-gradient(135deg, #1e293b, #3b82f6);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.close-chat {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #64748b;
    transition: 0.2s;
    line-height: 1;
    padding: 0 4px;
}

.close-chat:hover {
    color: #ef4444;
}

/* область сообщений */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #fafcff;
}

.message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 0.9rem;
    line-height: 1.4;
    word-break: break-word;
    position: relative;
}

.message.user {
    background: #3b82f6;
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.message.manager {
    background: #eef2ff;
    color: #1e293b;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.message.system {
    color: #475569;
    font-style: italic;
    font-size: 0.8rem;
    text-align: center;
    align-self: center;
    max-width: 90%;
}

.message.failed {
    opacity: 0.5;
}

.message .attachment-deleted {
    font-style: italic;
    opacity: 0.6;
}

.message-image {
    max-width: 200px;
    max-height: 150px;
    border-radius: 12px;
    margin-top: 5px;
    background-color: white;
    cursor: pointer;
}

.message-time {
    font-size: 0.7rem;
    opacity: 0.7;
    margin-top: 4px;
    text-align: right;
}

/* ввод сообщения */
.chat-input-area {
    padding: 12px;
    border-top: 1px solid #eef2f6;
    background: white;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.chat-input-area input[type="text"] {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 24px;
    padding: 10px 14px;
    font-size: 0.9rem;
    outline: none;
    transition: 0.2s;
}

.chat-input-area input[type="text"]:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59,130,246,0.2);
}

.attach-btn, .send-btn {
    background: #f1f5f9;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
    color: #334155;
}

.attach-btn:hover {
    background: #e2e8f0;
}

.send-btn {
    background: #3b82f6;
    color: white;
}

.send-btn:hover {
    background: #2563eb;
}

.attach-btn img {
  display: block;
  height: 22px;
}

.send-btn img {
  display: block;
  height: 16px;
  filter: invert(1);
}

/* модалка запроса имени */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(4px);
}

.name-modal {
    background: white;
    border-radius: 28px;
    width: 90%;
    max-width: 400px;
    padding: 1.5rem;
    box-shadow: 0 20px 35px rgba(0,0,0,0.2);
}

.name-modal h3 {
    margin-bottom: 1rem;
}

.name-modal input {
    width: 100%;
    padding: 12px;
    margin: 8px 0;
    border: 1px solid #cbd5e1;
    border-radius: 20px;
    font-size: 1rem;
}

.name-modal button {
    margin-top: 12px;
    background: #3b82f6;
    color: white;
    border: none;
    padding: 10px;
    width: 100%;
    border-radius: 40px;
    font-weight: 600;
    cursor: pointer;
}

.error-text {
    color: #ef4444;
    font-size: 0.8rem;
}


/* Контейнер формы внутри чата */
.system-form {
    align-self: stretch !important;
    max-width: 100% !important;
    padding: 0 !important;
    margin: 10px 0;
    background: transparent !important;
}

.in-chat-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.in-chat-card p {
    font-size: 0.85rem;
    color: #475569;
    margin-bottom: 4px;
}

.in-chat-card input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.in-chat-card input:focus {
    border-color: #3b82f6;
}

.in-chat-card button {
    background: #3b82f6;
    color: white;
    border: none;
    padding: 10px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.in-chat-card button:hover {
    background: #2563eb;
}

/* Стили для ссылок на файлы в сообщениях */
.file-attachment {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: inherit;
    padding: 4px 0;
}

.file-attachment img {
    width: 40px;
    height: auto;
}

/* Стили для кнопки переподключения */
.reconnect-btn {
    margin-top: 8px;
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    background: #2563eb;
    color: #fff;
    cursor: pointer;
    font-size: 14px;
}

.reconnect-btn:hover {
    opacity: 0.9;
}

.reconnect-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
}

.reconnect-btn:disabled {
    opacity: 0.7;
    cursor: default;
}

.reconnect-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(37, 99, 235, 0.2);
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: reconnect-spin 0.7s linear infinite;
}

@keyframes reconnect-spin {
    to {
        transform: rotate(360deg);
    }
}