/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Header */
.header {
    background: white;
    padding: 1rem 2rem;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.header-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.chat-selector {
    padding: 0.5rem 1rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.9rem;
    min-width: 200px;
}

.refresh-btn, .logout-btn {
    padding: 0.5rem 1rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    font-size: 0.9rem;
}

.refresh-btn:hover, .logout-btn:hover {
    background: #f0f0f0;
}

/* Main Content */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    overflow-y: auto;
    padding: 2rem;
}

.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #999;
    font-size: 1.1rem;
}

.messages-container {
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

/* Messages */
.message {
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
}

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

.message.assistant {
    align-items: flex-start;
}

.message-bubble {
    max-width: 70%;
    padding: 1rem 1.25rem;
    border-radius: 16px;
    position: relative;
    word-wrap: break-word;
}

.message.user .message-bubble {
    background: #007AFF;
    color: white;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-bubble {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
    cursor: pointer;
    padding: 2px; /* Border width */
    background: linear-gradient(
        135deg,
        #ffffff 0%,
        #ff0000 33%,
        #0000ff 66%,
        #ffffff 100%
    );
}

.message.assistant .message-bubble-content {
    background: white;
    border-radius: 14px; /* 16px - 2px border */
    padding: 12px 16px;
}

.message-timestamp {
    font-size: 0.75rem;
    color: #999;
    margin-top: 0.5rem;
    padding: 0 0.5rem;
}

.message.user .message-timestamp {
    text-align: right;
}

.message.assistant .message-timestamp {
    text-align: left;
}

/* Sidepane */
.sidepane {
    width: 30%;
    background: #f9f9f9;
    border-left: 1px solid #e0e0e0;
    overflow-y: auto;
    flex-shrink: 0;
}

.sidepane-content {
    padding: 1.5rem;
}

.feedback-section, .details-section {
    margin-bottom: 2rem;
}

.feedback-section h3, .details-section h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: #333;
}

.empty-message {
    color: #999;
    font-size: 0.9rem;
    font-style: italic;
}

/* Feedback Items */
.feedback-item {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    border: 1px solid #e0e0e0;
    cursor: pointer;
}

.feedback-item:hover {
    background: #f5f5f5;
}

.feedback-rating {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #007AFF;
}

.feedback-comment {
    margin-bottom: 0.5rem;
    color: #666;
}

.feedback-timestamp {
    font-size: 0.75rem;
    color: #999;
}

/* Message Details */
.details-section {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    position: relative;
}

.close-details-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    padding: 0.5rem 1rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    font-size: 0.9rem;
}

.detail-item {
    margin-bottom: 1.5rem;
}

.detail-item h4 {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-item-content {
    background: #f9f9f9;
    padding: 1rem;
    border-radius: 4px;
    font-size: 0.9rem;
}

.candidate-list {
    list-style: none;
}

.candidate-item {
    background: white;
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    border: 1px solid #e0e0e0;
}

.candidate-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.candidate-file {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 0.25rem;
}

.candidate-score {
    font-size: 0.85rem;
    color: #007AFF;
    margin-bottom: 0.5rem;
}

.candidate-trigger {
    font-size: 0.85rem;
    color: #999;
    font-style: italic;
}

.system-prompt-container {
    margin-top: 1rem;
}

.system-prompt-toggle {
    padding: 0.5rem 1rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.system-prompt-content {
    display: none;
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 1rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    max-height: 400px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.system-prompt-content.show {
    display: block;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    color: white;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Error Banner */
.error-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #ff4444;
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1001;
}

.error-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 0.5rem;
}

/* Login Modal */
.login-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.login-content {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    width: 100%;
    max-width: 400px;
}

.login-content h2 {
    margin-bottom: 1.5rem;
}

.login-content form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.login-content input {
    padding: 0.75rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1rem;
}

.password-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-input-wrapper input {
    flex: 1;
    padding-right: 3rem;
}

.password-toggle {
    position: absolute;
    right: 0.5rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0.25rem 0.5rem;
    color: #666;
}

.password-toggle:hover {
    color: #333;
}

.login-content button {
    padding: 0.75rem;
    background: #007AFF;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
}

.login-content button:hover {
    background: #0056b3;
}

.login-error {
    margin-top: 1rem;
    padding: 0.75rem;
    background: #ffebee;
    color: #c62828;
    border-radius: 4px;
    font-size: 0.9rem;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }

    .sidepane {
        width: 100%;
        max-height: 50vh;
    }

    .header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }

    .header-controls {
        flex-direction: column;
    }

    .message-bubble {
        max-width: 85%;
    }
}

.messages-array-container {
    margin-top: 1rem;
}

.messages-array-info {
    font-size: 0.875rem;
    color: #666;
    margin-bottom: 0.5rem;
}

.messages-array-json {
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 1rem;
    overflow-x: auto;
    font-size: 0.875rem;
    line-height: 1.5;
    max-height: 400px;
    overflow-y: auto;
}

