* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(89, 35, 217, 0.3) var(--bg-darker);
    background-color: var(--bg-playground);
}

@keyframes gradient {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
    100% { transform: translateY(0px); }
}

:root {
    --bg-dark: #1a1a2e;
    --bg-darker: #151525;
    --bg-light: #242438;
    --accent: #5923D9;
    --accent-dark: #3F0C85;
    --text-light: #e0e0e0;
    --text-dark: #1a1a2e;
    --text-muted: #9090a0;
    --bg-playground: #13131f;
}

body {
    font-family: 'Segoe UI', Arial, sans-serif;
    background: linear-gradient(-45deg, var(--bg-dark), var(--bg-darker), var(--accent-dark), var(--bg-dark));
    background-size: 400% 400%;
    animation: gradient 15s ease infinite;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 15px;
    margin: 0;
    color: var(--text-light);
    background-color: var(--bg-playground);
}

.page-container {
    display: flex;
    gap: 15px;
    align-items: flex-start;
    width: 100%;
    max-width: 800px;
    background: var(--bg-playground);
    border-radius: 12px;
    height: 100%;
}

.navigation {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
    background: var(--bg-playground);
    border-radius: 15px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(89, 35, 217, 0.2);
}

.nav-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.8rem;
    padding: 0.75rem;
    transition: all 0.2s;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 8px;
}

.nav-link:hover {
    background: rgba(89, 35, 217, 0.1);
    color: var(--accent);
}

.nav-link svg {
    width: 24px;
    height: 24px;
    margin-bottom: 0.25rem;
    fill: currentColor;
}

.app-container {
    background: var(--bg-playground);
    width: 100%;
    height: 85vh;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
    display: flex;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(89, 35, 217, 0.2);
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-playground);
    overflow: hidden;
    position: relative;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: .5rem 1rem;
    background: var(--bg-playground);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    position: relative;
    text-align: center;
    border-bottom: 1px solid rgba(89, 35, 217, 0.2);
    color: var(--text-light);
}

.header-title {
    font-weight: 600;
    font-size: 1.5rem;
    text-align: left;
    padding: 0.75rem;
    background: var(--bg-playground);
    border-bottom: 1px solid rgba(89, 35, 217, 0.2);
    color: var(--text-light);
}

.header-agent {
    color: var(--accent);
    font-size: 0.9rem;
    font-weight: normal;
}

.header-agent::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, #3F0C85, #5923D9);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.header-agent:hover::after {
    transform: scaleX(1);
}

.header-timestamp {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.header-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.refresh-btn {
    position: absolute;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-muted);
}

.refresh-btn:hover {
    color: var(--accent);
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    scroll-behavior: smooth;
}
.chat-container::-webkit-scrollbar {
    width: 8px;
}

.chat-container::-webkit-scrollbar-track {
    background: var(--bg-darker);
    border-radius: 4px;
}

.chat-container::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 4px;
    border: 2px solid var(--bg-darker);
}

.chat-container::-webkit-scrollbar-thumb:hover {
    background: var(--accent-dark);
}
.chat-container {
    scrollbar-width: thin;
    scrollbar-color: var(--accent) var(--bg-darker);
}

#chat-box {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: min-content;
}

.message-wrapper {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.message-wrapper.user {
    align-items: flex-end;
}

.message-wrapper.bot {
    align-items: flex-start;
}

.bubble {
    position: relative;
    max-width: max-content;
    width: auto;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.4;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    display: inline-block;
}

.bubble.user {
    background: linear-gradient(135deg, var(--accent-dark), var(--accent));
    color: var(--text-light);
    text-align: left;
    align-self: flex-end;
}

.bubble.bot {
    background: var(--bg-light);
    color: var(--text-light);
    text-align: left;
    border: 1px solid rgba(89, 35, 217, 0.2);
    align-self: flex-start;
}

.bubble.loading {
    background: var(--bg-light);
    color: var(--text-muted);
    font-style: italic;
    opacity: 0.7;
}

.bubble.error {
    background: rgba(255, 0, 0, 0.1);
    color: #ff6b6b;
    border: 1px solid rgba(255, 0, 0, 0.2);
}

.bubble .actions {
    position: absolute;
    bottom: 4px;
    right: 6px;
    display: flex;
    gap: 4px;
    font-size: 0.85rem;
    opacity: 0.7;
}

.bubble .actions button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px;
}

.bubble .actions button:hover {
    opacity: 1;
}

.copy-btn,
.edit-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: .9rem;
}

.copy-btn:hover,
.edit-btn:hover {
    opacity: .7;
}
.input-container {
    padding: 0.75rem 1rem;
    background: var(--bg-darker);
    box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.2);
    border-top: 1px solid rgba(89, 35, 217, 0.2);
    margin-top: auto;
}

.input-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
}

#user-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 2px solid rgba(89, 35, 217, 0.3);
    border-radius: 25px;
    font-size: 0.95rem;
    background: var(--bg-dark);
    color: var(--text-light);
}

#user-input::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

#user-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(89, 35, 217, 0.2);
    background: var(--bg-light);
}

#send-btn, #audio-btn {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--accent-dark), var(--accent));
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

#send-btn:hover, #audio-btn:hover {
    transform: scale(1.05) rotate(5deg);
    box-shadow: 0 4px 12px rgba(89, 35, 217, 0.4);
}

#send-btn:active, #audio-btn:active {
    transform: scale(0.95);
}

#send-btn svg, #audio-btn svg {
    width: 60%;
    height: 60%;
    fill: #fff;
    transition: transform 0.3s ease;
}

#send-btn:hover svg, #audio-btn:hover svg {
    transform: scale(1.1);
}

#send-btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

#audio-btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}
.sources-panel {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 300px;
    background: var(--bg-playground);
    box-shadow: -2px 0 5px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    transform: translateX(100%);
    border-left: 1px solid rgba(89, 35, 217, 0.2);
}

.sources-panel:not(.hidden) {
    transform: translateX(0);
}

.sources-header {
    padding: 1rem;
    border-bottom: 1px solid rgba(89, 35, 217, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-playground);
    color: var(--text-light);
}

.sources-header h2 {
    margin: 0;
    font-size: 1.2rem;
    color: #333;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #666;
    cursor: pointer;
    padding: 0.5rem;
}

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

.sources-content {
    flex: 1;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
    background: var(--bg-playground);
    color: var(--text-light);
}

.upload-area {
    border: 2px dashed rgba(89, 35, 217, 0.3);
    background: var(--bg-playground);
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-light);
}

.upload-area.drag-over {
    border-color: var(--accent);
    background: rgba(89, 35, 217, 0.1);
}

.upload-icon {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.upload-area p {
    margin: 0.5rem 0;
    color: #666;
}

.upload-area small {
    color: #999;
}

.files-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.file-item {
    background: var(--bg-playground);
    border: 1px solid rgba(89, 35, 217, 0.2);
    border-radius: 4px;
    padding: 0.75rem;
    color: var(--text-light);
}

.file-name {
    flex: 1;
    font-size: 0.9rem;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-size {
    font-size: 0.8rem;
    color: #666;
}

.remove-file {
    background: none;
    border: none;
    color: #ff4444;
    cursor: pointer;
    padding: 0.25rem;
    font-size: 1.2rem;
}

.sources-footer {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid #eee;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.sources-stats {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: #666;
}

.retrain-btn {
    background: #3F0C85;
    color: white;
    border: none;
    padding: 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.retrain-btn:hover {
    background: #5923D9;
}
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(89, 35, 217, 0.3) var(--bg-darker);
}
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
    background-color: var(--bg-darker);
}

::-webkit-scrollbar-track {
    background: var(--bg-darker);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: rgba(89, 35, 217, 0.3);
    border-radius: 4px;
    border: 2px solid var(--bg-darker);
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(89, 35, 217, 0.5);
}

::-webkit-scrollbar-corner {
    background: var(--bg-darker);
}
.chat-log {
    background: var(--bg-playground);
    color: var(--text-light);
    padding: 0.5rem;
    border-radius: 4px;
    margin: 0.5rem 0;
    font-family: monospace;
    white-space: pre-wrap;
    word-break: break-all;
}
.system-message {
    background: var(--bg-darker);
    color: var(--text-muted);
    padding: 0.5rem;
    border-radius: 4px;
    margin: 0.5rem auto;
    font-size: 0.9rem;
    max-width: 90%;
    text-align: center;
    border: 1px solid rgba(89, 35, 217, 0.1);
}
h1, h2, h3, h4, h5, h6 {
    color: var(--text-light);
}
.filter-btn, .export-btn {
    background: var(--bg-light);
    color: var(--text-light);
    border: 1px solid rgba(89, 35, 217, 0.2);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-btn:hover, .export-btn:hover {
    background: var(--bg-darker);
    border-color: var(--accent);
}
.content-container {
    background: var(--bg-playground);
    border-radius: 12px;
    width: 100%;
    height: 100%;
    overflow: hidden;
    padding: 0;
    margin: 0;
}
.chat-header,
.chat-footer,
.input-container,
.sources-header,
.sources-content,
.file-item,
.upload-area {
    background-color: var(--bg-playground);
}
input,
textarea,
select,
button {
    background-color: var(--bg-light);
    color: var(--text-light);
    border: 1px solid rgba(89, 35, 217, 0.2);
}
ul, li {
    background-color: transparent;
}
.modal,
.overlay,
.dropdown-menu {
    background-color: var(--bg-playground);
    color: var(--text-light);
}
* {
    background-color: transparent;
}

html, body {
    background-color: var(--bg-playground);
}
body > *,
.app-container > *,
.content-container > *,
.main-content > * {
    background-color: var(--bg-playground);
}
.app-container,
.app-container > div,
.app-container > section {
    background-color: var(--bg-playground) !important;
}
.card,
.panel,
.sidebar,
.header,
.footer,
.content,
.wrapper,
article,
section,
aside {
    background-color: var(--bg-playground) !important;
}
::-webkit-scrollbar,
::-webkit-scrollbar-track {
    background-color: var(--bg-playground);
}

input[type="text"],
input[type="search"],
input[type="email"],
input[type="password"],
textarea {
    background-color: var(--bg-light);
    color: var(--text-light);
    border: 1px solid rgba(89, 35, 217, 0.2);
}
[class*="background"],
[class*="bg-"],
[style*="background"] {
    background-color: var(--bg-playground) !important;
}

.chatlog-reader,
.chatlog-list {
    background-color: var(--bg-playground);
    color: var(--text-light);
    border-radius: 12px;
    width: 100%;
    height: 100%;
    overflow: auto;
    padding: 1rem;
}

.chatlog-item {
    background-color: var(--bg-light);
    border: 1px solid rgba(89, 35, 217, 0.2);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    color: var(--text-light);
}

.chatlog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid rgba(89, 35, 217, 0.2);
}

.chatlog-title {
    font-size: 1.5rem;
    color: var(--text-light);
    margin: 0;
    padding: 1rem;
    border-bottom: 1px solid rgba(89, 35, 217, 0.2);
}

.chatlog-actions {
    display: flex;
    gap: 0.5rem;
}

.chatlog-container {
    background-color: var(--bg-playground);
    border-radius: 12px;
    overflow: hidden;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.chatlog-content {
    background-color: var(--bg-playground);
    flex: 1;
    overflow: auto;
    padding: 1rem;
}

.chatlog-message {
    background-color: var(--bg-light);
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    border: 1px solid rgba(89, 35, 217, 0.2);
}

.chatlog-message.user {
    background: linear-gradient(135deg, var(--accent-dark), var(--accent));
    color: var(--text-light);
}

.chatlog-message.system {
    background-color: var(--bg-darker);
    border: 1px solid rgba(89, 35, 217, 0.1);
    color: var(--text-muted);
}

.chatlog-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-style: italic;
}

.chatlog-filters {
    background-color: var(--bg-playground);
    padding: 1rem;
    border-bottom: 1px solid rgba(89, 35, 217, 0.2);
    display: flex;
    gap: 1rem;
    align-items: center;
}

.filter-input {
    background-color: var(--bg-light);
    border: 1px solid rgba(89, 35, 217, 0.2);
    color: var(--text-light);
    padding: 0.5rem;
    border-radius: 6px;
    flex: 1;
}

.filter-input::placeholder {
    color: var(--text-muted);
}

.filter-button {
    background-color: var(--bg-light);
    border: 1px solid rgba(89, 35, 217, 0.2);
    color: var(--text-light);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-button:hover {
    background-color: var(--bg-darker);
    border-color: var(--accent);
}

.export-button {
    background-color: var(--accent);
    color: var(--text-light);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.export-button:hover {
    background-color: var(--accent-dark);
}