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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: #f7f7f8;
    color: #353740;
    height: 100vh;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

/* Login Page Styles */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-box {
    background: #ffffff;
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header h1 {
    font-size: 32px;
    font-weight: 700;
    color: #202123;
    margin-bottom: 8px;
}

.login-subtitle {
    font-size: 16px;
    color: #6e6e80;
    margin-bottom: 4px;
    font-weight: 500;
}

.login-by {
    font-size: 12px;
    color: #8e8ea0;
    margin-top: 4px;
}

.login-form {
    display: flex;
    flex-direction: column;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #202123;
    margin-bottom: 8px;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #e5e5e6;
    border-radius: 8px;
    font-size: 14px;
    color: #202123;
    background: #ffffff;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.login-error {
    background: #fee2e2;
    color: #991b1b;
    padding: 12px;
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 16px;
    text-align: center;
}

.login-button {
    width: 100%;
    padding: 14px;
    background: #667eea;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.login-button:hover {
    background: #5568d3;
}

.login-button:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

.logout-button {
    padding: 8px 16px;
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.logout-button:hover {
    background: #e5e7eb;
    border-color: #d1d5db;
}

.container {
    display: flex;
    height: 100vh;
    width: 100%;
}

/* Main Content */
.main-content {
    width: 100%;
    display: flex;
    flex-direction: column;
    background: #ffffff;
}

.chat-header {
    padding: 16px 24px;
    border-bottom: 1px solid #e5e5e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #6e6e80;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10a37f;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.status-indicator.processing .status-dot {
    background: #f59e0b;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.welcome-message {
    max-width: 800px;
    margin: 0 auto;
    text-align: center;
    padding: 40px 20px;
}

.welcome-message h3 {
    font-size: 24px;
    margin-bottom: 16px;
    color: #202123;
}

.welcome-message p {
    font-size: 15px;
    color: #6e6e80;
    margin-bottom: 12px;
}

.welcome-message ul {
    list-style: none;
    text-align: left;
    max-width: 400px;
    margin: 20px auto;
}

.welcome-message li {
    padding: 8px 0;
    color: #6e6e80;
}

.example-queries {
    margin-top: 24px;
    font-style: italic;
    color: #8e8ea0;
}

.message {
    max-width: 800px;
    margin: 0 auto;
    padding: 16px;
    border-radius: 8px;
}

.message.user {
    background: #f7f7f8;
    margin-left: auto;
    margin-right: 0;
}

.message.assistant {
    background: #ffffff;
    border: 1px solid #e5e5e6;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-weight: 600;
    font-size: 14px;
}

.message-content {
    line-height: 1.6;
    font-size: 15px;
    color: #353740;
    white-space: pre-wrap;
}

.message-content code {
    background: #f4f4f5;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
}

/* Phases/Sources */
.phases-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e5e5e6;
}

.phase-item {
    margin-bottom: 12px;
    padding: 12px;
    background: #f9f9fa;
    border-radius: 6px;
    font-size: 13px;
}

.phase-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.phase-header:hover {
    opacity: 0.8;
}

.phase-header h4 {
    font-size: 13px;
    font-weight: 600;
    margin: 0;
    color: #202123;
    flex: 1;
}

.phase-toggle {
    font-size: 12px;
    color: #6e6e80;
    margin-left: 12px;
}

.phase-content {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e5e5e6;
    display: none;
}

.phase-content.expanded {
    display: block;
}

.phase-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 8px;
}

.phase-status.completed {
    background: #d1fae5;
    color: #065f46;
}

.phase-status.failed {
    background: #fee2e2;
    color: #991b1b;
}

.phase-status.not_implemented {
    background: #fef3c7;
    color: #92400e;
}

.phase-time {
    color: #6e6e80;
    font-size: 12px;
    margin-top: 8px;
}

.phase-details {
    margin-top: 12px;
}

.detail-section {
    margin-bottom: 12px;
    padding: 10px;
    background: #ffffff;
    border-radius: 6px;
    border: 1px solid #e5e5e6;
}

.detail-section h5 {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #202123;
}

.detail-item {
    font-size: 12px;
    padding: 4px 0;
    color: #6e6e80;
}

.detail-item strong {
    color: #202123;
}

/* Entities List */
.entities-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.entity-tag {
    display: inline-block;
    padding: 4px 10px;
    background: #e0e7ff;
    color: #3730a3;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

.entity-tag .entity-label {
    font-weight: 600;
    margin-right: 4px;
}

/* BIOES Tags */
.bioes-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
}

.bioes-tag {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-family: 'Courier New', monospace;
    font-weight: 500;
}

.bioes-tag.O {
    background: #f3f4f6;
    color: #374151;
}

.bioes-tag.B {
    background: #dbeafe;
    color: #1e40af;
}

.bioes-tag.I {
    background: #dbeafe;
    color: #1e40af;
}

.bioes-tag.E {
    background: #dbeafe;
    color: #1e40af;
}

.bioes-tag.S {
    background: #dbeafe;
    color: #1e40af;
}

/* Tokens */
.tokens-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
    font-family: 'Courier New', monospace;
    font-size: 11px;
}

.token-item {
    padding: 2px 6px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    color: #374151;
}

.sources-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e5e5e6;
}

.sources-section h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    color: #202123;
}

.source-item {
    padding: 8px 12px;
    background: #f9f9fa;
    border-radius: 6px;
    margin-bottom: 8px;
    font-size: 13px;
    color: #6e6e80;
}

.document-item {
    padding: 12px;
    background: #ffffff;
    border: 1px solid #e5e5e6;
    border-radius: 6px;
    margin-bottom: 10px;
}

.document-item-header {
    font-weight: 600;
    color: #202123;
    margin-bottom: 8px;
    font-size: 13px;
}

.document-item-detail {
    font-size: 12px;
    color: #6e6e80;
    margin-bottom: 4px;
}

.document-item-detail strong {
    color: #202123;
}

.document-citation {
    font-size: 11px;
    color: #10a37f;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid #e5e5e6;
}

.timing-info {
    margin-top: 12px;
    padding: 12px;
    background: #f0f9ff;
    border-radius: 6px;
    font-size: 12px;
    color: #0369a1;
}

.timing-info strong {
    color: #0c4a6e;
}

/* Loading */
.loading {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #6e6e80;
    font-size: 14px;
}

.loading-dots {
    display: flex;
    gap: 4px;
}

.loading-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #8e8ea0;
    animation: bounce 1.4s infinite;
}

.loading-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-8px); }
}

/* Chat Input */
.chat-input-container {
    padding: 16px 24px;
    border-top: 1px solid #e5e5e6;
    background: #ffffff;
}

.chat-form {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

#query-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    font-size: 15px;
    font-family: inherit;
    resize: none;
    max-height: 200px;
    outline: none;
    transition: border-color 0.2s;
}

#query-input:focus {
    border-color: #10a37f;
}

.send-button {
    width: 40px;
    height: 40px;
    border: none;
    background: #10a37f;
    color: white;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.send-button:hover:not(:disabled) {
    background: #0d8f6e;
}

.send-button:disabled {
    background: #d1d5db;
    cursor: not-allowed;
}

/* Scrollbar */
.chat-messages::-webkit-scrollbar,
.sidebar-content::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track,
.sidebar-content::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chat-messages::-webkit-scrollbar-thumb,
.sidebar-content::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover,
.sidebar-content::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}
