* { margin: 0; padding: 0; box-sizing: border-box; }
body { 
	display: flex; 
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	height: 100vh;
	background: #f5f5f5;
}

/* Sidebar */
#sidebar { 
	height: 100vh;
	width: 280px; 
	background: beige;
	color: #2c3e50;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	transition: transform 0.3s ease;
}
#sidebar h3 { 
	padding: 15px 20px; /* reducido de 20px */
	/* padding: 20px; */
	margin: 0;
	color: #2c3e50;
	background: antiquewhite ;
	font-weight: 400;
	font-size: 16px;
	letter-spacing: 1px;
}

#sidebar .new-note { 
	display: block;
	padding: 12px 20px;
	background: #27ae60;
	color: white;
	text-decoration: none;
	text-align: center;
	font-weight: 500;
	transition: background 0.2s;
}
#sidebar .new-note:hover { background: #2ecc71; }



/* Botón toggle para móvil */
#sidebar-toggle {
	display: none;
	position: fixed;
	top: 10px;
	left: 10px;
	z-index: 100;
	background: white;
	color: #2c3e50;
	border: none;
	width: 45px;
	height: 45px;
	border-radius: 8px;
	font-size: 24px;
	cursor: pointer;
	box-shadow: 0 2px 5px rgba(0,0,0,0.2);
	align-items: center;
	justify-content: center;
}



/* NOTES TREE */
#notes-tree { 
	flex: 1;
	overflow-y: auto;
	padding: 5px;
	max-height: 50vh;/* para limitar la altura del árbol de notas - Ajustable */
	margin-bottom: 20px;
}
#notes-tree ul { 
	list-style: none; 
	margin-left: 12px;
}
#notes-tree ul.level-0 { margin-left: 0; }
#notes-tree li { margin: 2px 0; position: relative; line-height: 1.2;}
#notes-tree li.has-children > a { font-weight: 500; }
#notes-tree a { 
	color: #000; 
	text-decoration: none;
	display: block;
	padding: 4px 10px 4px 20px; /* vertical padding reducido */
	border-radius: 3px;
	font-size: 13px; /* un poco más pequeño */
	transition: background 0.2s;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 220px;
	cursor: pointer; /* cursor normal, no help */
}
#notes-tree a:hover { 
	text-shadow: 1px 1px 2px rgba(0,0,0,.5);
	background: orange;
	color: darkblue;
}



/* Contenido principal */
#content { 
	flex: 1; 
	padding: 0;
	background: oldlace;
	overflow-y: auto;
	display: flex;
	flex-direction: column;
}




/* Anonymous Notes */
.box{ padding: 0 8px;margin:auto;background:oldlace;border-radius:10px;} /* antiquewhite */
textarea{width:100%;height:100px;padding:10px;}
button{padding:5px 10px;background: #2563eb;color:white;border:none;border-radius:5px;}


/* NOTES OPTIONS */
.note-view { 
	display: flex;
	flex-direction: column;
	height: 100%;
	padding: 0 10px;
	max-width: 90%;
	margin: 0 auto;
	width: 100%;
}

.note-header {
	.note-header { 
		display: flex; 
		flex-direction: column; /* coloca los hijos en columna */ 
		align-items: flex-start; /* opcional, alinea a la izquierda */ 
		justify-content: flex-start; /* ya no distribuye en horizontal */ }
}

.note-header-actions {
	display: flex;
	gap: 8px;
	margin-left: 20px;
}

.note-header h2 { 
	margin: 0;
	color: #2c3e50;
	font-size: 1.8em;
	word-break: break-word;
	flex: 1;
}
.note-content-scrollable {
	padding: 20px 15px;
	font-size: 1.1rem;
	line-height: 1.6;
	color: #333;
	font-size: 16px;
	overflow-y: auto;
	flex: 1;
	min-height: 70vh;
	white-space: pre-wrap;
	word-wrap: break-word;
}

/* Espaciado del contenido - MÁS COMPACTO */
.note-content-scrollable {
	padding: 20px 30px 30px 30px; /* reducido de 30px */
	line-height: 1.5; /* reducido de 1.7 */
	color: #333;
	font-size: 15px; /* un poco más pequeño */
	overflow-y: auto;
	flex: 1;
	min-height: 0;
	white-space: pre-wrap;
	word-wrap: break-word;
}

/* Para párrafos dentro del contenido */
.note-content-scrollable p {
	margin-bottom: 0.2em; /* espacio entre párrafos */
}

.note-content-scrollable br {
	display: block;
	content: "";
	margin: 0.25em 0; /* espacio reducido para saltos de línea */
}

.note-content-scrollable {
	white-space: pre-wrap; /* To avoid blank line after paragraph */
}


/* Vista previa de notas en sidebar */
.note-link {
	position: relative;
	padding-left: 35px !important;
	gap: 10px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 210px;
}

/* Tooltip para títulos largos */
.note-link[title] {
	cursor: help;
}

.note-link i {
	margin-right: 6px;
	position: absolute;
	left: 8px; /* margen izquierdo de 8px */
	top: 4px;
	font-size: 14px;
	width: 18px;
	flex-shrink: 0; /* evitar que se encoja */
	text-align: center;
	color: #95a5a6;
}

/* Icono para notas raíz */
.note-link.root-note i {
	color: #0ff12d; /* amarillo para notas raíz */
}

/* Icono para subnotas */
.note-link.sub-note i {
	color: #85db34; /* azul para subnotas */
}

/* Hover effects */
.note-link:hover i {
	color: white;
}
/* Feedback visual al hacer click */
.note-link:active {
    opacity: 0.8;
    transition: opacity 0.1s;
}



/* Botones de acción */
.icon-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	border-radius: 8px;
	color: #7f8c8d;
	transition: all 0.2s;
	text-decoration: none;
}

.icon-btn:hover {
	background: #f0f0f0;
	color: #3498db;
}

.icon-btn.delete-btn:hover {
	background: #fee;
	color: #e74c3c;
}


.empty-state {
	text-align: center;
	color: #7f8c8d;
	margin-top: 50px;	/*100*/
}

.error-message {
	color: #e74c3c;
	padding: 20px;
	background: #fef5f5;
	border-radius: 8px;
	margin: 20px;
	border: 1px solid #f9d6d5;
}

.form-group { margin-bottom: 20px; }
.form-group input[type="text"],
.form-group select,
.form-group textarea {
	width: 100%;
	padding: 10px;
	border: 1px solid #ddd;
	border-radius: 4px;
	font-size: 14px;
}
.form-group textarea { font-family: monospace; }
.form-group label { 
	display: block;
	margin-bottom: 5px;
	color: #2c3e50;
	font-weight: 500;
}
.btn { 
	display: inline-block;
	padding: 8px 16px;
	background: #3498db;
	color: white;
	text-decoration: none;
	border-radius: 4px;
	margin-right: 10px;
	border: none;
	cursor: pointer;
	font-size: 14px;
}
.btn:hover { background: #2980b9; }
.btn-danger { background: #e74c3c; }
.btn-danger:hover { background: #c0392b; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    #anonNote {
        min-height: 40vh;
        font-size: 1.05rem;
        padding: 14px;
    }


	html, body {
        font-size: 18px !important;   /* base size bigger */
    }
	body {
		position: relative;
	}

	#notes-tree { max-height: 30vh; margin-bottom: 10px; }
	.box { margin-top: 5px; }

	.note-content-scrollable {
		font-size: 1.15rem !important;
		line-height: 1.6;
		padding: 20px;
        max-width: 1100px;    /* wider on desktop */
        margin: 0 auto;
	}
	
	.toggle-children {
		left: -10px;
		width: 18px;
		height: 18px;
	}

	#sidebar-toggle {
		display: flex;
	}
	
	#sidebar {	
        padding: 10px 8px;
		position: fixed;
		top: 0;
		left: 0;
		bottom: 0;
		z-index: 99;
		transform: translateX(-100%);
		box-shadow: 2px 0 10px rgba(0,0,0,0.3);
	}
	
	#sidebar.active {
		transform: translateX(0);
	}
	
	#content {
		width: 100%;
		padding-top: 10px;
	}
	#content, .note-view {
        font-size: 1.05rem;
    }
    
    h2 {
        font-size: 1.7rem !important;
    }
    
    .note-link, #notes-tree a {
        font-size: 15px !important;
    }
	.note-header {
		padding: 60px 20px 15px; /* Espacio para el botón toggle */
		flex-direction: column;
		align-items: flex-start;
		gap: 15px;
	}
	
	.note-header h2 {
		font-size: 1.4em;
		width: 100%;
	}
	
	.note-header-actions {
		margin-left: 0;
		width: 100%;
		justify-content: flex-end;
		border-top: 1px solid #ecf0f1;
		padding-top: 15px;
	}
	
	.note-content-scrollable {
		padding: 20px;
		font-size: 15px;
	}
	
	.icon-btn {
		width: 45px;
		height: 45px;
	}
	
	/* Ajustes para formularios */
	.form-group input[type="text"],
	.form-group select,
	.form-group textarea {
		font-size: 16px; /* Evita zoom en iOS */
	}
	
	.btn {
		display: block;
		width: 100%;
		margin: 10px 0;
		text-align: center;
	}
}

@media (max-width: 480px) {
	body {font-size: 17px;}

	.note-header {
		padding: 60px 15px 10px;
	}

	.note-header-actions {
		gap: 5px;
	}

	.icon-btn {
		width: 40px;
		height: 40px;
	}

	.note-content-scrollable {
		padding: 15px;
	}
}



/* Colapsibilidad */
.note-tree-item {
	position: relative;
}

.toggle-children {
	position: absolute;
	left: -5px;
	top: 8px;
	width: 16px;
	height: 16px;
	cursor: pointer;
	color: #7f8c8d;
	font-size: 10px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.2s;
	user-select: none;
	background: transparent;
	border-radius: 2px;
	z-index: 5;
}

.toggle-children:hover {
	color: white;
	background: #34495e;
}

.toggle-children.collapsed {
	transform: rotate(-90deg);
}

.children-container {
	transition: all 0.2s ease;
}

.children-container.collapsed {
	display: none;
}








html.invert {
	filter: invert(1);
	background: #000;
}
body.invert {
	filter: invert(1);
	background: #000;
}
#tgglBtn {
	cursor: pointer;
	font-size: 24px;
	border: none;
	background: none;
	position: relative;
	top: -15px; /* Up */
}



/* Estilo para invitados */
.guest-banner {
    background: #f39c12;
    color: white;
    padding: 10px;
    text-align: center;
    font-size: 14px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.guest-banner a {
    color: white;
    font-weight: bold;
    text-decoration: underline;
    margin: 0 5px;
}

.guest-banner a:hover {
    color: #2c3e50;
}

/* Botones de autenticación */
.auth-buttons {
    margin-top: auto;
    padding: 15px 20px;
    border-top: 1px solid #34495e;
}

.auth-buttons a {
    display: block;
    padding: 10px;
    margin: 5px 0;
    text-align: center;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-login {
    background: #3498db;
    color: white;
}

.btn-login:hover {
    background: #2980b9;
}

.btn-register {
    background: #27ae60;
    color: white;
}

.btn-register:hover {
    background: #2ecc71;
}

/* Deshabilitar acciones para invitados */
.guest-mode .icon-btn.delete-btn,
.guest-mode .icon-btn[title="Agregar subnota"],
.guest-mode .new-note {
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed;
}

.guest-mode .icon-btn[title="Editar nota"] {
    opacity: 0.5;
    pointer-events: none;
}

#anonNote {
    width: 100%;
    min-height: 300px;          /* much taller on mobile */
    height: 50vh;               /* grows with screen */
    max-height: 60vh;
    padding: 16px;
    font-size: 1.1rem;
    line-height: 1.6;
    border: 1px solid #ddd;
    border-radius: 6px;
    resize: vertical;
    box-sizing: border-box;
}
/*
++++++++++++++++++++++++++++++++++++++++++++++++++++++
*/

/* Force full width everywhere */
.note-view,
#content > form,
.box,
.anon-editor-box {
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 12px !important;
    box-sizing: border-box;
}

.note-content-scrollable,
#content form textarea[name="content"],
#anonNote {
    width: 100% !important;
    min-height: 60vh;
    font-size: 1.1rem;
    line-height: 1.6;
    padding: 16px;
}

/* Desktop/tablet wider comfortable reading */
@media (min-width: 768px) {
    .note-content-scrollable,
    #content form textarea[name="content"] {
        max-width: 1000px;
        margin: 0 auto;
        padding: 32px 48px;
    }
}

/* Mobile portrait — bigger base font + no tiny centering */
@media (max-width: 767px) and (orientation: portrait) {
    html, body {
        font-size: 17px !important;
    }
    
    h2 {
        font-size: 1.8rem !important;
        margin: 12px 0;
    }
    
    .note-view,
    .box,
    form {
        padding: 8px 12px !important;
    }
    
    textarea {
        font-size: 1.05rem !important;
        min-height: 55vh !important;
    }
}
/*-------------*/
#searchModal {
    display: none;
}
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    backdrop-filter: blur(3px);
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.modal.show {
    display: flex;
}

.modal-box {
    background: #fff;
    width: 600px;
    max-width: 90%;
    max-height: 80vh;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0,0,0,.2);
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    font-weight: 600;
}

.modal-content {
    overflow-y: auto;
    padding: 10px;
}

.result-item {
    padding: 10px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
}

.result-item:hover {
    background: #f5f5f5;
}