/* Matrix Chat Widget Styles */
.matrix-widget {
    position: fixed;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 14px;
    line-height: 1.4;
    box-sizing: border-box;
}

/* Position variants */
.matrix-widget--bottom-right {
    bottom: 20px;
    right: 20px;
}

.matrix-widget--bottom-left {
    bottom: 20px;
    left: 20px;
}

.matrix-widget--top-right {
    top: 20px;
    right: 20px;
}

.matrix-widget--top-left {
    top: 20px;
    left: 20px;
}

/* Toggle button */
.matrix-widget__toggle {
    position: relative;
    width: 60px;
    height: 60px;
    /*background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);*/
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    /*transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);*/
    border: none;
    outline: none;
}

.matrix-widget__toggle:hover {
    transform: scale(1.05);
    /*box-shadow: 0 6px 25px rgba(0, 0, 0, 0.2);*/
}

.matrix-widget__toggle:active {
    transform: scale(0.95);
}

/* Notification badge */
.matrix-widget__notification {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4757;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 11px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Chat container */
.matrix-widget__container {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 350px;
    height: 500px;
    background: #3a3e5b;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.matrix-widget--open .matrix-widget__container {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.matrix-widget--minimized .matrix-widget__container {
    height: 60px;
    bottom: 70px;
}

/* Header */
.matrix-widget__header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

.matrix-widget__title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 16px;
}

.matrix-widget__controls {
    display: flex;
    gap: 8px;
}

.matrix-widget__minimize,
.matrix-widget__close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.matrix-widget__minimize:hover,
.matrix-widget__close:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Content area */
.matrix-widget__content {
    height: calc(100% - 60px);
    display: flex;
    flex-direction: column;
}

.matrix-widget--minimized .matrix-widget__content {
    display: none;
}

/* Messages area */
.matrix-widget__messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #3a3e5b;
}

.matrix-widget__messages::-webkit-scrollbar {
    width: 6px;
}

.matrix-widget__messages::-webkit-scrollbar-track {
    background: transparent;
}

.matrix-widget__messages::-webkit-scrollbar-thumb {
    background: #dee2e6;
    border-radius: 3px;
}

.matrix-widget__messages::-webkit-scrollbar-thumb:hover {
    background: #adb5bd;
}

/* Welcome message */
.matrix-widget__welcome {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
}

.matrix-widget__welcome-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.matrix-widget__welcome-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #495057;
}

.matrix-widget__welcome-text {
    font-size: 14px;
    line-height: 1.5;
}

/* Messages */
.matrix-widget__message {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
}

.matrix-widget__message--user {
    align-items: flex-end;
}

.matrix-widget__message--agent {
    align-items: flex-start;
}

.matrix-widget__message-content {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    position: relative;
    word-wrap: break-word;
}

.matrix-widget__message--user .matrix-widget__message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 6px;
}

.matrix-widget__message--agent .matrix-widget__message-content {
    background: white;
    color: #495057;
    border: 1px solid #e9ecef;
    border-bottom-left-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.matrix-widget__message-text {
    margin-bottom: 4px;
    line-height: 1.4;
}

.matrix-widget__message-time {
    font-size: 11px;
    opacity: 0.7;
}

/* Error message */
.matrix-widget__error {
    background: #fff5f5;
    color: #e53e3e;
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid #fed7d7;
    margin-bottom: 16px;
    font-size: 13px;
}

/* Input area */
.matrix-widget__input-container {
    padding: 16px 20px;
    background: #3a3e5b;
    border-top: 1px solid #e9ecef;
}

/* Cooldown timer */
.matrix-widget__cooldown {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 8px;
    padding: 8px 12px;
    margin-bottom: 12px;
    text-align: center;
    font-size: 13px;
    color: #856404;
}

.matrix-widget__cooldown-text {
    font-weight: 500;
}

.matrix-widget__cooldown-timer {
    font-weight: bold;
    color: #e74c3c;
    font-size: 14px;
}

/* Disabled input state */
.matrix-widget__input:disabled {
    background-color: #f8f9fa;
    color: #6c757d;
    cursor: not-allowed;
}

.matrix-widget__send:disabled {
    background-color: #6c757d;
    cursor: not-allowed;
    opacity: 0.6;
}

.matrix-widget__send:disabled:hover {
    background-color: #6c757d;
    transform: none;
}

.matrix-widget__input-wrapper {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.matrix-widget__input {
    flex: 1;
    border: 1px solid #dee2e6;
    border-radius: 20px;
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.4;
    resize: none;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
    max-height: 120px;
    min-height: 44px;
}

.matrix-widget__input:focus {
    border-color: #667eea;
}

.matrix-widget__input::placeholder {
    color: #adb5bd;
}

.matrix-widget__send {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.matrix-widget__send:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.matrix-widget__send:active {
    transform: scale(0.95);
}

/* Dark theme */
.matrix-widget--dark .matrix-widget__container {
    background: #2d3748;
    color: #e2e8f0;
}

.matrix-widget--dark .matrix-widget__messages {
    background: #1a202c;
}

.matrix-widget--dark .matrix-widget__message--agent .matrix-widget__message-content {
    background: #4a5568;
    color: #e2e8f0;
    border-color: #2d3748;
}

.matrix-widget--dark .matrix-widget__input-container {
    background: #2d3748;
    border-top-color: #4a5568;
}

.matrix-widget--dark .matrix-widget__input {
    background: #4a5568;
    border-color: #2d3748;
    color: #e2e8f0;
}

.matrix-widget--dark .matrix-widget__input::placeholder {
    color: #a0aec0;
}

.matrix-widget--dark .matrix-widget__welcome {
    color: #a0aec0;
}

.matrix-widget--dark .matrix-widget__welcome-title {
    color: #e2e8f0;
}

/* Responsive design */
@media (max-width: 480px) {
    .matrix-widget__container {
        width: calc(100vw - 40px);
        right: -10px;
    }
    
    .matrix-widget--bottom-left .matrix-widget__container,
    .matrix-widget--top-left .matrix-widget__container {
        left: -10px;
        right: auto;
    }
}

/* Animation for new messages */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.matrix-widget__message {
    animation: slideInUp 0.3s ease-out;
}

/* Loading state */
.matrix-widget__loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #6c757d;
}

.matrix-widget__loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid #dee2e6;
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 8px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Typing indicator */
.matrix-widget__typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    color: #6c757d;
    font-size: 13px;
}

.matrix-widget__typing-dots {
    display: flex;
    gap: 2px;
}

.matrix-widget__typing-dot {
    width: 6px;
    height: 6px;
    background: #adb5bd;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.matrix-widget__typing-dot:nth-child(1) { animation-delay: -0.32s; }
.matrix-widget__typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.matrix-widget__status {
    display: inline-flex;
    align-items: center;
    margin-left: 8px;
    font-size: 12px;
    color: #888;
}

.matrix-widget__status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 4px;
}

.matrix-widget__status-dot--online {
    background-color: #4caf50;
}

.matrix-widget__status-dot--offline {
    background-color: #f44336;
}

.matrix-widget__status-dot--transition {
    background-color: yellow;
    animation: yellowToGreen 2s infinite alternate ease-in-out;
}

@keyframes yellowToGreen {
    0% {
        background-color: yellow;
    }
    100% {
        background-color: #4caf50; /* зелёный */
    }
}


/* Кнопка открытия виджета — сделать квадратной с мелким скруглением */
.matrix-widget__toggle {
    width: 56px;
    height: 56px;
    /*background: linear-gradient(135deg, #44475a 0%, #282a36 100%);
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);*/
    color: #f8f8f2;
    font-weight: 600;
    /*transition: all 0.2s ease-in-out;*/
}

.matrix-widget__toggle:hover {
    transform: scale(1.05);
    /*box-shadow: 0 4px 14px rgba(0, 0, 0, 0.7);*/
}

/* Контейнер чата — квадратные углы и темный фон */
.matrix-widget__container {
    width: 360px;
    height: 520px;
    background: #282a36;
    border-radius: 4px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
    color: #f8f8f2;
}

/* Хедер — простой темный фон с легкой тенью, мелкие скругления */
.matrix-widget__header {
    background: #44475a;
    border-radius: 4px 4px 0 0;
    box-shadow: inset 0 -1px 0 #6272a4;
    padding: 14px 18px;
}

/* Сообщения — фон темный и углы мелко скругленные */
.matrix-widget__message-content {
    border-radius: 6px;
    padding: 14px 18px;
    max-width: 80%;
    font-size: 14px;
    line-height: 1.5;
}

/* Сообщения от пользователя */
.matrix-widget__message--user .matrix-widget__message-content {
    background: #f66;
    color: #282a36;
    border-bottom-right-radius: 4px;
}

/* Сообщения от агента */
.matrix-widget__message--agent .matrix-widget__message-content {
    background: #44475a;
    color: #f8f8f2;
    border: none;
    border-bottom-left-radius: 4px;
    box-shadow: none;
}

/* Поле ввода — темный фон, квадратные углы, светлый текст */
.matrix-widget__input {
    background: #44475a;
    border: 1px solid #6272a4;
    border-radius: 4px;
    color: #f8f8f2;
    padding: 12px 16px;
    font-family: 'Fira Mono', monospace, sans-serif; /* если хочешь похожий стиль шрифта */
}

.matrix-widget__input:focus {
    border-color: #f66;
    outline: none;
}

/* Кнопка отправки — квадратная с минимальным скруглением */
.matrix-widget__send {
    width: 44px;
    height: 44px;
    background: #f66;
    border-radius: 4px;
    color: #282a36;
    transition: all 0.2s ease-in-out;
}

.matrix-widget__send:hover {
    background: #40e86f;
    box-shadow: 0 0 8px #40e86f;
    transform: scale(1.05);
}

/* Фон окна чата */
.matrix-widget__container {
    background: #1e1f29;
    border-radius: 4px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
    color: 3a3e5b;
}

/* Сообщения агента */
.matrix-widget__message--agent .matrix-widget__message-content {
    padding: 10px 14px;
    border-radius: 12px;
    line-height: 1.4;
    word-wrap: break-word;
    background: #2c2f48;
    color: #c8cbd6;
    border-bottom-left-radius: 4px;
}

/* Сообщения пользователя */
.matrix-widget__message--user .matrix-widget__message-content {
    padding: 10px 14px;
    border-radius: 12px;
    line-height: 1.4;
    word-wrap: break-word;
    background: #ff2b2b;
    color: #1e1f29;
    border-bottom-right-radius: 4px;
}

/* Поле ввода */
.matrix-widget__input {
    background: #2c2f48;
    border: 1px solid #3a3e5b;
    color: #c8cbd6;
}

/* При фокусе на поле ввода */
.matrix-widget__input:focus {
    border-color: #ff2b2b;
    outline: none;
}

/* Кнопка отправки */
.matrix-widget__send {
    background: #ff2b2b;
    color: #1e1f29;
    border-radius: 4px;
}

.matrix-widget__send:hover {
    background: #f66;
    box-shadow: 0 0 8px #f66;
    transform: scale(1.05);
}
