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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #0a0a0a;
    color: #ffffff;
    height: 100vh;
    overflow: hidden;
}

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

/* Sidebar Styles */
.sidebar {
    width: 280px;
    background: #111111;
    border-right: 1px solid #2a2a2a;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #2a2a2a;
}

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

.orbit-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    position: relative;
}

.orbit-icon::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    border: 2px solid white;
    border-radius: 50%;
    border-top: 2px solid transparent;
}

.logo span {
    font-size: 18px;
    font-weight: 600;
    color: #ffffff;
}

.new-chat-btn {
    width: 100%;
    padding: 12px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.new-chat-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.plus-icon {
    font-size: 18px;
    font-weight: 300;
}

.chat-list {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.chat-item {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    border-radius: 8px;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    position: relative;
}

.chat-item:hover {
    background: #1a1a1a;
    border-color: #333;
}

.chat-item.active {
    background: #1a1a1a;
    border-color: #667eea;
}

.chat-item-content {
    flex: 1;
    padding: 12px 16px;
    cursor: pointer;
    min-width: 0; /* Allow text truncation */
}

.chat-item-title {
    font-weight: 500;
    margin-bottom: 4px;
    color: #ffffff;
}

.chat-item-preview {
    font-size: 12px;
    color: #888;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 20px;

    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-top: auto;
}

.totogi-logo {
    height: 32px;
    width: auto;
    max-width: 120px;
    opacity: 0.8;
    transition: opacity 0.3s ease, transform 0.2s ease;
    object-fit: contain;
    object-position: center;
    border-radius: 4px;
    background: transparent;
}

.totogi-logo:hover {
    opacity: 1;
    transform: scale(1.05);
}

.totogi-logo[src*=".svg"] {
    filter: brightness(1.1);
}

.totogi-logo:not(:last-child) {
    margin-bottom: 8px;
}

/* Handle different logo aspect ratios */
.totogi-logo[style*="aspect-ratio"] {
    height: auto;
    width: 100%;
    max-width: 120px;
}

/* Loading state for logos */
.totogi-logo[src=""] {
    opacity: 0.3;
    background: linear-gradient(90deg, #333 25%, #444 50%, #333 75%);
    background-size: 200% 100%;
    animation: logoLoading 1.5s infinite;
}

@keyframes logoLoading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Error state for failed logos */
.totogi-logo.error {
    opacity: 0.5;
    filter: grayscale(100%);
}

/* Responsive logo sizing */
@media (max-width: 768px) {
    .totogi-logo {
        height: 28px;
        max-width: 100px;
    }
}

@media (max-width: 480px) {
    .totogi-logo {
        height: 24px;
        max-width: 80px;
    }
}

.powered-by {
    font-family: 'Poppins', sans-serif;
    font-size: 12px;
    font-weight: 400;
    color: #666;
    margin: 0;
    text-align: center;
}

.delete-chat-btn {
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: #666;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 8px;
    opacity: 0;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chat-item:hover .delete-chat-btn {
    opacity: 1;
}

.delete-chat-btn:hover {
    background: #ff4444;
    color: white;
    transform: scale(1.1);
}

.delete-chat-btn svg {
    width: 14px;
    height: 14px;
}

/* Main Chat Area */
.main-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #0a0a0a;
}

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

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

.view-selector select {
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 6px;
    color: #ffffff;
    padding: 8px 12px;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.2s ease;
}

.view-selector select:hover {
    border-color: #667eea;
}

.view-selector select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.view-selector select option {
    background: #1a1a1a;
    color: #ffffff;
    padding: 8px;
}

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

.welcome-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: #888;
}

.orbit-logo-large {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 16px;
    position: relative;
    margin-bottom: 24px;
}

.orbit-logo-large::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 32px;
    height: 32px;
    border: 3px solid white;
    border-radius: 50%;
    border-top: 3px solid transparent;
}

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

.message {
    display: flex;
    gap: 12px;
    max-width: 80%;
}

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

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
}

.user-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.bot-avatar {
    background: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.message-content {
    background: #1a1a1a;
    padding: 12px 16px;
    border-radius: 16px;
    border: 1px solid #2a2a2a;
    line-height: 1.5;
}

.message.user .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: transparent;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #666;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

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

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

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

/* Streaming cursor */
.cursor {
    color: #667eea;
    animation: blink 1s infinite;
    font-weight: bold;
}

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

/* Tool usage indicator */
.tool-usage {
    opacity: 0.8;
}

.tool-content {
    background: #2a2a2a !important;
    border: 1px solid #667eea;
    color: #667eea;
}

.tool-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.tool-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #333;
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Bottom tool usage indicator */
.tool-usage-bottom {
    padding: 12px 24px;
    border-top: 1px solid #2a2a2a;
    background: #111111;
    animation: slideUp 0.3s ease-out;
    position: relative;
    z-index: 100;
}

.tool-indicator-bottom {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: #667eea;
    background: #1a1a1a;
    border: 1px solid #667eea;
    border-radius: 8px;
    padding: 12px 16px;
}

.tool-emoji {
    font-size: 16px;
    flex-shrink: 0;
}

.tool-message {
    flex: 1;
    min-width: 0;
}

.tool-message strong {
    color: #ffffff;
    font-weight: 600;
}

.tool-message em {
    color: #ccc;
    font-style: italic;
}

.tool-message code {
    background: #2a2a2a;
    color: #667eea;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 12px;
}

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

/* Chat Input */
.chat-input-container {
    padding: 24px;
    border-top: 1px solid #2a2a2a;
}

.chat-input-wrapper {
    display: flex;
    gap: 12px;
    align-items: center;
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 12px;
    padding: 4px;
    transition: border-color 0.2s ease;
}

.chat-input-wrapper:focus-within {
    border-color: #667eea;
}

#messageInput {
    flex: 1;
    background: transparent;
    border: none;
    padding: 12px 16px;
    color: #ffffff;
    font-size: 14px;
    outline: none;
}

#messageInput::placeholder {
    color: #666;
}

#messageInput:disabled {
    opacity: 0.5;
}

#profileButton {
    width: 36px;
    height: 36px;
    background: #2a2a2a;
    border: none;
    border-radius: 6px;
    color: #888;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    margin-right: 4px;
}

#profileButton:hover {
    background: #333;
    color: #667eea;
    transform: translateY(-1px);
}

#sendButton {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

#sendButton:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

#sendButton:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Auth Dialog */
.auth-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.auth-dialog {
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow: hidden;
    animation: dialogSlideIn 0.3s ease-out;
}

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

.auth-dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #2a2a2a;
}

.auth-dialog-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #ffffff;
}

.auth-dialog-close {
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: #888;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.auth-dialog-close:hover {
    background: #2a2a2a;
    color: #ffffff;
}

.auth-dialog-content {
    padding: 24px;
}

.auth-dialog-content label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #ffffff;
    margin-bottom: 8px;
}

.auth-dialog-content textarea {
    width: 100%;
    background: #111111;
    border: 1px solid #2a2a2a;
    border-radius: 8px;
    padding: 12px 16px;
    color: #ffffff;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    outline: none;
    resize: vertical;
    min-height: 100px;
    transition: border-color 0.2s ease;
}

.auth-dialog-content textarea::placeholder {
    color: #666;
}

.auth-dialog-content textarea:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.auth-dialog-help {
    font-size: 12px;
    color: #888;
    margin-top: 8px;
    margin-bottom: 0;
    line-height: 1.4;
}

.auth-dialog-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding: 20px 24px;
    border-top: 1px solid #2a2a2a;
}

.auth-dialog-cancel,
.auth-dialog-save {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.auth-dialog-cancel {
    background: transparent;
    color: #888;
    border: 1px solid #2a2a2a;
}

.auth-dialog-cancel:hover {
    background: #2a2a2a;
    color: #ffffff;
}

.auth-dialog-save {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.auth-dialog-save:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* Scrollbar Styles */
::-webkit-scrollbar {
    width: 6px;
}

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

::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 3px;
}

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

/* Markdown styling */
.message-content h1,
.message-content h2,
.message-content h3 {
    margin: 16px 0 8px 0;
    color: #ffffff;
    font-weight: 600;
}

.message-content h1 {
    font-size: 24px;
    border-bottom: 2px solid #667eea;
    padding-bottom: 8px;
}

.message-content h2 {
    font-size: 20px;
    color: #667eea;
}

.message-content h3 {
    font-size: 18px;
    color: #888;
}

.message-content strong {
    color: #ffffff;
    font-weight: 600;
}

.message-content em {
    color: #ccc;
    font-style: italic;
}

.message-content code {
    background: #2a2a2a;
    color: #667eea;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
}

.message-content pre {
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 12px;
    margin: 12px 0;
    overflow-x: auto;
}

.message-content pre code {
    background: transparent;
    color: #ccc;
    padding: 0;
    font-size: 14px;
    line-height: 1.4;
}

.message-content ul,
.message-content ol {
    margin: 12px 0;
    padding-left: 24px;
}

.message-content li {
    margin: 4px 0;
    color: #ccc;
}

.message-content li::marker {
    color: #667eea;
}

.message-content a {
    color: #667eea;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s ease;
}

.message-content a:hover {
    border-bottom-color: #667eea;
}

.message-content blockquote {
    border-left: 4px solid #667eea;
    padding-left: 16px;
    margin: 12px 0;
    color: #888;
    font-style: italic;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: absolute;
        z-index: 1000;
        height: 100vh;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .message {
        max-width: 95%;
    }
}