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

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

.chat-container {
    display: flex;
    height: 100vh;
}

/* Sidebar Styles */
.sidebar {
    width: 280px;
    background: #202123;
    border-right: 1px solid #444654;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.sidebar.collapsed {
    transform: translateX(-280px);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #444654;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.toggle-sidebar-btn {
    background: transparent;
    border: none;
    color: #8e8ea0;
    font-size: 24px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.toggle-sidebar-btn:hover {
    background: #343541;
    color: #ececf1;
}

.sidebar.collapsed .toggle-sidebar-btn {
    transform: rotate(180deg);
}

.new-session-btn {
    margin: 16px;
    padding: 12px 16px;
    background: #343541;
    border: 1px solid #565869;
    color: #ececf1;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.new-session-btn:hover {
    background: #444654;
    border-color: #8e8ea0;
}

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

.sessions-list::-webkit-scrollbar {
    width: 6px;
}

.sessions-list::-webkit-scrollbar-track {
    background: #202123;
}

.sessions-list::-webkit-scrollbar-thumb {
    background: #444654;
    border-radius: 3px;
}

.session-item {
    padding: 12px;
    margin-bottom: 8px;
    background: #343541;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.session-item:hover {
    background: #444654;
    border-color: #565869;
}

.session-item.active {
    background: #444654;
    border-color: #667eea;
}

.session-title {
    font-size: 14px;
    color: #ececf1;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.session-date {
    font-size: 11px;
    color: #8e8ea0;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chat-header {
    padding: 20px;
    background: #202123;
    border-bottom: 1px solid #444654;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.mobile-toggle-btn {
    display: none;
    background: transparent;
    border: none;
    color: #8e8ea0;
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
}

.mobile-toggle-btn:hover {
    background: #343541;
    color: #ececf1;
}

.chat-header h1 {
    font-size: 20px;
    font-weight: 600;
}

.session-info {
    font-size: 12px;
    color: #8e8ea0;
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

#username-display {
    font-size: 13px;
    color: #ececf1;
    font-weight: 500;
    margin-bottom: 4px;
}

#session-id-display {
    display: block;
}

.logout-btn {
    margin-top: 4px;
    padding: 6px 12px;
    background: transparent;
    border: 1px solid #565869;
    color: #ececf1;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.logout-btn:hover {
    background: #444654;
    border-color: #d87070;
    color: #ff6b6b;
}

.logout-btn svg {
    flex-shrink: 0;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        z-index: 999;
        height: 100vh;
    }
    
    .sidebar.collapsed {
        transform: translateX(-100%);
    }
    
    .mobile-toggle-btn {
        display: block;
    }
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #343541;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #565869;
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #666;
}

.welcome-message {
    text-align: center;
    padding: 40px 20px;
    color: #8e8ea0;
}

.message {
    display: flex;
    gap: 16px;
    padding: 20px;
    border-radius: 8px;
}

.message.user {
    background: #444654;
    margin-left: auto;
    max-width: 80%;
}

.message.assistant {
    background: #343541;
    max-width: 100%;
}

.message-avatar {
    width: 30px;
    height: 30px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: #5436da;
}

.message.assistant .message-avatar {
    background: #19c37d;
}

.message-content {
    flex: 1;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.message-content p {
    margin-bottom: 10px;
}

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

.typing-indicator {
    display: inline-flex;
    gap: 4px;
    padding: 10px 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #8e8ea0;
    animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
    0%, 60%, 100% {
        opacity: 0.3;
        transform: translateY(0);
    }
    30% {
        opacity: 1;
        transform: translateY(-10px);
    }
}

.chat-input-container {
    padding: 20px;
    background: #343541;
    border-top: 1px solid #444654;
}

.input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    max-width: 900px;
    margin: 0 auto;
    background: #40414f;
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
}

#user-input {
    flex: 1;
    background: transparent;
    border: none;
    color: #ececf1;
    font-size: 16px;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 200px;
    min-height: 24px;
    line-height: 24px;
}

#user-input::placeholder {
    color: #8e8ea0;
}

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

.send-button:hover:not(:disabled) {
    background: #1a9f6a;
}

.send-button:disabled {
    background: #565869;
    cursor: not-allowed;
    opacity: 0.5;
}

.error-message {
    background: #f44336;
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    margin: 10px 0;
    font-size: 14px;
}

.cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: #ececf1;
    margin-left: 2px;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 50% {
        opacity: 1;
    }
    51%, 100% {
        opacity: 0;
    }
}

.thinking-section {
    background: #2a2b32;
    border: 1px solid #444654;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 16px;
    font-size: 14px;
}

.thinking-section summary {
    cursor: pointer;
    user-select: none;
    font-weight: 500;
    color: #b4b4c8;
    padding: 4px 0;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.thinking-section summary::-webkit-details-marker {
    display: none;
}

.thinking-section summary::before {
    content: '▶';
    display: inline-block;
    font-size: 10px;
    transition: transform 0.2s;
    color: #8e8ea0;
}

.thinking-section[open] summary::before {
    transform: rotate(90deg);
}

.thinking-section summary:hover {
    color: #ececf1;
}

.thinking-content {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #444654;
}

.thinking-step {
    padding: 8px 0;
    color: #b4b4c8;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    animation: fadeIn 0.3s ease-in;
}

.thinking-step .step-icon {
    flex-shrink: 0;
    font-size: 14px;
    opacity: 0.7;
}

/* Messages panel styles */
.messages-panel {
    background: #2a2b32;
    border: 1px solid #444654;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 16px;
    font-size: 14px;
}

.messages-panel summary {
    cursor: pointer;
    user-select: none;
    font-weight: 500;
    color: #b4b4c8;
    padding: 4px 0;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.loading-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid #444654;
    border-top: 2px solid #19c37d;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.messages-panel summary::-webkit-details-marker {
    display: none;
}

.messages-panel summary::before {
    content: '▶';
    display: inline-block;
    font-size: 10px;
    transition: transform 0.2s;
    color: #8e8ea0;
}

.messages-panel[open] summary::before {
    transform: rotate(90deg);
}

.messages-panel summary:hover {
    color: #ececf1;
}

.messages-content {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #444654;
    max-height: 300px;
    overflow-y: auto;
    pointer-events: auto;
}

.messages-content::-webkit-scrollbar {
    width: 6px;
}

.messages-content::-webkit-scrollbar-track {
    background: #2a2b32;
}

.messages-content::-webkit-scrollbar-thumb {
    background: #565869;
    border-radius: 3px;
}

.message-item {
    padding: 12px;
    color: #ececf1;
    background: #3a3b44;
    border-radius: 6px;
    margin-bottom: 6px;
    animation: fadeIn 0.3s ease-in;
    line-height: 1.5;
    font-size: 13px;
    font-family: 'Consolas', 'Monaco', monospace;
    transition: all 0.2s ease;
    user-select: text;
    pointer-events: auto;
}

.message-item.expanded {
    white-space: pre-wrap;
}

.message-item:last-child {
    margin-bottom: 0;
}

.message-text {
    font-weight: 600;
    margin-bottom: 8px;
    color: #ececf1;
}

.message-values {
    margin-top: 8px;
    padding-left: 12px;
}

.value-item {
    color: #b4b4c8;
    padding: 2px 0;
    font-size: 12px;
}

.debug-section {
    margin-top: 12px;
    border-top: 1px solid #444654;
    padding-top: 8px;
}

.debug-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: #444654;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    color: #19c37d;
    font-weight: 600;
    user-select: none;
    transition: background 0.2s;
}

.debug-toggle:hover {
    background: #565869;
}

.debug-content {
    margin-top: 8px;
    padding: 10px;
    background: #2a2b32;
    border: 1px solid #444654;
    border-radius: 4px;
    overflow-x: auto;
    font-size: 11px;
    line-height: 1.4;
    color: #e5c07b;
    max-height: 300px;
    overflow-y: auto;
}

.debug-content::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.debug-content::-webkit-scrollbar-track {
    background: #2a2b32;
}

.debug-content::-webkit-scrollbar-thumb {
    background: #565869;
    border-radius: 3px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-content {
    line-height: 1.6;
    color: #ececf1;
}

/* Markdown styling for result content */
.result-content h1,
.result-content h2,
.result-content h3,
.result-content h4,
.result-content h5,
.result-content h6 {
    margin-top: 1em;
    margin-bottom: 0.5em;
    font-weight: 600;
    line-height: 1.3;
}

.result-content h1 { font-size: 1.8em; }
.result-content h2 { font-size: 1.5em; }
.result-content h3 { font-size: 1.3em; }

.result-content p {
    margin-bottom: 1em;
}

.result-content ul,
.result-content ol {
    margin: 0.5em 0 1em 1.5em;
    padding-left: 0.5em;
}

.result-content li {
    margin-bottom: 0.5em;
}

.result-content code {
    background: #2a2b32;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
    color: #e06c75;
}

.result-content pre {
    background: #2a2b32;
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 1em 0;
    border: 1px solid #444654;
}

.result-content pre code {
    background: transparent;
    padding: 0;
    color: #ececf1;
}

.result-content blockquote {
    border-left: 3px solid #19c37d;
    padding-left: 1em;
    margin: 1em 0;
    color: #b4b4c8;
    font-style: italic;
}

.result-content a {
    color: #19c37d;
    text-decoration: none;
}

.result-content a:hover {
    text-decoration: underline;
}

.result-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 1em 0;
}

.result-content table th,
.result-content table td {
    border: 1px solid #444654;
    padding: 8px 12px;
    text-align: left;
}

.result-content table th {
    background: #2a2b32;
    font-weight: 600;
}

.result-content hr {
    border: none;
    border-top: 1px solid #444654;
    margin: 1.5em 0;
}

/* Login Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: #202123;
    border-radius: 12px;
    padding: 0;
    max-width: 450px;
    width: 90%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    border: 1px solid #444654;
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: 24px;
    border-bottom: 1px solid #444654;
}

.modal-header h2 {
    font-size: 24px;
    font-weight: 600;
    color: #ececf1;
    margin: 0;
}

.modal-body {
    padding: 24px;
    color: #c5c5d2;
    font-size: 16px;
    line-height: 1.6;
}

.modal-footer {
    padding: 24px;
    border-top: 1px solid #444654;
    display: flex;
    justify-content: center;
}

.login-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 14px 32px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.login-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.6);
}

.login-button:active {
    transform: translateY(0);
}
