:root {
	--bg-dark: #0f1923;
	--bg-panel: #1a2634;
	--bg-panel-lighter: #1e2c3a;
	--text-primary: #e9ecef;
	--text-secondary: rgba(255, 255, 255, 0.7);
	--text-muted: rgba(255, 255, 255, 0.4);
	--accent-blue: #4fbeff;
	--accent-green: #2b6a4a;
	--border-subtle: rgba(255, 255, 255, 0.1);
	--shadow-inset: 0 2px 10px rgba(0, 0, 0, 0.2) inset, 0 1px 0 rgba(255, 255, 255, 0.05);
	--shadow-subtle: 0 4px 15px rgba(0, 0, 0, 0.1);
	--shadow-strong: 0 10px 30px rgba(0, 0, 0, 0.5);
	--radius-sm: 6px;
	--radius-md: 8px;
	--radius-lg: 12px;
	--transition-normal: all 0.2s ease;
}

html {
	background: var(--bg-dark);
	margin: 0;
	padding: 0;
	width: 100%;
	height: 100%;
	font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
	color: var(--text-primary);
}

body {
	background: linear-gradient(145deg, var(--bg-panel) 0%, #131e2b 100%);
	border: none;
	margin: 0;
	padding: 0;
	width: 100%;
	height: 100vh;
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

/* Responsive adaptations */
@media (max-width: 900px) {
	.main-layout {
		grid-template-columns: 1fr;
		grid-template-rows: 1fr 300px;
	}
	
	.console-panel {
		border-left: none;
		border-top: 1px solid var(--border-subtle);
	}
}

header {
	padding: 15px 20px;
	border-bottom: 1px solid var(--border-subtle);
	display: flex;
	align-items: center;
	justify-content: space-between;
	background: rgba(15, 25, 35, 0.4);
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
	z-index: 10;
	position: relative;
}

h1 {
	font-size: 1.5rem;
	margin: 0;
	font-weight: 600;
	letter-spacing: -0.5px;
	text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Layout Principal avec 2 panneaux */
.main-layout {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 0;
	flex: 1;
	overflow: hidden;
	position: relative;
	transition: grid-template-columns 0.3s ease;
}



/* Content Panel (centre) */
.content-panel {
	background: var(--bg-panel-lighter);
	overflow-y: auto;
	overflow-x: hidden;
	padding: 30px 40px 100px 40px;
	height: 100%;
	position: relative;
}

.exercise-content {
	max-width: 800px;
	margin: 0 auto;
	padding-bottom: 50px;
}

.exercise-content h1 {
	color: var(--accent-blue);
	font-size: 2rem;
	margin-bottom: 1rem;
}

.exercise-content h2 {
	color: var(--text-primary);
	font-size: 1.5rem;
	margin-top: 2rem;
	margin-bottom: 1rem;
	border-bottom: 2px solid var(--border-subtle);
	padding-bottom: 0.5rem;
}

.exercise-content h3 {
	color: var(--text-secondary);
	font-size: 1.2rem;
	margin-top: 1.5rem;
	margin-bottom: 0.8rem;
}

.exercise-content p {
	line-height: 1.6;
	margin-bottom: 1rem;
	color: var(--text-secondary);
}

.exercise-content ul, .exercise-content ol {
	margin-bottom: 1rem;
	padding-left: 1.5rem;
}

.exercise-content li {
	margin-bottom: 0.5rem;
	line-height: 1.6;
	color: var(--text-secondary);
}

.exercise-content code {
	background: rgba(0, 0, 0, 0.3);
	padding: 2px 6px;
	border-radius: 3px;
	font-family: 'JetBrains Mono', monospace;
	font-size: 0.9em;
	color: var(--accent-blue);
}

.exercise-content pre {
	background: rgba(0, 0, 0, 0.3);
	padding: 15px;
	border-radius: var(--radius-md);
	overflow-x: auto;
	margin-bottom: 1rem;
}

.exercise-content pre code {
	background: none;
	padding: 0;
	color: var(--text-primary);
}

.exercise-content details {
	margin: 1rem 0;
	padding: 1rem;
	background: rgba(79, 190, 255, 0.05);
	border-left: 3px solid var(--accent-blue);
	border-radius: var(--radius-sm);
}

.exercise-content summary {
	cursor: pointer;
	font-weight: 600;
	color: var(--accent-blue);
	margin-bottom: 0.5rem;
}

/* Console Panel (droite) */
.console-panel {
	background: var(--bg-panel);
	border-left: 1px solid var(--border-subtle);
	display: flex;
	flex-direction: column;
	height: 100%;
	overflow: hidden;
}

/* Results Area (en bas) */
.results-area {
	background: var(--bg-panel);
	border-top: 1px solid var(--border-subtle);
	display: flex;
	flex-direction: column;
	max-height: 300px;
}

.results-panels {
	flex: 1;
	overflow-y: auto;
	padding: 15px;
}

.app-container {
	display: flex;
	flex: 1;
	overflow-y: auto;
	overflow-x: hidden;
	position: relative;
}

.toolbar {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-right: 60px;
}

.button {
	color: var(--text-primary);
	background: linear-gradient(145deg, var(--bg-panel-lighter) 0%, #162330 100%);
	border: 1px solid var(--border-subtle);
	border-radius: var(--radius-sm);
	padding: 8px 14px;
	transition: var(--transition-normal);
	font-family: inherit;
	font-size: 0.9em;
	font-weight: 500;
	cursor: pointer;
	box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2), 0 1px 0 rgba(255, 255, 255, 0.05) inset;
	display: flex;
	align-items: center;
	gap: 6px;
}

.button:active {
	background: linear-gradient(145deg, #162330 0%, var(--bg-panel-lighter) 100%);
	transform: translateY(1px);
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3) inset;
}

.button:hover, .button:focus {
	box-shadow: 0 0 0 2px rgba(79, 190, 255, 0.3), 0 1px 0 rgba(255, 255, 255, 0.05) inset;
	outline: none;
}

.button svg {
	width: 16px;
	height: 16px;
}

.button-primary {
	background: linear-gradient(145deg, #2b5d8b 0%, #1e4266 100%);
}

.button-primary:hover {
	background: linear-gradient(145deg, #306ca3 0%, #1e4266 100%);
}

.button-success {
	background: linear-gradient(145deg, #2b6a4a 0%, #1e4a33 100%);
}

.button-success:hover {
	background: linear-gradient(145deg, #307a55 0%, #1e4a33 100%);
}

label.button {
	display: inline-flex;
}

input[type="file"] {
	display: none;
}

.panel {
	display: flex;
	flex-direction: column;
	overflow: hidden;
	position: relative;
}

.panel-resizable {
	flex: 1;
	min-width: 300px;
	max-width: calc(100% - 300px);
	position: relative;
}

.editor-panel {
	border-right: 1px solid var(--border-subtle);
}

.results-panel {
	flex: 1;
	display: flex;
	flex-direction: column;
}

.panel-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 10px 15px;
	background: rgba(15, 25, 35, 0.4);
	border-bottom: 1px solid var(--border-subtle);
	font-weight: 500;
	color: var(--text-secondary);
}

/* Small status item shown in panel headers (e.g. Console SQL) */
.panel-header .status-item {
    font-size: 0.85em;
    color: var(--text-secondary);
}

.panel-content {
	flex: 1;
	overflow: auto;
	position: relative;
}

.CodeMirror {
	border: none;
	height: 100% !important;
	background: rgba(15, 25, 35, 0.6);
	box-shadow: var(--shadow-inset);
	font-family: 'JetBrains Mono', 'Fira Code', monospace;
	font-size: 14px;
}

.CodeMirror-gutters {
	background: rgba(15, 25, 35, 0.8);
	border-right: 1px solid var(--border-subtle);
}

.CodeMirror-linenumber {
	color: var(--text-muted);
}

.error {
	color: #ff6b6b;
	transition: .3s;
	overflow: hidden;
	padding: 10px 15px;
	border-radius: var(--radius-sm);
	background: rgba(255, 0, 0, 0.1);
	border-left: 3px solid #ff6b6b;
	margin: 10px;
	opacity: 0;
	height: 0;
}

.results-tabs {
	display: flex;
	background: rgba(15, 25, 35, 0.4);
	border-bottom: 1px solid var(--border-subtle);
	overflow-x: auto;
	scrollbar-width: thin;
}

.tab {
	padding: 8px 16px;
	background: transparent;
	border: none;
	border-right: 1px solid var(--border-subtle);
	color: var(--text-secondary);
	cursor: pointer;
	white-space: nowrap;
	transition: var(--transition-normal);
	font-family: inherit;
	font-size: 0.9em;
}

.tab.active {
	background: rgba(79, 190, 255, 0.1);
	color: var(--accent-blue);
	font-weight: 500;
}

.tab:hover:not(.active) {
	background: rgba(255, 255, 255, 0.05);
}

.tab-close {
	margin-left: 8px;
	opacity: 0.6;
	transition: var(--transition-normal);
}

.tab:hover .tab-close {
	opacity: 1;
}

.results-content {
	flex: 1;
	/* Make the panel a flex column so children can size correctly
	   and an inner element (the table-wrapper) can take the scrolling. */
	display: flex;
	flex-direction: column;
	padding: 15px;
	background: rgba(15, 25, 35, 0.4);
	box-shadow: var(--shadow-inset);
	/* Let the inner .table-wrapper handle scrolling (vertical/horizontal)
	   to ensure the table can fill the available height. */
	overflow: visible;
	min-height: 0; /* allow flex children to shrink and scroll */
}

.tab-panel {
	display: none;
	height: 100%;
	overflow: visible;
	/* ensure flex children can size correctly when active */
	min-height: 0;
}

.tab-panel.active {
	/* Use flex layout so results-content + table-wrapper can size and scroll
	   independently inside the panel */
	display: flex;
	flex-direction: column;
	min-height: 0;
}

/* Schema Tab Styles */
.schema-tab {
	background: rgba(79, 190, 255, 0.05);
	border-right: 2px solid var(--accent-blue);
	font-weight: 500;
}

.schema-content {
	padding: 0;
	max-width: 1200px;
	margin: -15px -15px 0 -15px; /* Compensate parent padding */
	padding: 15px;
}

.schema-section {
	margin-bottom: 0;
	background: transparent;
	border: none;
	border-radius: 0;
	padding: 0;
	box-shadow: none;
}

.schema-section h3 {
	margin: 0 0 15px 0;
	color: var(--accent-blue);
	font-size: 1.2em;
	font-weight: 600;
	border-bottom: 2px solid rgba(79, 190, 255, 0.3);
	padding-bottom: 10px;
}

.schema-diagram {
	text-align: center;
	padding: 20px;
	min-height: 200px;
	display: flex;
	align-items: center;
	justify-content: center;
}

.schema-diagram img {
	max-width: 100%;
	height: auto;
	border-radius: var(--radius-sm);
	box-shadow: var(--shadow-strong);
	background: white;
	padding: 10px;
}

.schema-placeholder {
	color: var(--text-muted);
	font-style: italic;
}

.schema-link {
	display: inline-flex;
	align-items: center;
	padding: 12px 20px;
	background: rgba(79, 190, 255, 0.1);
	border: 1px solid var(--accent-blue);
	border-radius: var(--radius-md);
	color: var(--accent-blue);
	text-decoration: none;
	font-weight: 500;
	transition: var(--transition-normal);
}

.schema-link:hover {
	background: rgba(79, 190, 255, 0.2);
	border-color: var(--accent-blue);
	box-shadow: 0 4px 12px rgba(79, 190, 255, 0.2);
	transform: translateY(-1px);
}

.schema-link:active {
	transform: translateY(0);
}

.schema-link svg {
	flex-shrink: 0;
}

.schema-details {
	display: grid;
	gap: 0;
}

.table-info {
	background: transparent;
	border: none;
	border-bottom: 1px solid var(--border-subtle);
	border-radius: 0;
	padding: 8px 0;
	transition: var(--transition-normal);
}

.table-info:last-child {
	border-bottom: none;
}

.table-info:hover {
	background: rgba(79, 190, 255, 0.05);
	border-bottom-color: var(--accent-blue);
}

.table-name {
	font-size: 1.1em;
	font-weight: 600;
	color: var(--accent-blue);
	margin-bottom: 10px;
	display: flex;
	align-items: center;
	gap: 8px;
}

.table-name::before {
	content: "📋";
	font-size: 1.2em;
}

.table-signature {
	font-family: 'Fira Code', 'JetBrains Mono', monospace;
	font-size: 0.9em;
	line-height: 1.4;
	color: var(--text-primary);
	padding: 0;
	background: transparent;
	border: none;
	border-radius: 0;
	border-left: none;
}

.table-keyword {
	color: var(--accent-blue);
	font-weight: 600;
	text-transform: uppercase;
	font-size: 0.85em;
}

.columns-list {
	list-style: none;
	padding: 0;
	margin: 0;
}

.column-item {
	padding: 6px 10px;
	margin: 3px 0;
	background: rgba(255, 255, 255, 0.02);
	border-radius: 4px;
	font-family: 'Fira Code', 'JetBrains Mono', monospace;
	font-size: 0.9em;
	display: flex;
	align-items: center;
	gap: 8px;
}

.column-item:hover {
	background: rgba(255, 255, 255, 0.05);
}

.column-name {
	color: var(--text-primary);
	font-weight: 500;
}

.column-type {
	color: var(--text-secondary);
	font-size: 0.85em;
}

.key-badge {
	display: inline-block;
	padding: 2px 6px;
	border-radius: 3px;
	font-size: 0.75em;
	font-weight: 600;
	text-transform: uppercase;
	margin-left: auto;
}

.key-badge.primary {
	background: rgba(79, 190, 255, 0.2);
	color: var(--accent-blue);
	border: 1px solid var(--accent-blue);
}

.key-badge.foreign {
	background: rgba(255, 193, 7, 0.2);
	color: #ffc107;
	border: 1px solid #ffc107;
}

.resizer {
	width: 6px;
	cursor: col-resize;
	background: transparent;
	position: absolute;
	top: 0;
	right: -3px;
	bottom: 0;
	z-index: 10;
	transition: background 0.2s;
}

.resizer:hover, .resizer.active {
	background: rgba(79, 190, 255, 0.3);
}

table {
	width: 100%;
	margin: 0 0 20px 0;
	border: 1px solid var(--border-subtle);
	border-collapse: collapse;
	border-radius: var(--radius-sm);
	overflow: hidden;
	box-shadow: var(--shadow-subtle);
	background: rgba(30, 40, 50, 0.4);
}

thead {
	background: rgba(40, 60, 80, 0.6);
	position: sticky;
	top: 0;
	z-index: 10;
}

th {
	text-align: left;
	padding: 12px 15px;
	font-weight: 600;
	color: var(--accent-blue);
	border-bottom: 1px solid var(--border-subtle);
}

td {
	padding: 10px 15px;
	border-bottom: 1px solid rgba(255, 255, 255, 0.05);
	font-family: 'Fira Code', 'JetBrains Mono', 'Cascadia Code', 'Source Code Pro', 'Roboto Mono', 'IBM Plex Mono', 'Ubuntu Mono', 'Inconsolata', 'Consolas', 'Menlo', 'Monaco', 'Courier New', monospace;
	white-space: break-spaces;
	font-size: 1rem;
}

tr:last-child td {
	border-bottom: none;
}

tr:nth-child(even) {
	background: rgba(255, 255, 255, 0.03);
}

.table-wrapper {
	 margin-bottom: 0; /* let the wrapper fill the available vertical space */
	 /* Allow both horizontal and vertical scrolling inside the wrapper so
		 the table can take the full panel height and scroll internally. */
	 flex: 1 1 auto;
	 min-height: 0;
	 overflow: auto;
	 -webkit-overflow-scrolling: touch;
}

.table-wrapper table {
	width: max-content; /* size to content so parent can scroll */
	min-width: 100%;
	border-collapse: collapse;
}

.table-wrapper table th,
.table-wrapper table td {
	white-space: nowrap; /* prevent wrapping so columns remain side-by-side */
}

/* Top scrollbar above wide tables so users can scroll horizontally without
   having to reach the bottom of the table. */
.table-scroll-top {
	height: 12px;
	overflow-x: auto;
	overflow-y: hidden;
	-webkit-overflow-scrolling: touch;
	background: transparent;
	margin-bottom: 6px;
}
.table-scroll-top-inner {
	height: 1px; /* minimal height; width is driven by JS */
}

/* Make the top scroller visually unobtrusive while keeping native scrollbar */
.table-scroll-top::-webkit-scrollbar {
	height: 8px;
}
.table-scroll-top::-webkit-scrollbar-thumb {
	background: rgba(79,190,255,0.18); /* soft blue tint */
	border-radius: 6px;
	box-shadow: 0 0 0 3px rgba(15,25,35,0.35) inset; /* subtle inset to improve contrast */
}
.table-scroll-top::-webkit-scrollbar-track {
	background: transparent;
}

/* Firefox scrollbar coloring */
.table-scroll-top {
	scrollbar-color: rgba(79,190,255,0.25) transparent; /* thumb track */
}

/* On hover make thumb stronger */
.table-scroll-top:hover::-webkit-scrollbar-thumb {
	background: rgba(79,190,255,0.28);
}
.table-scroll-top:hover {
	scrollbar-color: rgba(79,190,255,0.35) transparent;
}

.table-caption {
	color: var(--text-secondary);
	font-size: 0.85em;
	margin-bottom: 8px;
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.loading {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-direction: column;
	height: 100%;
	color: var(--text-secondary);
}

.spinner {
	width: 30px;
	height: 30px;
	border: 3px solid rgba(79, 190, 255, 0.3);
	border-radius: 50%;
	border-top-color: var(--accent-blue);
	animation: spin 1s ease-in-out infinite;
	margin-bottom: 15px;
}

@keyframes spin {
	to { transform: rotate(360deg); }
}

.no-results {
	color: var(--text-muted);
	text-align: center;
	padding: 30px;
}

.notification {
	position: fixed;
	bottom: -60px;
	left: 50%;
	transform: translateX(-50%);
	background: rgba(40, 60, 80, 0.9);
	color: #fff;
	padding: 12px 20px;
	border-radius: var(--radius-md);
	box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
	transition: bottom 0.3s ease;
	z-index: 10001;
	border-left: 3px solid var(--accent-blue);
}

.notification.show {
	bottom: 20px;
}

.button.active {
	transform: translateY(1px);
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3) inset;
}

.status-bar {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 6px 15px;
	background: rgba(15, 25, 35, 0.8);
	border-top: 1px solid var(--border-subtle);
	font-size: 0.8em;
	color: var(--text-secondary);
}

.status-item {
	display: flex;
	align-items: center;
	gap: 6px;
}

.status-success {
	color: #4ade80;
}

.status-error {
	color: #ff6b6b;
}

.status-info {
	color: var(--accent-blue);
}

.shortcuts {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-left: auto;
}

.shortcuts span {
	display: flex;
	align-items: center;
	margin-left: 8px;
	color: var(--text-muted);
}

.shortcut-key {
	background: rgba(255, 255, 255, 0.1);
	padding: 2px 6px;
	border-radius: 3px;
	font-family: 'JetBrains Mono', monospace;
	font-size: 0.85em;
	margin-left: 4px;
	color: var(--text-secondary);
}

footer {
	font-size: 0.65em;
	color: var(--text-muted);
	text-align: center;
	padding: 4px 0;
	background: rgba(15, 25, 35, 0.8);
	border-top: 1px solid var(--border-subtle);
	flex-shrink: 0;
}

footer a {
	color: var(--accent-blue);
	text-decoration: none;
}

footer a:hover {
	text-decoration: underline;
}

.query-history {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	background: rgba(30, 40, 50, 0.95);
	border: 1px solid var(--border-subtle);
	max-height: 0;
	height: 0;
	opacity: 0;
	visibility: hidden;
	overflow: hidden;
	transition: all 0.3s ease;
	z-index: 100;
	box-shadow: none;
	border-radius: var(--radius-md);
	margin: 10px;
}

.query-history.show {
	max-height: 400px;
	height: auto;
	opacity: 1;
	visibility: visible;
	overflow-y: auto;
	box-shadow: 0 0 20px rgba(79, 190, 255, 0.2), var(--shadow-strong);
}

.query-history-empty {
	padding: 20px;
	text-align: center;
	color: var(--text-muted);
	font-style: italic;
}

.history-item {
	padding: 8px 15px;
	border-bottom: 1px solid var(--border-subtle);
	cursor: pointer;
	transition: var(--transition-normal);
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.history-item:hover {
	background: rgba(255, 255, 255, 0.05);
}

.history-item.snippet {
	background: rgba(43, 106, 74, 0.1);
	border-left: 3px solid var(--accent-green);
}

.history-item.snippet:hover {
	background: rgba(43, 106, 74, 0.2);
}

.history-query {
	font-family: 'JetBrains Mono', monospace;
	font-size: 0.85em;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 80%;
}

.history-time {
	color: var(--text-muted);
	font-size: 0.8em;
}

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

::-webkit-scrollbar-track {
	background: rgba(0, 0, 0, 0.1);
	border-radius: 4px;
}

::-webkit-scrollbar-thumb {
	background: rgba(255, 255, 255, 0.1);
	border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
	background: rgba(255, 255, 255, 0.2);
}

@media (max-width: 768px) {
	.app-container {
		flex-direction: column;
	}
	
	.panel-resizable {
		max-width: 100%;
		width: 100% !important;
		height: 50%;
		min-height: 200px;
		max-height: calc(100% - 200px);
	}
	
	.editor-panel {
		border-right: none;
		border-bottom: 1px solid var(--border-subtle);
	}
	
	.resizer {
		width: 100%;
		height: 6px;
		cursor: row-resize;
		right: 0;
		bottom: -3px;
		top: auto;
	}
	
	.shortcuts {
		display: none;
	}
	
	.toolbar {
		margin-right: 50px;
	}
	
	.button {
		padding: 6px 10px;
		font-size: 0.8em;
	}
	
	h1 {
		font-size: 1.2rem;
	}
}

body.resizing {
	cursor: col-resize;
	user-select: none;
}

@media (max-width: 768px) {
	body.resizing {
		cursor: row-resize;
	}
}

.error-result {
	color: #ff6b6b;
	border-left: 3px solid #ff6b6b;
	background: rgba(255, 0, 0, 0.05);
}

.github-corner:hover .octo-arm {
	animation: octocat-wave 560ms ease-in-out;
}

.github-corner {
	z-index: 20;
	position: absolute;
	top: 0;
	right: 0;
}

.github-corner svg {
	opacity: 0.7;
	transition: opacity 0.3s ease;
}

.github-corner:hover svg {
	opacity: 1;
}

@keyframes octocat-wave {
	0%, 100% { transform: rotate(0); }
	20%, 60% { transform: rotate(-25deg); }
	40%, 80% { transform: rotate(10deg); }
}

@media (max-width: 500px) {
	.github-corner:hover .octo-arm {
		animation: none;
	}
	.github-corner .octo-arm {
		animation: octocat-wave 560ms ease-in-out;
	}
	.github-corner svg {
		width: 50px;
		height: 50px;
	}
}

.actions {
	display: flex;
	flex-wrap: wrap;
	margin: 15px 0;
}

.results-header, .editor-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 8px;
	color: rgba(255, 255, 255, 0.7);
	font-weight: 500;
}

/* SQL Snippets Menu */
.snippets-menu {
	position: absolute;
	background: rgba(30, 40, 50, 0.95);
	border: 1px solid var(--border-subtle);
	max-height: 0;
	width: 220px;
	opacity: 0;
	visibility: hidden;
	overflow: hidden;
	transition: all 0.3s ease;
	z-index: 100;
	box-shadow: none;
	border-radius: var(--radius-md);
	right: 15px;
	top: 45px;
}

.snippets-menu.show {
	max-height: 400px;
	opacity: 1;
	visibility: visible;
	overflow-y: auto;
	box-shadow: var(--shadow-strong);
}

.snippet-item {
	padding: 10px 14px;
	border-bottom: 1px solid var(--border-subtle);
	cursor: pointer;
	transition: var(--transition-normal);
	font-size: 0.9em;
}

.snippet-item:hover {
	background: rgba(79, 190, 255, 0.1);
	color: var(--accent-blue);
}

.snippet-item:last-child {
	border-bottom: none;
}

.button-icon {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	padding: 0;
	border-radius: 4px;
}

.button-icon svg {
	width: 16px;
	height: 16px;
}

.button-icon.active {
	background: rgba(79, 190, 255, 0.2);
}

/* CodeMirror Autocompletion Styles */
.CodeMirror-hint {
	font-family: 'JetBrains Mono', monospace;
	font-size: 13px;
	color: var(--text-primary);
	background-color: var(--bg-panel);
	padding: 8px 12px;
	cursor: pointer;
	white-space: nowrap;
	border-bottom: 1px solid rgba(255, 255, 255, 0.05);
	display: flex;
	align-items: center;
	gap: 10px;
	transition: all 0.15s ease;
}

.CodeMirror-hint:hover {
	background-color: var(--bg-panel-lighter);
	color: var(--accent-blue);
	padding-left: 16px;
}

.CodeMirror-hint.CodeMirror-hint-active {
	background-color: rgba(79, 190, 255, 0.25);
	color: var(--accent-blue);
	border-left: 3px solid var(--accent-blue);
	padding-left: 13px;
	font-weight: 500;
}

.CodeMirror-hints {
	background-color: var(--bg-panel) !important;
	border: 1px solid rgba(79, 190, 255, 0.3) !important;
	border-radius: var(--radius-md);
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(79, 190, 255, 0.1) !important;
	max-height: 280px;
	overflow-y: auto;
	padding: 4px 0;
	min-width: 200px;
	z-index: 9999 !important;
}

.CodeMirror-hints::-webkit-scrollbar {
	width: 8px;
}

.CodeMirror-hints::-webkit-scrollbar-track {
	background: rgba(255, 255, 255, 0.05);
	border-radius: 4px;
}

.CodeMirror-hints::-webkit-scrollbar-thumb {
	background: rgba(79, 190, 255, 0.3);
	border-radius: 4px;
}

.CodeMirror-hints::-webkit-scrollbar-thumb:hover {
	background: rgba(79, 190, 255, 0.5);
}

/* Icônes pour les différents types d'éléments */
.hint-icon {
	width: 18px;
	height: 18px;
	border-radius: 4px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 10px;
	font-weight: 600;
	flex-shrink: 0;
}

.hint-icon.cm-hint-keyword {
	background: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
	color: white;
}

.hint-icon.cm-hint-keyword::before {
	content: 'K';
}

.hint-icon.cm-hint-table {
	background: linear-gradient(135deg, #10b981 0%, #34d399 100%);
	color: white;
}

.hint-icon.cm-hint-table::before {
	content: 'T';
}

.hint-icon.cm-hint-column {
	background: linear-gradient(135deg, #3b82f6 0%, #60a5fa 100%);
	color: white;
}

.hint-icon.cm-hint-column::before {
	content: 'C';
}

.hint-text {
	flex: 1;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* Animation d'apparition des hints */
@keyframes hintFadeIn {
	from {
		opacity: 0;
		transform: translateY(-5px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.CodeMirror-hints {
	animation: hintFadeIn 0.15s ease;
}

/* Suppression des anciens styles */
.cm-hint-keyword::after,
.cm-hint-table::after,
.cm-hint-column::after {
	display: none;
}

/* Modal d'historique */
.modal {
	display: none;
	position: fixed;
	z-index: 10000;
	left: 0;
	top: 0;
	width: 100%;
	height: 100%;
	background-color: rgba(0, 0, 0, 0.7);
	backdrop-filter: blur(4px);
}

.modal.show {
	display: flex;
	align-items: center;
	justify-content: center;
	animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
	from { opacity: 0; }
	to { opacity: 1; }
}

.modal-content {
	background: var(--bg-panel);
	border-radius: var(--radius-lg);
	box-shadow: var(--shadow-strong);
	width: 90%;
	max-width: 900px;
	max-height: 85vh;
	display: flex;
	flex-direction: column;
	border: 1px solid rgba(79, 190, 255, 0.2);
	animation: slideUp 0.3s ease;
}

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

.modal-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 20px 24px;
	border-bottom: 1px solid var(--border-subtle);
}

.modal-header h2 {
	margin: 0;
	font-size: 20px;
	font-weight: 600;
	color: var(--text-primary);
}

.modal-close {
	background: transparent;
	border: none;
	color: var(--text-secondary);
	font-size: 32px;
	cursor: pointer;
	padding: 0;
	width: 32px;
	height: 32px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: var(--radius-sm);
	transition: var(--transition-normal);
}

.modal-close:hover {
	background: rgba(255, 255, 255, 0.1);
	color: var(--text-primary);
}

.modal-body {
	padding: 20px 24px;
	overflow: hidden;
	display: flex;
	flex-direction: column;
	flex: 1;
}

.history-toolbar {
	display: flex;
	gap: 12px;
	margin-bottom: 20px;
	flex-wrap: wrap;
}

.button-sm {
	padding: 8px 16px;
	font-size: 13px;
	display: flex;
	align-items: center;
	gap: 8px;
}

.button-sm svg {
	width: 16px;
	height: 16px;
}

.button-danger {
	background: rgba(220, 38, 38, 0.2);
	border-color: rgba(220, 38, 38, 0.3);
	color: #fca5a5;
}

.button-danger:hover {
	background: rgba(220, 38, 38, 0.3);
	border-color: rgba(220, 38, 38, 0.5);
}

.history-list {
	overflow-y: auto;
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 12px;
	padding-right: 8px;
}

.history-list::-webkit-scrollbar {
	width: 8px;
}

.history-list::-webkit-scrollbar-track {
	background: rgba(255, 255, 255, 0.05);
	border-radius: 4px;
}

.history-list::-webkit-scrollbar-thumb {
	background: rgba(79, 190, 255, 0.3);
	border-radius: 4px;
}

.history-list::-webkit-scrollbar-thumb:hover {
	background: rgba(79, 190, 255, 0.5);
}

.history-empty {
	text-align: center;
	color: var(--text-muted);
	padding: 60px 20px;
	font-size: 14px;
}

.history-item-card {
	background: var(--bg-panel-lighter);
	border: 1px solid var(--border-subtle);
	border-radius: var(--radius-md);
	padding: 16px;
	transition: var(--transition-normal);
}

.history-item-card:hover {
	border-color: rgba(79, 190, 255, 0.3);
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.history-item-header {
	display: flex;
	gap: 12px;
	align-items: center;
	margin-bottom: 12px;
	font-size: 12px;
	color: var(--text-muted);
}

.history-item-number {
	color: var(--accent-blue);
	font-weight: 600;
	font-family: 'JetBrains Mono', monospace;
}

.history-item-time {
	flex: 1;
}

.history-item-exec-time {
	background: rgba(79, 190, 255, 0.1);
	padding: 2px 8px;
	border-radius: 4px;
	font-family: 'JetBrains Mono', monospace;
	color: var(--accent-blue);
}

.history-item-query {
	background: var(--bg-dark);
	border: 1px solid var(--border-subtle);
	border-radius: var(--radius-sm);
	padding: 12px;
	margin: 0 0 12px 0;
	font-family: 'JetBrains Mono', monospace;
	font-size: 13px;
	color: var(--text-primary);
	overflow-x: auto;
	white-space: pre-wrap;
	word-wrap: break-word;
	max-height: 200px;
	overflow-y: auto;
}

.history-item-query::-webkit-scrollbar {
	height: 6px;
	width: 6px;
}

.history-item-query::-webkit-scrollbar-track {
	background: rgba(255, 255, 255, 0.05);
	border-radius: 3px;
}

.history-item-query::-webkit-scrollbar-thumb {
	background: rgba(79, 190, 255, 0.2);
	border-radius: 3px;
}

.history-item-actions {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
}

.history-action-btn {
	background: transparent;
	border: 1px solid var(--border-subtle);
	color: var(--text-secondary);
	padding: 6px 12px;
	border-radius: var(--radius-sm);
	cursor: pointer;
	font-size: 12px;
	font-family: 'Inter', sans-serif;
	display: flex;
	align-items: center;
	gap: 6px;
	transition: var(--transition-normal);
}

.history-action-btn svg {
	width: 14px;
	height: 14px;
}

.history-action-btn:hover {
	background: rgba(79, 190, 255, 0.1);
	border-color: rgba(79, 190, 255, 0.3);
	color: var(--accent-blue);
}

.history-action-btn.delete-query:hover {
	background: rgba(220, 38, 38, 0.1);
	border-color: rgba(220, 38, 38, 0.3);
	color: #fca5a5;
}

/* ==========================================
   BLOCS SQL CLIQUABLES AVEC PRISM.JS
   ========================================== */

/* Bloc SQL cliquable - Style de base */
pre.sql-clickable {
	position: relative;
	border: 1px solid rgba(79, 190, 255, 0.2);
	border-radius: var(--radius-md);
	transition: all 0.2s ease;
	cursor: pointer;
	user-select: none;
}

pre.sql-clickable:hover {
	border-color: rgba(79, 190, 255, 0.5);
	transform: translateY(-1px);
	box-shadow: 0 4px 12px rgba(79, 190, 255, 0.15);
}

/* Icône de lecture */
.sql-click-icon {
	position: absolute;
	top: 8px;
	right: 8px;
	width: 24px;
	height: 24px;
	background: rgba(79, 190, 255, 0.2);
	border-radius: 4px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 12px;
	color: var(--accent-blue);
	opacity: 0.5;
	transition: all 0.2s ease;
	pointer-events: none;
	z-index: 10;
}

pre.sql-clickable:hover .sql-click-icon {
	opacity: 1;
	background: rgba(79, 190, 255, 0.3);
	transform: scale(1.1);
}

/* Coloration syntaxique Prism.js - Tokens SQL */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
	color: #6a9955;
	font-style: italic;
}

.token.punctuation {
	color: #d4d4d4;
}

.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted {
	color: #b5cea8;
}

.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
	color: #ce9178;
}

.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
	color: #d4d4d4;
}

.token.atrule,
.token.attr-value,
.token.keyword {
	color: #c586c0;
}

.token.function,
.token.class-name {
	color: #dcdcaa;
}

.token.regex,
.token.important,
.token.variable {
	color: #d16969;
}

/* Tokens SQL spécifiques */
.token.keyword {
	color: #569cd6;
	font-weight: 600;
}

.token.string {
	color: #ce9178;
}

.token.number {
	color: #b5cea8;
}

.token.operator {
	color: #d4d4d4;
}

.token.punctuation {
	color: #d4d4d4;
}

/* Blocs de code pre/code */
pre[class*="language-"] {
	background: var(--bg-panel);
	padding: 16px;
	border-radius: var(--radius-md);
	overflow: auto;
	margin: 16px 0;
	line-height: 1.5;
	font-family: 'JetBrains Mono', 'Courier New', monospace;
	font-size: 14px;
}

code[class*="language-"] {
	font-family: 'JetBrains Mono', 'Courier New', monospace;
	font-size: 14px;
	line-height: 1.5;
	color: var(--text-primary);
	text-shadow: none;
}

/* Inline code (non Prism) */
:not(pre) > code {
	background: rgba(79, 190, 255, 0.1);
	color: var(--accent-blue);
	padding: 2px 6px;
	border-radius: 4px;
	font-family: 'JetBrains Mono', 'Courier New', monospace;
	font-size: 0.9em;
}

/* ============================================
   ONGLET SCHÉMA - DIAGRAMME ET STRUCTURE
   ============================================ */

.schema-tab {
	background: rgba(79, 190, 255, 0.05);
	border-right: 2px solid var(--accent-blue);
	font-weight: 500;
}

.schema-content {
	padding: 0;
	max-width: 1200px;
	margin: -15px -15px 0 -15px; /* Compensate parent padding */
	padding: 15px;
}

.schema-section {
	margin-bottom: 0;
	background: transparent;
	border: none;
	border-radius: 0;
	padding: 0;
	box-shadow: none;
}

.schema-section h3 {
	margin: 0 0 15px 0;
	color: var(--accent-blue);
	font-size: 1.2em;
	font-weight: 600;
	border-bottom: 2px solid rgba(79, 190, 255, 0.3);
	padding-bottom: 10px;
}

.schema-diagram {
	text-align: center;
	padding: 0;
	min-height: auto;
	display: block;
}

.schema-diagram img {
	max-width: 100%;
	height: auto;
	border-radius: var(--radius-sm);
	box-shadow: var(--shadow-strong);
	background: white;
	padding: 10px;
}

.schema-placeholder {
	color: var(--text-muted);
	font-style: italic;
}

.schema-link {
	display: inline-flex;
	align-items: center;
	padding: 12px 20px;
	background: rgba(79, 190, 255, 0.1);
	border: 1px solid var(--accent-blue);
	border-radius: var(--radius-md);
	color: var(--accent-blue);
	text-decoration: none;
	font-weight: 500;
	transition: var(--transition-normal);
}

.schema-link:hover {
	background: rgba(79, 190, 255, 0.2);
	border-color: var(--accent-blue);
	box-shadow: 0 4px 12px rgba(79, 190, 255, 0.2);
	transform: translateY(-1px);
}

.schema-link:active {
	transform: translateY(0);
}

.schema-link svg {
	flex-shrink: 0;
}

.schema-details {
	display: grid;
	gap: 0;
}

.table-info {
	background: transparent;
	border: none;
	border-bottom: 1px solid var(--border-subtle);
	border-radius: 0;
	padding: 8px 0;
	transition: var(--transition-normal);
}

.table-info:hover {
	background: rgba(79, 190, 255, 0.02);
}

.table-name {
	font-size: 1.1em;
	font-weight: 600;
	color: var(--accent-blue);
	margin-bottom: 10px;
	display: flex;
	align-items: center;
	gap: 8px;
}

.table-name::before {
	content: "📋";
	font-size: 1.2em;
}

.columns-list {
	list-style: none;
	padding: 0;
	margin: 0;
}

.column-item {
	padding: 6px 10px;
	margin: 3px 0;
	background: rgba(255, 255, 255, 0.02);
	border-radius: 4px;
	font-family: 'Fira Code', 'JetBrains Mono', monospace;
	font-size: 0.9em;
	display: flex;
	align-items: center;
	gap: 8px;
}

.column-item:hover {
	background: rgba(255, 255, 255, 0.05);
}

.column-name {
	color: var(--text-primary);
	font-weight: 500;
}

.column-type {
	color: var(--text-secondary);
	font-size: 0.85em;
}

.key-badge {
	display: inline-block;
	padding: 2px 6px;
	border-radius: 3px;
	font-size: 0.75em;
	font-weight: 600;
	text-transform: uppercase;
	margin-left: auto;
}

.key-badge.primary {
	background: rgba(79, 190, 255, 0.2);
	color: var(--accent-blue);
	border: 1px solid var(--accent-blue);
}

.key-badge.foreign {
	background: rgba(255, 193, 7, 0.2);
	color: #ffc107;
	border: 1px solid #ffc107;
}

.table-signature {
	font-family: 'Fira Code', 'JetBrains Mono', monospace;
	font-size: 0.9em;
	line-height: 1.4;
	color: var(--text-primary);
	padding: 0;
	background: transparent;
	border: none;
	border-radius: 0;
	border-left: none;
}

/* Navigation entre exercices */
.exercise-navigation {
	display: flex;
	justify-content: space-between;
	margin-top: 60px;
	padding-top: 30px;
	border-top: 1px solid var(--border-subtle);
	gap: 20px;
}

.nav-btn {
	display: flex;
	align-items: center;
	text-decoration: none;
	padding: 15px 20px;
	background: var(--bg-panel);
	border: 1px solid var(--border-subtle);
	border-radius: var(--radius-md);
	transition: var(--transition-normal);
	flex: 1;
	max-width: 45%;
	color: var(--text-primary);
}

.nav-btn:hover {
	background: rgba(79, 190, 255, 0.1);
	border-color: var(--accent-blue);
	transform: translateY(-2px);
	box-shadow: var(--shadow-subtle);
}

.nav-btn svg {
	flex-shrink: 0;
	color: var(--accent-blue);
}

.prev-btn svg {
	margin-right: 15px;
}

.next-btn {
	text-align: right;
	justify-content: flex-end;
}

.next-btn svg {
	margin-left: 15px;
}

.nav-text {
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.nav-label {
	font-size: 0.8em;
	text-transform: uppercase;
	letter-spacing: 1px;
	color: var(--text-muted);
	font-weight: 600;
}

.nav-title {
	font-weight: 500;
	color: var(--text-primary);
}

.nav-placeholder {
	flex: 1;
}

