/* General styles */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    padding: 15px;
    background-color: #19232D;
    color: #abb2bf;
    font-size: 16px;
}

/* Chat history container */
#history {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

/* Individual message blocks */
.message {
    max-width: 90%;
    word-wrap: break-word;
}

/* Message Header */
.message-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    font-size: 14px;
}

.icon {
    width: 32px;
    height: 32px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.role {
    font-weight: 600;
}

.timestamp {
    color: #6c757d;
    font-size: 12px;
}

/* User message */
.user {
    padding: 15px;
    background-color: #262E38;
    border-radius: 8px;
}

.user .icon {
    background-color: #2563eb;
}

/* User message copy button */
.copy-user-button {
    margin-left: auto;
    padding: 2px 6px;
    border: 1px solid transparent;
    background-color: transparent;
    color: #6c757d;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    opacity: 0;
    transition: opacity 0.2s, background-color 0.2s, color 0.2s, border-color 0.2s;
}

.user:hover .copy-user-button {
    opacity: 0.7;
}

.copy-user-button:hover {
    opacity: 1 !important;
    background-color: #3d4450;
    color: #abb2bf;
    border-color: #4b5563;
}

.copy-user-button.copied {
    opacity: 1 !important;
    color: #4ade80;
    border-color: #4ade80;
}

.copy-user-button.copy-error {
    opacity: 1 !important;
    color: #f87171;
    border-color: #f87171;
}

/* Assistant message */
.assistant {
    padding: 15px;
    background-color: #262E38;
    border-radius: 8px;
}

.assistant .icon {
    background-color: #5865f2;
}

/* Code blocks */
pre {
    position: relative;
    padding: 3.2em 1em 1em 1em;
    margin: 1em 0;
    overflow: auto;
    font-size: 85%;
    line-height: 1.45;
    background-color: #23241f; /* Monokai Background */
    border-radius: 6px;
}

/* Code block header bar */
.code-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    background-color: rgba(255, 255, 255, 0.04);
    border-bottom: 1px solid #3d4450;
    border-radius: 6px 6px 0 0;
    font-size: 12px;
    user-select: none;
}

.code-lang {
    color: #6b7280;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    user-select: none;
}

/* Code block copy button */
.copy-button {
    padding: 2px 10px;
    border: 1px solid #4b5563;
    background-color: transparent;
    color: #9ca3af;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    min-width: 64px;
    text-align: center;
    opacity: 0.7;
    transition: opacity 0.2s, background-color 0.2s, color 0.2s, border-color 0.2s;
}

pre:hover .copy-button {
    opacity: 1;
}

.copy-button:hover {
    background-color: #3d4450;
    color: #e5e7eb;
}

.copy-button.copied {
    color: #4ade80;
    border-color: #4ade80;
    opacity: 1;
}

.copy-button.copy-error {
    color: #f87171;
    border-color: #f87171;
    opacity: 1;
}

code {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

/* Tables */
table {
    border-collapse: collapse;
    width: 100%;
    margin: 1em 0;
    font-size: 0.9em;
}

th, td {
    border: 1px solid #4b5563;
    padding: 8px 15px;
}

th {
    font-weight: 600;
    background-color: #323840;
}

tr:nth-child(2n) {
    background-color: #2c3138;
}

/* Thinking container */
.thinking-container {
    margin-bottom: 15px;
    border: 1px solid #3d4450;
    border-radius: 8px;
    background-color: #1e2530;
    overflow: hidden;
}

.thinking-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    background-color: #252d38;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s;
}

.thinking-header:hover {
    background-color: #2a3340;
}

.thinking-icon {
    font-size: 16px;
}

.thinking-label {
    font-size: 13px;
    font-weight: 600;
    color: #9ca3af;
}

.thinking-toggle {
    margin-left: auto;
    font-size: 10px;
    color: #6b7280;
    transition: transform 0.2s;
}

.thinking-content {
    padding: 15px;
    font-size: 14px;
    color: #9ca3af;
    line-height: 1.6;
    border-top: 1px solid #3d4450;
}

.thinking-container.collapsed .thinking-content {
    display: none;
}

.thinking-content p {
    margin: 0 0 10px 0;
}

.thinking-content p:last-child {
    margin-bottom: 0;
}

/* Message footer */
.message-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid #3d4450;
}

/* Copy all button */
.copy-all-button {
    padding: 4px 10px;
    border: 1px solid #4b5563;
    background-color: transparent;
    color: #9ca3af;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    min-width: 64px;
    text-align: center;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.copy-all-button:hover:not(:disabled) {
    background-color: #3d4450;
    color: #abb2bf;
}

.copy-all-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.copy-all-button.copied {
    color: #4ade80;
    border-color: #4ade80;
}

.copy-all-button.copy-error {
    color: #f87171;
    border-color: #f87171;
}

/* Token usage display */
.token-usage {
    color: #6c757d;
    font-size: 12px;
    margin-right: auto;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}
