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

:root {
    --bg-primary: #0d1b2a;
    --bg-secondary: #1b2838;
    --bg-tertiary: #243447;
    --text-primary: #ffffff;
    --text-secondary: #a8c5e2;
    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --user-bg: #1d4ed8;
    --ai-bg: #1b2838;
    --border: #2d4a6a;
    --shadow: rgba(0, 0, 0, 0.3);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

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

.sidebar {
    width: 260px;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.new-chat-btn {
    width: 100%;
    padding: 12px 16px;
    background-color: var(--accent);
    border: none;
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.new-chat-btn:hover {
    background-color: var(--accent-hover);
}

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

.session-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 12px;
    margin-bottom: 4px;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s;
    color: var(--text-primary);
    background-color: transparent;
}

.session-item:hover {
    background-color: var(--bg-tertiary);
}

.session-item.active {
    background-color: var(--accent);
    color: white;
}

.session-content {
    flex: 1;
    cursor: pointer;
    min-width: 0;
}

.session-title {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    outline: none;
}

.session-title[contenteditable="true"] {
    background-color: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    white-space: normal;
    overflow: visible;
}

.session-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.session-item:hover .session-actions {
    opacity: 1;
}

.rename-btn, .delete-btn {
    width: 28px;
    height: 28px;
    padding: 6px;
    background-color: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.rename-btn:hover {
    background-color: rgba(0, 122, 255, 0.1);
    color: var(--accent);
}

.delete-btn:hover {
    background-color: rgba(255, 59, 48, 0.1);
    color: #FF3B30;
}

.session-item.active .session-actions {
    color: white;
    opacity: 0;
}

.session-item.active:hover .session-actions {
    opacity: 1;
}

.session-item.active .rename-btn:hover,
.session-item.active .delete-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
}

.no-sessions {
    padding: 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
}

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

.chat-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    background-color: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header-content {
    flex: 1;
}

.chat-header h1 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.subtitle {
    font-size: 14px;
    color: var(--text-secondary);
}

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

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background-color: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.user-info span {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
}

.logout-btn {
    padding: 6px 12px;
    background-color: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.logout-btn:hover {
    background-color: rgba(255, 59, 48, 0.1);
    border-color: #FF3B30;
    color: #FF3B30;
}

.auth-prompt {
    display: flex;
    align-items: center;
}

.auth-link {
    padding: 8px 16px;
    background-color: var(--accent);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.auth-link:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
}

.attribution {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    padding: 8px 16px;
    background-color: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background-color: var(--bg-primary);
}

.welcome-message {
    max-width: 600px;
    margin: 0 auto;
    text-align: center;
    padding: 48px 24px;
}

.welcome-message h2 {
    font-size: 24px;
    margin-bottom: 12px;
    color: var(--accent);
}

.welcome-message p {
    font-size: 16px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.message {
    display: flex;
    gap: 12px;
    max-width: 800px;
    animation: slideIn 0.3s ease-out;
}

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

.message.user {
    margin-left: auto;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background-color: var(--accent);
    color: white;
}

.message.ai .message-avatar {
    background-color: var(--bg-tertiary);
    color: var(--accent);
}

.message-content {
    background-color: var(--ai-bg);
    padding: 12px 16px;
    border-radius: 16px;
    line-height: 1.6;
    font-size: 15px;
    color: var(--text-primary);
    box-shadow: 0 2px 8px var(--shadow);
}

.message.user .message-content {
    background-color: var(--user-bg);
    color: #ffffff;
}

.typing-indicator {
    display: none;
    gap: 4px;
    padding: 12px 0;
    align-items: center;
}

.typing-indicator.active {
    display: flex;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background-color: var(--accent);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

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

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

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

.input-container {
    padding: 40px 24px;
    border-top: 1px solid var(--border);
    background-color: var(--bg-primary);
}

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

#messageInput {
    flex: 1;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 15px;
    font-family: inherit;
    resize: none;
    max-height: 200px;
    line-height: 1.5;
    box-shadow: 0 1px 4px var(--shadow);
}

#messageInput:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(74, 163, 255, 0.1);
}

#messageInput::placeholder {
    color: var(--text-secondary);
}

.send-btn {
    width: 44px;
    height: 44px;
    background-color: var(--accent);
    border: none;
    border-radius: 12px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(74, 163, 255, 0.3);
}

.send-btn:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74, 163, 255, 0.4);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.send-btn svg {
    width: 20px;
    height: 20px;
}

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

.help-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.help-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
}

.welcome-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.welcome-modal.hidden {
    display: none;
}

.welcome-modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 30px 40px;
    max-width: 550px;
    width: 90%;
    position: relative;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.close-modal-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 28px;
    cursor: pointer;
    transition: color 0.2s;
    line-height: 1;
}

.close-modal-btn:hover {
    color: var(--text-primary);
}

.modal-lang-switcher {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 25px;
}

.modal-lang-btn {
    padding: 8px 20px;
    background: var(--bg-tertiary);
    border: 2px solid var(--border);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-lang-btn:hover {
    border-color: var(--accent);
}

.modal-lang-btn.active {
    background: var(--accent);
    border-color: var(--accent);
}

.modal-text p {
    font-size: 16px;
    line-height: 1.7;
    color: var(--text-primary);
    text-align: center;
}

.modal-text strong {
    color: var(--accent-hover);
}
