/* X.com-inspired Design */

:root {
	/* Light theme colors */
	--bg-black: #ffffff;
	--bg-primary: #ffffff;
	--bg-secondary: rgb(247, 249, 249);
	--bg-hover: rgba(0, 0, 0, 0.03);
	--bg-active: rgba(0, 0, 0, 0.1);

	--text-primary: rgb(15, 20, 25);
	--text-secondary: rgb(83, 100, 113);
	--text-link: rgb(29, 155, 240);

	--border-color: rgb(239, 243, 244);

	/* X brand color */
	--x-blue: rgb(29, 155, 240);

	/* Typography */
	--font-primary: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

body {
	font-family: var(--font-primary);
	background-color: var(--bg-primary);
	color: var(--text-primary);
	font-size: 15px;
	line-height: 1.5;
	overflow-x: hidden;
}

/* Main Layout */
.app-container {
	display: flex;
	max-width: 1280px;
	margin: 0 auto;
	min-height: 100vh;
}

/* ===== LEFT SIDEBAR ===== */
.left-sidebar {
	width: 240px;
	padding: 0 12px;
	border-right: 1px solid var(--border-color);
	position: sticky;
	top: 0;
	height: 100vh;
	overflow-y: auto;
}

.sidebar-content {
	padding: 4px 0;
}

/* Logo */
.logo {
	padding: 12px;
	margin-bottom: 4px;
	width: 50px;
	height: 50px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 0;
	transition: background-color 0.2s;
}

.logo:hover {
	background-color: var(--bg-hover);
}

.logo svg {
	width: 30px;
	height: 30px;
	fill: var(--text-primary);
}

.logo-img {
	width: 30px;
	height: 30px;
	object-fit: contain;
}

/* Navigation */
.sidebar-nav {
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.nav-item {
	display: flex;
	align-items: center;
	gap: 20px;
	padding: 12px;
	color: var(--text-primary);
	text-decoration: none;
	font-size: 20px;
	font-weight: 400;
	border-radius: 9999px;
	transition: background-color 0.2s;
	cursor: pointer;
}

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

.nav-item.active {
	font-weight: 700;
}

.nav-icon {
	width: 26px;
	height: 26px;
	display: flex;
	align-items: center;
	justify-content: center;
}

.nav-icon svg {
	width: 26px;
	height: 26px;
	fill: currentColor;
}

/* ===== MAIN FEED ===== */
.main-feed {
	flex: 1;
	min-width: 0;
	border-right: 1px solid var(--border-color);
}

.feed-section {
	display: none;
}

.feed-section.active {
	display: block;
}

/* Feed Header */
.feed-header {
	position: sticky;
	top: 0;
	background-color: rgba(255, 255, 255, 0.85);
	backdrop-filter: blur(12px);
	padding: 12px 16px;
	border-bottom: 1px solid var(--border-color);
	z-index: 2;
}

.feed-header h2 {
	font-size: 20px;
	font-weight: 700;
	color: var(--text-primary);
}

/* Post Feed (Blog Posts as Tweets) */
.post-feed {
	min-height: 400px;
}

.tweet-post {
	padding: 12px 16px;
	border-bottom: 1px solid var(--border-color);
	transition: background-color 0.2s;
	cursor: pointer;
}

.tweet-post:hover {
	background-color: var(--bg-hover);
}

.post-header {
	display: flex;
	gap: 12px;
	margin-bottom: 24px;
}

.post-avatar {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	object-fit: cover;
	flex-shrink: 0;
}

.post-info {
	flex: 1;
	min-width: 0;
	display: flex;
	align-items: center;
}

.post-author {
	display: flex;
	align-items: center;
	gap: 4px;
}

.post-name {
	font-weight: 700;
	color: var(--text-primary);
	font-size: 15px;
}

.post-handle {
	color: var(--text-secondary);
	font-size: 15px;
}

.post-date {
	color: var(--text-secondary);
	font-size: 15px;
}

.post-separator {
	margin: 0 4px;
}

.post-title {
	font-size: 23px;
	font-weight: 700;
	color: var(--text-primary);
	margin-bottom: 8px;
	line-height: 1.3;
}

.post-title-link {
	color: var(--text-primary);
	text-decoration: none;
}

.post-title-link:hover {
	text-decoration: underline;
}

.post-body {
	color: var(--text-primary);
	font-size: 15px;
	line-height: 1.5;
	margin-bottom: 12px;
}

.post-body h1,
.post-body h2,
.post-body h3 {
	margin-top: 24px;
	margin-bottom: 12px;
	line-height: 1.3;
}

.post-body h1 {
	font-size: 24px;
	font-weight: 700;
}

.post-body h2 {
	font-size: 20px;
	font-weight: 700;
}

.post-body h3 {
	font-size: 17px;
	font-weight: 700;
}

.post-body p {
	margin-bottom: 12px;
}

.post-body a {
	color: var(--x-blue);
	text-decoration: none;
}

.post-body a:hover {
	text-decoration: underline;
}

.post-body code {
	background-color: var(--bg-secondary);
	padding: 2px 6px;
	border-radius: 4px;
	font-family: 'Courier New', monospace;
	font-size: 14px;
}

.post-body pre {
	background-color: var(--bg-secondary);
	padding: 16px;
	border-radius: 8px;
	overflow-x: auto;
	margin: 12px 0;
}

.post-body pre code {
	background: none;
	padding: 0;
}

.post-body ul,
.post-body ol {
	margin-left: 20px;
	margin-bottom: 12px;
}

.post-body blockquote {
	border-left: 3px solid var(--border-color);
	padding-left: 16px;
	margin: 12px 0;
	color: var(--text-secondary);
}

.post-tags {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 12px;
}

.post-tag {
	color: var(--x-blue);
	font-size: 15px;
	cursor: pointer;
	transition: opacity 0.2s;
}

.post-tag:hover {
	text-decoration: underline;
}

.tweet-image {
	width: 100%;
	max-height: 510px;
	border-radius: 16px;
	margin-top: 12px;
	border: 1px solid var(--border-color);
	object-fit: cover;
	display: block;
}

/* Multiple images grid */
.tweet-images {
	display: grid;
	gap: 2px;
	margin-top: 12px;
	border-radius: 16px;
	overflow: hidden;
}

.tweet-images-2 {
	grid-template-columns: 1fr 1fr;
}

.tweet-images-3 {
	grid-template-columns: 1fr 1fr;
	grid-template-rows: 1fr 1fr;
}

.tweet-images-3 .tweet-image:first-child {
	grid-row: 1 / 3;
}

.tweet-images-4 {
	grid-template-columns: 1fr 1fr;
	grid-template-rows: 1fr 1fr;
}

.tweet-images .tweet-image {
	margin: 0;
	border: none;
	border-radius: 0;
	height: 100%;
	min-height: 200px;
}

/* Single Post View */
.single-post-container {
	padding: 16px;
	max-width: 680px;
	margin: 0 auto;
}

.single-post-container .post-title {
	font-size: 28px;
	margin-bottom: 16px;
}

.single-post-container .post-meta {
	color: var(--text-secondary);
	font-size: 15px;
	margin-bottom: 24px;
}

.back-button {
	background: none;
	border: none;
	color: var(--text-primary);
	font-size: 15px;
	font-weight: 600;
	cursor: pointer;
	padding: 0;
	display: flex;
	align-items: center;
	gap: 4px;
	font-family: var(--font-primary);
}

.back-button:hover {
	text-decoration: underline;
}

/* ===== RIGHT SIDEBAR ===== */
.right-sidebar {
	width: 320px;
	padding: 8px 16px;
	position: sticky;
	top: 0;
	height: 100vh;
	overflow-y: auto;
}

.sidebar-module {
	background-color: var(--bg-secondary);
	border-radius: 16px;
	margin-bottom: 16px;
	overflow: hidden;
}

.module-title {
	font-size: 20px;
	font-weight: 800;
	padding: 12px 16px;
	color: var(--text-primary);
}

/* Trending Tags */
.trending-list {
	display: flex;
	flex-direction: column;
}

.trending-item {
	padding: 12px 16px;
	transition: background-color 0.2s;
	cursor: pointer;
	text-decoration: none;
	display: block;
}

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

.trending-category {
	font-size: 13px;
	color: var(--text-secondary);
	margin-bottom: 2px;
}

.trending-name {
	font-size: 15px;
	font-weight: 700;
	color: var(--text-primary);
	margin-bottom: 2px;
}

.trending-count {
	font-size: 13px;
	color: var(--text-secondary);
}

/* Follow List */
.follow-list {
	display: flex;
	flex-direction: column;
}

.follow-item {
	padding: 12px 16px;
	display: flex;
	align-items: center;
	gap: 12px;
	transition: background-color 0.2s;
	text-decoration: none;
	color: var(--text-primary);
}

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

.follow-avatar {
	width: 48px;
	height: 48px;
	border-radius: 50%;
	background-color: var(--bg-hover);
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.follow-avatar svg {
	width: 24px;
	height: 24px;
	fill: var(--text-secondary);
}

.follow-info {
	flex: 1;
	min-width: 0;
}

.follow-name {
	font-size: 15px;
	font-weight: 700;
	color: var(--text-primary);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.follow-handle {
	font-size: 15px;
	color: var(--text-secondary);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* ===== PAPERS (BOOKMARKS) ===== */
.papers-list {
	display: flex;
	flex-direction: column;
}

.paper-item {
	padding: 12px 16px;
	border-bottom: 1px solid var(--border-color);
	transition: background-color 0.2s;
	text-decoration: none;
	color: inherit;
	display: block;
	cursor: pointer;
}

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

.paper-title {
	font-size: 15px;
	font-weight: 600;
	color: var(--text-primary);
	margin-bottom: 8px;
	line-height: 1.4;
}

.paper-meta {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
}

.paper-date {
	font-size: 13px;
	color: var(--text-secondary);
}

.paper-link {
	color: var(--x-blue);
	font-size: 13px;
	font-weight: 500;
}

/* ===== CHAT ===== */
.chat-container {
	display: flex;
	flex-direction: column;
	height: calc(100vh - 53px);
}

.chat-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
}

.message {
	margin-bottom: 16px;
	padding: 12px 16px;
	border-radius: 16px;
	max-width: 80%;
}

.message.user {
	background-color: var(--x-blue);
	color: white;
	margin-left: auto;
}

.message.bot {
	background-color: var(--bg-secondary);
	color: var(--text-primary);
	margin-right: auto;
}

.message p {
	margin: 0 0 8px 0;
	line-height: 1.5;
}

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

/* Chat message formatting */
.message h1,
.message h2,
.message h3 {
	margin-top: 16px;
	margin-bottom: 12px;
	line-height: 1.3;
	font-weight: 700;
}

.message h1:first-child,
.message h2:first-child,
.message h3:first-child {
	margin-top: 0;
}

.message h1 {
	font-size: 20px;
}

.message h2 {
	font-size: 18px;
}

.message h3 {
	font-size: 16px;
}

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

.message li {
	margin: 4px 0;
	line-height: 1.5;
}

.message-citations {
	margin-top: 12px;
	padding-top: 12px;
	border-top: 1px solid rgba(0, 0, 0, 0.1);
	font-size: 13px;
}

.message-citations-title {
	font-weight: 700;
	margin-bottom: 8px;
	color: var(--text-secondary);
}

.citation-link {
	display: block;
	color: var(--x-blue);
	text-decoration: none;
	margin: 4px 0;
	padding: 4px 0;
}

.citation-link:hover {
	text-decoration: underline;
}

.chat-input-container {
	padding: 12px 16px;
	border-top: 1px solid var(--border-color);
	display: flex;
	gap: 12px;
	background-color: var(--bg-primary);
}

.chat-input {
	flex: 1;
	background-color: var(--bg-secondary);
	border: 1px solid var(--border-color);
	border-radius: 20px;
	padding: 12px 16px;
	color: var(--text-primary);
	font-size: 15px;
	font-family: var(--font-primary);
	outline: none;
}

.chat-input:focus {
	border-color: var(--x-blue);
}

.chat-send {
	background-color: var(--x-blue);
	color: white;
	border: none;
	border-radius: 20px;
	padding: 12px 24px;
	font-size: 15px;
	font-weight: 700;
	cursor: pointer;
	transition: background-color 0.2s;
	font-family: var(--font-primary);
}

.chat-send:hover {
	background-color: rgb(26, 140, 216);
}

.chat-send:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

/* ===== PROFILE ===== */
.profile-content {
	background-color: var(--bg-primary);
}

.profile-banner {
	width: 100%;
	height: 200px;
	background-image: url('/images/header.jpg');
	background-size: cover;
	background-position: center;
}

.profile-info {
	padding: 16px;
	position: relative;
}

.profile-avatar {
	width: 134px;
	height: 134px;
	border-radius: 50%;
	border: 4px solid var(--bg-primary);
	margin-top: -67px;
	margin-bottom: 12px;
	overflow: hidden;
	display: flex;
	align-items: center;
	justify-content: center;
}

.avatar-image {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.profile-name {
	font-size: 20px;
	font-weight: 800;
	color: var(--text-primary);
	margin-bottom: 4px;
}

.profile-handle-location {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
	margin-bottom: 12px;
	font-size: 15px;
	color: var(--text-secondary);
}

.profile-handle {
	color: var(--text-secondary);
}

.profile-separator {
	color: var(--text-secondary);
}

.profile-bio-location {
	margin-bottom: 12px;
}

.profile-email {
	color: var(--x-blue);
	text-decoration: none;
}

.profile-email:hover {
	text-decoration: underline;
}

.profile-bio {
	font-size: 15px;
	color: var(--text-primary);
	line-height: 1.5;
	margin: 0;
}

.profile-location {
	display: flex;
	align-items: center;
	gap: 4px;
	color: var(--text-secondary);
	font-size: 15px;
}

.location-icon {
	width: 18px;
	height: 18px;
	fill: currentColor;
}

/* ===== LOADING ===== */
.loading {
	padding: 32px;
	text-align: center;
	color: var(--text-secondary);
	font-size: 15px;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
	width: 8px;
	height: 8px;
}

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

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

::-webkit-scrollbar-thumb:hover {
	background: rgb(60, 64, 67);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
	.right-sidebar {
		display: none;
	}
}

@media (max-width: 768px) {
	.left-sidebar {
		width: 68px;
	}

	.nav-item span {
		display: none;
	}

	.sidebar-content {
		align-items: center;
	}
}

/* ===== MOBILE OPTIMIZATIONS (Twitter iOS Style) ===== */
@media (max-width: 500px) {
	/* iOS Safe Area Support */
	body {
		padding-bottom: env(safe-area-inset-bottom);
		-webkit-overflow-scrolling: touch;
	}

	/* Container Layout */
	.app-container {
		flex-direction: column;
	}

	/* Bottom Navigation (Twitter iOS Style) */
	.left-sidebar {
		width: 100%;
		height: 56px;
		position: fixed;
		bottom: 0;
		top: auto;
		left: 0;
		right: 0;
		border-right: none;
		border-top: 1px solid var(--border-color);
		z-index: 1000;
		background-color: var(--bg-primary);
		padding: 0;
		padding-bottom: env(safe-area-inset-bottom);
		overflow-y: visible;
	}

	.sidebar-content {
		padding: 0;
		height: 100%;
		display: flex;
		align-items: center;
	}

	.sidebar-nav {
		flex-direction: row;
		justify-content: space-around;
		width: 100%;
		gap: 0;
		height: 100%;
		align-items: center;
	}

	.nav-item {
		padding: 0;
		min-width: 44px;
		min-height: 44px;
		display: flex;
		align-items: center;
		justify-content: center;
		position: relative;
		border-radius: 0;
		flex: 1;
	}

	.nav-item:hover {
		background-color: transparent;
	}

	/* Active Tab Indicator (Blue Underline) */
	.nav-item.active::after {
		content: '';
		position: absolute;
		bottom: 0;
		left: 50%;
		transform: translateX(-50%);
		width: 56px;
		height: 4px;
		background-color: var(--x-blue);
		border-radius: 4px 4px 0 0;
	}

	.nav-item span {
		display: none;
	}

	.logo {
		display: flex;
		position: fixed;
		top: 8px;
		right: 8px;
		z-index: 1001;
		background-color: var(--bg-primary);
		width: 40px;
		height: 40px;
		border-radius: 0;
		padding: 0;
	}

	.nav-icon {
		width: 26px;
		height: 26px;
	}

	.nav-icon svg {
		width: 26px;
		height: 26px;
	}

	/* Main Feed - Full Width */
	.main-feed {
		margin-bottom: calc(56px + env(safe-area-inset-bottom));
		width: 100%;
		border-right: none;
		border-left: none;
	}

	.right-sidebar {
		display: none;
	}

	/* Touch-Friendly Interactions */
	* {
		-webkit-tap-highlight-color: transparent;
	}

	/* Feed Header */
	.feed-header {
		padding: 16px;
	}

	.feed-header h2 {
		font-size: 19px;
	}

	/* Post Feed - Touch Optimized */
	.tweet-post {
		padding: 16px;
	}

	.post-header {
		margin-bottom: 12px;
	}

	.post-title {
		font-size: 19px;
		line-height: 1.4;
	}

	.post-body {
		font-size: 15px;
		line-height: 1.5;
	}

	.post-body h1 {
		font-size: 21px;
		margin-top: 20px;
	}

	.post-body h2 {
		font-size: 19px;
		margin-top: 18px;
	}

	.post-body h3 {
		font-size: 17px;
		margin-top: 16px;
	}

	/* Code Blocks - Touch Scroll */
	.post-body pre {
		-webkit-overflow-scrolling: touch;
		overflow-x: auto;
		padding: 12px;
		margin: 16px 0;
	}

	.post-body code {
		font-size: 13px;
	}

	/* Profile - Mobile Optimized */
	.profile-banner {
		height: 160px;
	}

	.profile-avatar {
		width: 80px;
		height: 80px;
		margin-top: -40px;
		border: 3px solid var(--bg-primary);
	}

	.profile-info {
		padding: 12px 16px;
	}

	.profile-name {
		font-size: 19px;
	}

	.profile-handle {
		font-size: 15px;
	}

	.profile-bio {
		font-size: 15px;
	}

	.profile-bio-location {
		flex-direction: column;
		align-items: flex-start;
		gap: 8px;
	}

	/* Chat - Adjusted for Bottom Nav */
	.chat-container {
		height: calc(100vh - 53px - 56px - env(safe-area-inset-bottom));
	}

	.chat-messages {
		padding: 12px;
		-webkit-overflow-scrolling: touch;
	}

	.message {
		padding: 12px 16px;
		font-size: 15px;
		max-width: 85%;
	}

	.chat-input-container {
		padding: 12px 16px;
		padding-bottom: calc(12px + env(safe-area-inset-bottom));
	}

	.chat-input {
		font-size: 16px;
		padding: 10px 14px;
	}

	.chat-send {
		min-width: 44px;
		min-height: 44px;
		padding: 10px 20px;
	}

	/* Papers/Bookmarks - Touch Optimized */
	.paper-item {
		padding: 16px;
		min-height: 44px;
	}

	.paper-title {
		font-size: 15px;
		line-height: 1.5;
	}

	.paper-date {
		font-size: 13px;
	}

	.paper-link {
		font-size: 13px;
		min-height: 44px;
		display: flex;
		align-items: center;
	}

	/* Back Button - Touch Friendly */
	.back-button {
		min-width: 44px;
		min-height: 44px;
		font-size: 15px;
	}

	/* Single Post View */
	.single-post-container {
		padding: 16px;
	}

	.single-post-container .post-title {
		font-size: 23px;
	}

	/* Images - Responsive */
	.tweet-image {
		border-radius: 12px;
	}

	.tweet-images {
		border-radius: 12px;
	}

	/* Post Tags */
	.post-tag {
		min-height: 44px;
		display: inline-flex;
		align-items: center;
	}
}

/* Extra Small Devices (375px and below) */
@media (max-width: 375px) {
	.post-title {
		font-size: 17px;
	}

	.post-body {
		font-size: 14px;
	}

	.feed-header h2 {
		font-size: 17px;
	}

	.profile-name {
		font-size: 17px;
	}

	.single-post-container .post-title {
		font-size: 21px;
	}
}
