.iwtr-chat-container {
    max-width: 800px;
    margin: 20px auto;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #fff;
    display: flex;
    flex-direction: column;
    height: 600px;
}

.iwtr-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    font-size: 16px;
}

.iwtr-chat-message {
    display: flex;
    margin-bottom: 10px;
}

.iwtr-chat-message-user {
    justify-content: flex-end;
}

.iwtr-chat-message-assistant {
    justify-content: flex-start;
}

.iwtr-chat-message-content {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.4;
    font-size: 16px;
}

.iwtr-chat-message-user .iwtr-chat-message-content {
    background: #007bff;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.iwtr-chat-message-assistant .iwtr-chat-message-content {
    background: #f1f1f1;
    color: #333;
    border-bottom-left-radius: 4px;
}

.iwtr-chat-loading .iwtr-chat-message-content {
    background: #f1f1f1;
    color: #999;
    font-style: italic;
}

.iwtr-chat-form {
    display: flex;
    padding: 15px;
    border-top: 1px solid #ddd;
    gap: 10px;
}

.iwtr-chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 24px;
    font-size: 16px;
    outline: none;
    min-height: 60px;
    max-height: 200px;
    overflow-y: auto;
    resize: vertical;
    font-family: inherit;
    line-height: 1.5;
}

.iwtr-chat-input:focus {
    border-color: #007bff;
}

.iwtr-chat-input:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
}

.iwtr-chat-submit {
    padding: 12px 24px;
    background: #007bff;
    color: #fff;
    border: none;
    border-radius: 24px;
    font-size: 14px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s;
}

.iwtr-chat-submit:hover:not(:disabled) {
    background: #0056b3;
}

.iwtr-chat-submit:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Скроллбар для сообщений */
.iwtr-chat-messages::-webkit-scrollbar {
    width: 8px;
}

.iwtr-chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.iwtr-chat-messages::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.iwtr-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Markdown стили для содержимого сообщений */
.iwtr-chat-message-content h1,
.iwtr-chat-message-content h2,
.iwtr-chat-message-content h3,
.iwtr-chat-message-content h4,
.iwtr-chat-message-content h5,
.iwtr-chat-message-content h6 {
    margin: 12px 0 8px 0;
    font-weight: 600;
    line-height: 1.3;
}

.iwtr-chat-message-content h1 {
    font-size: 1.5em;
}

.iwtr-chat-message-content h2 {
    font-size: 1.3em;
}

.iwtr-chat-message-content h3 {
    font-size: 1.15em;
}

.iwtr-chat-message-content h4 {
    font-size: 1.05em;
}

.iwtr-chat-message-content h5 {
    font-size: 1em;
}

.iwtr-chat-message-content h6 {
    font-size: 0.9em;
}

.iwtr-chat-message-content p {
    margin: 8px 0;
}

.iwtr-chat-message-content p:first-child {
    margin-top: 0;
}

.iwtr-chat-message-content p:last-child {
    margin-bottom: 0;
}

.iwtr-chat-message-content ul,
.iwtr-chat-message-content ol {
    margin: 8px 0;
    padding-left: 24px;
}

.iwtr-chat-message-content li {
    margin: 4px 0;
    line-height: 1.5;
}

.iwtr-chat-message-content ul {
    list-style-type: disc;
}

.iwtr-chat-message-content ol {
    list-style-type: decimal;
}

.iwtr-chat-message-content ul ul,
.iwtr-chat-message-content ol ol,
.iwtr-chat-message-content ul ol,
.iwtr-chat-message-content ol ul {
    margin: 4px 0;
}

.iwtr-chat-message-content strong {
    font-weight: 600;
}

.iwtr-chat-message-content em {
    font-style: italic;
}

.iwtr-chat-message-content code {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
}

.iwtr-chat-message-content pre {
    background: rgba(0, 0, 0, 0.05);
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 12px 0;
    line-height: 1.4;
}

.iwtr-chat-message-content pre code {
    background: transparent;
    padding: 0;
    border-radius: 0;
    font-size: 0.85em;
}

.iwtr-chat-message-content blockquote {
    margin: 12px 0;
    padding: 8px 16px;
    border-left: 4px solid rgba(0, 0, 0, 0.2);
    background: rgba(0, 0, 0, 0.03);
    font-style: italic;
}

.iwtr-chat-message-content hr {
    margin: 16px 0;
    border: none;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.iwtr-chat-message-content a {
    color: #007bff;
    text-decoration: underline;
}

.iwtr-chat-message-content a:hover {
    color: #0056b3;
}

.iwtr-chat-message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 0.9em;
}

.iwtr-chat-message-content table th,
.iwtr-chat-message-content table td {
    padding: 8px 12px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    text-align: left;
}

.iwtr-chat-message-content table th {
    background: rgba(0, 0, 0, 0.05);
    font-weight: 600;
}

.iwtr-chat-message-content table tr:nth-child(even) {
    background: rgba(0, 0, 0, 0.02);
}

/* Стили для сообщений пользователя (белый текст) */
.iwtr-chat-message-user .iwtr-chat-message-content code {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.iwtr-chat-message-user .iwtr-chat-message-content pre {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.iwtr-chat-message-user .iwtr-chat-message-content blockquote {
    border-left-color: rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
}

.iwtr-chat-message-user .iwtr-chat-message-content hr {
    border-top-color: rgba(255, 255, 255, 0.2);
}

.iwtr-chat-message-user .iwtr-chat-message-content a {
    color: #fff;
    text-decoration: underline;
}

.iwtr-chat-message-user .iwtr-chat-message-content table th,
.iwtr-chat-message-user .iwtr-chat-message-content table td {
    border-color: rgba(255, 255, 255, 0.2);
}

.iwtr-chat-message-user .iwtr-chat-message-content table th {
    background: rgba(255, 255, 255, 0.15);
}

.iwtr-chat-message-user .iwtr-chat-message-content table tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.1);
}

/* Role Selection UI */
.iwtr-chat-role-selection {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.iwtr-chat-role-selection-content {
    text-align: center;
    max-width: 600px;
    width: 100%;
}

.iwtr-chat-role-selection-title {
    font-size: 24px;
    font-weight: 600;
    margin: 0 0 10px 0;
    color: #333;
}

.iwtr-chat-role-selection-description {
    font-size: 16px;
    color: #666;
    margin: 0 0 30px 0;
}

.iwtr-chat-role-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.iwtr-chat-role-button {
    padding: 16px 24px;
    background: #fff;
    border: 2px solid #007bff;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    color: #007bff;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.iwtr-chat-role-button:hover {
    background: #007bff;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 123, 255, 0.2);
}

.iwtr-chat-role-button:active {
    transform: translateY(0);
}

/* Role Indicator */
.iwtr-chat-role-indicator {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #f8f9fa;
    border-bottom: 1px solid #ddd;
    margin-bottom: 15px;
    border-radius: 4px 4px 0 0;
}

.iwtr-chat-role-indicator-text {
    font-size: 14px;
    color: #666;
}

.iwtr-chat-role-indicator-text strong {
    color: #333;
    font-weight: 600;
}

.iwtr-chat-role-change-button {
    padding: 6px 12px;
    background: #6c757d;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.iwtr-chat-role-change-button:hover {
    background: #5a6268;
}

/* Disclaimer */
.iwtr-chat-disclaimer {
    padding: 12px 20px;
    font-size: 12px;
    line-height: 1.5;
    color: #666;
    text-align: center;
    border-top: 1px solid #eee;
    background: #fafafa;
}
