/* ════════════════════════════════════════════════════════════════════════════ */
/* ── components.css — Note cards, folders, toolbar, pickers, menus ─────────── */
/* ════════════════════════════════════════════════════════════════════════════ */

/* ════════════════════════════════════════════════════════════════════════════ */
/* ── NOTE ITEMS — refined premium cards with subtle color accent ───────────── */
/* ════════════════════════════════════════════════════════════════════════════ */
.note-item {
	padding: 0;
	border-radius: var(--radius-md);
	cursor: pointer;
	margin-bottom: 6px;
	transition: var(--transition);
	border: 1px solid var(--border);
	position: relative;
	display: flex;
	align-items: stretch;
	overflow: hidden;
	background: var(--surface);
	box-shadow: var(--shadow-xs);
}
.note-item:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.note-item.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow-sm); }
.note-item:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* ── Color accent band on the left edge (uses inline --note-accent set by JS) ─ */
.note-item::before {
	content: '';
	position: absolute;
	left: 0;
	top: 0;
	bottom: 0;
	width: 4px;
	background: var(--note-accent, var(--note-mustard));
	border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.note-item-content { flex: 1; min-width: 0; padding: 12px 14px 12px 18px; }

.note-item-title-row { display: flex; align-items: center; gap: 5px; margin-bottom: 4px; overflow: hidden; }

.pin-icon { width: 12px; height: 12px; flex-shrink: 0; opacity: 0.75; color: var(--accent-hover); }

.note-item-title {
	font-weight: 700;
	font-size: 0.9rem;
	color: var(--text-primary);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	letter-spacing: -0.2px;
}

.note-item-preview {
	font-size: 0.78rem;
	color: var(--text-secondary);
	overflow: hidden;
	display: -webkit-box;
	-webkit-line-clamp: 1;
	-webkit-box-orient: vertical;
	white-space: nowrap;
	text-overflow: ellipsis;
	word-break: break-word;
	line-height: 1.5;
	max-height: 1.5em;
}

.note-item-meta {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	margin-top: 5px;
	min-width: 0;
}
.note-item-date { font-size: 0.68rem; color: var(--text-muted); flex-shrink: 0; white-space: nowrap; }
.note-item-folder {
	font-size: 0.68rem;
	color: var(--text-secondary);
	min-width: 0;
	flex-shrink: 1;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	text-align: right;
	opacity: 0.9;
}

/* ── Pinned separator ──────────────────────────────────────────────────────── */
.note-list-separator {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 8px 4px 10px;
	padding: 0 2px;
	user-select: none;
}
.note-list-separator::before,
.note-list-separator::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.note-list-separator-label {
	font-size: 0.64rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.09em;
	color: var(--text-muted);
	flex-shrink: 0;
}

/* ── Kebab ─────────────────────────────────────────────────────────────────── */
.note-kebab-wrapper { position: relative; display: flex; align-items: center; flex-shrink: 0; }

.note-kebab-btn {
	background: transparent;
	border: none;
	cursor: pointer;
	width: 34px;
	height: 34px;
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--text-muted);
	font-size: 1.2rem;
	border-radius: var(--radius-sm);
	transition: var(--transition);
	margin-right: 6px;
	flex-shrink: 0;
	align-self: center;
}
.note-kebab-btn:hover { background: var(--accent-soft); color: var(--text-primary); }

/* ── Floating layer ────────────────────────────────────────────────────────── */
#floating-layer {
	position: fixed;
	inset: 0;
	z-index: var(--z-floating);
	pointer-events: none;
	overflow: visible;
}

.note-kebab-menu {
	position: fixed;
	top: 0;
	left: 0;
	background: var(--surface-elevated);
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
	box-shadow: var(--shadow-md);
	z-index: var(--z-floating);
	min-width: 170px;
	max-width: min(240px, calc(100vw - 24px));
	max-height: calc(100vh - 24px);
	overflow-y: auto;
	pointer-events: auto;
	padding: 6px;
}

.kebab-item {
	display: flex;
	align-items: center;
	width: 100%;
	padding: 10px 12px;
	border: none;
	background: transparent;
	color: var(--text-primary);
	font-size: 0.86rem;
	font-family: var(--font);
	font-weight: 500;
	cursor: pointer;
	text-align: left;
	transition: var(--transition-fast);
	white-space: nowrap;
	border-radius: var(--radius-sm);
}
.kebab-item:hover { background: var(--accent-soft); }
.kebab-item-danger { color: var(--danger-dark); }
.kebab-item-danger:hover { background: var(--danger-soft) !important; color: var(--danger-dark); }

/* ── Shared dropdown item ──────────────────────────────────────────────────── */
.dropdown-item {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	padding: 11px 14px;
	border: none;
	background: transparent;
	color: var(--text-primary);
	font-size: 0.87rem;
	font-family: var(--font);
	font-weight: 500;
	cursor: pointer;
	text-align: left;
	transition: var(--transition-fast);
	white-space: nowrap;
	border-radius: var(--radius-sm);
}
.dropdown-item:hover { background: var(--accent-soft); color: var(--text-primary); }

/* ════════════════════════════════════════════════════════════════════════════ */
/* ── FOLDERS PANEL ───────────────────────────────────────────────────────── */
/* ════════════════════════════════════════════════════════════════════════════ */
#folders-content { display: flex; flex-direction: column; flex: 0 0 auto; }

.folders-list-section { flex: 0 0 auto; border-bottom: 1px solid var(--border); padding: 6px 10px 10px; }

.folders-header-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 8px 6px; flex-shrink: 0; }
.folders-header-row h3 {
	font-size: 0.72rem; font-weight: 700; color: var(--text-muted);
	text-transform: uppercase; letter-spacing: 0.07em;
}

.new-folder-btn {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	padding: 5px 10px;
	font-size: 0.74rem;
	font-family: var(--font);
	font-weight: 600;
	color: var(--text-secondary);
	cursor: pointer;
	transition: var(--transition);
	white-space: nowrap;
}
.new-folder-btn:hover { border-color: var(--accent); color: var(--accent-hover); background: var(--accent-soft); }

.folder-item {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 9px 11px;
	border-radius: var(--radius-sm);
	cursor: pointer;
	transition: var(--transition);
	border: 1px solid transparent;
	margin-bottom: 3px;
}
.folder-item:hover { background: var(--accent-soft); }
.folder-item.active { background: var(--accent-soft); border-color: var(--accent); }

.folder-item-name {
	flex: 1; font-size: 0.86rem; font-weight: 600; color: var(--text-primary);
	white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.folder-item-count {
	font-size: 0.7rem; color: var(--text-secondary); background: var(--border);
	padding: 2px 8px; border-radius: var(--radius-pill); flex-shrink: 0; font-variant-numeric: tabular-nums;
}
.folder-item-actions { display: flex; gap: 2px; flex-shrink: 0; opacity: 0; transition: opacity 0.15s ease; }
.folder-item:hover .folder-item-actions,
.folder-item:focus-within .folder-item-actions { opacity: 1; }

.folder-action-btn {
	background: transparent; border: none; cursor: pointer; padding: 5px 6px;
	border-radius: var(--radius-xs); font-size: 0.8rem; color: var(--text-muted);
	transition: var(--transition); line-height: 1; min-width: 30px; min-height: 30px;
}
.folder-action-btn:hover { background: var(--border); color: var(--text-primary); }
.folder-action-btn-danger:hover { background: var(--danger-soft); color: var(--danger-dark); }

.folder-notes-section { display: flex; flex-direction: column; flex: 0 0 auto; }
.folder-notes-header { padding: 10px 14px 4px; flex-shrink: 0; }
.folder-notes-header h3 {
	font-size: 0.72rem; font-weight: 700; color: var(--text-muted);
	text-transform: uppercase; letter-spacing: 0.07em;
}

/* ── Locked panel ──────────────────────────────────────────────────────────── */
.panel-locked {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	min-height: 340px;
	padding: 36px 26px;
	text-align: center;
	gap: 14px;
}
.panel-locked-icon { font-size: 2.8rem; opacity: 0.9; }
.panel-locked-title { font-size: 1.05rem; font-weight: 700; color: var(--text-primary); }
.panel-locked-body { font-size: 0.86rem; color: var(--text-secondary); line-height: 1.7; max-width: 230px; }
.panel-locked-btn {
	background: var(--accent); color: var(--accent-contrast); border: none;
	border-radius: var(--radius-sm); padding: 11px 24px; font-size: 0.9rem;
	font-weight: 700; font-family: var(--font); cursor: pointer; transition: var(--transition);
	box-shadow: var(--shadow-xs);
}
.panel-locked-btn:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: var(--shadow-sm); }

/* ════════════════════════════════════════════════════════════════════════════ */
/* ── EDITOR — toolbar, title, canvas, tables ───────────────────────────────── */
/* ════════════════════════════════════════════════════════════════════════════ */
.editor-toolbar {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 4px;
	padding: 10px 16px;
	background: var(--surface);
	border-bottom: 1px solid var(--border);
	flex-shrink: 0;
}
.toolbar-group { display: flex; align-items: center; gap: 2px; position: relative; }
.toolbar-divider { width: 1px; height: 22px; background: var(--border); margin: 0 6px; }

.tool-btn {
	background: transparent;
	border: 1px solid transparent;
	border-radius: var(--radius-sm);
	padding: 5px 9px;
	cursor: pointer;
	font-size: 0.88rem;
	font-family: var(--font);
	color: var(--text-secondary);
	transition: var(--transition-fast);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 30px;
	height: 30px;
}
.tool-btn:hover { background: var(--accent-soft); color: var(--text-primary); }
.tool-btn.active { background: var(--accent); border-color: var(--accent-hover); color: var(--accent-contrast); }

#font-size-select {
	padding: 5px 9px;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	font-size: 0.84rem;
	font-family: var(--font);
	background: var(--surface);
	color: var(--text-primary);
	cursor: pointer;
	outline: none;
	height: 30px;
}
#font-size-select:focus { border-color: var(--accent); }
#font-size-select:disabled { opacity: 0.45; cursor: not-allowed; }

.tool-label { font-size: 0.78rem; color: var(--text-secondary); margin-right: 5px; }

.color-options { display: flex; gap: 7px; align-items: center; }

.color-dot {
	width: 22px;
	height: 22px;
	border-radius: 50%;
	cursor: pointer;
	border: 2px solid transparent;
	box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08), var(--shadow-xs);
	transition: var(--transition);
	flex-shrink: 0;
	padding: 0;
	appearance: none;
	-webkit-appearance: none;
}
.color-dot:hover { transform: scale(1.18); }
.color-dot.active,
.color-dot[aria-pressed="true"] {
	border-color: var(--text-primary);
	transform: scale(1.18);
	box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent);
}

/* ── Table Picker ──────────────────────────────────────────────────────────── */
.table-picker {
	position: absolute;
	top: calc(100% + 8px);
	left: 0;
	background: var(--surface-elevated);
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
	padding: 12px;
	box-shadow: var(--shadow-md);
	z-index: var(--z-floating);
	min-width: 170px;
	max-width: calc(100vw - 24px);
}
.table-picker-grid {
	display: grid;
	grid-template-columns: repeat(8, 19px);
	grid-template-rows: repeat(8, 19px);
	gap: 3px;
}
.table-cell-selector {
	width: 19px; height: 19px; border: 1px solid var(--border);
	border-radius: 3px; cursor: pointer; background: var(--bg); transition: var(--transition-fast);
}
.table-cell-selector.highlighted { background: var(--accent); border-color: var(--accent-hover); }
.table-picker-label { text-align: center; font-size: 0.78rem; color: var(--text-secondary); margin-top: 9px; font-weight: 600; }

/* ── Note Title Bar ────────────────────────────────────────────────────────── */
.note-title-bar {
	display: flex;
	align-items: center;
	padding: 10px 24px;
	border-bottom: 1px solid var(--border);
	background: var(--surface);
	gap: 12px;
	flex-shrink: 0;
}
.note-title-bar-main { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 3px; }

#note-title-input {
	flex: 1;
	border: none;
	outline: none;
	font-size: 1.4rem;
	font-weight: 800;
	font-family: var(--font);
	background: transparent;
	color: var(--text-primary);
	min-width: 0;
	width: 100%;
	letter-spacing: -0.4px;
}
#note-title-input::placeholder { color: var(--text-muted); font-weight: 500; }

/* ── Breadcrumb ────────────────────────────────────────────────────────────── */
.note-folder-breadcrumb {
	display: flex;
	align-items: center;
	gap: 5px;
	font-size: 0.72rem;
	font-weight: 600;
	color: var(--text-muted);
	line-height: 1.2;
	min-width: 0;
	max-width: 100%;
	overflow: hidden;
	white-space: nowrap;
}
.note-folder-breadcrumb .breadcrumb-icon { flex-shrink: 0; opacity: 0.75; }
.note-folder-breadcrumb .breadcrumb-root { flex-shrink: 0; opacity: 0.85; }
.note-folder-breadcrumb .breadcrumb-sep { flex-shrink: 0; opacity: 0.5; user-select: none; }
.note-folder-breadcrumb .breadcrumb-folder {
	min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
	color: var(--text-secondary); font-weight: 700;
}

.note-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.note-actions .icon-btn { min-width: 42px; min-height: 42px; padding: 9px; }
.note-actions .icon-btn svg { width: 19px; height: 19px; }

/* ── Export dropdown ───────────────────────────────────────────────────────── */
.export-dropdown-group { position: relative; display: inline-flex; align-items: center; }
.export-dropdown {
	position: absolute;
	top: calc(100% + 8px);
	right: 0;
	background: var(--surface-elevated);
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
	box-shadow: var(--shadow-md);
	z-index: var(--z-floating);
	min-width: 190px;
	max-width: calc(100vw - 24px);
	overflow: hidden;
	padding: 6px;
}

/* ── Note Canvas ───────────────────────────────────────────────────────────── */
.note-canvas {
	flex: 1;
	padding: 36px 48px;
	overflow-y: auto;
	outline: none;
	font-size: 1.02rem;
	line-height: 1.75;
	color: var(--text-primary);
	word-break: break-word;
	background: transparent;
	font-family: var(--font-editor);
	max-width: 860px;
	width: 100%;
	margin: 0 auto;
}
.note-canvas:empty::before {
	content: attr(data-placeholder);
	color: var(--text-muted);
	pointer-events: none;
}

.note-canvas.logical-select-all-active {
	box-shadow: inset 0 0 0 3px var(--accent);
	background-image: linear-gradient(rgba(245, 200, 66, 0.1), rgba(245, 200, 66, 0.1));
	border-radius: var(--radius-md);
}

/* ── Editor list indentation ───────────────────────────────────────────────── */
.note-canvas ul, .note-canvas ol { padding-left: 26px; margin: 8px 0; }

/* ── Table scroll wrapper ──────────────────────────────────────────────────── */
.table-scroll { overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; }

.note-canvas table {
	border-collapse: collapse;
	width: 100%;
	margin: 14px 0;
	font-size: 0.95rem;
	border-radius: var(--radius-sm);
	overflow: hidden;
}
.note-canvas table td, .note-canvas table th {
	border: 1px solid var(--border-strong);
	padding: 9px 13px;
	min-width: 80px;
	vertical-align: top;
}
.note-canvas table th { background: var(--accent-soft); font-weight: 700; }
.note-canvas table td ul, .note-canvas table td ol,
.note-canvas table th ul, .note-canvas table th ol { padding-left: 18px; margin: 0; }
.note-canvas table tr:nth-child(even) td { background: rgba(0,0,0,0.015); }
html.night-mode .note-canvas table tr:nth-child(even) td { background: rgba(255,255,255,0.02); }

/* ── Save Indicator ────────────────────────────────────────────────────────── */
.save-indicator {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 8px 24px;
	background: var(--surface);
	border-top: 1px solid var(--border);
	flex-shrink: 0;
}
#save-status { font-size: 0.76rem; color: var(--text-muted); font-weight: 500; }
.note-counts { font-size: 0.74rem; color: var(--text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ── Folder picker items ───────────────────────────────────────────────────── */
.folder-picker-item {
	display: flex;
	align-items: center;
	width: 100%;
	padding: 11px 14px;
	border: 1.5px solid transparent;
	border-radius: var(--radius-sm);
	background: var(--bg);
	color: var(--text-primary);
	font-size: 0.88rem;
	font-family: var(--font);
	font-weight: 500;
	cursor: pointer;
	text-align: left;
	transition: var(--transition);
	margin-bottom: 5px;
}
.folder-picker-item:hover { background: var(--accent-soft); border-color: var(--accent); }
.folder-picker-item.active { background: var(--accent-soft); border-color: var(--accent-hover); font-weight: 700; }
.folder-picker-empty { font-size: 0.84rem; color: var(--text-muted); text-align: center; padding: 14px 0; font-style: italic; }

.folder-name-input {
	width: 100%;
	padding: 11px 13px;
	border: 1.5px solid var(--border);
	border-radius: var(--radius-sm);
	font-size: 0.95rem;
	font-family: var(--font);
	background: var(--bg);
	color: var(--text-primary);
	outline: none;
	transition: var(--transition);
}
.folder-name-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ════════════════════════════════════════════════════════════════════════════ */
/* ── RESPONSIVE — mobile editor ────────────────────────────────────────────── */
/* ════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
	.editor-toolbar { padding: 8px 10px; gap: 2px; overflow-x: auto; flex-wrap: nowrap; }
	.toolbar-divider { display: none; }
	.toolbar-group { flex-shrink: 0; }

	.note-canvas { padding: 22px 20px; font-size: 1rem; }

	.note-actions { gap: 4px; }
	.note-actions .icon-btn { min-width: 44px; min-height: 44px; padding: 10px; }
	.note-actions .icon-btn svg { width: 20px; height: 20px; }

	.note-title-bar { gap: 8px; padding: 8px 16px; }
	#note-title-input { min-width: 0; font-size: 1.2rem; }

	.note-folder-breadcrumb { font-size: 0.68rem; gap: 3px; }
	.note-folder-breadcrumb .breadcrumb-icon { width: 12px; height: 12px; }

	.note-canvas table td, .note-canvas table th { padding: 7px 9px; font-size: 0.9rem; }
	.note-canvas .table-scroll table td,
	.note-canvas .table-scroll table th { min-width: 92px; }

	.table-picker {
		position: fixed;
		left: 50%;
		right: auto;
		top: auto;
		bottom: max(16px, env(safe-area-inset-bottom, 0px));
		transform: translateX(-50%);
		max-width: calc(100vw - 24px);
		max-height: calc(100vh - 96px);
		overflow: auto;
	}
	.table-picker-grid {
		grid-template-columns: repeat(8, minmax(18px, 20px));
		grid-template-rows: repeat(8, minmax(18px, 20px));
	}

	.export-dropdown { right: 0; left: auto; }

	.save-indicator { padding: 7px 16px; }
}

/* ── Landscape phones ──────────────────────────────────────────────────────── */
@media (max-height: 500px) and (orientation: landscape) {
	.panel-header { padding: 10px 14px 8px; }
	.panel-search { padding: 4px 14px 8px; }
	.section-app-footer { padding: 8px 14px; }
	.table-picker { max-height: calc(100vh - 32px); }
}