:root {
    --body-bg: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    --msger-bg: #fff;
    --border: 2px solid #ddd;
    --left-msg-bg: #ececec;
    --right-msg-bg: #579ffb;
}

html {
    box-sizing: border-box;
}

.msger-header-title {
    font-size: 1.2em;
}

.msger-header-options button {
    margin-left: 10px;
    color: #fff;
    width: 40px;
    height: 30px;
    cursor: pointer;
    transition: background 0.23s;
}

.msger-header-options button:hover {
    background: darkorange;
}

*,
*:before,
*:after {
    margin: 0;
    padding: 0;
    box-sizing: inherit;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background-image: var(--body-bg);
    font-family: Helvetica, sans-serif;
}

.msger {
    display: flex;
    flex-flow: column wrap;
    justify-content: space-between;
    width: 100%;
    max-width: 867px;
    margin: 25px 10px;
    height: calc(100% - 50px);
    border: var(--border);
    border-radius: 5px;
    background: var(--msger-bg);
    box-shadow: 0 15px 15px -5px rgba(0, 0, 0, 0.2);
}

.msger > * {
    width: 100%;
}

@media (max-width: 768px) {
    .msger {
        max-width: 96%;
        margin: 10px;
        height: calc(100% - 20px);
    }
}

.msger-header {
    display: flex;
    justify-content: space-between;
    padding: 15px;
    border-bottom: var(--border);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border-radius: 5px 5px 0 0;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.msg-chat {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.msger-chat::-webkit-scrollbar {
    width: 6px;
}

.msger-chat::-webkit-scrollbar-track {
    background: #ddd;
}

.msger-chat::-webkit-scrollbar-thumb {
    background: #bdbdbd;
}

.msg {
    display: flex;
    align-items: flex-end;
    margin-bottom: 10px;
}

.msg:last-of-type {
    margin: 0;
}

.msg-img {
    width: 50px;
    height: 50px;
    min-width: 50px;
    min-height: 50px;
    margin-right: 10px;
    background: #ddd;
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
    border-radius: 50%;
}

.msg-bubble {
    padding: 15px;
    border-radius: 15px;
    background: var(--left-msg-bg);
}

.msg-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.msg-info-name {
    margin-right: 10px;
    font-weight: bold;
}

.msg-info-time {
    font-size: 0.85em;
}

.left-msg .msg-bubble {
    border-bottom-left-radius: 0;
}

.right-msg {
    flex-direction: row-reverse;
}

.right-msg .msg-bubble {
    background: var(--right-msg-bg);
    color: #fff;
    border-bottom-right-radius: 0;
}

.right-msg .msg-img {
    margin: 0 0 0 10px;
}

.msg-form {
    display: flex;
    padding: 10px;
    border-top: var(--border);
    background: #eee;
}

.msg-form * {
    padding: 10px;
    border: none;
    border-radius: 3px;
    font-size: 1em;
}

.msger-input {
    flex: 1;
    background: #ddd;
    min-width: 50px;
}

.msger-send-btn {
    margin-left: 10px;
    background: rgb(0, 196, 65);
    color: #fff;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.23s;
}

.msger-send-btn:hover {
    background: rgb(0, 180, 50);
}

.msger-speech-btn {
    margin-left: 10px;
    background: orange;
    color: #fff;
    width: 60px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.23s;
}

.msger-speech-btn:hover {
    background: darkorange;
}

.msg-chat {
    background-color: #fcfcfe;
    background-image: url(./background.svg);
}

.suggestions-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
}

.suggestion-btn {
    margin: 5px;
    padding: 10px 15px;
    border: none;
    border-radius: 5px;
    background: lightgray;
    cursor: pointer;
    transition: background 0.23s;
}

.suggestion-btn:hover {
    background: rgb(0, 180, 50);
}

.content {
    font-family: Arial, sans-serif;
}

.content h1 {
    color: #333;
}

.content p {
    font-size: 16px;
}

.content ul {
    list-style-type: disc;
    margin-left: 20px;
}
.content ol {
    padding: 10px 0 10px 20px;
}

.thinking-popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.thinking-popup-content {
    background-color: white;
    padding: 16px;
    border-radius: 15px;
    width: 95%;
    height: 95%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.thinking-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 10px;
    border-bottom: 2px solid #e0e0e0;
}

.thinking-data-container {
    max-height: 100%;
    flex: 1;
    overflow-y: auto;
    margin-top: 10px;
}

.thinking-table {
    width: 100%;
    border-collapse: collapse;
}

.thinking-table thead tr {
    background-color: #f2f2f2;
}

.thinking-table th,
.thinking-table td {
    padding: 10px;
    border: 1px solid #ddd;
    vertical-align: top;
}

.thinking-table tbody tr {
    background-color: #ffffff;
}

.thinking-table td:first-child {
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sub-thinking-table {
    width: 100%;
    border-collapse: collapse;
    margin: 5px 0;
}

.sub-thinking-table td {
    padding: 8px 10px;
    border: 1px solid #e0e0e0;
    vertical-align: top;
}

.sub-thinking-table td:first-child {
    background-color: #f9f9f9;
    max-width: 180px;
}

/* Field name cell */
.field-name-cell {
    font-weight: 600;
}

/* Field value content */
td.field-value-content {
    white-space: pre-wrap;
    word-break: break-word;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.5;
}

.close-popup {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-popup:hover,
.close-popup:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

/* File Upload Styles */
.file-upload-container {
    margin: 10px 0;
}

.file-drop-area {
    border: 2px dashed #ddd;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fafafa;
    margin-bottom: 10px;
}

.file-drop-area:hover {
    border-color: #667eea;
    background: #f0f4ff;
}

.file-drop-area.drag-over {
    border-color: #667eea;
    background: #e6f0ff;
    transform: scale(1.02);
}

.drop-area-content {
    pointer-events: none;
}

.drop-icon {
    font-size: 2em;
    margin-bottom: 10px;
}

.drop-text {
    margin-bottom: 5px;
    font-size: 14px;
    color: #333;
}

.drop-primary {
    color: #667eea;
    font-weight: bold;
}

.drop-info {
    font-size: 12px;
    color: #666;
}

.file-attachments {
    max-height: 150px;
    overflow-y: auto;
    margin-bottom: 10px;
}

.file-attachment {
    margin-bottom: 5px;
}

.file-attachment-content {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background: #f5f5f5;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

.file-icon {
    margin-right: 8px;
    font-size: 16px;
}

.file-info {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-size: 13px;
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-size {
    font-size: 11px;
    color: #666;
}

.file-remove-btn {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 12px;
    transition: all 0.2s ease;
}

.file-remove-btn:hover {
    background: #ff4444;
    color: white;
}

.file-upload-toggle {
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 3px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
    margin-right: 10px;
}

.file-upload-toggle:hover {
    background: #e0e0e0;
}

.file-upload-toggle.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.file-errors {
    margin-top: 5px;
}

.file-error {
    color: #ff4444;
    font-size: 12px;
    margin-bottom: 3px;
}

/* Message attachments display */
.msg-attachments {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(0,0,0,0.1);
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.msg-attachment {
    display: inline-flex;
    align-items: center;
    background: rgba(255,255,255,0.2);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 11px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border: 1px solid rgba(0,0,0,0.1);
}

.msg-attachment:hover {
    background: rgba(255,255,255,0.3);
    transform: translateY(-1px);
}

.msg-attachment-icon {
    margin-right: 6px;
    font-size: 14px;
}

.msg-attachment-name {
    max-width: 120px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.msg-attachment-size {
    margin-left: 6px;
    opacity: 0.7;
    font-size: 10px;
}

/* Different styles for left and right messages */
.left-msg .msg-attachment {
    background: rgba(0,0,0,0.05);
    border-color: rgba(0,0,0,0.1);
}

.left-msg .msg-attachment:hover {
    background: rgba(0,0,0,0.1);
}

.right-msg .msg-attachment {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.3);
    color: white;
}

.right-msg .msg-attachment:hover {
    background: rgba(255,255,255,0.3);
}

/* Loading animation */
.loading-dots {
    display: inline-flex;
    align-items: center;
}

.loading-dots span {
    animation: loading-pulse 1.4s ease-in-out infinite both;
    font-size: 12px;
    margin: 0 1px;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }
.loading-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes loading-pulse {
    0%, 80%, 100% {
        opacity: 0.3;
        transform: scale(0.8);
    }
    40% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Hidden click area */
.hidden-click-area {
    position: absolute;
    top: 0;
    right: 0;
    width: 30px;
    height: 100%;
    cursor: default;
}

.msger-header-title {
    position: relative;
    user-select: none;
}

/* Advanced dropdown menu */
.advanced-dropdown {
    position: absolute;
    top: 60px;
    right: 60px;
    background: white;
    border: none;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    overflow: hidden;
    animation: dropdownFadeIn 0.2s ease-out;
    width: max-content;
}

@keyframes dropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dropdown-item {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 14px 18px;
    border: none;
    background: white;
    text-align: left;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    color: #333;
    gap: 10px;
    border-bottom: 1px solid #f0f0f0;
    white-space: nowrap;
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover {
    background: #f8f9fa;
    padding-left: 22px;
}

.dropdown-item:active {
    background: #e9ecef;
}

.debug-icon {
    cursor: pointer;
    margin-right: 5px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.debug-icon:hover {
    opacity: 1;
}

/* Custom messages modal */
.custom-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.custom-modal-content {
    background-color: white;
    padding: 0;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.custom-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e0e0e0;
    background: #f8f9fa;
}

.custom-modal-body {
    padding: 24px;
}

.custom-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid #e0e0e0;
    background: #f8f9fa;
}

.close-modal {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

.close-modal:hover {
    color: #333;
}

.custom-messages-textarea {
    width: 100%;
    min-height: 200px;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    resize: vertical;
    transition: border-color 0.2s;
}

.custom-messages-textarea:focus {
    outline: none;
    border-color: #667eea;
}

.modal-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-btn-cancel {
    background: #e0e0e0;
    color: #333;
}

.modal-btn-cancel:hover {
    background: #d0d0d0;
}

.modal-btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.modal-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.modal-btn-primary:active {
    transform: translateY(0);
}
