/* CodeMentor AI — custom styling on top of Tailwind */

html,
body {
	height: 100%;
	margin: 0;
}

/* Shared tokens */
.topbtn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2rem;
	height: 2rem;
	border-radius: 0.5rem;
	background: rgb(31 41 55); /* gray-800 */
	border: 1px solid rgb(55 65 81); /* gray-700 */
	font-size: 0.95rem;
	transition: background 0.15s, transform 0.1s;
}
.topbtn:hover {
	background: rgb(55 65 81);
}
.topbtn:active {
	transform: scale(0.95);
}

.primary-btn {
	padding: 0.5rem 0.75rem;
	border-radius: 0.5rem;
	background: rgb(5 150 105); /* emerald-600 */
	color: white;
	font-weight: 600;
	font-size: 0.875rem;
	transition: background 0.15s;
}
.primary-btn:hover {
	background: rgb(16 185 129);
}
.primary-btn:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

.secondary-btn {
	padding: 0.4rem 0.75rem;
	border-radius: 0.5rem;
	background: rgb(31 41 55);
	color: rgb(229 231 235);
	border: 1px solid rgb(55 65 81);
	font-size: 0.875rem;
	transition: background 0.15s;
}
.secondary-btn:hover {
	background: rgb(55 65 81);
}

.validate-btn {
	padding: 0.75rem 1rem;
	border-radius: 0.5rem;
	background: linear-gradient(135deg, rgb(79 70 229) 0%, rgb(147 51 234) 100%);
	color: white;
	font-weight: 700;
	font-size: 0.95rem;
	box-shadow: 0 4px 14px rgba(147, 51, 234, 0.3);
	transition: transform 0.15s, box-shadow 0.15s;
}
.validate-btn:hover {
	transform: translateY(-1px);
	box-shadow: 0 6px 20px rgba(147, 51, 234, 0.45);
}
.validate-btn:active {
	transform: translateY(0);
}
.validate-btn:disabled {
	opacity: 0.7;
	cursor: wait;
}

.sidebar-section {
	font-size: 0.7rem;
	font-weight: 600;
	color: rgb(107 114 128);
	text-transform: uppercase;
	letter-spacing: 0.08em;
	margin-bottom: 0.35rem;
}

/* Tabs */
.tab-btn {
	padding: 0.6rem 1rem;
	font-size: 0.85rem;
	color: rgb(156 163 175);
	border-bottom: 2px solid transparent;
	transition: color 0.15s, border-color 0.15s;
}
.tab-btn:hover {
	color: rgb(229 231 235);
}
.tab-active {
	color: rgb(52 211 153);
	border-bottom-color: rgb(52 211 153);
}

.tab-panel {
	display: flex;
}
.tab-panel.hidden {
	display: none;
}

/* Console tabs */
.console-tab {
	padding: 0.4rem 0.75rem;
	color: rgb(156 163 175);
	border-bottom: 2px solid transparent;
	transition: color 0.15s, border-color 0.15s;
}
.console-tab:hover {
	color: rgb(229 231 235);
}
.console-tab-active {
	color: rgb(147 197 253);
	border-bottom-color: rgb(147 197 253);
}

/* Sidebar tree */
.tree-subject {
	margin-bottom: 0.5rem;
}
.tree-subject-title {
	display: flex;
	align-items: center;
	gap: 0.25rem;
	font-size: 0.8rem;
	font-weight: 600;
	color: rgb(229 231 235);
	padding: 0.25rem 0.25rem;
	cursor: pointer;
	border-radius: 0.25rem;
}
.tree-subject-title:hover {
	background: rgb(17 24 39);
}
.tree-subject-chevron {
	transition: transform 0.15s;
	display: inline-block;
	width: 0.75rem;
}
.tree-subject.collapsed .tree-subject-chevron {
	transform: rotate(-90deg);
}
.tree-subject.collapsed .tree-subsubjects {
	display: none;
}
.tree-subsubjects {
	margin: 0.25rem 0 0 0.75rem;
	padding-left: 0.5rem;
	border-left: 1px solid rgb(31 41 55);
	display: flex;
	flex-direction: column;
	gap: 0.1rem;
}
.tree-item {
	display: flex;
	align-items: center;
	gap: 0.4rem;
	padding: 0.25rem 0.5rem;
	border-radius: 0.25rem;
	font-size: 0.8rem;
	color: rgb(209 213 219);
	cursor: pointer;
	text-align: left;
	background: transparent;
	border: none;
	width: 100%;
}
.tree-item:hover {
	background: rgb(31 41 55);
	color: white;
}
.tree-item.active {
	background: rgba(5, 150, 105, 0.15);
	color: rgb(110 231 183);
}
.tree-item.passed::before {
	content: '✓';
	color: rgb(52 211 153);
	font-weight: 700;
}
.tree-item.bookmarked::after {
	content: '🔖';
	margin-left: auto;
	font-size: 0.7rem;
	opacity: 0.8;
}

/* Course list buttons */
.course-btn {
	width: 100%;
	text-align: left;
	padding: 0.4rem 0.6rem;
	border-radius: 0.4rem;
	font-size: 0.8rem;
	background: rgb(17 24 39);
	border: 1px solid rgb(31 41 55);
	color: rgb(229 231 235);
	transition: background 0.15s, border-color 0.15s;
}
.course-btn:hover {
	background: rgb(31 41 55);
	border-color: rgb(55 65 81);
}
.course-btn.active {
	border-color: rgb(16 185 129);
	background: rgba(5, 150, 105, 0.15);
}

/* Mentor panel typography */
.mentor-markdown {
	color: rgb(229 231 235);
	font-size: 0.925rem;
	line-height: 1.55;
}
.mentor-markdown h1,
.mentor-markdown h2,
.mentor-markdown h3 {
	color: rgb(110 231 183);
	font-weight: 600;
	margin-top: 0.75em;
	margin-bottom: 0.35em;
}
.mentor-markdown h1 {
	font-size: 1.3rem;
}
.mentor-markdown h2 {
	font-size: 1.15rem;
}
.mentor-markdown h3 {
	font-size: 1rem;
}
.mentor-markdown p {
	margin: 0.5em 0;
}
.mentor-markdown ul,
.mentor-markdown ol {
	margin: 0.5em 0;
	padding-left: 1.3em;
}
.mentor-markdown li {
	margin: 0.2em 0;
}
.mentor-markdown code {
	background: rgba(16, 185, 129, 0.1);
	color: rgb(110 231 183);
	padding: 0.1em 0.3em;
	border-radius: 0.25em;
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 0.88em;
}
.mentor-markdown pre {
	background: rgb(17 24 39);
	border: 1px solid rgb(31 41 55);
	border-radius: 0.5rem;
	padding: 0.75rem;
	overflow-x: auto;
	margin: 0.75em 0;
	font-size: 0.85em;
}
.mentor-markdown pre code {
	background: transparent;
	color: inherit;
	padding: 0;
}
.mentor-markdown blockquote {
	border-left: 3px solid rgb(5 150 105);
	padding: 0.25em 0.75em;
	color: rgb(156 163 175);
	margin: 0.75em 0;
	background: rgba(5, 150, 105, 0.05);
}
.mentor-markdown a {
	color: rgb(147 197 253);
	text-decoration: underline;
}

/* Progress bar */
.step-progress-track {
	height: 0.5rem;
	background: rgb(31 41 55);
	border-radius: 0.25rem;
	overflow: hidden;
}
.step-progress-fill {
	height: 100%;
	background: linear-gradient(90deg, rgb(16 185 129), rgb(59 130 246));
	transition: width 0.4s ease;
}

/* Quiz UI */
.quiz-option {
	display: block;
	width: 100%;
	text-align: left;
	padding: 0.5rem 0.75rem;
	border-radius: 0.5rem;
	background: rgb(17 24 39);
	border: 1px solid rgb(31 41 55);
	margin-bottom: 0.4rem;
	cursor: pointer;
	transition: border-color 0.15s, background 0.15s;
}
.quiz-option:hover {
	border-color: rgb(55 65 81);
}
.quiz-option.selected {
	border-color: rgb(59 130 246);
	background: rgba(59, 130, 246, 0.1);
}
.quiz-option.correct {
	border-color: rgb(16 185 129);
	background: rgba(16, 185, 129, 0.15);
}
.quiz-option.incorrect {
	border-color: rgb(239 68 68);
	background: rgba(239, 68, 68, 0.15);
}

/* Chat bubbles */
.chat-msg {
	max-width: 85%;
	padding: 0.65rem 0.85rem;
	border-radius: 0.75rem;
	font-size: 0.9rem;
	white-space: pre-wrap;
	word-wrap: break-word;
}
.chat-msg.user {
	background: rgb(29 78 216);
	color: white;
	margin-left: auto;
	border-bottom-right-radius: 0.25rem;
}
.chat-msg.assistant {
	background: rgb(31 41 55);
	color: rgb(229 231 235);
	border-bottom-left-radius: 0.25rem;
}

/* Modals */
.modal-backdrop {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.6);
	backdrop-filter: blur(4px);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 60;
	padding: 1rem;
	animation: fade-in 0.15s ease;
}
.modal-backdrop.hidden {
	display: none;
}
.modal-card {
	background: rgb(17 24 39);
	border: 1px solid rgb(31 41 55);
	border-radius: 0.75rem;
	padding: 1.25rem;
	width: 100%;
	max-width: 28rem;
	box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
	animation: pop-in 0.2s ease;
}
.modal-close {
	color: rgb(156 163 175);
	font-size: 1rem;
	padding: 0.25rem 0.5rem;
	border-radius: 0.25rem;
}
.modal-close:hover {
	color: white;
	background: rgb(31 41 55);
}

/* Auth modal tabs */
.auth-tab {
	flex: 1;
	padding: 0.4rem 0.75rem;
	border-radius: 0.375rem;
	background: rgb(31 41 55);
	color: rgb(156 163 175);
	font-weight: 500;
}
.auth-tab-active {
	background: rgb(5 150 105);
	color: white;
}

/* Toast */
.toast {
	min-width: 18rem;
	max-width: 26rem;
	padding: 0.75rem 1rem;
	border-radius: 0.5rem;
	background: rgb(17 24 39);
	border: 1px solid rgb(55 65 81);
	color: rgb(229 231 235);
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
	animation: slide-in 0.25s ease;
	font-size: 0.875rem;
	display: flex;
	gap: 0.5rem;
	align-items: flex-start;
}
.toast.success {
	border-color: rgb(16 185 129);
}
.toast.error {
	border-color: rgb(239 68 68);
}
.toast.info {
	border-color: rgb(59 130 246);
}
.toast.achievement {
	border-color: rgb(234 179 8);
	background: linear-gradient(135deg, rgba(234, 179, 8, 0.15), rgba(17, 24, 39, 1));
}
.toast-icon {
	font-size: 1.25rem;
	line-height: 1;
}
.toast-body {
	flex: 1;
}
.toast-title {
	font-weight: 600;
	margin-bottom: 0.1rem;
}
.toast-desc {
	color: rgb(156 163 175);
	font-size: 0.8rem;
}

/* Progress cards */
.stat-card {
	background: rgb(17 24 39);
	border: 1px solid rgb(31 41 55);
	border-radius: 0.5rem;
	padding: 0.75rem;
}
.stat-card .label {
	font-size: 0.7rem;
	text-transform: uppercase;
	color: rgb(107 114 128);
	letter-spacing: 0.06em;
}
.stat-card .value {
	font-size: 1.5rem;
	font-weight: 700;
	color: rgb(229 231 235);
}
.stat-card .trend {
	font-size: 0.75rem;
	color: rgb(52 211 153);
}

.lang-chip {
	padding: 0.25rem 0.6rem;
	border-radius: 999px;
	background: rgba(59, 130, 246, 0.15);
	border: 1px solid rgba(59, 130, 246, 0.4);
	color: rgb(147 197 253);
	font-size: 0.75rem;
	text-transform: capitalize;
}

/* Achievement cards */
.ach-card {
	display: flex;
	gap: 0.6rem;
	padding: 0.75rem;
	border: 1px solid rgb(31 41 55);
	border-radius: 0.5rem;
	background: rgb(17 24 39);
	opacity: 0.55;
	transition: opacity 0.15s, border-color 0.15s;
}
.ach-card.unlocked {
	opacity: 1;
	border-color: rgba(234, 179, 8, 0.5);
	background: linear-gradient(135deg, rgba(234, 179, 8, 0.08), rgba(17, 24, 39, 1));
}
.ach-card .icon {
	font-size: 1.75rem;
	line-height: 1;
}
.ach-card .title {
	font-weight: 600;
}
.ach-card .desc {
	font-size: 0.75rem;
	color: rgb(156 163 175);
}

/* Leaderboard */
.lb-row {
	display: grid;
	grid-template-columns: 2rem 1fr auto auto;
	gap: 0.5rem;
	align-items: center;
	padding: 0.5rem 0.75rem;
	border-bottom: 1px solid rgb(31 41 55);
}
.lb-row .rank {
	color: rgb(156 163 175);
	font-weight: 700;
}
.lb-row.top .rank {
	color: rgb(250 204 21);
}
.lb-row .xp {
	color: rgb(52 211 153);
	font-weight: 700;
}

/* Kbd styling */
kbd {
	background: rgb(31 41 55);
	border: 1px solid rgb(55 65 81);
	border-radius: 0.25rem;
	padding: 0.1rem 0.4rem;
	font-size: 0.75rem;
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* Console */
#console-output .log-row {
	padding: 0.1rem 0.25rem;
	border-bottom: 1px solid rgba(31, 41, 55, 0.6);
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
#console-output .log-info {
	color: rgb(209 213 219);
}
#console-output .log-ok {
	color: rgb(74 222 128);
}
#console-output .log-err {
	color: rgb(248 113 113);
}
#console-output .log-warn {
	color: rgb(250 204 21);
}
#console-output .log-sys {
	color: rgb(147 197 253);
}

/* Scrollbars */
.scrollbar-thin {
	scrollbar-width: thin;
	scrollbar-color: rgb(55 65 81) rgb(17 24 39);
}
.scrollbar-thin::-webkit-scrollbar {
	width: 8px;
	height: 8px;
}
.scrollbar-thin::-webkit-scrollbar-track {
	background: rgb(17 24 39);
}
.scrollbar-thin::-webkit-scrollbar-thumb {
	background: rgb(55 65 81);
	border-radius: 4px;
}
.scrollbar-thin::-webkit-scrollbar-thumb:hover {
	background: rgb(75 85 99);
}

/* CodeMirror fit */
.CodeMirror {
	height: 100% !important;
	font-size: var(--cm-font-size, 13px);
}

/* Animations */
@keyframes fade-in {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}
@keyframes pop-in {
	from {
		opacity: 0;
		transform: scale(0.95);
	}
	to {
		opacity: 1;
		transform: scale(1);
	}
}
@keyframes slide-in {
	from {
		transform: translateX(30px);
		opacity: 0;
	}
	to {
		transform: translateX(0);
		opacity: 1;
	}
}

/* Spinner */
.spinner {
	display: inline-block;
	width: 1rem;
	height: 1rem;
	border: 2px solid rgba(255, 255, 255, 0.25);
	border-top-color: white;
	border-radius: 50%;
	animation: spin 0.75s linear infinite;
}
@keyframes spin {
	to {
		transform: rotate(360deg);
	}
}

/* Utility */
.hidden-force {
	display: none !important;
}
