:root {
    --primary-color: #0a3161;  /* Lords of Lending dark blue */
    --secondary-color: #d4af37;  /* Lords of Lending gold */
    --primary-light: #e8f0fe;
    --bg-color: #000000;
    --text-color: #ffffff;
    --border-color: #2a2a2a;
    --user-message-bg: #0a3161;
    --assistant-message-bg: #2a2a2a;
    --shadow-color: rgba(0, 0, 0, 0.25);
    --citation-color: #888888;
    --gold-accent: #d4af37;  /* Gold accent color */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: #000000;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.chat-interface {
    width: 90%;
    max-width: 1200px;
    height: 80vh;
    display: flex;
    background-color: #121212; /* Dark background for chat area */
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    position: relative;
    border: 1px solid #2a2a2a;
    margin: 40px auto;
}

.chat-history-panel {
    width: 280px;
    height: 100%;
    background-color: #1a1a1a;
    border-right: 1px solid #2a2a2a;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding: 0;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 10;
}

.chat-history-panel.open {
    transform: translateX(0);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid #2a2a2a;
    background-color: #1e1e1e;
    position: relative;
    color: white;
}

.history-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
    margin: 0;
}

.history-header {
    position: relative;
}

#history-close-button {
    background-color: #2c2c2c;
    border: 1px solid var(--secondary-color);
    color: var(--secondary-color);
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    position: absolute;
    right: 10px;
    top: 15px;
    transform: none;
    z-index: 100;
    width: 30px;
    height: 30px;
    opacity: 1;
    pointer-events: auto;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    top: 50%;           /* Center vertically */
    transform: translateY(-50%); /* Fine-tune vertical centering */
    z-index: 15;        /* Ensure it's above other elements */
    width: 30px;        /* Increased width */
    height: 30px;       /* Increased height */
    opacity: 1;         /* Make fully visible */
    pointer-events: auto; /* Ensure it's clickable */
    box-shadow: 0 1px 3px rgba(0,0,0,0.1); /* Add subtle shadow */
    background-color: red !important;
    color: white !important;
    opacity: 1 !important;
    z-index: 9999 !important;
    border: 2px solid yellow !important;
}

#history-close-button:hover {
    background-color: #d4af37 !important;
    background: #d4af37 !important;
    color: black !important;
    transform: scale(1.05) !important;
}

#history-close-button svg {
    width: 16px !important;
    height: 16px !important;
    display: block !important;
    fill: #d4af37 !important;
    color: #d4af37 !important;
}

#history-close-button:hover svg {
    fill: black !important;
    color: black !important;
}

.history-list-container {
    padding: 16px 0;
    overflow-y: auto;
    flex-grow: 1;
}

.history-item {
    padding: 12px 16px;
    border-bottom: 1px solid #2a2a2a;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    padding-right: 32px;
    color: #dddddd;
}

.history-item:hover {
    background-color: #2a2a2a;
    border-left: 2px solid var(--secondary-color);
}

.history-item.active {
    background-color: #333333;
    border-left: 3px solid var(--secondary-color);
    color: var(--secondary-color);
}

.history-title {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.history-date {
    font-size: 12px;
    color: #888888;
}

.history-delete {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #888888;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, background-color 0.2s;
}

.history-delete:hover {
    color: #ff6b6b;
    background-color: rgba(255, 107, 107, 0.1);
}

.history-empty {
    padding: 20px;
    text-align: center;
    color: #888888;
    font-style: italic;
}

.chat-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background-color: #121212;
    overflow: hidden;
    z-index: 1;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #2a2a2a;
    background-color: #1e1e1e; /* Dark charcoal color */
    color: white;
}

.chat-controls {
    display: flex;
    align-items: center;
}

.chat-controls button {
    background-color: #2c2c2c;
    border: 1px solid var(--secondary-color);
    color: var(--secondary-color);
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-controls button:hover {
    background-color: var(--secondary-color);
    color: black;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-container {
    height: 40px;
    width: 40px;
    background-color: black;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--secondary-color);
    padding: 0;
    overflow: hidden;
}

.logo img {
    height: 30px;
    width: 30px;
    filter: brightness(0) invert(1); /* Make logo white */
    object-fit: contain;
    background: transparent;
}

.logo h1 {
    font-size: 20px;
    font-weight: 700;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.messages {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background-color: #121212;
}

.message {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: fade-in 0.3s ease-in-out;
    margin-bottom: 8px;
}

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: #000000;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    border: 1px solid var(--secondary-color);
}

.user .avatar {
    background-color: #000000;
    color: white;
    border: 1px solid var(--secondary-color);
}

.avatar img {
    width: 20px;
    height: 20px;
    object-fit: contain;
    border-radius: 0;
    background-color: transparent;
    /* Remove filter that might be making logo white */
    filter: none !important;
}

.user .avatar svg {
    width: 14px;
    height: 14px;
    fill: white;
}

.content {
    padding: 14px 18px;
    border-radius: 8px;
    max-width: calc(100% - 44px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.assistant .content {
    background-color: #2a2a2a;
    border: 1px solid #3a3a3a;
    border-radius: 8px 8px 8px 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    color: #ffffff;
}

.user .content {
    background-color: #2c2c2c;
    color: white;
    border-radius: 8px 8px 0 8px;
    border: 1px solid var(--secondary-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.content p {
    margin-bottom: 8px;
}

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

.sources {
    margin-top: 12px;
    font-size: 13px;
    color: #aaaaaa;
    border-top: 1px solid #3a3a3a;
    padding-top: 8px;
}

.source-item {
    display: flex;
    align-items: baseline;
    margin-bottom: 4px;
}

.source-badge {
    background-color: var(--gold-accent);
    color: #333;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 4px;
    margin-right: 6px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.source-text {
    font-size: 12px;
    color: #aaaaaa;
}

.message-form {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 24px;
    border-top: 1px solid #2a2a2a;
    background-color: #1e1e1e;
    position: relative;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
}

#message-input {
    flex-grow: 1;
    padding: 14px 18px;
    border: 1px solid #2a2a2a;
    border-radius: 6px;
    resize: none;
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    max-height: 150px;
    overflow-y: auto;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    background-color: #2a2a2a;
    color: white;
}

#message-input::placeholder {
    color: #888888;
    opacity: 0.8;
}

#message-input:focus {
    outline: none;
    border-color: var(--secondary-color);
    background-color: #333333;
}

#send-button {
    background-color: var(--secondary-color);
    color: white;
    border: none;
    width: 46px;
    height: 46px;
    border-radius: 6px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

#send-button:hover {
    background-color: #b69121;
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
}

#send-button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.attribution {
    text-align: center;
    font-size: 12px;
    padding: 12px;
    border-top: 1px solid #2a2a2a;
    background-color: #1e1e1e; /* Dark charcoal color */
    color: rgba(255, 255, 255, 0.7);
}

.attribution-links {
    margin: 8px 0;
}

.attribution-links a {
    color: var(--gold-accent);
    text-decoration: none;
    transition: color 0.2s;
}

.attribution-links a:hover {
    color: white;
    text-decoration: underline;
}

.typing-indicator {
    display: inline-flex;
    align-items: center;
    margin-left: 4px;
}

.typing-indicator span {
    height: 4px;
    width: 4px;
    margin: 0 1px;
    background-color: var(--citation-color);
    border-radius: 50%;
    display: inline-block;
    animation: bounce 1.2s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

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

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

/* Custom Scrollbar Styling for Dark Theme */
/* For WebKit browsers (Chrome, Safari) */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #1a1a1a;
}

::-webkit-scrollbar-thumb {
    background: #444444;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555555;
}

/* For Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: #444444 #1a1a1a;
}

/* Make textarea auto-resize */
#message-input {
    overflow: hidden;
    resize: none;
}

/* Responsive styles */
@media (max-width: 768px) {
    .chat-interface {
        max-width: 100%;
        height: 100%;
        max-height: none;
        border-radius: 0;
    }
    
    .chat-container {
        height: 100%;
    }
    
    .message {
        max-width: 100%;
    }
    
    .chat-history-panel {
        width: 80%;
        max-width: 320px;
        z-index: 100;
        box-shadow: 3px 0 10px rgba(0, 0, 0, 0.1);
    }
    
    .chat-history-panel.open {
        transform: translateX(0);
    }
}

/* Embed mode */
.embed-mode {
    border-radius: 0;
    max-height: none;
    height: 100%;
}

.embed-mode .chat-header,
.embed-mode .chat-history-panel,
.embed-mode #chat-history-button {
    display: none;
}

.embed-mode .attribution {
    display: none;
}
