/* =========================================================
   P-32 — styles applicatifs (landing, auth, espace de travail)
   S'appuie sur les variables CSS du thème (Bootstrap 5 / Keen)
   ========================================================= */

/* ---------- Identité ---------- */
.p32-logo-mark {
	font-weight: 800;
	font-size: 1.45rem;
	letter-spacing: 0.04em;
	background: linear-gradient(135deg, var(--bs-primary) 0%, #9b7bff 100%);
	-webkit-background-clip: text;
	background-clip: text;
	-webkit-text-fill-color: transparent;
	color: var(--bs-primary);
}

.p32-gradient-text {
	background: linear-gradient(135deg, var(--bs-primary) 0%, #9b7bff 60%, #5ad1e6 100%);
	-webkit-background-clip: text;
	background-clip: text;
	-webkit-text-fill-color: transparent;
}

.p32-hero-title {
	font-size: clamp(2.6rem, 6vw, 4.2rem);
	font-weight: 800;
	line-height: 1.08;
	letter-spacing: -0.02em;
}

.p32-inline-code {
	background: var(--bs-gray-200);
	color: var(--bs-primary);
	border-radius: 0.35rem;
	padding: 0.1rem 0.45rem;
	font-size: 0.85em;
}

.p32-footer-logo {
	opacity: 0.45;
	filter: grayscale(35%);
	transition: opacity 0.2s ease, filter 0.2s ease;
}

.p32-footer-logo:hover {
	opacity: 1;
	filter: none;
}

.p32-kbd {
	display: inline-block;
	padding: 0.1rem 0.5rem;
	border-radius: 0.35rem;
	border: 1px solid var(--bs-gray-300);
	border-bottom-width: 2px;
	background: var(--bs-gray-100);
	color: var(--bs-gray-700);
	font-size: 0.75rem;
	font-weight: 600;
}

/* ---------- Landing ---------- */
.p32-feature-card {
	border: 1px solid var(--bs-gray-200);
	transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.p32-feature-card:hover {
	transform: translateY(-4px);
	border-color: var(--bs-primary);
	box-shadow: 0 1rem 2.5rem rgba(0, 0, 0, 0.08);
}

.p32-cta-card {
	background: linear-gradient(135deg, var(--bs-primary) 0%, #7c5cff 100%);
	border: 0;
	overflow: hidden;
}

.p32-hero-graph {
	color: var(--bs-primary);
}

.p32-node {
	fill: var(--bs-primary);
	opacity: 0.85;
	animation: p32-pulse 3.2s ease-in-out infinite;
	transform-origin: center;
	transform-box: fill-box;
}

.p32-node-main {
	fill: #9b7bff;
}

@keyframes p32-pulse {
	0%, 100% { transform: scale(1); opacity: 0.85; }
	50% { transform: scale(1.18); opacity: 1; }
}

.p32-vault-card {
	border: 1px solid var(--bs-gray-200);
	transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.p32-vault-card:hover {
	transform: translateY(-3px);
	box-shadow: 0 0.75rem 2rem rgba(0, 0, 0, 0.09);
}

/* =========================================================
   Espace de travail
   ========================================================= */
.p32-workspace-body {
	overflow: hidden;
}

.p32-workspace {
	display: flex;
	height: 100vh;
	width: 100vw;
	background: var(--bs-body-bg);
}

/* ---------- Rail ---------- */
.p32-rail {
	width: 58px;
	flex-shrink: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	padding: 0.9rem 0;
	background: var(--bs-gray-100);
	border-right: 1px solid var(--bs-gray-200);
	z-index: 20;
}

.p32-rail-logo {
	font-weight: 800;
	font-size: 0.8rem;
	letter-spacing: 0.03em;
	color: var(--bs-primary);
	text-decoration: none;
	margin-bottom: 1.4rem;
}

.p32-rail-logo:hover { color: #9b7bff; }

.p32-rail-group {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.35rem;
}

.p32-rail-bottom {
	margin-top: auto;
}

.p32-rail-btn {
	width: 40px;
	height: 40px;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 0;
	border-radius: 0.6rem;
	background: transparent;
	color: var(--bs-gray-600);
	transition: background 0.15s ease, color 0.15s ease;
}

.p32-rail-btn:hover,
.p32-rail-btn.is-active {
	background: var(--bs-gray-200);
	color: var(--bs-primary);
}

.p32-rail-btn i { color: inherit; }

.p32-rail-sykerio {
	height: 22px;
	margin-top: 0.7rem;
	opacity: 0.4;
	filter: grayscale(40%);
	border-radius: 0.3rem;
	transition: opacity 0.2s ease, filter 0.2s ease;
}

.p32-rail-sykerio:hover { opacity: 1; filter: none; }

/* ---------- Explorateur ---------- */
.p32-explorer {
	width: 280px;
	flex-shrink: 0;
	display: flex;
	flex-direction: column;
	background: var(--bs-gray-100);
	border-right: 1px solid var(--bs-gray-200);
	transition: margin-left 0.2s ease;
}

.p32-explorer.is-collapsed {
	margin-left: -280px;
}

.p32-explorer-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0.9rem 1rem 0.6rem;
	gap: 0.5rem;
}

.p32-vault-name {
	font-weight: 700;
	font-size: 0.95rem;
	color: var(--bs-gray-800);
	display: flex;
	align-items: center;
	min-width: 0;
}

.p32-explorer-actions {
	display: flex;
	gap: 0.15rem;
	flex-shrink: 0;
}

.p32-icon-btn {
	width: 30px;
	height: 30px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border: 0;
	border-radius: 0.5rem;
	background: transparent;
	color: var(--bs-gray-500);
	transition: background 0.15s ease, color 0.15s ease;
}

.p32-icon-btn:hover {
	background: var(--bs-gray-200);
	color: var(--bs-gray-800);
}

.p32-icon-btn i { color: inherit; }

.p32-explorer-tabs {
	display: flex;
	gap: 0.25rem;
	padding: 0 1rem 0.6rem;
	border-bottom: 1px solid var(--bs-gray-200);
}

.p32-tab {
	flex: 1;
	border: 0;
	background: transparent;
	color: var(--bs-gray-500);
	font-size: 0.8rem;
	font-weight: 600;
	padding: 0.35rem 0.4rem;
	border-radius: 0.5rem;
	transition: background 0.15s ease, color 0.15s ease;
}

.p32-tab:hover { color: var(--bs-gray-800); }

.p32-tab.is-active {
	background: var(--bs-gray-200);
	color: var(--bs-primary);
}

.p32-explorer-body {
	flex: 1;
	overflow-y: auto;
	padding: 0.6rem 0.6rem 1rem;
}

/* Arborescence */
.p32-tree-folder-row,
.p32-tree-note {
	display: flex;
	align-items: center;
	gap: 0.4rem;
	width: 100%;
	padding: 0.28rem 0.5rem;
	border-radius: 0.45rem;
	color: var(--bs-gray-700);
	font-size: 0.86rem;
	cursor: pointer;
	user-select: none;
	border: 0;
	background: transparent;
	text-align: left;
}

.p32-tree-folder-row:hover,
.p32-tree-note:hover {
	background: var(--bs-gray-200);
}

.p32-tree-note.is-active {
	background: var(--bs-primary);
	color: #fff;
}

.p32-tree-note.is-active i { color: #fff !important; }

.p32-tree-note .p32-note-fav {
	margin-left: auto;
	font-size: 0.7rem;
	color: var(--bs-warning);
}

.p32-tree-caret {
	transition: transform 0.15s ease;
	font-size: 0.6rem;
	color: var(--bs-gray-500);
	width: 10px;
	flex-shrink: 0;
}

.p32-tree-folder.is-open > .p32-tree-folder-row .p32-tree-caret {
	transform: rotate(90deg);
}

.p32-tree-children {
	display: none;
	margin-left: 0.85rem;
	padding-left: 0.45rem;
	border-left: 1px solid var(--bs-gray-300);
}

.p32-tree-folder.is-open > .p32-tree-children {
	display: block;
}

.p32-tree-label {
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	min-width: 0;
	flex: 1;
}

.p32-tree-item-actions {
	display: none;
	gap: 0.1rem;
	margin-left: auto;
	flex-shrink: 0;
}

.p32-tree-folder-row:hover .p32-tree-item-actions,
.p32-tree-note:hover .p32-tree-item-actions {
	display: inline-flex;
}

.p32-tree-item-actions button {
	border: 0;
	background: transparent;
	color: inherit;
	opacity: 0.65;
	padding: 0 0.15rem;
	font-size: 0.75rem;
	line-height: 1;
}

.p32-tree-item-actions button:hover { opacity: 1; }

.p32-tag-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	padding: 0.32rem 0.6rem;
	border: 0;
	background: transparent;
	border-radius: 0.45rem;
	color: var(--bs-gray-700);
	font-size: 0.86rem;
	cursor: pointer;
	text-align: left;
}

.p32-tag-row:hover { background: var(--bs-gray-200); }

.p32-empty-hint {
	color: var(--bs-gray-500);
	font-size: 0.82rem;
	padding: 1rem 0.6rem;
	text-align: center;
}

/* ---------- Zone principale ---------- */
.p32-main {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	position: relative;
}

.p32-empty {
	flex: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 2rem;
}

.p32-editor {
	flex: 1;
	display: flex;
	flex-direction: column;
	min-height: 0;
}

.p32-editor-header {
	display: flex;
	align-items: center;
	gap: 0.6rem;
	padding: 0.8rem 1.4rem 0.4rem;
}

.p32-title-input {
	flex: 1;
	min-width: 0;
	border: 0;
	outline: 0;
	background: transparent;
	font-size: 1.55rem;
	font-weight: 800;
	color: var(--bs-gray-900);
	letter-spacing: -0.01em;
	padding: 0.15rem 0.25rem;
	border-radius: 0.4rem;
}

.p32-title-input:focus { background: var(--bs-gray-100); }

.p32-editor-tools {
	display: flex;
	align-items: center;
	gap: 0.3rem;
	flex-shrink: 0;
}

.p32-save-state {
	font-size: 0.75rem;
	color: var(--bs-gray-500);
	min-width: 70px;
	text-align: right;
}

.p32-save-state.is-saving { color: var(--bs-warning); }
.p32-save-state.is-saved { color: var(--bs-success); }

#p32_fav_btn.is-fav { color: var(--bs-warning); }
#p32_fav_btn.is-fav i { color: var(--bs-warning); }

.p32-mode-switch {
	display: inline-flex;
	background: var(--bs-gray-100);
	border-radius: 0.55rem;
	padding: 0.15rem;
	gap: 0.1rem;
}

.p32-mode-btn {
	border: 0;
	background: transparent;
	color: var(--bs-gray-500);
	width: 32px;
	height: 28px;
	border-radius: 0.45rem;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

.p32-mode-btn:hover { color: var(--bs-gray-800); }

.p32-mode-btn.is-active {
	background: var(--bs-body-bg);
	color: var(--bs-primary);
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

.p32-mode-btn i { color: inherit; }

/* Barre d'outils markdown */
.p32-toolbar {
	display: flex;
	align-items: center;
	gap: 0.15rem;
	padding: 0.3rem 1.4rem 0.55rem;
	border-bottom: 1px solid var(--bs-gray-200);
	flex-wrap: wrap;
}

.p32-toolbar button {
	border: 0;
	background: transparent;
	color: var(--bs-gray-600);
	min-width: 30px;
	height: 28px;
	padding: 0 0.45rem;
	border-radius: 0.4rem;
	font-size: 0.8rem;
	font-weight: 600;
	font-family: var(--bs-font-monospace);
}

.p32-toolbar button:hover {
	background: var(--bs-gray-200);
	color: var(--bs-gray-900);
}

.p32-toolbar-sep {
	width: 1px;
	height: 18px;
	background: var(--bs-gray-300);
	margin: 0 0.35rem;
}

/* Panneaux d'édition */
.p32-editor-panes {
	flex: 1;
	display: flex;
	min-height: 0;
}

.p32-pane-edit,
.p32-pane-preview {
	flex: 1;
	min-width: 0;
	overflow-y: auto;
	position: relative;
}

.p32-editor-panes.is-split .p32-pane-edit {
	border-right: 1px solid var(--bs-gray-200);
}

.p32-textarea {
	width: 100%;
	height: 100%;
	border: 0;
	outline: 0;
	resize: none;
	background: transparent;
	color: var(--bs-gray-800);
	font-size: 1rem;
	line-height: 1.75;
	padding: 1.2rem 1.6rem 40vh;
	font-family: "Inter", ui-sans-serif, system-ui, sans-serif;
}

.p32-preview {
	padding: 1.2rem 1.6rem 40vh;
}

/* Rendu markdown */
.markdown-body { color: var(--bs-gray-800); font-size: 1rem; line-height: 1.75; }
.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5 {
	font-weight: 700;
	margin-top: 1.6em;
	margin-bottom: 0.5em;
	letter-spacing: -0.01em;
}
.markdown-body h1:first-child, .markdown-body h2:first-child, .markdown-body p:first-child { margin-top: 0; }
.markdown-body h1 { font-size: 1.9rem; }
.markdown-body h2 { font-size: 1.5rem; border-bottom: 1px solid var(--bs-gray-200); padding-bottom: 0.3rem; }
.markdown-body h3 { font-size: 1.2rem; }
.markdown-body blockquote {
	border-left: 3px solid var(--bs-primary);
	background: var(--bs-gray-100);
	padding: 0.6rem 1rem;
	border-radius: 0 0.5rem 0.5rem 0;
	color: var(--bs-gray-700);
	margin: 1rem 0;
}
.markdown-body code {
	background: var(--bs-gray-200);
	color: var(--bs-danger);
	border-radius: 0.3rem;
	padding: 0.12rem 0.4rem;
	font-size: 0.86em;
}
.markdown-body pre {
	background: var(--bs-gray-100);
	border: 1px solid var(--bs-gray-200);
	border-radius: 0.6rem;
	padding: 1rem 1.2rem;
	overflow-x: auto;
}
.markdown-body pre code { background: transparent; color: var(--bs-gray-800); padding: 0; }
.markdown-body table {
	border-collapse: collapse;
	margin: 1rem 0;
	width: 100%;
}
.markdown-body th, .markdown-body td {
	border: 1px solid var(--bs-gray-300);
	padding: 0.45rem 0.8rem;
	text-align: left;
}
.markdown-body th { background: var(--bs-gray-100); }
.markdown-body img { max-width: 100%; border-radius: 0.5rem; }
.markdown-body ul, .markdown-body ol { padding-left: 1.4rem; }
.markdown-body li.task-list-item { list-style: none; margin-left: -1.4rem; }
.markdown-body li.task-list-item input { margin-right: 0.45rem; accent-color: var(--bs-primary); }
.markdown-body hr { border-color: var(--bs-gray-300); margin: 1.6rem 0; }

.p32-wikilink {
	color: var(--bs-primary);
	font-weight: 600;
	text-decoration: none;
	border-bottom: 1px dashed transparent;
	transition: border-color 0.15s ease;
}

.p32-wikilink:hover { border-bottom-color: var(--bs-primary); }

.p32-wikilink.is-unresolved {
	color: #9b7bff;
	opacity: 0.75;
	font-style: italic;
}

.p32-tag {
	display: inline-block;
	background: var(--bs-gray-200);
	color: var(--bs-primary);
	border-radius: 1rem;
	padding: 0.02rem 0.55rem;
	font-size: 0.85em;
	font-weight: 600;
	text-decoration: none;
	transition: background 0.15s ease;
}

.p32-tag:hover { background: var(--bs-gray-300); color: var(--bs-primary); }

/* Barre d'état */
.p32-statusbar {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.35rem 1.4rem;
	border-top: 1px solid var(--bs-gray-200);
	color: var(--bs-gray-500);
	font-size: 0.76rem;
}

.p32-statusbar-sep { opacity: 0.5; }

/* Autocomplétion [[ ]] */
.p32-autocomplete {
	position: absolute;
	z-index: 30;
	min-width: 240px;
	max-width: 340px;
	max-height: 260px;
	overflow-y: auto;
	background: var(--bs-body-bg);
	border: 1px solid var(--bs-gray-300);
	border-radius: 0.6rem;
	box-shadow: 0 0.8rem 2rem rgba(0, 0, 0, 0.18);
	padding: 0.3rem;
}

.p32-ac-item {
	display: block;
	width: 100%;
	text-align: left;
	border: 0;
	background: transparent;
	padding: 0.4rem 0.7rem;
	border-radius: 0.45rem;
	color: var(--bs-gray-800);
	font-size: 0.88rem;
	cursor: pointer;
}

.p32-ac-item:hover, .p32-ac-item.is-selected {
	background: var(--bs-primary);
	color: #fff;
}

.p32-ac-item .p32-ac-new {
	font-size: 0.72rem;
	opacity: 0.7;
}

/* ---------- Panneau droit ---------- */
.p32-right {
	width: 300px;
	flex-shrink: 0;
	border-left: 1px solid var(--bs-gray-200);
	background: var(--bs-gray-100);
	overflow-y: auto;
	padding: 1rem;
	display: flex;
	flex-direction: column;
	gap: 1.2rem;
}

.p32-right-section { min-height: 0; }

.p32-right-title {
	display: flex;
	align-items: center;
	font-size: 0.78rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--bs-gray-600);
	margin-bottom: 0.6rem;
}

.p32-count {
	margin-left: auto;
	background: var(--bs-gray-200);
	color: var(--bs-gray-600);
	border-radius: 1rem;
	font-size: 0.72rem;
	padding: 0.05rem 0.5rem;
}

.p32-backlink {
	display: block;
	width: 100%;
	text-align: left;
	background: var(--bs-body-bg);
	border: 1px solid var(--bs-gray-200);
	border-radius: 0.6rem;
	padding: 0.6rem 0.8rem;
	margin-bottom: 0.5rem;
	cursor: pointer;
	transition: border-color 0.15s ease, transform 0.15s ease;
}

.p32-backlink:hover {
	border-color: var(--bs-primary);
	transform: translateX(2px);
}

.p32-backlink-title {
	font-weight: 700;
	font-size: 0.85rem;
	color: var(--bs-primary);
	margin-bottom: 0.15rem;
}

.p32-backlink-snippet {
	font-size: 0.76rem;
	color: var(--bs-gray-600);
	line-height: 1.45;
}

/* ---------- Overlays (switcher, graphe, corbeille) ---------- */
.p32-overlay {
	position: fixed;
	inset: 0;
	z-index: 100;
	background: rgba(0, 0, 0, 0.45);
	backdrop-filter: blur(3px);
	display: flex;
	align-items: flex-start;
	justify-content: center;
	padding: 8vh 1rem 1rem;
}

.p32-switcher {
	width: 100%;
	max-width: 620px;
	background: var(--bs-body-bg);
	border-radius: 0.9rem;
	box-shadow: 0 1.5rem 4rem rgba(0, 0, 0, 0.35);
	overflow: hidden;
	border: 1px solid var(--bs-gray-300);
}

.p32-switcher-input-wrap {
	display: flex;
	align-items: center;
	gap: 0.7rem;
	padding: 0.9rem 1.1rem;
	border-bottom: 1px solid var(--bs-gray-200);
}

.p32-switcher-input-wrap input {
	flex: 1;
	border: 0;
	outline: 0;
	background: transparent;
	font-size: 1.05rem;
	color: var(--bs-gray-900);
}

.p32-switcher-results {
	max-height: 46vh;
	overflow-y: auto;
	padding: 0.4rem;
}

.p32-switcher-item {
	display: block;
	width: 100%;
	text-align: left;
	border: 0;
	background: transparent;
	border-radius: 0.55rem;
	padding: 0.55rem 0.9rem;
	cursor: pointer;
}

.p32-switcher-item:hover, .p32-switcher-item.is-selected {
	background: var(--bs-gray-100);
}

.p32-switcher-item.is-selected {
	outline: 2px solid var(--bs-primary);
	outline-offset: -2px;
}

.p32-switcher-item .p32-sw-title {
	font-weight: 700;
	font-size: 0.92rem;
	color: var(--bs-gray-900);
}

.p32-switcher-item .p32-sw-snippet {
	font-size: 0.78rem;
	color: var(--bs-gray-500);
	margin-top: 0.1rem;
}

/* Graphe */
.p32-graph-panel, .p32-trash-panel {
	width: 100%;
	max-width: 1100px;
	height: 84vh;
	background: var(--bs-body-bg);
	border-radius: 0.9rem;
	border: 1px solid var(--bs-gray-300);
	box-shadow: 0 1.5rem 4rem rgba(0, 0, 0, 0.35);
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.p32-trash-panel { max-width: 640px; height: auto; max-height: 76vh; }

.p32-graph-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 1rem 1.4rem;
	border-bottom: 1px solid var(--bs-gray-200);
}

#p32_graph_canvas {
	flex: 1;
	width: 100%;
	min-height: 0;
	cursor: grab;
}

#p32_graph_canvas:active { cursor: grabbing; }

.p32-graph-hint {
	padding: 0.5rem 1.4rem;
	font-size: 0.75rem;
	color: var(--bs-gray-500);
	border-top: 1px solid var(--bs-gray-200);
}

.p32-trash-body {
	overflow-y: auto;
	padding: 1rem 1.4rem;
}

.p32-trash-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: 0.6rem 0;
	border-bottom: 1px dashed var(--bs-gray-200);
}

.p32-trash-row:last-child { border-bottom: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 991px) {
	.p32-right { display: none !important; }
	.p32-explorer {
		position: absolute;
		left: 58px;
		top: 0;
		bottom: 0;
		z-index: 15;
		box-shadow: 0.5rem 0 2rem rgba(0, 0, 0, 0.15);
	}
	.p32-explorer.is-collapsed { margin-left: -340px; }
}

/* ---------- Mode sombre : ajustements fins ---------- */
[data-bs-theme="dark"] .p32-mode-btn.is-active {
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

[data-bs-theme="dark"] .p32-feature-card:hover {
	box-shadow: 0 1rem 2.5rem rgba(0, 0, 0, 0.45);
}

[data-bs-theme="dark"] .markdown-body code {
	color: #ff8a8a;
}
